diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index c2820eee66d529..58a06086679e06 100644 --- a/.github/.wordlist.txt +++ b/.github/.wordlist.txt @@ -634,6 +634,7 @@ GPL GPLv Gradle gradlew +graphviz Groupcast GroupId GroupKeyManagement diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index 18bfc8d25896c3..88c84d72e28080 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -49,7 +49,7 @@ jobs: with: platform: nrfconnect - name: Detect changed paths - uses: dorny/paths-filter@v2 + uses: dorny/paths-filter@v3 id: changed_paths with: filters: | diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index bdfb51adeec423..9fbe9a970a0495 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 \ @@ -194,6 +195,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 +462,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 +472,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 +498,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/data_model/ValveConfigurationControl.xml b/data_model/ValveConfigurationControl.xml deleted file mode 100644 index 2d1554df10df59..00000000000000 --- a/data_model/ValveConfigurationControl.xml +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/clusters.md b/docs/clusters.md index 28a817e0a044a9..d197e1b8bc0ed1 100644 --- a/docs/clusters.md +++ b/docs/clusters.md @@ -77,6 +77,7 @@ 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 | 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 c2ab0dc702df53..044a51213fd746 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 @@ -2929,7 +2929,7 @@ cluster RvcRunMode = 84 { } bitmap Feature : bitmap32 { - kOnOff = 0x1; + kNoFeatures = 0x0; } struct ModeTagStruct { @@ -2945,7 +2945,6 @@ cluster RvcRunMode = 84 { readonly attribute ModeOptionStruct supportedModes[] = 0; readonly attribute int8u currentMode = 1; - attribute optional nullable int8u onMode = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2982,7 +2981,7 @@ cluster RvcCleanMode = 85 { } bitmap Feature : bitmap32 { - kOnOff = 0x1; + kNoFeatures = 0x0; } struct ModeTagStruct { @@ -2998,7 +2997,6 @@ cluster RvcCleanMode = 85 { readonly attribute ModeOptionStruct supportedModes[] = 0; readonly attribute int8u currentMode = 1; - attribute optional nullable int8u onMode = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3480,10 +3478,6 @@ cluster RvcOperationalState = 97 { /** Upon receipt, the device SHALL pause its operation if it is possible based on the current function of the server. */ command Pause(): OperationalCommandResponse = 0; - /** Upon receipt, the device SHALL stop its operation if it is at a position where it is safe to do so and/or permitted. */ - command Stop(): OperationalCommandResponse = 1; - /** Upon receipt, the device SHALL start its operation if it is safe to do so and the device is in an operational state from which it can be started. */ - command Start(): OperationalCommandResponse = 2; /** Upon receipt, the device SHALL resume its operation from the point it was at when it received the Pause command, or from the point when it was paused by means outside of this cluster (for example by manual button press). */ command Resume(): OperationalCommandResponse = 3; /** On receipt of this command, the device SHALL start seeking the charging dock, if possible in the current state of the device. */ @@ -3865,6 +3859,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; @@ -3913,8 +4012,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; @@ -3936,6 +4042,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; @@ -7807,9 +7914,9 @@ endpoint 1 { server cluster RvcRunMode { callback attribute supportedModes; callback attribute currentMode; - callback attribute onMode; callback attribute generatedCommandList; callback attribute acceptedCommandList; + callback attribute eventList; callback attribute attributeList; callback attribute featureMap; ram attribute clusterRevision default = 2; @@ -7821,9 +7928,9 @@ endpoint 1 { server cluster RvcCleanMode { callback attribute supportedModes; callback attribute currentMode; - callback attribute onMode; callback attribute generatedCommandList; callback attribute acceptedCommandList; + callback attribute eventList; callback attribute attributeList; callback attribute featureMap; ram attribute clusterRevision default = 2; @@ -7971,6 +8078,7 @@ endpoint 1 { callback attribute operationalError; callback attribute generatedCommandList; callback attribute acceptedCommandList; + callback attribute eventList; callback attribute attributeList; ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; @@ -8088,6 +8196,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; @@ -8096,11 +8233,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 438aef17a0516e..87d3e856477718 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": [ @@ -9470,11 +9470,11 @@ "reportableChange": 0 }, { - "name": "OnMode", - "code": 3, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, @@ -9486,8 +9486,8 @@ "reportableChange": 0 }, { - "name": "GeneratedCommandList", - "code": 65528, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", "type": "array", @@ -9502,8 +9502,8 @@ "reportableChange": 0 }, { - "name": "AcceptedCommandList", - "code": 65529, + "name": "EventList", + "code": 65530, "mfgCode": null, "side": "server", "type": "array", @@ -9626,11 +9626,11 @@ "reportableChange": 0 }, { - "name": "OnMode", - "code": 3, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, @@ -9642,8 +9642,8 @@ "reportableChange": 0 }, { - "name": "GeneratedCommandList", - "code": 65528, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", "type": "array", @@ -9658,8 +9658,8 @@ "reportableChange": 0 }, { - "name": "AcceptedCommandList", - "code": 65529, + "name": "EventList", + "code": 65530, "mfgCode": null, "side": "server", "type": "array", @@ -11353,6 +11353,22 @@ "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, @@ -12674,6 +12690,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, @@ -12763,6 +13199,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, @@ -12834,10 +13286,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/boolcfg-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/boolcfg-stub.cpp index 36716ec69ce52e..fe2ec9050683e8 100644 --- a/examples/all-clusters-app/all-clusters-common/src/boolcfg-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/boolcfg-stub.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include +#include #include #include 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/all-clusters-common/src/rvc-modes.cpp b/examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp index 999d62ae48c263..627709a8c30921 100644 --- a/examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp @@ -17,6 +17,7 @@ */ #include #include +#include using namespace chip::app::Clusters; using namespace chip::app::Clusters::RvcRunMode; @@ -40,14 +41,24 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands: { uint8_t currentMode = mInstance->GetCurrentMode(); - // Our business logic states that we can only switch into the mapping state from the idle state. - if (NewMode == RvcRunMode::ModeMapping && currentMode != RvcRunMode::ModeIdle) + // Our business logic states that we can only switch into a running mode from the idle state. + if (NewMode != RvcRunMode::ModeIdle && currentMode != RvcRunMode::ModeIdle) { response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode); - response.statusText.SetValue(chip::CharSpan::fromCharString("Change to the mapping mode is only allowed from idle")); + response.statusText.SetValue(chip::CharSpan::fromCharString("Change to a running mode is only allowed from idle")); return; } + auto rvcOpStateInstance = RvcOperationalState::GetRvcOperationalStateInstance(); + if (NewMode == RvcRunMode::ModeIdle) + { + rvcOpStateInstance->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped)); + } + else + { + rvcOpStateInstance->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)); + } + response.status = to_underlying(ModeBase::StatusCode::kSuccess); } @@ -112,7 +123,8 @@ void emberAfRvcRunModeClusterInitCallback(chip::EndpointId endpointId) VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1. VerifyOrDie(gRvcRunModeDelegate == nullptr && gRvcRunModeInstance == nullptr); gRvcRunModeDelegate = new RvcRunMode::RvcRunModeDelegate; - gRvcRunModeInstance = new ModeBase::Instance(gRvcRunModeDelegate, 0x1, RvcRunMode::Id, 0); + gRvcRunModeInstance = + new ModeBase::Instance(gRvcRunModeDelegate, 0x1, RvcRunMode::Id, chip::to_underlying(RvcRunMode::Feature::kNoFeatures)); gRvcRunModeInstance->Init(); } @@ -201,6 +213,7 @@ void emberAfRvcCleanModeClusterInitCallback(chip::EndpointId endpointId) VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1. VerifyOrDie(gRvcCleanModeDelegate == nullptr && gRvcCleanModeInstance == nullptr); gRvcCleanModeDelegate = new RvcCleanMode::RvcCleanModeDelegate; - gRvcCleanModeInstance = new ModeBase::Instance(gRvcCleanModeDelegate, 0x1, RvcCleanMode::Id, 0); + gRvcCleanModeInstance = + new ModeBase::Instance(gRvcCleanModeDelegate, 0x1, RvcCleanMode::Id, chip::to_underlying(RvcRunMode::Feature::kNoFeatures)); gRvcCleanModeInstance->Init(); } diff --git a/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp index 4b1e883a6b7d17..88c85f71fc3687 100644 --- a/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/examples/all-clusters-app/ameba/main/SmokeCOAlarmManager.cpp b/examples/all-clusters-app/ameba/main/SmokeCOAlarmManager.cpp index bede2bcf537a76..027bb055cca44f 100644 --- a/examples/all-clusters-app/ameba/main/SmokeCOAlarmManager.cpp +++ b/examples/all-clusters-app/ameba/main/SmokeCOAlarmManager.cpp @@ -16,7 +16,7 @@ */ #include "SmokeCOAlarmManager.h" -#include +#include #include using namespace chip; diff --git a/examples/all-clusters-app/ameba/main/chipinterface.cpp b/examples/all-clusters-app/ameba/main/chipinterface.cpp index 21280c676154be..20de9cd1ff0124 100644 --- a/examples/all-clusters-app/ameba/main/chipinterface.cpp +++ b/examples/all-clusters-app/ameba/main/chipinterface.cpp @@ -140,8 +140,10 @@ static void InitServer(intptr_t context) static chip::CommonCaseDeviceServerInitParams initParams; #if CONFIG_ENABLE_AMEBA_TEST_EVENT_TRIGGER - static AmebaTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + // TODO(#31723): Show to customers that they can do `Server::GetInstance().GetTestEventTriggerDelegate().AddHandler(xxx)` + // to add custom handlers during their app init, after InitServer. + static AmebaTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; #endif initParams.InitializeStaticResourcesBeforeServerInit(); diff --git a/examples/all-clusters-app/ameba/main/include/SmokeCOAlarmManager.h b/examples/all-clusters-app/ameba/main/include/SmokeCOAlarmManager.h index 390ee679d0d255..af6177299a3948 100644 --- a/examples/all-clusters-app/ameba/main/include/SmokeCOAlarmManager.h +++ b/examples/all-clusters-app/ameba/main/include/SmokeCOAlarmManager.h @@ -22,8 +22,6 @@ #include #include -bool emberAfHandleEventTrigger(uint64_t eventTrigger); - class SmokeCoAlarmManager { public: diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index f2f432a60d615a..641cbca7b55af0 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -36,7 +36,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/mode-support" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" @@ -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/nrfconnect/main/AppTask.cpp b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp index 9f471943406c80..f8d117790fac3d 100644 --- a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp +++ b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp @@ -27,8 +27,9 @@ #include #include +#include #include -#include +#include #include #include @@ -204,9 +205,12 @@ CHIP_ERROR AppTask::Init() #endif static CommonCaseDeviceServerInitParams initParams; - static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR); (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams)); AppFabricTableDelegate::Init(); diff --git a/examples/all-clusters-app/nxp/mw320/main.cpp b/examples/all-clusters-app/nxp/mw320/main.cpp index e103359f593400..b778d95fc4430b 100644 --- a/examples/all-clusters-app/nxp/mw320/main.cpp +++ b/examples/all-clusters-app/nxp/mw320/main.cpp @@ -1152,12 +1152,10 @@ void task_test_main(void * param) PRINTF("--> update CurrentPosition [%d] \r\n", value); Clusters::Switch::Attributes::CurrentPosition::Set(1, value); #ifdef SUPPORT_MANUAL_CTRL -#error \ - "This code thinks it's setting the OnOff attribute, but it's actually setting the NumberOfPositions attribute! And passing the wrong size for either case. Figure out what it's trying to do." - // sync-up the Light attribute (for test event, OO.M.ManuallyControlled) - PRINTF("--> update [Clusters::Switch::Id]: OnOff::Id [%d] \r\n", value); - emAfWriteAttribute(1, Clusters::Switch::Id, Clusters::OnOff::Attributes::OnOff::Id, (uint8_t *) &value, sizeof(value), - true, false); +#error "Not implemented" + // TODO: previous code was trying to write a OnOff cluster attribute id to a switch attribute, generally + // not working. Determine if this should maybe be + // OnOff::Attributes::OnOff::Set(1, is_on) or similar #endif // SUPPORT_MANUAL_CTRL need2sync_sw_attr = false; 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/chef/NEW_CHEF_DEVICES.md b/examples/chef/NEW_CHEF_DEVICES.md index 4f52b29966f415..c2e8538e7b8e5a 100644 --- a/examples/chef/NEW_CHEF_DEVICES.md +++ b/examples/chef/NEW_CHEF_DEVICES.md @@ -94,13 +94,13 @@ Basic device availability should show when running: ### Compilation -This example uses `rootnode_contactsensor_lFAGG1bfRO` for commands. Substitute +This example uses `rootnode_contactsensor_27f76aeaf5` for commands. Substitute your own device for testing newly created devices. ``` ./examples/chef/chef.py \ -t linux \ - -d rootnode_contactsensor_lFAGG1bfRO \ + -d rootnode_contactsensor_27f76aeaf5 \ -b ``` @@ -113,5 +113,5 @@ Where options used are: ### Execution Build will be available in -`examples/chef/linux/out/rootnode_contactsensor_lFAGG1bfRO` (path will vary +`examples/chef/linux/out/rootnode_contactsensor_27f76aeaf5` (path will vary based on platform and device being built) diff --git a/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter b/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter index 2fe383530fea5c..51dec4bd2d148c 100644 --- a/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter +++ b/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter @@ -1407,6 +1407,491 @@ cluster BooleanState = 69 { readonly attribute int16u clusterRevision = 65533; } +/** The Test Cluster is meant to validate the generated code */ +internal cluster UnitTesting = 4294048773 { + revision 1; // NOTE: Default/not specifically set + + enum SimpleEnum : enum8 { + kUnspecified = 0; + kValueA = 1; + kValueB = 2; + kValueC = 3; + } + + bitmap Bitmap16MaskMap : bitmap16 { + kMaskVal1 = 0x1; + kMaskVal2 = 0x2; + kMaskVal3 = 0x4; + kMaskVal4 = 0x4000; + } + + bitmap Bitmap32MaskMap : bitmap32 { + kMaskVal1 = 0x1; + kMaskVal2 = 0x2; + kMaskVal3 = 0x4; + kMaskVal4 = 0x40000000; + } + + bitmap Bitmap64MaskMap : bitmap64 { + kMaskVal1 = 0x1; + kMaskVal2 = 0x2; + kMaskVal3 = 0x4; + kMaskVal4 = 0x4000000000000000; + } + + bitmap Bitmap8MaskMap : bitmap8 { + kMaskVal1 = 0x1; + kMaskVal2 = 0x2; + kMaskVal3 = 0x4; + kMaskVal4 = 0x40; + } + + bitmap SimpleBitmap : bitmap8 { + kValueA = 0x1; + kValueB = 0x2; + kValueC = 0x4; + } + + struct SimpleStruct { + int8u a = 0; + boolean b = 1; + SimpleEnum c = 2; + octet_string d = 3; + char_string e = 4; + SimpleBitmap f = 5; + single g = 6; + double h = 7; + } + + fabric_scoped struct TestFabricScoped { + fabric_sensitive int8u fabricSensitiveInt8u = 1; + optional fabric_sensitive int8u optionalFabricSensitiveInt8u = 2; + nullable fabric_sensitive int8u nullableFabricSensitiveInt8u = 3; + optional nullable fabric_sensitive int8u nullableOptionalFabricSensitiveInt8u = 4; + fabric_sensitive char_string fabricSensitiveCharString = 5; + fabric_sensitive SimpleStruct fabricSensitiveStruct = 6; + fabric_sensitive int8u fabricSensitiveInt8uList[] = 7; + fabric_idx fabricIndex = 254; + } + + struct NullablesAndOptionalsStruct { + nullable int16u nullableInt = 0; + optional int16u optionalInt = 1; + optional nullable int16u nullableOptionalInt = 2; + nullable char_string nullableString = 3; + optional char_string optionalString = 4; + optional nullable char_string nullableOptionalString = 5; + nullable SimpleStruct nullableStruct = 6; + optional SimpleStruct optionalStruct = 7; + optional nullable SimpleStruct nullableOptionalStruct = 8; + nullable SimpleEnum nullableList[] = 9; + optional SimpleEnum optionalList[] = 10; + optional nullable SimpleEnum nullableOptionalList[] = 11; + } + + struct NestedStruct { + int8u a = 0; + boolean b = 1; + SimpleStruct c = 2; + } + + struct NestedStructList { + int8u a = 0; + boolean b = 1; + SimpleStruct c = 2; + SimpleStruct d[] = 3; + int32u e[] = 4; + octet_string f[] = 5; + int8u g[] = 6; + } + + struct DoubleNestedStructList { + NestedStructList a[] = 0; + } + + struct TestListStructOctet { + int64u member1 = 0; + octet_string<32> member2 = 1; + } + + info event TestEvent = 1 { + int8u arg1 = 1; + SimpleEnum arg2 = 2; + boolean arg3 = 3; + SimpleStruct arg4 = 4; + SimpleStruct arg5[] = 5; + SimpleEnum arg6[] = 6; + } + + fabric_sensitive info event TestFabricScopedEvent = 2 { + fabric_idx fabricIndex = 254; + } + + info event TestDifferentVendorMeiEvent = 4294050030 { + int8u arg1 = 1; + } + + attribute boolean boolean = 0; + attribute Bitmap8MaskMap bitmap8 = 1; + attribute Bitmap16MaskMap bitmap16 = 2; + attribute Bitmap32MaskMap bitmap32 = 3; + attribute Bitmap64MaskMap bitmap64 = 4; + attribute int8u int8u = 5; + attribute int16u int16u = 6; + attribute int24u int24u = 7; + attribute int32u int32u = 8; + attribute int40u int40u = 9; + attribute int48u int48u = 10; + attribute int56u int56u = 11; + attribute int64u int64u = 12; + attribute int8s int8s = 13; + attribute int16s int16s = 14; + attribute int24s int24s = 15; + attribute int32s int32s = 16; + attribute int40s int40s = 17; + attribute int48s int48s = 18; + attribute int56s int56s = 19; + attribute int64s int64s = 20; + attribute enum8 enum8 = 21; + attribute enum16 enum16 = 22; + attribute single floatSingle = 23; + attribute double floatDouble = 24; + attribute octet_string<10> octetString = 25; + attribute int8u listInt8u[] = 26; + attribute octet_string listOctetString[] = 27; + attribute TestListStructOctet listStructOctetString[] = 28; + attribute long_octet_string<1000> longOctetString = 29; + attribute char_string<10> charString = 30; + attribute long_char_string<1000> longCharString = 31; + attribute epoch_us epochUs = 32; + attribute epoch_s epochS = 33; + attribute vendor_id vendorId = 34; + attribute NullablesAndOptionalsStruct listNullablesAndOptionalsStruct[] = 35; + attribute SimpleEnum enumAttr = 36; + attribute SimpleStruct structAttr = 37; + attribute int8u rangeRestrictedInt8u = 38; + attribute int8s rangeRestrictedInt8s = 39; + attribute int16u rangeRestrictedInt16u = 40; + attribute int16s rangeRestrictedInt16s = 41; + attribute long_octet_string listLongOctetString[] = 42; + attribute TestFabricScoped listFabricScoped[] = 43; + timedwrite attribute boolean timedWriteBoolean = 48; + attribute boolean generalErrorBoolean = 49; + attribute boolean clusterErrorBoolean = 50; + attribute optional boolean unsupported = 255; + attribute nullable boolean nullableBoolean = 16384; + attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385; + attribute nullable Bitmap16MaskMap nullableBitmap16 = 16386; + attribute nullable Bitmap32MaskMap nullableBitmap32 = 16387; + attribute nullable Bitmap64MaskMap nullableBitmap64 = 16388; + attribute nullable int8u nullableInt8u = 16389; + attribute nullable int16u nullableInt16u = 16390; + attribute nullable int24u nullableInt24u = 16391; + attribute nullable int32u nullableInt32u = 16392; + attribute nullable int40u nullableInt40u = 16393; + attribute nullable int48u nullableInt48u = 16394; + attribute nullable int56u nullableInt56u = 16395; + attribute nullable int64u nullableInt64u = 16396; + attribute nullable int8s nullableInt8s = 16397; + attribute nullable int16s nullableInt16s = 16398; + attribute nullable int24s nullableInt24s = 16399; + attribute nullable int32s nullableInt32s = 16400; + attribute nullable int40s nullableInt40s = 16401; + attribute nullable int48s nullableInt48s = 16402; + attribute nullable int56s nullableInt56s = 16403; + attribute nullable int64s nullableInt64s = 16404; + attribute nullable enum8 nullableEnum8 = 16405; + attribute nullable enum16 nullableEnum16 = 16406; + attribute nullable single nullableFloatSingle = 16407; + attribute nullable double nullableFloatDouble = 16408; + attribute nullable octet_string<10> nullableOctetString = 16409; + attribute nullable char_string<10> nullableCharString = 16414; + attribute nullable SimpleEnum nullableEnumAttr = 16420; + attribute nullable SimpleStruct nullableStruct = 16421; + attribute nullable int8u nullableRangeRestrictedInt8u = 16422; + attribute nullable int8s nullableRangeRestrictedInt8s = 16423; + attribute nullable int16u nullableRangeRestrictedInt16u = 16424; + attribute nullable int16s nullableRangeRestrictedInt16s = 16425; + attribute optional int8u writeOnlyInt8u = 16426; + attribute int8u meiInt8u = 4294070017; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + response struct TestSpecificResponse = 0 { + int8u returnValue = 0; + } + + response struct TestAddArgumentsResponse = 1 { + int8u returnValue = 0; + } + + response struct TestSimpleArgumentResponse = 2 { + boolean returnValue = 0; + } + + response struct TestStructArrayArgumentResponse = 3 { + NestedStructList arg1[] = 0; + SimpleStruct arg2[] = 1; + SimpleEnum arg3[] = 2; + boolean arg4[] = 3; + SimpleEnum arg5 = 4; + boolean arg6 = 5; + } + + request struct TestAddArgumentsRequest { + int8u arg1 = 0; + int8u arg2 = 1; + } + + response struct TestListInt8UReverseResponse = 4 { + int8u arg1[] = 0; + } + + request struct TestSimpleArgumentRequestRequest { + boolean arg1 = 0; + } + + response struct TestEnumsResponse = 5 { + vendor_id arg1 = 0; + SimpleEnum arg2 = 1; + } + + request struct TestStructArrayArgumentRequestRequest { + NestedStructList arg1[] = 0; + SimpleStruct arg2[] = 1; + SimpleEnum arg3[] = 2; + boolean arg4[] = 3; + SimpleEnum arg5 = 4; + boolean arg6 = 5; + } + + response struct TestNullableOptionalResponse = 6 { + boolean wasPresent = 0; + optional boolean wasNull = 1; + optional int8u value = 2; + optional nullable int8u originalValue = 3; + } + + request struct TestStructArgumentRequestRequest { + SimpleStruct arg1 = 0; + } + + response struct TestComplexNullableOptionalResponse = 7 { + boolean nullableIntWasNull = 0; + optional int16u nullableIntValue = 1; + boolean optionalIntWasPresent = 2; + optional int16u optionalIntValue = 3; + boolean nullableOptionalIntWasPresent = 4; + optional boolean nullableOptionalIntWasNull = 5; + optional int16u nullableOptionalIntValue = 6; + boolean nullableStringWasNull = 7; + optional char_string nullableStringValue = 8; + boolean optionalStringWasPresent = 9; + optional char_string optionalStringValue = 10; + boolean nullableOptionalStringWasPresent = 11; + optional boolean nullableOptionalStringWasNull = 12; + optional char_string nullableOptionalStringValue = 13; + boolean nullableStructWasNull = 14; + optional SimpleStruct nullableStructValue = 15; + boolean optionalStructWasPresent = 16; + optional SimpleStruct optionalStructValue = 17; + boolean nullableOptionalStructWasPresent = 18; + optional boolean nullableOptionalStructWasNull = 19; + optional SimpleStruct nullableOptionalStructValue = 20; + boolean nullableListWasNull = 21; + optional SimpleEnum nullableListValue[] = 22; + boolean optionalListWasPresent = 23; + optional SimpleEnum optionalListValue[] = 24; + boolean nullableOptionalListWasPresent = 25; + optional boolean nullableOptionalListWasNull = 26; + optional SimpleEnum nullableOptionalListValue[] = 27; + } + + request struct TestNestedStructArgumentRequestRequest { + NestedStruct arg1 = 0; + } + + response struct BooleanResponse = 8 { + boolean value = 0; + } + + request struct TestListStructArgumentRequestRequest { + SimpleStruct arg1[] = 0; + } + + response struct SimpleStructResponse = 9 { + SimpleStruct arg1 = 0; + } + + request struct TestListInt8UArgumentRequestRequest { + int8u arg1[] = 0; + } + + response struct TestEmitTestEventResponse = 10 { + int64u value = 0; + } + + request struct TestNestedStructListArgumentRequestRequest { + NestedStructList arg1 = 0; + } + + response struct TestEmitTestFabricScopedEventResponse = 11 { + int64u value = 0; + } + + request struct TestListNestedStructListArgumentRequestRequest { + NestedStructList arg1[] = 0; + } + + response struct TestBatchHelperResponse = 12 { + octet_string<800> buffer = 0; + } + + request struct TestListInt8UReverseRequestRequest { + int8u arg1[] = 0; + } + + request struct TestEnumsRequestRequest { + vendor_id arg1 = 0; + SimpleEnum arg2 = 1; + } + + request struct TestNullableOptionalRequestRequest { + optional nullable int8u arg1 = 0; + } + + request struct TestComplexNullableOptionalRequestRequest { + nullable int16u nullableInt = 0; + optional int16u optionalInt = 1; + optional nullable int16u nullableOptionalInt = 2; + nullable char_string nullableString = 3; + optional char_string optionalString = 4; + optional nullable char_string nullableOptionalString = 5; + nullable SimpleStruct nullableStruct = 6; + optional SimpleStruct optionalStruct = 7; + optional nullable SimpleStruct nullableOptionalStruct = 8; + nullable SimpleEnum nullableList[] = 9; + optional SimpleEnum optionalList[] = 10; + optional nullable SimpleEnum nullableOptionalList[] = 11; + } + + request struct SimpleStructEchoRequestRequest { + SimpleStruct arg1 = 0; + } + + request struct TestSimpleOptionalArgumentRequestRequest { + optional boolean arg1 = 0; + } + + request struct TestEmitTestEventRequestRequest { + int8u arg1 = 0; + SimpleEnum arg2 = 1; + boolean arg3 = 2; + } + + request struct TestEmitTestFabricScopedEventRequestRequest { + int8u arg1 = 0; + } + + request struct TestBatchHelperRequestRequest { + int16u sleepBeforeResponseTimeMs = 0; + int16u sizeOfResponseBuffer = 1; + int8u fillCharacter = 2; + } + + request struct TestSecondBatchHelperRequestRequest { + int16u sleepBeforeResponseTimeMs = 0; + int16u sizeOfResponseBuffer = 1; + int8u fillCharacter = 2; + } + + request struct TestDifferentVendorMeiRequestRequest { + int8u arg1 = 0; + } + + response struct TestDifferentVendorMeiResponse = 4294049979 { + int8u arg1 = 0; + int64u eventNumber = 1; + } + + /** Simple command without any parameters and without a specific response. + To aid in unit testing, this command will re-initialize attribute storage to defaults. */ + command Test(): DefaultSuccess = 0; + /** Simple command without any parameters and without a specific response not handled by the server */ + command TestNotHandled(): DefaultSuccess = 1; + /** Simple command without any parameters and with a specific response */ + command TestSpecific(): TestSpecificResponse = 2; + /** Simple command that should not be added to the server. */ + command TestUnknownCommand(): DefaultSuccess = 3; + /** Command that takes two arguments and returns their sum. */ + command TestAddArguments(TestAddArgumentsRequest): TestAddArgumentsResponse = 4; + /** Command that takes an argument which is bool */ + command TestSimpleArgumentRequest(TestSimpleArgumentRequestRequest): TestSimpleArgumentResponse = 5; + /** Command that takes various arguments that are arrays, including an array of structs which have a list member. */ + command TestStructArrayArgumentRequest(TestStructArrayArgumentRequestRequest): TestStructArrayArgumentResponse = 6; + /** Command that takes an argument which is struct. The response echoes the + 'b' field of the single arg. */ + command TestStructArgumentRequest(TestStructArgumentRequestRequest): BooleanResponse = 7; + /** Command that takes an argument which is nested struct. The response + echoes the 'b' field of ar1.c. */ + command TestNestedStructArgumentRequest(TestNestedStructArgumentRequestRequest): BooleanResponse = 8; + /** Command that takes an argument which is a list of structs. The response + returns false if there is some struct in the list whose 'b' field is + false, and true otherwise (including if the list is empty). */ + command TestListStructArgumentRequest(TestListStructArgumentRequestRequest): BooleanResponse = 9; + /** Command that takes an argument which is a list of INT8U. The response + returns false if the list contains a 0 in it, true otherwise (including + if the list is empty). */ + command TestListInt8UArgumentRequest(TestListInt8UArgumentRequestRequest): BooleanResponse = 10; + /** Command that takes an argument which is a Nested Struct List. The + response returns false if there is some struct in arg1 (either directly + in arg1.c or in the arg1.d list) whose 'b' field is false, and true + otherwise. */ + command TestNestedStructListArgumentRequest(TestNestedStructListArgumentRequestRequest): BooleanResponse = 11; + /** Command that takes an argument which is a list of Nested Struct List. + The response returns false if there is some struct in arg1 (either + directly in as the 'c' field of an entry 'd' list of an entry) whose 'b' + field is false, and true otherwise (including if the list is empty). */ + command TestListNestedStructListArgumentRequest(TestListNestedStructListArgumentRequestRequest): BooleanResponse = 12; + /** Command that takes an argument which is a list of INT8U and expects a + response that reverses the list. */ + command TestListInt8UReverseRequest(TestListInt8UReverseRequestRequest): TestListInt8UReverseResponse = 13; + /** Command that sends a vendor id and an enum. The server is expected to + echo them back. */ + command TestEnumsRequest(TestEnumsRequestRequest): TestEnumsResponse = 14; + /** Command that takes an argument which is nullable and optional. The + response returns a boolean indicating whether the argument was present, + if that's true a boolean indicating whether the argument was null, and + if that' false the argument it received. */ + command TestNullableOptionalRequest(TestNullableOptionalRequestRequest): TestNullableOptionalResponse = 15; + /** Command that takes various arguments which can be nullable and/or optional. The + response returns information about which things were received and what + their state was. */ + command TestComplexNullableOptionalRequest(TestComplexNullableOptionalRequestRequest): TestComplexNullableOptionalResponse = 16; + /** Command that takes an argument which is a struct. The response echoes + the struct back. */ + command SimpleStructEchoRequest(SimpleStructEchoRequestRequest): SimpleStructResponse = 17; + /** Command that just responds with a success status if the timed invoke + conditions are met. */ + timed command TimedInvokeRequest(): DefaultSuccess = 18; + /** Command that takes an optional argument which is bool. It responds with a success value if the optional is set to any value. */ + command TestSimpleOptionalArgumentRequest(TestSimpleOptionalArgumentRequestRequest): DefaultSuccess = 19; + /** Command that takes identical arguments to the fields of the TestEvent and logs the TestEvent to the buffer. Command returns an event ID as the response. */ + command TestEmitTestEventRequest(TestEmitTestEventRequestRequest): TestEmitTestEventResponse = 20; + /** Command that takes identical arguments to the fields of the TestFabricScopedEvent and logs the TestFabricScopedEvent to the buffer. Command returns an event ID as the response. */ + command TestEmitTestFabricScopedEventRequest(TestEmitTestFabricScopedEventRequestRequest): TestEmitTestFabricScopedEventResponse = 21; + /** Command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */ + command TestBatchHelperRequest(TestBatchHelperRequestRequest): TestBatchHelperResponse = 22; + /** Second command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */ + command TestSecondBatchHelperRequest(TestSecondBatchHelperRequestRequest): TestBatchHelperResponse = 23; + /** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */ + command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962; +} + endpoint 0 { device type ma_rootdevice = 22, version 1; @@ -1661,6 +2146,127 @@ endpoint 1 { ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; } + + server cluster UnitTesting { + emits event TestEvent; + emits event TestFabricScopedEvent; + emits event TestDifferentVendorMeiEvent; + ram attribute boolean default = false; + ram attribute bitmap8 default = 0; + ram attribute bitmap16 default = 0; + ram attribute bitmap32 default = 0; + ram attribute bitmap64 default = 0; + ram attribute int8u default = 0; + ram attribute int16u default = 0; + ram attribute int24u default = 0; + ram attribute int32u default = 0; + ram attribute int40u default = 0; + ram attribute int48u default = 0; + ram attribute int56u default = 0; + ram attribute int64u default = 0; + ram attribute int8s default = 0; + ram attribute int16s default = 0; + ram attribute int24s default = 0; + ram attribute int32s default = 0; + ram attribute int40s default = 0; + ram attribute int48s default = 0; + ram attribute int56s default = 0; + ram attribute int64s default = 0; + ram attribute enum8 default = 0; + ram attribute enum16 default = 0; + ram attribute floatSingle default = 0; + ram attribute floatDouble default = 0; + ram attribute octetString; + callback attribute listInt8u; + callback attribute listOctetString; + callback attribute listStructOctetString; + ram attribute longOctetString; + ram attribute charString; + ram attribute longCharString; + ram attribute epochUs; + ram attribute epochS; + ram attribute vendorId; + callback attribute listNullablesAndOptionalsStruct; + ram attribute enumAttr; + callback attribute structAttr; + ram attribute rangeRestrictedInt8u default = 70; + ram attribute rangeRestrictedInt8s default = -20; + ram attribute rangeRestrictedInt16u default = 200; + ram attribute rangeRestrictedInt16s default = -100; + callback attribute listLongOctetString; + callback attribute listFabricScoped; + ram attribute timedWriteBoolean; + callback attribute generalErrorBoolean; + callback attribute clusterErrorBoolean; + ram attribute nullableBoolean default = false; + ram attribute nullableBitmap8 default = 0; + ram attribute nullableBitmap16 default = 0; + ram attribute nullableBitmap32 default = 0; + ram attribute nullableBitmap64 default = 0; + ram attribute nullableInt8u default = 0; + ram attribute nullableInt16u default = 0; + ram attribute nullableInt24u default = 0; + ram attribute nullableInt32u default = 0; + ram attribute nullableInt40u default = 0; + ram attribute nullableInt48u default = 0; + ram attribute nullableInt56u default = 0; + ram attribute nullableInt64u default = 0; + ram attribute nullableInt8s default = 0; + ram attribute nullableInt16s default = 0; + ram attribute nullableInt24s default = 0; + ram attribute nullableInt32s default = 0; + ram attribute nullableInt40s default = 0; + ram attribute nullableInt48s default = 0; + ram attribute nullableInt56s default = 0; + ram attribute nullableInt64s default = 0; + ram attribute nullableEnum8 default = 0; + ram attribute nullableEnum16 default = 0; + ram attribute nullableFloatSingle default = 0; + ram attribute nullableFloatDouble default = 0; + ram attribute nullableOctetString; + ram attribute nullableCharString; + ram attribute nullableEnumAttr; + callback attribute nullableStruct; + ram attribute nullableRangeRestrictedInt8u default = 70; + ram attribute nullableRangeRestrictedInt8s default = -20; + ram attribute nullableRangeRestrictedInt16u default = 200; + ram attribute nullableRangeRestrictedInt16s default = -100; + callback attribute writeOnlyInt8u default = 0; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + ram attribute meiInt8u default = 0; + + handle command Test; + handle command TestSpecificResponse; + handle command TestNotHandled; + handle command TestAddArgumentsResponse; + handle command TestSpecific; + handle command TestAddArguments; + handle command TestListInt8UReverseResponse; + handle command TestEnumsResponse; + handle command TestNullableOptionalResponse; + handle command TestStructArgumentRequest; + handle command TestNestedStructArgumentRequest; + handle command TestListStructArgumentRequest; + handle command SimpleStructResponse; + handle command TestListInt8UArgumentRequest; + handle command TestEmitTestEventResponse; + handle command TestNestedStructListArgumentRequest; + handle command TestEmitTestFabricScopedEventResponse; + handle command TestListNestedStructListArgumentRequest; + handle command TestListInt8UReverseRequest; + handle command TestEnumsRequest; + handle command TestNullableOptionalRequest; + handle command SimpleStructEchoRequest; + handle command TimedInvokeRequest; + handle command TestSimpleOptionalArgumentRequest; + handle command TestEmitTestEventRequest; + handle command TestEmitTestFabricScopedEventRequest; + handle command TestBatchHelperRequest; + handle command TestSecondBatchHelperRequest; + handle command TestDifferentVendorMeiRequest; + handle command TestDifferentVendorMeiResponse; + } } diff --git a/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.zap b/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.zap index cbbcbea13c6d81..b50f9ae5b24dfd 100644 --- a/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.zap +++ b/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.zap @@ -2889,6 +2889,1626 @@ "reportableChange": 0 } ] + }, + { + "name": "Unit Testing", + "code": 4294048773, + "mfgCode": null, + "define": "UNIT_TESTING_CLUSTER", + "side": "server", + "enabled": 1, + "apiMaturity": "internal", + "commands": [ + { + "name": "Test", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestSpecificResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "TestNotHandled", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestAddArgumentsResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "TestSpecific", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestAddArguments", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestListInt8UReverseResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "TestEnumsResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "TestNullableOptionalResponse", + "code": 6, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "TestStructArgumentRequest", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestNestedStructArgumentRequest", + "code": 8, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestListStructArgumentRequest", + "code": 9, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "SimpleStructResponse", + "code": 9, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "TestListInt8UArgumentRequest", + "code": 10, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestEmitTestEventResponse", + "code": 10, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "TestNestedStructListArgumentRequest", + "code": 11, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestEmitTestFabricScopedEventResponse", + "code": 11, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, + { + "name": "TestListNestedStructListArgumentRequest", + "code": 12, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestListInt8UReverseRequest", + "code": 13, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestEnumsRequest", + "code": 14, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestNullableOptionalRequest", + "code": 15, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "SimpleStructEchoRequest", + "code": 17, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TimedInvokeRequest", + "code": 18, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestSimpleOptionalArgumentRequest", + "code": 19, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestEmitTestEventRequest", + "code": 20, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestEmitTestFabricScopedEventRequest", + "code": 21, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestBatchHelperRequest", + "code": 22, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestSecondBatchHelperRequest", + "code": 23, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestDifferentVendorMeiRequest", + "code": 4294049962, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestDifferentVendorMeiResponse", + "code": 4294049979, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "boolean", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "false", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "bitmap8", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "Bitmap8MaskMap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "bitmap16", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "Bitmap16MaskMap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "bitmap32", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "Bitmap32MaskMap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "bitmap64", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "Bitmap64MaskMap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "int8u", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "int16u", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "int24u", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int24u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "int32u", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "int40u", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int40u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "int48u", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "int48u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "int56u", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "int56u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "int64u", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "int8s", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "int8s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "int16s", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "int16s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "int24s", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "int24s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "int32s", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int32s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "int40s", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int40s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "int48s", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int48s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "int56s", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int56s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "int64s", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "int64s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "enum8", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "enum16", + "code": 22, + "mfgCode": null, + "side": "server", + "type": "enum16", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "float_single", + "code": 23, + "mfgCode": null, + "side": "server", + "type": "single", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "float_double", + "code": 24, + "mfgCode": null, + "side": "server", + "type": "double", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "octet_string", + "code": 25, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "list_int8u", + "code": 26, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "list_octet_string", + "code": 27, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "list_struct_octet_string", + "code": 28, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "long_octet_string", + "code": 29, + "mfgCode": null, + "side": "server", + "type": "long_octet_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "char_string", + "code": 30, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "long_char_string", + "code": 31, + "mfgCode": null, + "side": "server", + "type": "long_char_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "epoch_us", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "epoch_us", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "epoch_s", + "code": 33, + "mfgCode": null, + "side": "server", + "type": "epoch_s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "vendor_id", + "code": 34, + "mfgCode": null, + "side": "server", + "type": "vendor_id", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "list_nullables_and_optionals_struct", + "code": 35, + "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": "enum_attr", + "code": 36, + "mfgCode": null, + "side": "server", + "type": "SimpleEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "struct_attr", + "code": 37, + "mfgCode": null, + "side": "server", + "type": "SimpleStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "range_restricted_int8u", + "code": 38, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "70", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "range_restricted_int8s", + "code": 39, + "mfgCode": null, + "side": "server", + "type": "int8s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "-20", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "range_restricted_int16u", + "code": 40, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "200", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "range_restricted_int16s", + "code": 41, + "mfgCode": null, + "side": "server", + "type": "int16s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "-100", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "list_long_octet_string", + "code": 42, + "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": "list_fabric_scoped", + "code": 43, + "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": "timed_write_boolean", + "code": 48, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "general_error_boolean", + "code": 49, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "cluster_error_boolean", + "code": 50, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_boolean", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "false", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_bitmap8", + "code": 16385, + "mfgCode": null, + "side": "server", + "type": "Bitmap8MaskMap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_bitmap16", + "code": 16386, + "mfgCode": null, + "side": "server", + "type": "Bitmap16MaskMap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_bitmap32", + "code": 16387, + "mfgCode": null, + "side": "server", + "type": "Bitmap32MaskMap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_bitmap64", + "code": 16388, + "mfgCode": null, + "side": "server", + "type": "Bitmap64MaskMap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int8u", + "code": 16389, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int16u", + "code": 16390, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int24u", + "code": 16391, + "mfgCode": null, + "side": "server", + "type": "int24u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int32u", + "code": 16392, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int40u", + "code": 16393, + "mfgCode": null, + "side": "server", + "type": "int40u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int48u", + "code": 16394, + "mfgCode": null, + "side": "server", + "type": "int48u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int56u", + "code": 16395, + "mfgCode": null, + "side": "server", + "type": "int56u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int64u", + "code": 16396, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int8s", + "code": 16397, + "mfgCode": null, + "side": "server", + "type": "int8s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int16s", + "code": 16398, + "mfgCode": null, + "side": "server", + "type": "int16s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int24s", + "code": 16399, + "mfgCode": null, + "side": "server", + "type": "int24s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int32s", + "code": 16400, + "mfgCode": null, + "side": "server", + "type": "int32s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int40s", + "code": 16401, + "mfgCode": null, + "side": "server", + "type": "int40s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int48s", + "code": 16402, + "mfgCode": null, + "side": "server", + "type": "int48s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int56s", + "code": 16403, + "mfgCode": null, + "side": "server", + "type": "int56s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_int64s", + "code": 16404, + "mfgCode": null, + "side": "server", + "type": "int64s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_enum8", + "code": 16405, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_enum16", + "code": 16406, + "mfgCode": null, + "side": "server", + "type": "enum16", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_float_single", + "code": 16407, + "mfgCode": null, + "side": "server", + "type": "single", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_float_double", + "code": 16408, + "mfgCode": null, + "side": "server", + "type": "double", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_octet_string", + "code": 16409, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_char_string", + "code": 16414, + "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": "nullable_enum_attr", + "code": 16420, + "mfgCode": null, + "side": "server", + "type": "SimpleEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_struct", + "code": 16421, + "mfgCode": null, + "side": "server", + "type": "SimpleStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_range_restricted_int8u", + "code": 16422, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "70", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_range_restricted_int8s", + "code": 16423, + "mfgCode": null, + "side": "server", + "type": "int8s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "-20", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_range_restricted_int16u", + "code": 16424, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "200", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_range_restricted_int16s", + "code": 16425, + "mfgCode": null, + "side": "server", + "type": "int16s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "-100", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "write_only_int8u", + "code": 16426, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "mei_int8u", + "code": 4294070017, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "TestEvent", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "TestFabricScopedEvent", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "TestDifferentVendorMeiEvent", + "code": 4294050030, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] } ] } diff --git a/examples/chef/devices/rootnode_roboticvacuumcleaner_1807ff0c49.matter b/examples/chef/devices/rootnode_roboticvacuumcleaner_1807ff0c49.matter index 58e7d6e04bb19d..dc190ad05ecd31 100644 --- a/examples/chef/devices/rootnode_roboticvacuumcleaner_1807ff0c49.matter +++ b/examples/chef/devices/rootnode_roboticvacuumcleaner_1807ff0c49.matter @@ -1020,7 +1020,7 @@ cluster RvcRunMode = 84 { } bitmap Feature : bitmap32 { - kOnOff = 0x1; + kNoFeatures = 0x0; } struct ModeTagStruct { @@ -1036,7 +1036,6 @@ cluster RvcRunMode = 84 { readonly attribute ModeOptionStruct supportedModes[] = 0; readonly attribute int8u currentMode = 1; - attribute optional nullable int8u onMode = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1073,7 +1072,7 @@ cluster RvcCleanMode = 85 { } bitmap Feature : bitmap32 { - kOnOff = 0x1; + kNoFeatures = 0x0; } struct ModeTagStruct { @@ -1089,7 +1088,6 @@ cluster RvcCleanMode = 85 { readonly attribute ModeOptionStruct supportedModes[] = 0; readonly attribute int8u currentMode = 1; - attribute optional nullable int8u onMode = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1172,10 +1170,6 @@ cluster RvcOperationalState = 97 { /** Upon receipt, the device SHALL pause its operation if it is possible based on the current function of the server. */ command Pause(): OperationalCommandResponse = 0; - /** Upon receipt, the device SHALL stop its operation if it is at a position where it is safe to do so and/or permitted. */ - command Stop(): OperationalCommandResponse = 1; - /** Upon receipt, the device SHALL start its operation if it is safe to do so and the device is in an operational state from which it can be started. */ - command Start(): OperationalCommandResponse = 2; /** Upon receipt, the device SHALL resume its operation from the point it was at when it received the Pause command, or from the point when it was paused by means outside of this cluster (for example by manual button press). */ command Resume(): OperationalCommandResponse = 3; /** On receipt of this command, the device SHALL start seeking the charging dock, if possible in the current state of the device. */ @@ -1410,7 +1404,6 @@ endpoint 1 { server cluster RvcRunMode { callback attribute supportedModes; callback attribute currentMode; - callback attribute onMode; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; @@ -1425,7 +1418,6 @@ endpoint 1 { server cluster RvcCleanMode { callback attribute supportedModes; callback attribute currentMode; - callback attribute onMode; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; @@ -1454,8 +1446,6 @@ endpoint 1 { ram attribute clusterRevision default = 1; handle command Pause; - handle command Stop; - handle command Start; handle command Resume; handle command OperationalCommandResponse; } diff --git a/examples/chef/esp32/main/CMakeLists.txt b/examples/chef/esp32/main/CMakeLists.txt index 6c342d07b4fa15..e6ab518f3494a9 100644 --- a/examples/chef/esp32/main/CMakeLists.txt +++ b/examples/chef/esp32/main/CMakeLists.txt @@ -141,6 +141,17 @@ pw_proto_library(attributes_service pw_protobuf.common_proto ) +pw_proto_library(boolean_state_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/boolean_state_service.proto + PREFIX + boolean_state_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_proto +) + pw_proto_library(button_service SOURCES ${CHIP_ROOT}/examples/common/pigweed/protos/button_service.proto @@ -191,6 +202,7 @@ pw_proto_library(wifi_service target_link_libraries(${COMPONENT_LIB} PUBLIC attributes_service.nanopb_rpc + boolean_state_service.nanopb_rpc button_service.nanopb_rpc descriptor_service.nanopb_rpc device_service.nanopb_rpc @@ -215,6 +227,7 @@ target_link_options(${COMPONENT_LIB} target_compile_options(${COMPONENT_LIB} PRIVATE "-DPW_RPC_ATTRIBUTE_SERVICE=1" + "-DPW_RPC_BOOLEAN_STATE_SERVICE=1" "-DPW_RPC_BUTTON_SERVICE=1" "-DPW_RPC_DEVICE_SERVICE=1" "-DPW_RPC_DESCRIPTOR_SERVICE=1" diff --git a/examples/chef/linux/BUILD.gn b/examples/chef/linux/BUILD.gn index fa12a79a91a09f..a25c1f5ffa11ce 100644 --- a/examples/chef/linux/BUILD.gn +++ b/examples/chef/linux/BUILD.gn @@ -69,6 +69,7 @@ executable("${sample_name}") { defines = [ "PW_RPC_ENABLED", "PW_RPC_ATTRIBUTE_SERVICE=1", + "PW_RPC_BOOLEAN_STATE_SERVICE=1", "PW_RPC_BUTTON_SERVICE=1", "PW_RPC_DESCRIPTOR_SERVICE=1", "PW_RPC_DEVICE_SERVICE=1", @@ -95,6 +96,7 @@ executable("${sample_name}") { "$dir_pw_trace_tokenized:trace_rpc_service", "${chip_root}/config/linux/lib/pw_rpc:pw_rpc", "${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:boolean_state_service.nanopb_rpc", "${chip_root}/examples/common/pigweed:button_service.nanopb_rpc", "${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc", "${chip_root}/examples/common/pigweed:device_service.nanopb_rpc", diff --git a/examples/chef/nrfconnect/CMakeLists.txt b/examples/chef/nrfconnect/CMakeLists.txt index 1d9ab2fb436a62..17556ef398b27a 100644 --- a/examples/chef/nrfconnect/CMakeLists.txt +++ b/examples/chef/nrfconnect/CMakeLists.txt @@ -133,6 +133,17 @@ pw_proto_library(attributes_service pw_protobuf.common_proto ) +pw_proto_library(boolean_state_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/boolean_state_service.proto + PREFIX + boolean_state_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_proto +) + pw_proto_library(descriptor_service SOURCES ${CHIP_ROOT}/examples/common/pigweed/protos/descriptor_service.proto @@ -202,6 +213,7 @@ target_include_directories(app PRIVATE target_compile_options(app PRIVATE "-DPW_RPC_ATTRIBUTE_SERVICE=1" + "-DPW_RPC_BOOLEAN_STATE_SERVICE=1" "-DPW_RPC_DESCRIPTOR_SERVICE=1" "-DPW_RPC_DEVICE_SERVICE=1" "-DPW_RPC_THREAD_SERVICE=1" @@ -209,6 +221,7 @@ target_compile_options(app PRIVATE target_link_libraries(app PRIVATE attributes_service.nanopb_rpc + boolean_state_service.nanopb_rpc descriptor_service.nanopb_rpc device_service.nanopb_rpc thread_service.nanopb_rpc diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index c6f5edc819ba95..a27c3cd65716bd 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -110,6 +110,7 @@ static_library("chip-tool-utils") { "${chip_root}/src/controller/data_model", "${chip_root}/src/credentials:file_attestation_trust_store", "${chip_root}/src/lib", + "${chip_root}/src/lib/core:types", "${chip_root}/src/lib/support/jsontlv", "${chip_root}/src/platform", "${chip_root}/third_party/inipp", diff --git a/examples/chip-tool/commands/clusters/ModelCommand.cpp b/examples/chip-tool/commands/clusters/ModelCommand.cpp index 31fd2e14a15a1f..c908f9fa71b548 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.cpp +++ b/examples/chip-tool/commands/clusters/ModelCommand.cpp @@ -19,6 +19,7 @@ #include "ModelCommand.h" #include +#include #include using namespace ::chip; @@ -35,6 +36,7 @@ CHIP_ERROR ModelCommand::RunCommand() } ChipLogProgress(chipTool, "Sending command to node 0x%" PRIx64, mDestinationId); + CheckPeerICDType(); CommissioneeDeviceProxy * commissioneeDeviceProxy = nullptr; if (CHIP_NO_ERROR == CurrentCommissioner().GetDeviceBeingCommissioned(mDestinationId, &commissioneeDeviceProxy)) @@ -73,3 +75,31 @@ void ModelCommand::Shutdown() CHIPCommand::Shutdown(); } + +void ModelCommand::CheckPeerICDType() +{ + if (mIsPeerLIT.HasValue()) + { + ChipLogProgress(chipTool, "Peer ICD type is set to %s", mIsPeerLIT.Value() == 1 ? "LIT-ICD" : "non LIT-ICD"); + return; + } + + app::ICDClientInfo info; + auto destinationPeerId = chip::ScopedNodeId(mDestinationId, CurrentCommissioner().GetFabricIndex()); + auto iter = CHIPCommand::sICDClientStorage.IterateICDClientInfo(); + if (iter == nullptr) + { + return; + } + app::DefaultICDClientStorage::ICDClientInfoIteratorWrapper clientInfoIteratorWrapper(iter); + + while (iter->Next(info)) + { + if (ScopedNodeId(info.peer_node.GetNodeId(), info.peer_node.GetFabricIndex()) == destinationPeerId) + { + ChipLogProgress(chipTool, "Peer is a registered LIT ICD."); + mIsPeerLIT.SetValue(true); + return; + } + } +} diff --git a/examples/chip-tool/commands/clusters/ModelCommand.h b/examples/chip-tool/commands/clusters/ModelCommand.h index 0b6339ab60f5ed..9561932c9b74e0 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.h +++ b/examples/chip-tool/commands/clusters/ModelCommand.h @@ -52,6 +52,10 @@ class ModelCommand : public CHIPCommand "Endpoint the command is targeted at."); } } + AddArgument( + "lit-icd-peer", 0, 1, &mIsPeerLIT, + "Whether to treat the peer as a LIT ICD. false: Always no, true: Always yes, (not set): Yes if the peer is registered " + "to this controller."); AddArgument("timeout", 0, UINT16_MAX, &mTimeout); } @@ -66,11 +70,16 @@ class ModelCommand : public CHIPCommand void Shutdown() override; protected: + bool IsPeerLIT() { return mIsPeerLIT.ValueOr(false); } + chip::Optional mTimeout; private: chip::NodeId mDestinationId; std::vector mEndPointId; + chip::Optional mIsPeerLIT; + + void CheckPeerICDType(); static void OnDeviceConnectedFn(void * context, chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle); diff --git a/examples/chip-tool/commands/clusters/ReportCommand.h b/examples/chip-tool/commands/clusters/ReportCommand.h index eefd938c2d0717..e2c0f1db785900 100644 --- a/examples/chip-tool/commands/clusters/ReportCommand.h +++ b/examples/chip-tool/commands/clusters/ReportCommand.h @@ -277,6 +277,7 @@ class SubscribeAttribute : public SubscribeCommand CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override { + SubscribeCommand::SetPeerLIT(IsPeerLIT()); return SubscribeCommand::SubscribeAttribute(device, endpointIds, mClusterIds, mAttributeIds); } @@ -407,6 +408,7 @@ class SubscribeEvent : public SubscribeCommand CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override { + SubscribeCommand::SetPeerLIT(IsPeerLIT()); return SubscribeCommand::SubscribeEvent(device, endpointIds, mClusterIds, mEventIds); } @@ -538,6 +540,7 @@ class SubscribeAll : public SubscribeCommand CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override { + SubscribeCommand::SetPeerLIT(IsPeerLIT()); return SubscribeCommand::SubscribeAll(device, endpointIds, mClusterIds, mAttributeIds, mEventIds); } diff --git a/examples/chip-tool/commands/icd/ICDCommand.cpp b/examples/chip-tool/commands/icd/ICDCommand.cpp index 4d8ab7e93452d1..fbfc6a2083a5d5 100644 --- a/examples/chip-tool/commands/icd/ICDCommand.cpp +++ b/examples/chip-tool/commands/icd/ICDCommand.cpp @@ -18,6 +18,7 @@ #include "ICDCommand.h" +#include #include #include @@ -29,6 +30,11 @@ CHIP_ERROR ICDListCommand::RunCommand() auto iter = CHIPCommand::sICDClientStorage.IterateICDClientInfo(); char icdAesKeyHex[Crypto::kAES_CCM128_Key_Length * 2 + 1]; char icdHmacKeyHex[Crypto::kHMAC_CCM128_Key_Length * 2 + 1]; + if (iter == nullptr) + { + return CHIP_ERROR_NO_MEMORY; + } + app::DefaultICDClientStorage::ICDClientInfoIteratorWrapper clientInfoIteratorWrapper(iter); fprintf(stderr, " +-----------------------------------------------------------------------------+\n"); fprintf(stderr, " | %-75s |\n", "Known ICDs:"); fprintf(stderr, " +-----------------------------------------------------------------------------+\n"); @@ -54,8 +60,6 @@ CHIP_ERROR ICDListCommand::RunCommand() } fprintf(stderr, " +-----------------------------------------------------------------------------+\n"); - - iter->Release(); SetCommandExitStatus(CHIP_NO_ERROR); return CHIP_NO_ERROR; } diff --git a/examples/common/pigweed/BUILD.gn b/examples/common/pigweed/BUILD.gn index d190b07fd85082..e056f2ef228a8a 100644 --- a/examples/common/pigweed/BUILD.gn +++ b/examples/common/pigweed/BUILD.gn @@ -43,6 +43,13 @@ pw_proto_library("attributes_service") { prefix = "attributes_service" } +pw_proto_library("boolean_state_service") { + sources = [ "protos/boolean_state_service.proto" ] + deps = [ "$dir_pw_protobuf:common_protos" ] + strip_prefix = "protos" + prefix = "boolean_state_service" +} + pw_proto_library("device_service") { sources = [ "protos/device_service.proto" ] inputs = [ "protos/device_service.options" ] diff --git a/examples/common/pigweed/protos/boolean_state_service.proto b/examples/common/pigweed/protos/boolean_state_service.proto new file mode 100644 index 00000000000000..ea15c0174f33b9 --- /dev/null +++ b/examples/common/pigweed/protos/boolean_state_service.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +import 'pw_protobuf_protos/common.proto'; + +package chip.rpc; + +// This may eventually contain more attributes. +message BooleanStateState { + bool state_value = 1; +} + +message BooleanStateSetRequest { + uint32 endpoint_id = 1; + bool state_value = 2; +} + +message BooleanStateSetResponse { + uint64 event_number = 1; +} + +message BooleanStateGetRequest { + uint32 endpoint_id = 1; +} + +message BooleanStateGetResponse { + BooleanStateState state = 1; +} + +service BooleanState { + // Set will return generated event number (caused by change) if all supported fields are successfully applied, any + // unsupported fields will be ignored. + rpc Set(BooleanStateSetRequest) returns (BooleanStateSetResponse){} + + // Get will populate all of the supported boolean state cluster state fields + // with the current values. + rpc Get(BooleanStateGetRequest) returns (BooleanStateGetResponse){} +} diff --git a/examples/common/pigweed/rpc_console/py/BUILD.gn b/examples/common/pigweed/rpc_console/py/BUILD.gn index 5c74b7b2599544..a050fb64747302 100644 --- a/examples/common/pigweed/rpc_console/py/BUILD.gn +++ b/examples/common/pigweed/rpc_console/py/BUILD.gn @@ -40,6 +40,7 @@ pw_python_package("chip_rpc") { "$dir_pw_system/py", "$dir_pw_tokenizer/py", "${chip_root}/examples/common/pigweed:attributes_service.python", + "${chip_root}/examples/common/pigweed:boolean_state_service.python", "${chip_root}/examples/common/pigweed:button_service.python", "${chip_root}/examples/common/pigweed:descriptor_service.python", "${chip_root}/examples/common/pigweed:device_service.python", diff --git a/examples/common/pigweed/rpc_console/py/chip_rpc/console.py b/examples/common/pigweed/rpc_console/py/chip_rpc/console.py index 6d2b06fd73208f..f5ed5b5ab4d582 100644 --- a/examples/common/pigweed/rpc_console/py/chip_rpc/console.py +++ b/examples/common/pigweed/rpc_console/py/chip_rpc/console.py @@ -47,6 +47,7 @@ # Protos # isort: off from attributes_service import attributes_service_pb2 +from boolean_state_service import boolean_state_service_pb2 from button_service import button_service_pb2 from descriptor_service import descriptor_service_pb2 from device_service import device_service_pb2 @@ -128,6 +129,7 @@ def show_console(device: str, baudrate: int, use_ipython=True, compiled_protos=[ attributes_service_pb2, + boolean_state_service_pb2, button_service_pb2, descriptor_service_pb2, device_service_pb2, diff --git a/examples/common/pigweed/rpc_services/BooleanState.h b/examples/common/pigweed/rpc_services/BooleanState.h new file mode 100644 index 00000000000000..bb4b524459d03d --- /dev/null +++ b/examples/common/pigweed/rpc_services/BooleanState.h @@ -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. + */ + +#pragma once + +#include "app/util/attribute-storage.h" +#include "boolean_state_service/boolean_state_service.rpc.pb.h" +#include "pigweed/rpc_services/internal/StatusUtils.h" +#include +#include +#include + +namespace chip { +namespace rpc { + +class BooleanState final : public pw_rpc::nanopb::BooleanState::Service +{ +public: + virtual ~BooleanState() = default; + + virtual pw::Status Set(const chip_rpc_BooleanStateSetRequest & request, chip_rpc_BooleanStateSetResponse & response) + { + EndpointId endpointId = request.endpoint_id; + bool newState = request.state_value; + + EventNumber eventNumber; + { + DeviceLayer::StackLock lock; + + // Update attribute first, then emit StateChange event only on success. + RETURN_STATUS_IF_NOT_OK(app::Clusters::BooleanState::Attributes::StateValue::Set(endpointId, newState)); + + chip::app::Clusters::BooleanState::Events::StateChange::Type event{ newState }; + RETURN_STATUS_IF_NOT_OK(app::LogEvent(event, endpointId, eventNumber)); + } + + response.event_number = static_cast(eventNumber); + return pw::OkStatus(); + } + + virtual pw::Status Get(const chip_rpc_BooleanStateGetRequest & request, chip_rpc_BooleanStateGetResponse & response) + { + EndpointId endpointId = request.endpoint_id; + bool state_value = false; + + { + DeviceLayer::StackLock lock; + RETURN_STATUS_IF_NOT_OK(app::Clusters::BooleanState::Attributes::StateValue::Get(endpointId, &state_value)); + } + + response.state.state_value = state_value; + return pw::OkStatus(); + } +}; + +} // namespace rpc +} // namespace chip diff --git a/examples/common/pigweed/rpc_services/internal/StatusUtils.h b/examples/common/pigweed/rpc_services/internal/StatusUtils.h index 444759f818efa2..f92ee66afc44bb 100644 --- a/examples/common/pigweed/rpc_services/internal/StatusUtils.h +++ b/examples/common/pigweed/rpc_services/internal/StatusUtils.h @@ -20,12 +20,13 @@ #pragma once #include "app/util/attribute-storage.h" +#include "protocols/interaction_model/StatusCode.h" #include "pw_status/status.h" #define RETURN_STATUS_IF_NOT_OK(expr) \ do \ { \ - pw::Status __status = chip::rpc::EmberStatusToPwStatus(expr); \ + pw::Status __status = chip::rpc::ToPwStatus(expr); \ if (!__status.ok()) \ { \ return __status; \ @@ -35,7 +36,7 @@ namespace chip { namespace rpc { -constexpr pw::Status EmberStatusToPwStatus(EmberAfStatus ember_status) +constexpr pw::Status ToPwStatus(EmberAfStatus ember_status) { switch (ember_status) { @@ -50,5 +51,26 @@ constexpr pw::Status EmberStatusToPwStatus(EmberAfStatus ember_status) } } +constexpr pw::Status ToPwStatus(CHIP_ERROR chip_error_status) +{ + switch (chip_error_status.AsInteger()) + { + case CHIP_NO_ERROR.AsInteger(): + return pw::OkStatus(); + case CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute).AsInteger(): + case CHIP_IM_GLOBAL_STATUS(UnsupportedCommand).AsInteger(): + case CHIP_IM_GLOBAL_STATUS(UnsupportedEndpoint).AsInteger(): + case CHIP_IM_GLOBAL_STATUS(UnsupportedEvent).AsInteger(): + return pw::Status::NotFound(); + case CHIP_IM_GLOBAL_STATUS(UnsupportedAccess).AsInteger(): + return pw::Status::PermissionDenied(); + case CHIP_IM_GLOBAL_STATUS(InvalidAction).AsInteger(): + case CHIP_IM_GLOBAL_STATUS(InvalidCommand).AsInteger(): + return pw::Status::InvalidArgument(); + default: + return pw::Status::Unknown(); + } +} + } // namespace rpc } // namespace chip diff --git a/examples/common/tracing/BUILD.gn b/examples/common/tracing/BUILD.gn index 266c3fc0f31581..cf6fdc2da525b4 100644 --- a/examples/common/tracing/BUILD.gn +++ b/examples/common/tracing/BUILD.gn @@ -93,7 +93,10 @@ source_set("trace_handlers_decoder") { public_configs = [ ":default_config" ] - deps = [ "${chip_root}/src/lib" ] + deps = [ + "${chip_root}/src/lib", + "${chip_root}/src/lib/core:types", + ] public_deps = [ "${chip_root}/third_party/jsoncpp" ] cflags = [ "-Wconversion" ] @@ -121,6 +124,7 @@ executable("chip-trace-decoder") { public_deps = [ "${chip_root}/src/lib", + "${chip_root}/src/lib/core:types", "${chip_root}/third_party/jsoncpp", ] diff --git a/examples/common/websocket-server/BUILD.gn b/examples/common/websocket-server/BUILD.gn index 1ea2687ce6afda..7eee9e2a40c967 100644 --- a/examples/common/websocket-server/BUILD.gn +++ b/examples/common/websocket-server/BUILD.gn @@ -34,6 +34,7 @@ static_library("websocket-server") { ] public_deps = [ + "${chip_root}/src/lib/core:types", "${chip_root}/src/lib/support", "${chip_root}/third_party/libwebsockets", ] diff --git a/examples/darwin-framework-tool/BUILD.gn b/examples/darwin-framework-tool/BUILD.gn index 1973c64a889e20..e31acadec076b6 100644 --- a/examples/darwin-framework-tool/BUILD.gn +++ b/examples/darwin-framework-tool/BUILD.gn @@ -42,6 +42,9 @@ declare_args() { } enable_provisional_features = config_enable_yaml_tests + + # Disable generating compiler database by default + generate_compilation_database = false } sdk = "macosx" @@ -107,6 +110,12 @@ action("build-darwin-framework") { args += [ "--no-clang" ] } + if (generate_compilation_database) { + args += [ "--compdb" ] + } else { + args += [ "--no-compdb" ] + } + if (config_enable_yaml_tests) { args += [ "--enable-encoding-sentinel-enum-values" ] } else { diff --git a/examples/darwin-framework-tool/commands/common/RemoteDataModelLogger.h b/examples/darwin-framework-tool/commands/common/RemoteDataModelLogger.h index d8130143e20d8c..39605e6fb56390 100644 --- a/examples/darwin-framework-tool/commands/common/RemoteDataModelLogger.h +++ b/examples/darwin-framework-tool/commands/common/RemoteDataModelLogger.h @@ -31,5 +31,6 @@ CHIP_ERROR LogAttributeAsJSON(NSNumber * endpointId, NSNumber * clusterId, NSNum CHIP_ERROR LogCommandAsJSON(NSNumber * endpointId, NSNumber * clusterId, NSNumber * commandId, id result); CHIP_ERROR LogAttributeErrorAsJSON(NSNumber * endpointId, NSNumber * clusterId, NSNumber * attributeId, NSError * error); CHIP_ERROR LogCommandErrorAsJSON(NSNumber * endpointId, NSNumber * clusterId, NSNumber * commandId, NSError * error); +CHIP_ERROR LogGetCommissionerNodeId(NSNumber * nodeId); void SetDelegate(RemoteDataModelLoggerDelegate * delegate); }; // namespace RemoteDataModelLogger diff --git a/examples/darwin-framework-tool/commands/common/RemoteDataModelLogger.mm b/examples/darwin-framework-tool/commands/common/RemoteDataModelLogger.mm index 196af6048356a4..760fe0bc998ed5 100644 --- a/examples/darwin-framework-tool/commands/common/RemoteDataModelLogger.mm +++ b/examples/darwin-framework-tool/commands/common/RemoteDataModelLogger.mm @@ -34,6 +34,7 @@ constexpr char kErrorIdKey[] = "error"; constexpr char kClusterErrorIdKey[] = "clusterError"; constexpr char kValueKey[] = "value"; +constexpr char kNodeIdKey[] = "nodeId"; constexpr char kBase64Header[] = "base64:"; @@ -191,5 +192,17 @@ CHIP_ERROR LogCommandErrorAsJSON(NSNumber * endpointId, NSNumber * clusterId, NS return LogError(value, status); } +CHIP_ERROR LogGetCommissionerNodeId(NSNumber * value) +{ + VerifyOrReturnError(gDelegate != nullptr, CHIP_NO_ERROR); + + Json::Value rootValue; + rootValue[kValueKey] = Json::Value(); + rootValue[kValueKey][kNodeIdKey] = [value unsignedLongLongValue]; + + auto valueStr = JsonToString(rootValue); + return gDelegate->LogJSON(valueStr.c_str()); +} + void SetDelegate(RemoteDataModelLoggerDelegate * delegate) { gDelegate = delegate; } }; // namespace RemoteDataModelLogger diff --git a/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.h b/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.h index 04d65bdf565db0..7f621afcfe80ea 100644 --- a/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.h +++ b/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.h @@ -31,5 +31,6 @@ - (void)controller:(MTRDeviceController *)controller statusUpdate:(MTRCommissioningStatus)status; - (void)controller:(MTRDeviceController *)controller commissioningSessionEstablishmentDone:(NSError *)error; - (void)controller:(MTRDeviceController *)controller commissioningComplete:(NSError *)error; +- (void)controller:(MTRDeviceController *)controller commissioningComplete:(NSError *)error nodeID:(NSNumber *)nodeID metrics:(MTRMetrics *)metrics; @end diff --git a/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm b/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm index 7b9f4369a79c7d..c8594a6f4fa87c 100644 --- a/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm +++ b/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm @@ -63,4 +63,11 @@ - (void)controller:(MTRDeviceController *)controller commissioningComplete:(NSEr _commandBridge->SetCommandExitStatus(error, "Pairing Commissioning Complete"); } +- (void)controller:(MTRDeviceController *)controller commissioningComplete:(NSError *)error nodeID:(NSNumber *)nodeID metrics:(MTRMetrics *)metrics +{ + (void) nodeID; + NSString * message = [NSString stringWithFormat:@"Pairing Commissioning Complete with metrics %@", metrics]; + _commandBridge->SetCommandExitStatus(error, [message UTF8String]); +} + @end diff --git a/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.mm b/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.mm index 1dd852bd4d0817..34d3c87603d2f3 100644 --- a/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.mm +++ b/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.mm @@ -19,15 +19,17 @@ #import #include "GetCommissionerNodeIdCommand.h" +#include "RemoteDataModelLogger.h" CHIP_ERROR GetCommissionerNodeIdCommand::RunCommand() { auto * controller = CurrentCommissioner(); VerifyOrReturnError(nil != controller, CHIP_ERROR_INCORRECT_STATE); - ChipLogProgress( - chipTool, "Commissioner Node Id 0x" ChipLogFormatX64, ChipLogValueX64(controller.controllerNodeId.unsignedLongLongValue)); + auto controllerNodeId = controller.controllerNodeId; + ChipLogProgress(chipTool, "Commissioner Node Id 0x" ChipLogFormatX64, ChipLogValueX64(controllerNodeId.unsignedLongLongValue)); + ReturnErrorOnFailure(RemoteDataModelLogger::LogGetCommissionerNodeId(controllerNodeId)); SetCommandExitStatus(CHIP_NO_ERROR); return CHIP_NO_ERROR; } 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..0e997312433125 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 @@ -948,8 +948,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 +978,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; @@ -1685,7 +1693,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/src/EVSEManufacturerImpl.cpp b/examples/energy-management-app/energy-management-common/src/EVSEManufacturerImpl.cpp index 70cd63e7926c8d..0f204671a9feca 100644 --- a/examples/energy-management-app/energy-management-common/src/EVSEManufacturerImpl.cpp +++ b/examples/energy-management-app/energy-management-common/src/EVSEManufacturerImpl.cpp @@ -18,9 +18,9 @@ #include #include -#include +#include #include -#include +#include using namespace chip; using namespace chip::app; diff --git a/examples/energy-management-app/linux/README.md b/examples/energy-management-app/linux/README.md index d316dd807c13e2..424ef46d58e259 100644 --- a/examples/energy-management-app/linux/README.md +++ b/examples/energy-management-app/linux/README.md @@ -366,7 +366,7 @@ If you haven't implemented a real EVSE but want to simulate plugging in an EV then you can use a few of the test event triggers to simulate these scenarios. The test event triggers values can be found in: -[EnergyEvseTestEventTriggerDelegate.h](../../../src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h) +[EnergyEvseTestEventTriggerHandler.h](../../../src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h) - 0x0099000000000000 - Simulates the EVSE being installed on a 32A supply - 0x0099000000000002 - Simulates the EVSE being plugged in (this should diff --git a/examples/light-switch-app/esp32/main/CMakeLists.txt b/examples/light-switch-app/esp32/main/CMakeLists.txt index 5bdac22300b33f..210cbcefee9a23 100644 --- a/examples/light-switch-app/esp32/main/CMakeLists.txt +++ b/examples/light-switch-app/esp32/main/CMakeLists.txt @@ -31,7 +31,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic-information" diff --git a/examples/light-switch-app/infineon/cyw30739/src/main.cpp b/examples/light-switch-app/infineon/cyw30739/src/main.cpp index dbfdb81b875b3f..483a475b51cee0 100644 --- a/examples/light-switch-app/infineon/cyw30739/src/main.cpp +++ b/examples/light-switch-app/infineon/cyw30739/src/main.cpp @@ -26,8 +26,9 @@ #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR #include #endif +#include #include -#include +#include #include #include #include @@ -192,10 +193,13 @@ void InitApp(intptr_t args) // Print QR Code URL PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); /* Start CHIP datamodel server */ - static chip::OTATestEventTriggerDelegate testEventTriggerDelegate{ chip::ByteSpan(sTestEventTriggerEnableKey) }; + static chip::SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static chip::OTATestEventTriggerHandler sOtaTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(chip::ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR); static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; diff --git a/examples/light-switch-app/nrfconnect/main/AppTask.cpp b/examples/light-switch-app/nrfconnect/main/AppTask.cpp index a4b5ac5b47b318..06ac797f6a6899 100644 --- a/examples/light-switch-app/nrfconnect/main/AppTask.cpp +++ b/examples/light-switch-app/nrfconnect/main/AppTask.cpp @@ -24,8 +24,9 @@ #include "LightSwitch.h" #include +#include #include -#include +#include #include #include #include @@ -215,9 +216,12 @@ CHIP_ERROR AppTask::Init() #endif static CommonCaseDeviceServerInitParams initParams; - static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR); (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams)); AppFabricTableDelegate::Init(); diff --git a/examples/light-switch-app/qpg/BUILD.gn b/examples/light-switch-app/qpg/BUILD.gn index 659f2d4ab1efd3..055cfd46f95abb 100644 --- a/examples/light-switch-app/qpg/BUILD.gn +++ b/examples/light-switch-app/qpg/BUILD.gn @@ -51,7 +51,7 @@ qpg_executable("light_switch_app") { output_name = "chip-${qpg_target_ic}-light-switch-example.out" sources = [ - "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp", + "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp", "${examples_plat_dir}/app/main.cpp", "${examples_plat_dir}/ota/ota.cpp", "src/AppTask.cpp", diff --git a/examples/light-switch-app/qpg/src/AppTask.cpp b/examples/light-switch-app/qpg/src/AppTask.cpp index 9f6662206f2e74..f02823b178220d 100644 --- a/examples/light-switch-app/qpg/src/AppTask.cpp +++ b/examples/light-switch-app/qpg/src/AppTask.cpp @@ -31,7 +31,8 @@ using namespace ::chip; #include -#include +#include +#include #include #include #include @@ -191,10 +192,13 @@ void AppTask::InitServer(intptr_t arg) nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); initParams.endpointNativeParams = static_cast(&nativeParams); - // Use GenericFaultTestEventTriggerDelegate to inject faults - static GenericFaultTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + // Use GenericFaultTestEventTriggerHandler to inject faults + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static GenericFaultTestEventTriggerHandler sFaultTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sFaultTestEventTriggerHandler) == CHIP_NO_ERROR); (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; chip::Server::GetInstance().Init(initParams); diff --git a/examples/light-switch-app/silabs/README.md b/examples/light-switch-app/silabs/README.md index a7e19ba18b2e98..615b27c7bc3cd9 100644 --- a/examples/light-switch-app/silabs/README.md +++ b/examples/light-switch-app/silabs/README.md @@ -59,8 +59,9 @@ Silicon Labs platform. (For Mac OS X, `commander` is located inside `Commander.app/Contents/MacOS/`.) -- Download and install a suitable ARM gcc tool chain: - [GNU Arm Embedded Toolchain 9-2019-q4-major](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) +- Download and install a suitable ARM gcc tool chain (For most Host, the + bootstrap already installs the toolchain): + [GNU Arm Embedded Toolchain 12.2 Rel1](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) - Install some additional tools(likely already present for CHIP developers): diff --git a/examples/lighting-app/infineon/cyw30739/src/main.cpp b/examples/lighting-app/infineon/cyw30739/src/main.cpp index 14730252de08b3..f851e2e8819664 100644 --- a/examples/lighting-app/infineon/cyw30739/src/main.cpp +++ b/examples/lighting-app/infineon/cyw30739/src/main.cpp @@ -26,8 +26,9 @@ #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR #include #endif +#include #include -#include +#include #include #include #include @@ -191,10 +192,13 @@ void InitApp(intptr_t args) // Print QR Code URL PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); /* Start CHIP datamodel server */ - static chip::OTATestEventTriggerDelegate testEventTriggerDelegate{ chip::ByteSpan(sTestEventTriggerEnableKey) }; + static chip::SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static chip::OTATestEventTriggerHandler sOtaTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(chip::ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR); static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp index 03632106fc8667..494095e04de9dc 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -27,8 +27,9 @@ #include #include #include +#include #include -#include +#include #include #include #include @@ -243,9 +244,12 @@ CHIP_ERROR AppTask::Init() #endif static CommonCaseDeviceServerInitParams initParams; - static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR); (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams)); AppFabricTableDelegate::Init(); diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp index 557293f6bac2aa..b1fc51c7c29360 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -286,8 +286,8 @@ void AppTask::InitServer(intptr_t arg) chip::DeviceLayer::SetDeviceInfoProvider(&infoProvider); // Init ZCL Data Model and start server - static DefaultTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + static DefaultTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; nativeParams.lockCb = LockOpenThreadTask; nativeParams.unlockCb = UnlockOpenThreadTask; diff --git a/examples/lighting-app/nxp/k32w/k32w1/main/AppTask.cpp b/examples/lighting-app/nxp/k32w/k32w1/main/AppTask.cpp index 66eee725c581c2..7150003f599588 100644 --- a/examples/lighting-app/nxp/k32w/k32w1/main/AppTask.cpp +++ b/examples/lighting-app/nxp/k32w/k32w1/main/AppTask.cpp @@ -214,8 +214,8 @@ void AppTask::InitServer(intptr_t arg) #endif // Init ZCL Data Model and start server - static DefaultTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + static DefaultTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; nativeParams.lockCb = LockOpenThreadTask; nativeParams.unlockCb = UnlockOpenThreadTask; diff --git a/examples/lighting-app/qpg/BUILD.gn b/examples/lighting-app/qpg/BUILD.gn index d8f86311d627eb..c835e0bf3cdaed 100644 --- a/examples/lighting-app/qpg/BUILD.gn +++ b/examples/lighting-app/qpg/BUILD.gn @@ -51,7 +51,7 @@ qpg_executable("lighting_app") { output_name = "chip-${qpg_target_ic}-lighting-example.out" sources = [ - "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp", + "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp", "${examples_plat_dir}/app/main.cpp", "${examples_plat_dir}/ota/ota.cpp", "${examples_plat_dir}/powercycle_counting.c", diff --git a/examples/lighting-app/qpg/src/AppTask.cpp b/examples/lighting-app/qpg/src/AppTask.cpp index 1dd1aa85514a7a..4dafde6ac41960 100644 --- a/examples/lighting-app/qpg/src/AppTask.cpp +++ b/examples/lighting-app/qpg/src/AppTask.cpp @@ -33,7 +33,8 @@ #include #include -#include +#include +#include #include #include #include @@ -264,10 +265,13 @@ void AppTask::InitServer(intptr_t arg) nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); initParams.endpointNativeParams = static_cast(&nativeParams); - // Use GenericFaultTestEventTriggerDelegate to inject faults - static GenericFaultTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + // Use GenericFaultTestEventTriggerHandler to inject faults + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static GenericFaultTestEventTriggerHandler sFaultTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sFaultTestEventTriggerHandler) == CHIP_NO_ERROR); (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; chip::Server::GetInstance().Init(initParams); diff --git a/examples/lighting-app/silabs/README.md b/examples/lighting-app/silabs/README.md index 639afd163fe7ef..08db63d9d3f0ea 100644 --- a/examples/lighting-app/silabs/README.md +++ b/examples/lighting-app/silabs/README.md @@ -57,8 +57,9 @@ Silicon Labs platform. (For Mac OS X, `commander` is located inside `Commander.app/Contents/MacOS/`.) -- Download and install a suitable ARM gcc tool chain: - [GNU Arm Embedded Toolchain 9-2019-q4-major](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) +- Download and install a suitable ARM gcc tool chain (For most Host, the + bootstrap already installs the toolchain): + [GNU Arm Embedded Toolchain 12.2 Rel1](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) - Install some additional tools (likely already present for CHIP developers): diff --git a/examples/lit-icd-app/linux/BUILD.gn b/examples/lit-icd-app/linux/BUILD.gn index 6a2a26c7b8a034..fd8c0dfbbad343 100644 --- a/examples/lit-icd-app/linux/BUILD.gn +++ b/examples/lit-icd-app/linux/BUILD.gn @@ -21,7 +21,7 @@ executable("lit-icd-app") { deps = [ "${chip_root}/examples/lit-icd-app/lit-icd-common", "${chip_root}/examples/platform/linux:app-main", - "${chip_root}/src/app/icd:manager", + "${chip_root}/src/app/icd/server:manager", "${chip_root}/src/lib", "${chip_root}/third_party/jsoncpp", ] diff --git a/examples/lit-icd-app/silabs/README.md b/examples/lit-icd-app/silabs/README.md index 4a5b6b35851581..f359eacbd23cf4 100644 --- a/examples/lit-icd-app/silabs/README.md +++ b/examples/lit-icd-app/silabs/README.md @@ -59,8 +59,9 @@ Labs platform. (For Mac OS X, `commander` is located inside `Commander.app/Contents/MacOS/`.) -- Download and install a suitable ARM gcc tool chain: - [GNU Arm Embedded Toolchain 9-2019-q4-major](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) +- Download and install a suitable ARM gcc tool chain (For most Host, the + bootstrap already installs the toolchain): + [GNU Arm Embedded Toolchain 12.2 Rel1](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) - Install some additional tools(likely already present for CHIP developers): diff --git a/examples/lock-app/esp32/main/CMakeLists.txt b/examples/lock-app/esp32/main/CMakeLists.txt index 7efc567f107ffd..e7266908ff3c1d 100644 --- a/examples/lock-app/esp32/main/CMakeLists.txt +++ b/examples/lock-app/esp32/main/CMakeLists.txt @@ -50,7 +50,7 @@ idf_component_register(INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic-information" @@ -163,7 +163,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic-information" diff --git a/examples/lock-app/infineon/cyw30739/src/main.cpp b/examples/lock-app/infineon/cyw30739/src/main.cpp index 76fa8484ce74eb..a0a92487a807bc 100644 --- a/examples/lock-app/infineon/cyw30739/src/main.cpp +++ b/examples/lock-app/infineon/cyw30739/src/main.cpp @@ -28,9 +28,10 @@ #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR #include #endif +#include #include #include -#include +#include #include #include #include @@ -191,10 +192,13 @@ void InitApp(intptr_t args) // Print QR Code URL PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); /* Start CHIP datamodel server */ - static chip::OTATestEventTriggerDelegate testEventTriggerDelegate{ chip::ByteSpan(sTestEventTriggerEnableKey) }; + static chip::SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static chip::OTATestEventTriggerHandler sOtaTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(chip::ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR); static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; diff --git a/examples/lock-app/nrfconnect/main/AppTask.cpp b/examples/lock-app/nrfconnect/main/AppTask.cpp index d64a4950ace777..07a96b6d6c29b2 100644 --- a/examples/lock-app/nrfconnect/main/AppTask.cpp +++ b/examples/lock-app/nrfconnect/main/AppTask.cpp @@ -25,9 +25,10 @@ #include #include +#include #include #include -#include +#include #include #include #include @@ -209,9 +210,12 @@ CHIP_ERROR AppTask::Init() #endif static CommonCaseDeviceServerInitParams initParams; - static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR); (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams)); AppFabricTableDelegate::Init(); diff --git a/examples/lock-app/qpg/BUILD.gn b/examples/lock-app/qpg/BUILD.gn index 2426fa7c3179d5..30794878fd1ae8 100644 --- a/examples/lock-app/qpg/BUILD.gn +++ b/examples/lock-app/qpg/BUILD.gn @@ -51,7 +51,7 @@ qpg_executable("lock_app") { output_name = "chip-${qpg_target_ic}-lock-example.out" sources = [ - "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp", + "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp", "${examples_plat_dir}/app/main.cpp", "${examples_plat_dir}/ota/ota.cpp", "src/AppTask.cpp", diff --git a/examples/lock-app/qpg/src/AppTask.cpp b/examples/lock-app/qpg/src/AppTask.cpp index 8bbd6b7ce19a8a..54a4b2a5d2a3f3 100644 --- a/examples/lock-app/qpg/src/AppTask.cpp +++ b/examples/lock-app/qpg/src/AppTask.cpp @@ -26,7 +26,8 @@ #include #include -#include +#include +#include #include #include #include @@ -189,10 +190,13 @@ void AppTask::InitServer(intptr_t arg) nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); initParams.endpointNativeParams = static_cast(&nativeParams); - // Use GenericFaultTestEventTriggerDelegate to inject faults - static GenericFaultTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + // Use GenericFaultTestEventTriggerHandler to inject faults + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static GenericFaultTestEventTriggerHandler sFaultTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sFaultTestEventTriggerHandler) == CHIP_NO_ERROR); (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; chip::Server::GetInstance().Init(initParams); diff --git a/examples/lock-app/silabs/README.md b/examples/lock-app/silabs/README.md index 7d8d576c68492c..1bce8c431bee54 100644 --- a/examples/lock-app/silabs/README.md +++ b/examples/lock-app/silabs/README.md @@ -54,8 +54,9 @@ Labs platform. (For Mac OS X, `commander` is located inside `Commander.app/Contents/MacOS/`.) -- Download and install a suitable ARM gcc tool chain: - [GNU Arm Embedded Toolchain 9-2019-q4-major](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) +- Download and install a suitable ARM gcc tool chain (For most Host, the + bootstrap already installs the toolchain): + [GNU Arm Embedded Toolchain 12.2 Rel1](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) - Install some additional tools(likely already present for CHIP developers): 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/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.cpp b/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.cpp index 9cfddd6f3de9fa..8bbae5e1978097 100644 --- a/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.cpp +++ b/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.cpp @@ -28,10 +28,4 @@ bool AmebaTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKe return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); } -CHIP_ERROR AmebaTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) -{ - bool success = emberAfHandleEventTrigger(eventTrigger); - return success ? CHIP_NO_ERROR : CHIP_ERROR_INVALID_ARGUMENT; -} - } // namespace chip diff --git a/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.h b/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.h index d461194de9b642..9e770406303645 100644 --- a/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.h +++ b/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.h @@ -18,15 +18,38 @@ #pragma once -#include "SmokeCOAlarmManager.h" +#include + #include +#include +#include +#include + +/** + * @brief User handler for handling the test event trigger + * + * @note If TestEventTrigger is enabled, it needs to be implemented in the app + * + * @param eventTrigger Event trigger to handle + * + * @warning *** DO NOT USE FOR STANDARD CLUSTER EVENT TRIGGERS *** + * + * TODO(#31723): Rename `emberAfHandleEventTrigger` to `AmebaHandleGlobalTestEventTrigger` + * + * @retval true on success + * @retval false if error happened + */ +bool emberAfHandleEventTrigger(uint64_t eventTrigger); namespace chip { -class AmebaTestEventTriggerDelegate : public TestEventTriggerDelegate +class AmebaTestEventTriggerDelegate : public TestEventTriggerDelegate, TestEventTriggerHandler { public: - explicit AmebaTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {} + explicit AmebaTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) + { + VerifyOrDie(AddHandler(this) == CHIP_NO_ERROR); + } /** * @brief Checks to see if `enableKey` provided matches value chosen by the manufacturer. @@ -35,27 +58,14 @@ class AmebaTestEventTriggerDelegate : public TestEventTriggerDelegate */ bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; - /** - * @brief User handler for handling the test event trigger based on `eventTrigger` provided. - * @param eventTrigger Event trigger to handle. - * @return CHIP_NO_ERROR on success or CHIP_ERROR_INVALID_ARGUMENT on failure. - */ - CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; + CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override + { + // WARNING: LEGACY SUPPORT ONLY, DO NOT EXTEND FOR STANDARD CLUSTERS + return (emberAfHandleEventTrigger(eventTrigger)) ? CHIP_NO_ERROR : CHIP_ERROR_INVALID_ARGUMENT; + } private: ByteSpan mEnableKey; }; } // namespace chip - -/** - * @brief User handler for handling the test event trigger - * - * @note If TestEventTrigger is enabled, it needs to be implemented in the app - * - * @param eventTrigger Event trigger to handle - * - * @retval true on success - * @retval false if error happened - */ -bool emberAfHandleEventTrigger(uint64_t eventTrigger); diff --git a/examples/platform/esp32/Rpc.cpp b/examples/platform/esp32/Rpc.cpp index 57f01b8f60b2ae..61efb842f089b7 100644 --- a/examples/platform/esp32/Rpc.cpp +++ b/examples/platform/esp32/Rpc.cpp @@ -33,6 +33,10 @@ #include "pigweed/rpc_services/Attributes.h" #endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#if defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE +#include "pigweed/rpc_services/BooleanState.h" +#endif // defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE + #if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE #if CONFIG_DEVICE_TYPE_M5STACK #include "ScreenManager.h" @@ -275,6 +279,10 @@ StackType_t sRpcTaskStack[RPC_TASK_STACK_SIZE]; Attributes attributes_service; #endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#if defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE +BooleanState boolean_state_service; +#endif // defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE + #if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE Esp32Button button_service; #endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE @@ -309,6 +317,10 @@ void RegisterServices(pw::rpc::Server & server) server.RegisterService(attributes_service); #endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#if defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE + server.RegisterService(boolean_state_service); +#endif // defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE + #if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE server.RegisterService(button_service); #endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE diff --git a/examples/platform/esp32/common/Esp32AppServer.cpp b/examples/platform/esp32/common/Esp32AppServer.cpp index fee87880d2d9e1..b60685d34debca 100644 --- a/examples/platform/esp32/common/Esp32AppServer.cpp +++ b/examples/platform/esp32/common/Esp32AppServer.cpp @@ -19,8 +19,9 @@ #include "Esp32AppServer.h" #include "CHIPDeviceManager.h" #include +#include #include -#include +#include #include #include #include @@ -169,8 +170,11 @@ void Esp32AppServer::Init(AppDelegate * sAppDelegate) ESP_LOGE(TAG, "Failed to convert the EnableKey string to octstr type value"); memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } - static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR); + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; #endif // CONFIG_TEST_EVENT_TRIGGER_ENABLED (void) initParams.InitializeStaticResourcesBeforeServerInit(); if (sAppDelegate != nullptr) diff --git a/examples/platform/linux/AppMain.cpp b/examples/platform/linux/AppMain.cpp index 04274ab2f33c24..061d7b66c5e4c6 100644 --- a/examples/platform/linux/AppMain.cpp +++ b/examples/platform/linux/AppMain.cpp @@ -75,19 +75,19 @@ #endif #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR -#include +#include #endif #if CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER -#include +#include #endif #if CHIP_DEVICE_CONFIG_ENABLE_BOOLEAN_STATE_CONFIGURATION_TRIGGER -#include +#include #endif #if CHIP_DEVICE_CONFIG_ENABLE_ENERGY_EVSE_TRIGGER -#include +#include #endif #if CHIP_DEVICE_CONFIG_ENABLE_ENERGY_REPORTING_TRIGGER -#include +#include #endif #include @@ -331,34 +331,13 @@ static bool EnsureWiFiIsStarted() } #endif -class SampleTestEventTriggerDelegate : public TestEventTriggerDelegate +class SampleTestEventTriggerHandler : public TestEventTriggerHandler { -public: - /// NOTE: If you copy this, please use the reserved range FFFF_FFFF__xxxx for your trigger codes. + /// NOTE: If you copy this for NON-STANDARD CLUSTERS OR USAGES, please use the reserved range FFFF_FFFF__xxxx for your + /// trigger codes. NOTE: Standard codes are _xxxx_xxxx_xxxx. static constexpr uint64_t kSampleTestEventTriggerAlwaysSuccess = static_cast(0xFFFF'FFFF'FFF1'0000ull); - SampleTestEventTriggerDelegate() { memset(&mEnableKey[0], 0, sizeof(mEnableKey)); } - - /** - * @brief Initialize the delegate with a key and an optional other handler - * - * The `otherDelegate` will be called if there is no match of the eventTrigger - * when HandleEventTrigger is called, if it is non-null. - * - * @param enableKey - EnableKey to use for this instance. - * @param otherDelegate - Other delegate (e.g. OTA delegate) where defer trigger. Can be nullptr - * @return CHIP_NO_ERROR on success, CHIP_ERROR_INVALID_ARGUMENT if enableKey is wrong size. - */ - CHIP_ERROR Init(ByteSpan enableKey, TestEventTriggerDelegate * otherDelegate) - { - VerifyOrReturnError(enableKey.size() == sizeof(mEnableKey), CHIP_ERROR_INVALID_ARGUMENT); - mOtherDelegate = otherDelegate; - MutableByteSpan ourEnableKeySpan(mEnableKey); - return CopySpanToMutableSpan(enableKey, ourEnableKeySpan); - } - - bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override { return enableKey.data_equal(ByteSpan(mEnableKey)); } - +public: CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override { ChipLogProgress(Support, "Saw TestEventTrigger: " ChipLogFormatX64, ChipLogValueX64(eventTrigger)); @@ -370,12 +349,8 @@ class SampleTestEventTriggerDelegate : public TestEventTriggerDelegate return CHIP_NO_ERROR; } - return (mOtherDelegate != nullptr) ? mOtherDelegate->HandleEventTrigger(eventTrigger) : CHIP_ERROR_INVALID_ARGUMENT; + return CHIP_ERROR_INVALID_ARGUMENT; } - -private: - uint8_t mEnableKey[TestEventTriggerDelegate::kEnableKeyLength]; - TestEventTriggerDelegate * mOtherDelegate = nullptr; }; int ChipLinuxAppInit(int argc, char * const argv[], OptionSet * customOptions, @@ -549,44 +524,36 @@ void ChipLinuxAppMainLoop(AppMainLoopImplementation * impl) initParams.operationalKeystore = &LinuxDeviceOptions::GetInstance().mCSRResponseOptions.badCsrOperationalKeyStoreForTest; } - TestEventTriggerDelegate * otherDelegate = nullptr; + // For general testing of TestEventTrigger, we have a common "core" event trigger delegate. + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate; + static SampleTestEventTriggerHandler sTestEventTriggerHandler; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey)) == + CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sTestEventTriggerHandler) == CHIP_NO_ERROR); + #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR // We want to allow triggering OTA queries if OTA requestor is enabled - static OTATestEventTriggerDelegate otaTestEventTriggerDelegate{ ByteSpan( - LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey) }; - otherDelegate = &otaTestEventTriggerDelegate; + static OTATestEventTriggerHandler sOtaTestEventTriggerHandler; + sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler); #endif #if CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER - static SmokeCOTestEventTriggerDelegate smokeCOTestEventTriggerDelegate{ - ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey), otherDelegate - }; - otherDelegate = &smokeCOTestEventTriggerDelegate; + static SmokeCOTestEventTriggerHandler sSmokeCOTestEventTriggerHandler; + sTestEventTriggerDelegate.AddHandler(&sSmokeCOTestEventTriggerHandler); #endif #if CHIP_DEVICE_CONFIG_ENABLE_BOOLEAN_STATE_CONFIGURATION_TRIGGER - static BooleanStateConfigurationTestEventTriggerDelegate booleanStateConfigurationTestEventTriggerDelegate{ - ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey), otherDelegate - }; - otherDelegate = &booleanStateConfigurationTestEventTriggerDelegate; + static BooleanStateConfigurationTestEventTriggerHandler sBooleanStateConfigurationTestEventTriggerHandler; + sTestEventTriggerDelegate.AddHandler(&sBooleanStateConfigurationTestEventTriggerHandler); #endif #if CHIP_DEVICE_CONFIG_ENABLE_ENERGY_EVSE_TRIGGER - static EnergyEvseTestEventTriggerDelegate energyEvseTestEventTriggerDelegate{ - ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey), otherDelegate - }; - otherDelegate = &energyEvseTestEventTriggerDelegate; + static EnergyEvseTestEventTriggerHandler sEnergyEvseTestEventTriggerHandler; + sTestEventTriggerDelegate.AddHandler(&sEnergyEvseTestEventTriggerHandler); #endif #if CHIP_DEVICE_CONFIG_ENABLE_ENERGY_REPORTING_TRIGGER - static EnergyReportingTestEventTriggerDelegate energyReportingTestEventTriggerDelegate{ - ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey), otherDelegate - }; - otherDelegate = &energyReportingTestEventTriggerDelegate; + static EnergyReportingTestEventTriggerHandler sEnergyReportingTestEventTriggerHandler; + sTestEventTriggerDelegate.AddHandler(&sEnergyReportingTestEventTriggerHandler); #endif - // For general testing of TestEventTrigger, we have a common "core" event trigger delegate. - static SampleTestEventTriggerDelegate testEventTriggerDelegate; - VerifyOrDie(testEventTriggerDelegate.Init(ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey), - otherDelegate) == CHIP_NO_ERROR); - - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; // We need to set DeviceInfoProvider before Server::Init to setup the storage of DeviceInfoProvider properly. DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); diff --git a/examples/platform/linux/BUILD.gn b/examples/platform/linux/BUILD.gn index f82702be227709..8cf00c5be5e62c 100644 --- a/examples/platform/linux/BUILD.gn +++ b/examples/platform/linux/BUILD.gn @@ -32,24 +32,24 @@ config("app-main-config") { source_set("ota-test-event-trigger") { sources = [ - "${chip_root}/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h", + "${chip_root}/src/app/clusters/ota-requestor/OTATestEventTriggerHandler.h", ] } source_set("smco-test-event-trigger") { - sources = [ "${chip_root}/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h" ] + sources = [ "${chip_root}/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h" ] } source_set("boolean-state-configuration-test-event-trigger") { - sources = [ "${chip_root}/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.h" ] + sources = [ "${chip_root}/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.h" ] } source_set("energy-evse-test-event-trigger") { - sources = [ "${chip_root}/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h" ] + sources = [ "${chip_root}/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h" ] } source_set("energy-reporting-test-event-trigger") { - sources = [ "${chip_root}/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.h" ] + sources = [ "${chip_root}/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h" ] } source_set("app-main") { diff --git a/examples/platform/linux/Rpc.cpp b/examples/platform/linux/Rpc.cpp index f45df32d750a81..da6b73b9135c13 100644 --- a/examples/platform/linux/Rpc.cpp +++ b/examples/platform/linux/Rpc.cpp @@ -26,6 +26,10 @@ #include "pigweed/rpc_services/Attributes.h" #endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#if defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE +#include "pigweed/rpc_services/BooleanState.h" +#endif // defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE + #if defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE #include "pigweed/rpc_services/Descriptor.h" #endif // defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE @@ -68,6 +72,10 @@ namespace { Attributes attributes_service; #endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#if defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE +BooleanState boolean_state_service; +#endif // defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE + #if defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE Descriptor descriptor_service; #endif // defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE @@ -90,6 +98,10 @@ void RegisterServices(pw::rpc::Server & server) server.RegisterService(attributes_service); #endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#if defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE + server.RegisterService(boolean_state_service); +#endif // defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE + #if defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE server.RegisterService(descriptor_service); #endif // defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE diff --git a/examples/platform/nrfconnect/Rpc.cpp b/examples/platform/nrfconnect/Rpc.cpp index ec21fd7e379f05..8b47215d6a0680 100644 --- a/examples/platform/nrfconnect/Rpc.cpp +++ b/examples/platform/nrfconnect/Rpc.cpp @@ -32,6 +32,10 @@ LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); #include "pigweed/rpc_services/Attributes.h" #endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#if defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE +#include "pigweed/rpc_services/BooleanState.h" +#endif // defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE + #if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE #include "pigweed/rpc_services/Button.h" #endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE @@ -139,6 +143,10 @@ struct k_thread rpc_thread_data; Attributes attributes_service; #endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#if defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE +BooleanState boolean_state_service; +#endif // defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE + #if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE NrfButton button_service; #endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE @@ -177,6 +185,10 @@ void RegisterServices(pw::rpc::Server & server) server.RegisterService(attributes_service); #endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#if defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE + server.RegisterService(boolean_state_service); +#endif // defined(PW_RPC_BOOLEAN_STATE_SERVICE) && PW_RPC_BOOLEAN_STATE_SERVICE + #if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE server.RegisterService(button_service); #endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE diff --git a/examples/platform/nxp/se05x/linux/AppMain.cpp b/examples/platform/nxp/se05x/linux/AppMain.cpp index 2c04b81b0ce8bb..bd13e249683fcb 100644 --- a/examples/platform/nxp/se05x/linux/AppMain.cpp +++ b/examples/platform/nxp/se05x/linux/AppMain.cpp @@ -69,7 +69,8 @@ #endif // CHIP_CONFIG_TRANSPORT_TRACE_ENABLED #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR -#include +#include +#include #endif #include @@ -315,9 +316,12 @@ void ChipLinuxAppMainLoop(AppMainLoopImplementation * impl) } #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR - static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan( - LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey) }; - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey)) == + CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR); + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; #endif // We need to set DeviceInfoProvider before Server::Init to setup the storage of DeviceInfoProvider properly. diff --git a/examples/platform/nxp/se05x/linux/BUILD.gn b/examples/platform/nxp/se05x/linux/BUILD.gn index 2a93a4bf085a3e..a5efe460745ddd 100644 --- a/examples/platform/nxp/se05x/linux/BUILD.gn +++ b/examples/platform/nxp/se05x/linux/BUILD.gn @@ -25,7 +25,7 @@ config("app-main-config") { source_set("ota-test-event-trigger") { sources = [ - "${chip_root}/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h", + "${chip_root}/src/app/clusters/ota-requestor/OTATestEventTriggerHandler.h", ] } diff --git a/examples/platform/silabs/BaseApplication.cpp b/examples/platform/silabs/BaseApplication.cpp index 3677c1bed72b83..d2c6266a58382b 100644 --- a/examples/platform/silabs/BaseApplication.cpp +++ b/examples/platform/silabs/BaseApplication.cpp @@ -36,7 +36,7 @@ #include "SilabsDeviceDataProvider.h" #if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 -#include // nogncheck +#include // nogncheck #endif #include #include diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index 1197e4d48cd83b..3a78cf774c8c5a 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -219,8 +219,9 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) SILABS_LOG("Failed to convert the EnableKey string to octstr type value"); memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } - static SilabsTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + // TODO(#31723): Show to customers that they can do `Server::GetInstance().GetTestEventTriggerDelegate().AddHandler()` + static SilabsTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; #endif // SILABS_TEST_EVENT_TRIGGER_ENABLED #if CHIP_CRYPTO_PLATFORM && !(defined(SIWX_917)) @@ -232,8 +233,9 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) #ifdef PERFORMANCE_TEST_ENABLED // Set up Test Event Trigger command of the General Diagnostics cluster. Used only in performance testing - static SilabsTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(kTestEventTriggerEnableKey) }; - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + // TODO(#31723): Show to customers that they can do `Server::GetInstance().GetTestEventTriggerDelegate().AddHandler()` + static SilabsTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(kTestEventTriggerEnableKey) }; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; #endif // Initialize the remaining (not overridden) providers to the SDK example defaults diff --git a/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp b/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp index f231067cec851b..f9a11df74d7ae9 100644 --- a/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp +++ b/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp @@ -27,10 +27,4 @@ bool SilabsTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableK return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); } -CHIP_ERROR SilabsTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) -{ - bool success = emberAfHandleEventTrigger(eventTrigger); - return success ? CHIP_NO_ERROR : CHIP_ERROR_INVALID_ARGUMENT; -} - } // namespace chip diff --git a/examples/platform/silabs/SilabsTestEventTriggerDelegate.h b/examples/platform/silabs/SilabsTestEventTriggerDelegate.h index e9cd62fb813e50..03ceabd69a7898 100644 --- a/examples/platform/silabs/SilabsTestEventTriggerDelegate.h +++ b/examples/platform/silabs/SilabsTestEventTriggerDelegate.h @@ -18,14 +18,38 @@ #pragma once +#include + #include +#include +#include +#include + +/** + * @brief User handler for handling the test event trigger + * + * @note If TestEventTrigger is enabled, it needs to be implemented in the app + * + * @param eventTrigger Event trigger to handle + * + * @warning *** DO NOT USE FOR STANDARD CLUSTER EVENT TRIGGERS *** + * + * TODO(#31723): Rename `emberAfHandleEventTrigger` to `SilabsHandleGlobalTestEventTrigger` + * + * @retval true on success + * @retval false if error happened + */ +bool emberAfHandleEventTrigger(uint64_t eventTrigger); namespace chip { -class SilabsTestEventTriggerDelegate : public TestEventTriggerDelegate +class SilabsTestEventTriggerDelegate : public TestEventTriggerDelegate, TestEventTriggerHandler { public: - explicit SilabsTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {} + explicit SilabsTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) + { + VerifyOrDie(AddHandler(this) == CHIP_NO_ERROR); + } /** * @brief Checks to see if `enableKey` provided matches value chosen by the manufacturer. @@ -35,26 +59,19 @@ class SilabsTestEventTriggerDelegate : public TestEventTriggerDelegate bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; /** - * @brief User handler for handling the test event trigger based on `eventTrigger` provided. - * @param eventTrigger Event trigger to handle. - * @return CHIP_NO_ERROR on success or CHIP_ERROR_INVALID_ARGUMENT on failure. + * @brief Delegates handling to global `emberAfHandleEventTrigger` function. DO NOT EXTEND. + * + * @param eventTrigger - trigger to process. + * @return CHIP_NO_ERROR if properly handled, else another CHIP_ERROR. */ - CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; + CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override + { + // WARNING: LEGACY SUPPORT ONLY, DO NOT EXTEND FOR STANDARD CLUSTERS + return (emberAfHandleEventTrigger(eventTrigger)) ? CHIP_NO_ERROR : CHIP_ERROR_INVALID_ARGUMENT; + } private: ByteSpan mEnableKey; }; } // namespace chip - -/** - * @brief User handler for handling the test event trigger - * - * @note If TestEventTrigger is enabled, it needs to be implemented in the app - * - * @param eventTrigger Event trigger to handle - * - * @retval true on success - * @retval false if error happened - */ -bool emberAfHandleEventTrigger(uint64_t eventTrigger); diff --git a/examples/providers/DeviceInfoProviderImpl.cpp b/examples/providers/DeviceInfoProviderImpl.cpp index 5524b770c0585a..7b07561c2caf98 100644 --- a/examples/providers/DeviceInfoProviderImpl.cpp +++ b/examples/providers/DeviceInfoProviderImpl.cpp @@ -100,8 +100,8 @@ bool DeviceInfoProviderImpl::FixedLabelIteratorImpl::Next(FixedLabelType & outpu VerifyOrReturnError(std::strlen(labelPtr) <= kMaxLabelNameLength, false); VerifyOrReturnError(std::strlen(valuePtr) <= kMaxLabelValueLength, false); - Platform::CopyString(mFixedLabelNameBuf, kMaxLabelNameLength + 1, labelPtr); - Platform::CopyString(mFixedLabelValueBuf, kMaxLabelValueLength + 1, valuePtr); + Platform::CopyString(mFixedLabelNameBuf, labelPtr); + Platform::CopyString(mFixedLabelValueBuf, valuePtr); output.label = CharSpan::fromCharString(mFixedLabelNameBuf); output.value = CharSpan::fromCharString(mFixedLabelValueBuf); diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp index fa38eba254853a..329c8d95f64beb 100644 --- a/examples/pump-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-app/nrfconnect/main/AppTask.cpp @@ -25,7 +25,8 @@ #include #include -#include +#include +#include #include #include #include @@ -186,9 +187,12 @@ CHIP_ERROR AppTask::Init() #endif static CommonCaseDeviceServerInitParams initParams; - static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR); (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams)); AppFabricTableDelegate::Init(); diff --git a/examples/pump-app/silabs/README.md b/examples/pump-app/silabs/README.md index 9a6e4e2af9be8f..56e6ad938f82db 100644 --- a/examples/pump-app/silabs/README.md +++ b/examples/pump-app/silabs/README.md @@ -56,8 +56,9 @@ Labs platform. (For Mac OS X, `commander` is located inside `Commander.app/Contents/MacOS/`.) -- Download and install a suitable ARM gcc tool chain: - [GNU Arm Embedded Toolchain 9-2019-q4-major](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) +- Download and install a suitable ARM gcc tool chain (For most Host, the + bootstrap already installs the toolchain): + [GNU Arm Embedded Toolchain 12.2 Rel1](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) - Install some additional tools (likely already present for CHIP developers): diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp index db96480e5acb9d..ca79a41160a9d2 100644 --- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp @@ -25,7 +25,8 @@ #include #include -#include +#include +#include #include #include #include @@ -184,9 +185,12 @@ CHIP_ERROR AppTask::Init() #endif static CommonCaseDeviceServerInitParams initParams; - static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR); (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams)); AppFabricTableDelegate::Init(); diff --git a/examples/rvc-app/rvc-common/rvc-app.matter b/examples/rvc-app/rvc-common/rvc-app.matter index 4089d016fd603f..6ed9387af4a2db 100644 --- a/examples/rvc-app/rvc-common/rvc-app.matter +++ b/examples/rvc-app/rvc-common/rvc-app.matter @@ -943,7 +943,7 @@ cluster RvcRunMode = 84 { } bitmap Feature : bitmap32 { - kOnOff = 0x1; + kNoFeatures = 0x0; } struct ModeTagStruct { @@ -959,7 +959,6 @@ cluster RvcRunMode = 84 { readonly attribute ModeOptionStruct supportedModes[] = 0; readonly attribute int8u currentMode = 1; - attribute optional nullable int8u onMode = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -996,7 +995,7 @@ cluster RvcCleanMode = 85 { } bitmap Feature : bitmap32 { - kOnOff = 0x1; + kNoFeatures = 0x0; } struct ModeTagStruct { @@ -1012,7 +1011,6 @@ cluster RvcCleanMode = 85 { readonly attribute ModeOptionStruct supportedModes[] = 0; readonly attribute int8u currentMode = 1; - attribute optional nullable int8u onMode = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1095,10 +1093,6 @@ cluster RvcOperationalState = 97 { /** Upon receipt, the device SHALL pause its operation if it is possible based on the current function of the server. */ command Pause(): OperationalCommandResponse = 0; - /** Upon receipt, the device SHALL stop its operation if it is at a position where it is safe to do so and/or permitted. */ - command Stop(): OperationalCommandResponse = 1; - /** Upon receipt, the device SHALL start its operation if it is safe to do so and the device is in an operational state from which it can be started. */ - command Start(): OperationalCommandResponse = 2; /** Upon receipt, the device SHALL resume its operation from the point it was at when it received the Pause command, or from the point when it was paused by means outside of this cluster (for example by manual button press). */ command Resume(): OperationalCommandResponse = 3; /** On receipt of this command, the device SHALL start seeking the charging dock, if possible in the current state of the device. */ diff --git a/examples/shell/shell_common/cmd_otcli.cpp b/examples/shell/shell_common/cmd_otcli.cpp index 590fda96e16fae..98736c2cb4215d 100644 --- a/examples/shell/shell_common/cmd_otcli.cpp +++ b/examples/shell/shell_common/cmd_otcli.cpp @@ -48,6 +48,7 @@ static char sTxBuffer[SHELL_OTCLI_TX_BUFFER_SIZE]; static constexpr uint16_t sTxLength = SHELL_OTCLI_TX_BUFFER_SIZE; #endif // !CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI) #endif +static constexpr uint16_t kMaxLineLength = 384; #else #include #include @@ -81,8 +82,6 @@ CHIP_ERROR cmd_otcli_dispatch(int argc, char ** argv) { CHIP_ERROR error = CHIP_NO_ERROR; -// From OT CLI internal lib, kMaxLineLength = 128 -#define kMaxLineLength 128 char buff[kMaxLineLength] = { 0 }; char * buff_ptr = buff; int i = 0; diff --git a/examples/smoke-co-alarm-app/silabs/README.md b/examples/smoke-co-alarm-app/silabs/README.md index d62ba82bc59ab4..b5548b69f24f54 100644 --- a/examples/smoke-co-alarm-app/silabs/README.md +++ b/examples/smoke-co-alarm-app/silabs/README.md @@ -18,6 +18,7 @@ An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. - [Debug build / release build](#debug-build--release-build) - [Disabling LCD](#disabling-lcd) - [KVS maximum entry count](#kvs-maximum-entry-count) + - [Enabling test event trigger](#enabling-test-event-trigger)
@@ -54,8 +55,9 @@ Silicon Labs platform. (For Mac OS X, `commander` is located inside `Commander.app/Contents/MacOS/`.) -- Download and install a suitable ARM gcc tool chain: - [GNU Arm Embedded Toolchain 9-2019-q4-major](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) +- Download and install a suitable ARM gcc tool chain (For most Host, the + bootstrap already installs the toolchain): + [GNU Arm Embedded Toolchain 12.2 Rel1](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) - Install some additional tools(likely already present for CHIP developers): diff --git a/examples/smoke-co-alarm-app/silabs/src/SmokeCoAlarmManager.cpp b/examples/smoke-co-alarm-app/silabs/src/SmokeCoAlarmManager.cpp index 85c8bca2193a67..7d64a036371a6f 100644 --- a/examples/smoke-co-alarm-app/silabs/src/SmokeCoAlarmManager.cpp +++ b/examples/smoke-co-alarm-app/silabs/src/SmokeCoAlarmManager.cpp @@ -21,7 +21,7 @@ #include "AppTask.h" #include -#include +#include #include using namespace chip; diff --git a/examples/thermostat/qpg/BUILD.gn b/examples/thermostat/qpg/BUILD.gn index d4285571114721..9989e349fc6c86 100644 --- a/examples/thermostat/qpg/BUILD.gn +++ b/examples/thermostat/qpg/BUILD.gn @@ -51,7 +51,7 @@ qpg_executable("thermostat") { output_name = "chip-${qpg_target_ic}-thermostat-example.out" sources = [ - "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp", + "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp", "${examples_plat_dir}/app/main.cpp", "${examples_plat_dir}/ota/ota.cpp", "src/AppTask.cpp", diff --git a/examples/thermostat/silabs/README.md b/examples/thermostat/silabs/README.md index 0d9c760c5821c6..3440277c64dfee 100644 --- a/examples/thermostat/silabs/README.md +++ b/examples/thermostat/silabs/README.md @@ -59,8 +59,9 @@ Silicon Labs platform. (For Mac OS X, `commander` is located inside `Commander.app/Contents/MacOS/`.) -- Download and install a suitable ARM gcc tool chain: - [GNU Arm Embedded Toolchain 9-2019-q4-major](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) +- Download and install a suitable ARM gcc tool chain (For most Host, the + bootstrap already installs the toolchain): + [GNU Arm Embedded Toolchain 12.2 Rel1](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) - Install some additional tools(likely already present for CHIP developers): diff --git a/examples/tv-app/android/BUILD.gn b/examples/tv-app/android/BUILD.gn index 0793b7d2993ef8..63de5a515b0754 100644 --- a/examples/tv-app/android/BUILD.gn +++ b/examples/tv-app/android/BUILD.gn @@ -33,8 +33,6 @@ shared_library("jni") { "include/audio-output/AudioOutputManager.cpp", "include/audio-output/AudioOutputManager.h", "include/cluster-init.cpp", - "include/content-app-observer/ContentAppObserver.cpp", - "include/content-app-observer/ContentAppObserver.h", "include/content-control/ContentController.cpp", "include/content-control/ContentController.h", "include/content-launcher/AppContentLauncherManager.cpp", @@ -118,6 +116,8 @@ android_library("java") { "java/src/com/matter/tv/server/tvapp/ChannelLineupInfo.java", "java/src/com/matter/tv/server/tvapp/ChannelManager.java", "java/src/com/matter/tv/server/tvapp/ChannelManagerStub.java", + "java/src/com/matter/tv/server/tvapp/ChannelProgramInfo.java", + "java/src/com/matter/tv/server/tvapp/ChannelProgramResponse.java", "java/src/com/matter/tv/server/tvapp/Clusters.java", "java/src/com/matter/tv/server/tvapp/ContentAppEndpointManager.java", "java/src/com/matter/tv/server/tvapp/ContentLaunchBrandingInformation.java", @@ -142,6 +142,7 @@ android_library("java") { "java/src/com/matter/tv/server/tvapp/MediaPlaybackManager.java", "java/src/com/matter/tv/server/tvapp/MediaPlaybackManagerStub.java", "java/src/com/matter/tv/server/tvapp/MediaPlaybackPosition.java", + "java/src/com/matter/tv/server/tvapp/MediaTrack.java", "java/src/com/matter/tv/server/tvapp/OnOffManager.java", "java/src/com/matter/tv/server/tvapp/OnOffManagerStub.java", "java/src/com/matter/tv/server/tvapp/TvApp.java", diff --git a/examples/tv-app/android/java/AppImpl.h b/examples/tv-app/android/java/AppImpl.h index 7d6bf20c7bb37c..7c0537242657ca 100644 --- a/examples/tv-app/android/java/AppImpl.h +++ b/examples/tv-app/android/java/AppImpl.h @@ -35,7 +35,6 @@ #include "../include/account-login/AccountLoginManager.h" #include "../include/application-basic/ApplicationBasicManager.h" #include "../include/application-launcher/ApplicationLauncherManager.h" -#include "../include/content-app-observer/ContentAppObserver.h" #include "../include/content-control/ContentController.h" #include "../include/content-launcher/AppContentLauncherManager.h" #include "../include/media-playback/AppMediaPlaybackManager.h" @@ -49,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -76,7 +74,6 @@ using ApplicationBasicDelegate = app::Clusters::ApplicationBasic::Delegate; using ApplicationLauncherDelegate = app::Clusters::ApplicationLauncher::Delegate; using ChannelDelegate = app::Clusters::Channel::Delegate; using ContentLauncherDelegate = app::Clusters::ContentLauncher::Delegate; -using ContentAppObserverDelegate = app::Clusters::ContentAppObserver::Delegate; using ContentControlDelegate = app::Clusters::ContentControl::Delegate; using KeypadInputDelegate = app::Clusters::KeypadInput::Delegate; using MediaPlaybackDelegate = app::Clusters::MediaPlayback::Delegate; @@ -118,11 +115,6 @@ class DLL_EXPORT ContentAppImpl : public ContentApp mContentLauncherDelegate.SetEndpointId(GetEndpointId()); return &mContentLauncherDelegate; }; - ContentAppObserverDelegate * GetContentAppObserverDelegate() override - { - mContentAppObserverDelegate.SetEndpointId(GetEndpointId()); - return &mContentAppObserverDelegate; - }; ContentControlDelegate * GetContentControlDelegate() override { mContentControlDelegate.SetEndpointId(GetEndpointId()); @@ -146,7 +138,6 @@ class DLL_EXPORT ContentAppImpl : public ContentApp ApplicationLauncherManager mApplicationLauncherDelegate; ChannelManager mChannelDelegate; ContentController mContentControlDelegate; - ContentAppObserver mContentAppObserverDelegate; AppContentLauncherManager mContentLauncherDelegate; KeypadInputManager mKeypadInputDelegate; AppMediaPlaybackManager mMediaPlaybackDelegate; diff --git a/examples/tv-app/android/java/ChannelManager.cpp b/examples/tv-app/android/java/ChannelManager.cpp index 586e56bf99b27f..d471bebf3075f6 100644 --- a/examples/tv-app/android/java/ChannelManager.cpp +++ b/examples/tv-app/android/java/ChannelManager.cpp @@ -59,11 +59,12 @@ CHIP_ERROR ChannelManager::HandleGetChannelList(AttributeValueEncoder & aEncoder { CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NULL_OBJECT, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received ChannelManager::HandleGetChannelList"); VerifyOrExit(mChannelManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetChannelListMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); return aEncoder.EncodeList([this, env](const auto & encoder) -> CHIP_ERROR { jobjectArray channelInfoList = (jobjectArray) env->CallObjectMethod(mChannelManagerObject, mGetChannelListMethod); @@ -135,11 +136,12 @@ CHIP_ERROR ChannelManager::HandleGetLineup(AttributeValueEncoder & aEncoder) chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type lineupInfo; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NULL_OBJECT, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received ChannelManager::HandleGetLineup"); VerifyOrExit(mChannelManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetLineupMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); { jobject channelLineupObject = env->CallObjectMethod(mChannelManagerObject, mGetLineupMethod); @@ -197,10 +199,12 @@ CHIP_ERROR ChannelManager::HandleGetCurrentChannel(AttributeValueEncoder & aEnco chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type channelInfo; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NULL_OBJECT, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); + ChipLogProgress(Zcl, "Received ChannelManager::HandleGetCurrentChannel"); VerifyOrExit(mChannelManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetCurrentChannelMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); { jobject channelInfoObject = env->CallObjectMethod(mChannelManagerObject, mGetCurrentChannelMethod); @@ -232,6 +236,14 @@ CHIP_ERROR ChannelManager::HandleGetCurrentChannel(AttributeValueEncoder & aEnco channelInfo.affiliateCallSign = Optional(affiliateCallSign.charSpan()); } + jfieldID getJidentifierField = env->GetFieldID(channelClass, "identifier", "Ljava/lang/String;"); + jstring jidentifier = static_cast(env->GetObjectField(channelInfoObject, getJidentifierField)); + JniUtfString identifier(env, jidentifier); + if (jidentifier != nullptr) + { + channelInfo.identifier = Optional(identifier.charSpan()); + } + jfieldID majorNumField = env->GetFieldID(channelClass, "majorNumber", "I"); jint jmajorNum = env->GetIntField(channelInfoObject, majorNumField); channelInfo.majorNumber = static_cast(jmajorNum); @@ -262,11 +274,12 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelperExceptionClear(); @@ -334,11 +348,12 @@ bool ChannelManager::HandleSkipChannel(const int16_t & count) { jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received ChannelManager::HandleSkipChannel count %d", count); VerifyOrExit(mChannelManagerObject != nullptr, ChipLogError(Zcl, "mChannelManagerObject null")); VerifyOrExit(mSkipChannelMethod != nullptr, ChipLogError(Zcl, "mSkipChannelMethod null")); - VerifyOrExit(env != NULL, ChipLogError(Zcl, "env null")); env->ExceptionClear(); @@ -363,30 +378,286 @@ void ChannelManager::HandleGetProgramGuide( const chip::Optional> & externalIdList, const chip::Optional & data) { - - // 1. Decode received parameters - // 2. Perform search - // 3. Return results ProgramGuideResponseType response; - // response.channelPagingStruct; - // response.programList; - helper.Success(response); + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); + + std::vector needToFreePrograms; + std::vector needToFreeChannels; + std::vector tempPrograms; + std::vector needToFreeStrings; + + ChipLogProgress(Zcl, "Received ChannelManager::HandleGetProgramGuide"); + VerifyOrExit(mChannelManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mGetProgramGuideMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + + { + // NOTE: this example app does not pass the Data, PageToken, ChannelsArray or ExternalIdList through to the Java layer + UtfString jData(env, ""); + UtfString jToken(env, ""); + jobjectArray channelsArray = nullptr; + jobjectArray externalIDListArray = (jobjectArray) env->NewObjectArray(0, env->FindClass("java/util/Map$Entry"), NULL); + + jobject resp = env->CallObjectMethod( + mChannelManagerObject, mGetProgramGuideMethod, static_cast(startTime.ValueOr(0)), + static_cast(endTime.ValueOr(0)), channelsArray, jToken.jniValue(), + static_cast(recordingFlag.ValueOr(0).Raw() != 0), externalIDListArray, jData.jniValue()); + if (env->ExceptionCheck()) + { + ChipLogError(Zcl, "Java exception in ChannelManager::HandleGetProgramGuide"); + env->ExceptionDescribe(); + env->ExceptionClear(); + err = CHIP_ERROR_INCORRECT_STATE; + goto exit; + } + + VerifyOrExit(resp != nullptr, err = CHIP_JNI_ERROR_NULL_OBJECT); + jclass respCls = env->GetObjectClass(resp); + jfieldID programsFid = env->GetFieldID(respCls, "programs", "[Lcom/matter/tv/server/tvapp/ChannelProgramInfo;"); + VerifyOrExit(programsFid != nullptr, err = CHIP_JNI_ERROR_FIELD_NOT_FOUND); + + jobjectArray programsArray = (jobjectArray) env->GetObjectField(resp, programsFid); + jint size = env->GetArrayLength(programsArray); + for (jint i = 0; i < size; i++) + { + ProgramType * program = new ProgramType(); + VerifyOrExit(program != nullptr, err = CHIP_ERROR_NO_MEMORY); + + jobject programObject = env->GetObjectArrayElement(programsArray, i); + jclass programClass = env->GetObjectClass(programObject); + + jfieldID getIdentifierField = env->GetFieldID(programClass, "identifier", "Ljava/lang/String;"); + jstring jidentifier = static_cast(env->GetObjectField(programObject, getIdentifierField)); + JniUtfString * identifier = new JniUtfString(env, jidentifier); + VerifyOrExit(identifier != nullptr, err = CHIP_ERROR_NO_MEMORY); + needToFreeStrings.push_back(identifier); + if (jidentifier != nullptr) + { + program->identifier = identifier->charSpan(); + } + + jfieldID getChannelField = env->GetFieldID(programClass, "channel", "Lcom/matter/tv/server/tvapp/ChannelInfo;"); + jobject channelInfoObject = env->GetObjectField(programObject, getChannelField); + if (channelInfoObject != nullptr) + { + jclass channelClass = env->GetObjectClass(channelInfoObject); + + ChannelInfoType * channelInfo = new ChannelInfoType(); + VerifyOrExit(channelInfo != nullptr, err = CHIP_ERROR_NO_MEMORY); + + jfieldID getCallSignField = env->GetFieldID(channelClass, "callSign", "Ljava/lang/String;"); + jstring jcallSign = static_cast(env->GetObjectField(channelInfoObject, getCallSignField)); + JniUtfString * callsign = new JniUtfString(env, jcallSign); + VerifyOrExit(callsign != nullptr, err = CHIP_ERROR_NO_MEMORY); + needToFreeStrings.push_back(callsign); + if (jcallSign != nullptr) + { + channelInfo->callSign = Optional(callsign->charSpan()); + } + + jfieldID getNameField = env->GetFieldID(channelClass, "name", "Ljava/lang/String;"); + jstring jname = static_cast(env->GetObjectField(channelInfoObject, getNameField)); + JniUtfString * name = new JniUtfString(env, jname); + VerifyOrExit(name != nullptr, err = CHIP_ERROR_NO_MEMORY); + needToFreeStrings.push_back(name); + if (jname != nullptr) + { + channelInfo->name = Optional(name->charSpan()); + } + + jfieldID getJaffiliateCallSignField = env->GetFieldID(channelClass, "affiliateCallSign", "Ljava/lang/String;"); + jstring jaffiliateCallSign = + static_cast(env->GetObjectField(channelInfoObject, getJaffiliateCallSignField)); + JniUtfString * affiliateCallSign = new JniUtfString(env, jaffiliateCallSign); + VerifyOrExit(affiliateCallSign != nullptr, err = CHIP_ERROR_NO_MEMORY); + needToFreeStrings.push_back(affiliateCallSign); + if (jaffiliateCallSign != nullptr) + { + channelInfo->affiliateCallSign = Optional(affiliateCallSign->charSpan()); + } + + jfieldID getJchanIdentifierField = env->GetFieldID(channelClass, "identifier", "Ljava/lang/String;"); + jstring jchanidentifier = static_cast(env->GetObjectField(channelInfoObject, getJchanIdentifierField)); + JniUtfString * chanidentifier = new JniUtfString(env, jchanidentifier); + VerifyOrExit(chanidentifier != nullptr, err = CHIP_ERROR_NO_MEMORY); + needToFreeStrings.push_back(chanidentifier); + if (jchanidentifier != nullptr) + { + channelInfo->identifier = Optional(chanidentifier->charSpan()); + } + + jfieldID majorNumField = env->GetFieldID(channelClass, "majorNumber", "I"); + jint jmajorNum = env->GetIntField(channelInfoObject, majorNumField); + channelInfo->majorNumber = static_cast(jmajorNum); + + jfieldID minorNumField = env->GetFieldID(channelClass, "minorNumber", "I"); + jint jminorNum = env->GetIntField(channelInfoObject, minorNumField); + channelInfo->minorNumber = static_cast(jminorNum); + + program->channel = *channelInfo; + needToFreeChannels.push_back(channelInfo); + } + + jfieldID getTitleField = env->GetFieldID(programClass, "title", "Ljava/lang/String;"); + jstring jtitle = static_cast(env->GetObjectField(programObject, getTitleField)); + JniUtfString * title = new JniUtfString(env, jtitle); + VerifyOrExit(title != nullptr, err = CHIP_ERROR_NO_MEMORY); + needToFreeStrings.push_back(title); + if (jtitle != nullptr) + { + program->title = title->charSpan(); + } + + jfieldID getSubTitleField = env->GetFieldID(programClass, "subTitle", "Ljava/lang/String;"); + jstring jsubTitle = static_cast(env->GetObjectField(programObject, getSubTitleField)); + JniUtfString * subTitle = new JniUtfString(env, jsubTitle); + VerifyOrExit(subTitle != nullptr, err = CHIP_ERROR_NO_MEMORY); + needToFreeStrings.push_back(subTitle); + if (jsubTitle != nullptr) + { + program->subtitle = MakeOptional(subTitle->charSpan()); + } + + jfieldID getDescriptionField = env->GetFieldID(programClass, "description", "Ljava/lang/String;"); + jstring jdescription = static_cast(env->GetObjectField(programObject, getDescriptionField)); + JniUtfString * description = new JniUtfString(env, jdescription); + VerifyOrExit(description != nullptr, err = CHIP_ERROR_NO_MEMORY); + needToFreeStrings.push_back(description); + if (jdescription != nullptr) + { + program->description = Optional(description->charSpan()); + } + + jfieldID startTimeField = env->GetFieldID(programClass, "startTime", "J"); + jlong jstartTime = env->GetLongField(programObject, startTimeField); + program->startTime = static_cast(jstartTime); + + jfieldID endTimeField = env->GetFieldID(programClass, "endTime", "J"); + jlong jendTime = env->GetLongField(programObject, endTimeField); + program->endTime = static_cast(jendTime); + + uint32_t recordFlag = 0; + jfieldID recordFlagScheduledField = env->GetFieldID(programClass, "recordFlagScheduled", "Z"); + jboolean jrecordFlagScheduled = env->GetBooleanField(programObject, recordFlagScheduledField); + if (jrecordFlagScheduled) + { + recordFlag |= 1; + } + jfieldID recordFlagSeriesField = env->GetFieldID(programClass, "recordFlagSeries", "Z"); + jboolean jrecordFlagSeries = env->GetBooleanField(programObject, recordFlagSeriesField); + if (jrecordFlagSeries) + { + recordFlag |= 2; + } + jfieldID recordFlagRecordedField = env->GetFieldID(programClass, "recordFlagRecorded", "Z"); + jboolean jrecordFlagRecorded = env->GetBooleanField(programObject, recordFlagRecordedField); + if (jrecordFlagRecorded) + { + recordFlag |= 4; + } + + program->recordingFlag = MakeOptional(static_cast(recordFlag)); + + needToFreePrograms.push_back(program); + tempPrograms.push_back(*program); + } + + response.programList = DataModel::List(tempPrograms.data(), tempPrograms.size()); + + err = helper.Success(response); + } + +exit: + for (ProgramType * program : needToFreePrograms) + { + delete program; + } + + for (JniUtfString * str : needToFreeStrings) + { + delete str; + } + + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "ChannelManager::HandleGetProgramGuide status error: %s", err.AsString()); + } } bool ChannelManager::HandleRecordProgram(const chip::CharSpan & programIdentifier, bool shouldRecordSeries, const DataModel::DecodableList & externalIdList, const chip::ByteSpan & data) { - // Start recording - return true; + jboolean ret = JNI_FALSE; + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); + + ChipLogProgress(Zcl, "Received ChannelManager::HandleRecordProgram"); + VerifyOrExit(mChannelManagerObject != nullptr, ChipLogError(Zcl, "mChannelManagerObject null")); + VerifyOrExit(mRecordProgramMethod != nullptr, ChipLogError(Zcl, "mRecordProgramMethod null")); + + env->ExceptionClear(); + + { + UtfString jIdentifier(env, programIdentifier); + + // NOTE: this example app does not pass the Data or ExternalIdList through to the Java layer + UtfString jData(env, ""); + jobjectArray externalIDListArray = (jobjectArray) env->NewObjectArray(0, env->FindClass("java/util/Map$Entry"), NULL); + + ret = env->CallBooleanMethod(mChannelManagerObject, mRecordProgramMethod, jIdentifier.jniValue(), + static_cast(shouldRecordSeries), externalIDListArray, jData.jniValue()); + if (env->ExceptionCheck()) + { + ChipLogError(DeviceLayer, "Java exception in ChannelManager::HandleRecordProgram"); + env->ExceptionDescribe(); + env->ExceptionClear(); + return false; + } + } + +exit: + return static_cast(ret); } bool ChannelManager::HandleCancelRecordProgram(const chip::CharSpan & programIdentifier, bool shouldRecordSeries, const DataModel::DecodableList & externalIdList, const chip::ByteSpan & data) { - // Cancel recording - return true; + jboolean ret = JNI_FALSE; + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); + + ChipLogProgress(Zcl, "Received ChannelManager::HandleCancelRecordProgram"); + VerifyOrExit(mChannelManagerObject != nullptr, ChipLogError(Zcl, "mChannelManagerObject null")); + VerifyOrExit(mCancelRecordProgramMethod != nullptr, ChipLogError(Zcl, "mCancelRecordProgramMethod null")); + + env->ExceptionClear(); + + { + UtfString jIdentifier(env, programIdentifier); + + // NOTE: this example app does not pass the Data or ExternalIdList through to the Java layer + UtfString jData(env, ""); + jobjectArray externalIDListArray = (jobjectArray) env->NewObjectArray(0, env->FindClass("java/util/Map$Entry"), NULL); + + ret = env->CallBooleanMethod(mChannelManagerObject, mCancelRecordProgramMethod, jIdentifier.jniValue(), + static_cast(shouldRecordSeries), externalIDListArray, jData.jniValue()); + if (env->ExceptionCheck()) + { + ChipLogError(DeviceLayer, "Java exception in ChannelManager::HandleCancelRecordProgram"); + env->ExceptionDescribe(); + env->ExceptionClear(); + return false; + } + } + +exit: + return static_cast(ret); } void ChannelManager::InitializeWithObjects(jobject managerObject) @@ -442,6 +713,31 @@ void ChannelManager::InitializeWithObjects(jobject managerObject) ChipLogError(Zcl, "Failed to access ChannelManager 'skipChannel' method"); env->ExceptionClear(); } + + mGetProgramGuideMethod = env->GetMethodID(managerClass, "getProgramGuide", + "(JJ[Lcom/matter/tv/server/tvapp/ChannelInfo;Ljava/lang/String;Z[Ljava/util/" + "Map$Entry;Ljava/lang/String;)Lcom/matter/tv/server/tvapp/ChannelProgramResponse;"); + if (mGetProgramGuideMethod == nullptr) + { + ChipLogError(Zcl, "Failed to access ChannelManager 'getProgramGuide' method"); + env->ExceptionClear(); + } + + mRecordProgramMethod = + env->GetMethodID(managerClass, "recordProgram", "(Ljava/lang/String;Z[Ljava/util/Map$Entry;Ljava/lang/String;)Z"); + if (mRecordProgramMethod == nullptr) + { + ChipLogError(Zcl, "Failed to access ChannelManager 'recordProgram' method"); + env->ExceptionClear(); + } + + mCancelRecordProgramMethod = + env->GetMethodID(managerClass, "cancelRecordProgram", "(Ljava/lang/String;Z[Ljava/util/Map$Entry;Ljava/lang/String;)Z"); + if (mCancelRecordProgramMethod == nullptr) + { + ChipLogError(Zcl, "Failed to access ChannelManager 'cancelRecordProgram' method"); + env->ExceptionClear(); + } } uint32_t ChannelManager::GetFeatureMap(chip::EndpointId endpoint) diff --git a/examples/tv-app/android/java/ChannelManager.h b/examples/tv-app/android/java/ChannelManager.h index fca3d03056f0fe..85d645beda40a3 100644 --- a/examples/tv-app/android/java/ChannelManager.h +++ b/examples/tv-app/android/java/ChannelManager.h @@ -31,6 +31,8 @@ using ChannelInfoType = chip::app::Clusters::Channel::Structs::Channel using AdditionalInfoType = chip::app::Clusters::Channel::Structs::AdditionalInfoStruct::Type; using LineupInfoType = chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type; using PageTokenType = chip::app::Clusters::Channel::Structs::PageTokenStruct::Type; +using ProgramType = chip::app::Clusters::Channel::Structs::ProgramStruct::Type; +using ChannelPagingType = chip::app::Clusters::Channel::Structs::ChannelPagingStruct::Type; class ChannelManager : public ChannelDelegate { @@ -73,6 +75,10 @@ class ChannelManager : public ChannelDelegate jmethodID mChangeChannelByNumberMethod = nullptr; jmethodID mSkipChannelMethod = nullptr; + jmethodID mGetProgramGuideMethod = nullptr; + jmethodID mRecordProgramMethod = nullptr; + jmethodID mCancelRecordProgramMethod = nullptr; + // TODO: set this based upon meta data from app uint32_t mDynamicEndpointFeatureMap = 3; }; diff --git a/examples/tv-app/android/java/ContentLauncherManager.cpp b/examples/tv-app/android/java/ContentLauncherManager.cpp index ee2f36c1667666..aec5319a567f27 100644 --- a/examples/tv-app/android/java/ContentLauncherManager.cpp +++ b/examples/tv-app/android/java/ContentLauncherManager.cpp @@ -54,11 +54,12 @@ void ContentLauncherManager::HandleLaunchContent(CommandResponseHelper acceptedHeadersList; + VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NO_ENV, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received ContentLauncherManager::GetAcceptHeader"); VerifyOrExit(mContentLauncherManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetAcceptHeaderMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); return aEncoder.EncodeList([this, env](const auto & encoder) -> CHIP_ERROR { jobjectArray acceptedHeadersArray = @@ -203,11 +206,12 @@ uint32_t ContentLauncherManager::HandleGetSupportedStreamingProtocols() CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); uint32_t supportedStreamingProtocols = 0; + VerifyOrReturnValue(env != nullptr, 0, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received ContentLauncherManager::GetSupportedStreamingProtocols"); VerifyOrExit(mContentLauncherManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetSupportedStreamingProtocolsMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); { jlong jSupportedStreamingProtocols = diff --git a/examples/tv-app/android/java/KeypadInputManager.cpp b/examples/tv-app/android/java/KeypadInputManager.cpp index 5267f1ec70c9db..2b642a825b0bef 100644 --- a/examples/tv-app/android/java/KeypadInputManager.cpp +++ b/examples/tv-app/android/java/KeypadInputManager.cpp @@ -23,6 +23,7 @@ #include #include #include +#include using namespace chip; using namespace chip::app::Clusters::KeypadInput; @@ -48,11 +49,12 @@ void KeypadInputManager::HandleSendKey(CommandResponseHelperExceptionClear(); ret = env->CallIntMethod(mKeypadInputManagerObject, mSendKeyMethod, static_cast(keyCode)); @@ -74,6 +76,7 @@ void KeypadInputManager::InitializeWithObjects(jobject managerObject) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Failed to GetEnvForCurrentThread for KeypadInputManager")); + JniLocalReferenceScope scope(env); mKeypadInputManagerObject = env->NewGlobalRef(managerObject); VerifyOrReturn(mKeypadInputManagerObject != nullptr, ChipLogError(Zcl, "Failed to NewGlobalRef KeypadInputManager")); diff --git a/examples/tv-app/android/java/LevelManager.cpp b/examples/tv-app/android/java/LevelManager.cpp index 80ad32490ddb16..cefb26ecfe325d 100644 --- a/examples/tv-app/android/java/LevelManager.cpp +++ b/examples/tv-app/android/java/LevelManager.cpp @@ -92,6 +92,7 @@ CHIP_ERROR LevelManager::InitializeWithObjects(jobject managerObject) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturnLogError(env != nullptr, CHIP_ERROR_INCORRECT_STATE); + JniLocalReferenceScope scope(env); mLevelManagerObject = env->NewGlobalRef(managerObject); VerifyOrReturnLogError(mLevelManagerObject != nullptr, CHIP_ERROR_INVALID_ARGUMENT); @@ -115,7 +116,9 @@ void LevelManager::HandleLevelChanged(uint8_t value) ChipLogProgress(Zcl, "LevelManager::HandleLevelChanged"); JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - VerifyOrReturn(env != NULL, ChipLogProgress(Zcl, "env null")); + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); + VerifyOrReturn(mLevelManagerObject != nullptr, ChipLogProgress(Zcl, "mLevelManagerObject null")); VerifyOrReturn(mHandleLevelChangedMethod != nullptr, ChipLogProgress(Zcl, "mHandleLevelChangedMethod null")); diff --git a/examples/tv-app/android/java/LowPowerManager.cpp b/examples/tv-app/android/java/LowPowerManager.cpp index b7f8f56a40b93a..9b21a1ce872c31 100644 --- a/examples/tv-app/android/java/LowPowerManager.cpp +++ b/examples/tv-app/android/java/LowPowerManager.cpp @@ -46,6 +46,7 @@ void LowPowerManager::InitializeWithObjects(jobject managerObject) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Failed to GetEnvForCurrentThread for LowPowerManager")); + JniLocalReferenceScope scope(env); mLowPowerManagerObject = env->NewGlobalRef(managerObject); VerifyOrReturn(mLowPowerManagerObject != nullptr, ChipLogError(Zcl, "Failed to NewGlobalRef LowPowerManager")); @@ -65,6 +66,7 @@ bool LowPowerManager::HandleSleep() { jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received LowPowerManager::Sleep"); VerifyOrExit(mLowPowerManagerObject != nullptr, ChipLogError(Zcl, "mLowPowerManagerObject null")); diff --git a/examples/tv-app/android/java/MediaInputManager.cpp b/examples/tv-app/android/java/MediaInputManager.cpp index b28609d0efc3fa..1c183c205c6628 100644 --- a/examples/tv-app/android/java/MediaInputManager.cpp +++ b/examples/tv-app/android/java/MediaInputManager.cpp @@ -53,11 +53,12 @@ CHIP_ERROR MediaInputManager::HandleGetInputList(chip::app::AttributeValueEncode { CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NO_ENV, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received MediaInputManager::HandleGetInputList"); VerifyOrExit(mMediaInputManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetInputListMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); return aEncoder.EncodeList([this, env](const auto & encoder) -> CHIP_ERROR { jobjectArray inputArray = (jobjectArray) env->CallObjectMethod(mMediaInputManagerObject, mGetInputListMethod); @@ -123,6 +124,8 @@ uint8_t MediaInputManager::HandleGetCurrentInput() CHIP_ERROR err = CHIP_NO_ERROR; jint index = -1; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, 0, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received MediaInputManager::HandleGetCurrentInput"); VerifyOrExit(mMediaInputManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); @@ -153,11 +156,12 @@ bool MediaInputManager::HandleSelectInput(const uint8_t index) { jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received MediaInputManager::HandleSelectInput %d", index); VerifyOrExit(mMediaInputManagerObject != nullptr, ChipLogError(Zcl, "mMediaInputManagerObject null")); VerifyOrExit(mSelectInputMethod != nullptr, ChipLogError(Zcl, "mSelectInputMethod null")); - VerifyOrExit(env != NULL, ChipLogError(Zcl, "env null")); env->ExceptionClear(); ret = env->CallBooleanMethod(mMediaInputManagerObject, mSelectInputMethod, static_cast(index)); @@ -177,11 +181,12 @@ bool MediaInputManager::HandleShowInputStatus() { jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received MediaInputManager::HandleShowInputStatus"); VerifyOrExit(mMediaInputManagerObject != nullptr, ChipLogError(Zcl, "mMediaInputManagerObject null")); VerifyOrExit(mShowInputStatusMethod != nullptr, ChipLogError(Zcl, "mShowInputStatusMethod null")); - VerifyOrExit(env != NULL, ChipLogError(Zcl, "env null")); env->ExceptionClear(); ret = env->CallBooleanMethod(mMediaInputManagerObject, mShowInputStatusMethod); @@ -201,11 +206,12 @@ bool MediaInputManager::HandleHideInputStatus() { jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received MediaInputManager::HandleHideInputStatus"); VerifyOrExit(mMediaInputManagerObject != nullptr, ChipLogError(Zcl, "mMediaInputManagerObject null")); VerifyOrExit(mHideInputStatusMethod != nullptr, ChipLogError(Zcl, "mHideInputStatusMethod null")); - VerifyOrExit(env != NULL, ChipLogError(Zcl, "env null")); env->ExceptionClear(); ret = env->CallBooleanMethod(mMediaInputManagerObject, mHideInputStatusMethod); @@ -226,11 +232,12 @@ bool MediaInputManager::HandleRenameInput(const uint8_t index, const chip::CharS std::string inputname(name.data(), name.size()); jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received MediaInputManager::HandleRenameInput %d to %s", index, name.data()); VerifyOrExit(mMediaInputManagerObject != nullptr, ChipLogError(Zcl, "mMediaInputManagerObject null")); VerifyOrExit(mRenameInputMethod != nullptr, ChipLogError(Zcl, "mHideInputStatusMethod null")); - VerifyOrExit(env != NULL, ChipLogError(Zcl, "env null")); { UtfString jniInputname(env, inputname.data()); diff --git a/examples/tv-app/android/java/MediaPlaybackManager.cpp b/examples/tv-app/android/java/MediaPlaybackManager.cpp index 30931a48709a0f..52666e8da9bfda 100644 --- a/examples/tv-app/android/java/MediaPlaybackManager.cpp +++ b/examples/tv-app/android/java/MediaPlaybackManager.cpp @@ -92,40 +92,162 @@ uint64_t MediaPlaybackManager::HandleGetSeekRangeEnd() CHIP_ERROR MediaPlaybackManager::HandleGetActiveAudioTrack(AttributeValueEncoder & aEncoder) { - TrackType mActiveAudioTrack; - return aEncoder.Encode(mActiveAudioTrack); + return HandleGetActiveTrack(true, aEncoder); +} + +CHIP_ERROR MediaPlaybackManager::HandleGetActiveTrack(bool audio, AttributeValueEncoder & aEncoder) +{ + Structs::TrackStruct::Type response; + Structs::TrackAttributesStruct::Type trackAttributes; + response.trackAttributes = Nullable(trackAttributes); + + jobject trackObj; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NULL_OBJECT, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); + + ChipLogProgress(Zcl, "MediaPlaybackManager::HandleGetActiveAudioTrack"); + VerifyOrExit(mMediaPlaybackManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mGetActiveTrackMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + + env->ExceptionClear(); + trackObj = env->CallObjectMethod(mMediaPlaybackManagerObject, mGetActiveTrackMethod, static_cast(audio)); + if (env->ExceptionCheck()) + { + ChipLogError(AppServer, "Java exception in MediaPlaybackManager::HandleGetActiveAudioTrack"); + env->ExceptionDescribe(); + env->ExceptionClear(); + goto exit; + } + + if (trackObj != nullptr) + { + jclass trackClass = env->GetObjectClass(trackObj); + jfieldID getIdField = env->GetFieldID(trackClass, "id", "Ljava/lang/String;"); + jstring jid = static_cast(env->GetObjectField(trackObj, getIdField)); + JniUtfString id(env, jid); + if (jid != nullptr) + { + response.id = id.charSpan(); + } + + jfieldID getLanguageCodeField = env->GetFieldID(trackClass, "languageCode", "Ljava/lang/String;"); + jstring jlanguagecode = static_cast(env->GetObjectField(trackObj, getLanguageCodeField)); + JniUtfString languageCode(env, jlanguagecode); + if (jlanguagecode != nullptr) + { + trackAttributes.languageCode = languageCode.charSpan(); + } + + jfieldID getDisplayNameField = env->GetFieldID(trackClass, "displayName", "Ljava/lang/String;"); + jstring jdisplayname = static_cast(env->GetObjectField(trackObj, getDisplayNameField)); + JniUtfString displayName(env, jdisplayname); + if (jdisplayname != nullptr) + { + trackAttributes.displayName = Optional>>( + Nullable>(displayName.charSpan())); + } + } + else + { + err = aEncoder.EncodeNull(); + } + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "MediaPlaybackManager::HandleGetActiveAudioTrack status error: %s", err.AsString()); + } + + return aEncoder.Encode(response); } CHIP_ERROR MediaPlaybackManager::HandleGetAvailableAudioTracks(AttributeValueEncoder & aEncoder) { - std::vector mAvailableAudioTracks; - // TODO: Insert code here - return aEncoder.EncodeList([mAvailableAudioTracks](const auto & encoder) -> CHIP_ERROR { - for (auto const & audioTrack : mAvailableAudioTracks) + return HandleGetAvailableTracks(true, aEncoder); +} + +CHIP_ERROR MediaPlaybackManager::HandleGetAvailableTracks(bool audio, AttributeValueEncoder & aEncoder) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NULL_OBJECT, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); + + ChipLogProgress(Zcl, "MediaPlaybackManager::HandleGetAvailableAudioTracks"); + VerifyOrExit(mMediaPlaybackManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mGetAvailableTracksMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + + return aEncoder.EncodeList([this, env, audio](const auto & encoder) -> CHIP_ERROR { + jobjectArray trackList = (jobjectArray) env->CallObjectMethod(mMediaPlaybackManagerObject, mGetAvailableTracksMethod, + static_cast(audio)); + if (env->ExceptionCheck()) { - ReturnErrorOnFailure(encoder.Encode(audioTrack)); + ChipLogError(Zcl, "Java exception in MediaPlaybackManager::HandleGetAvailableAudioTracks"); + env->ExceptionDescribe(); + env->ExceptionClear(); + return CHIP_ERROR_INCORRECT_STATE; + } + + jint length = env->GetArrayLength(trackList); + + for (jint i = 0; i < length; i++) + { + Structs::TrackStruct::Type track; + Structs::TrackAttributesStruct::Type trackAttributes; + track.trackAttributes = Nullable(trackAttributes); + + jobject trackObject = env->GetObjectArrayElement(trackList, i); + jclass trackClass = env->GetObjectClass(trackObject); + + jfieldID getIdField = env->GetFieldID(trackClass, "id", "Ljava/lang/String;"); + jstring jid = static_cast(env->GetObjectField(trackObject, getIdField)); + JniUtfString id(env, jid); + if (jid != nullptr) + { + track.id = id.charSpan(); + } + + jfieldID getLanguageCodeField = env->GetFieldID(trackClass, "languageCode", "Ljava/lang/String;"); + jstring jlanguagecode = static_cast(env->GetObjectField(trackObject, getLanguageCodeField)); + JniUtfString languageCode(env, jlanguagecode); + if (jlanguagecode != nullptr) + { + trackAttributes.languageCode = languageCode.charSpan(); + } + + jfieldID getDisplayNameField = env->GetFieldID(trackClass, "displayName", "Ljava/lang/String;"); + jstring jdisplayname = static_cast(env->GetObjectField(trackObject, getDisplayNameField)); + JniUtfString displayName(env, jdisplayname); + if (jdisplayname != nullptr) + { + trackAttributes.displayName = Optional>>( + Nullable>(displayName.charSpan())); + } + + ReturnErrorOnFailure(encoder.Encode(track)); } return CHIP_NO_ERROR; }); + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "MediaPlaybackManager::HandleGetAvailableAudioTracks status error: %s", err.AsString()); + } + + return err; } CHIP_ERROR MediaPlaybackManager::HandleGetActiveTextTrack(AttributeValueEncoder & aEncoder) { - TrackType mActiveTextTrack; - return aEncoder.Encode(mActiveTextTrack); + return HandleGetActiveTrack(false, aEncoder); } CHIP_ERROR MediaPlaybackManager::HandleGetAvailableTextTracks(AttributeValueEncoder & aEncoder) { - std::vector mAvailableTextTracks; - // TODO: Insert code here - return aEncoder.EncodeList([mAvailableTextTracks](const auto & encoder) -> CHIP_ERROR { - for (auto const & textTrack : mAvailableTextTracks) - { - ReturnErrorOnFailure(encoder.Encode(textTrack)); - } - return CHIP_NO_ERROR; - }); + return HandleGetAvailableTracks(false, aEncoder); } void MediaPlaybackManager::HandlePlay(CommandResponseHelper & helper) @@ -190,23 +312,64 @@ void MediaPlaybackManager::HandleStartOver(CommandResponseHelperExceptionClear(); + ret = env->CallIntMethod(mMediaPlaybackManagerObject, mActivateTrackMethod, static_cast(audio), jniid.jniValue()); + if (env->ExceptionCheck()) + { + ChipLogError(AppServer, "Java exception in MediaPlaybackManager::HandleActivateTrack %s", id.c_str()); + env->ExceptionDescribe(); + env->ExceptionClear(); + } + } +exit: + return static_cast(ret) == 0; } bool MediaPlaybackManager::HandleActivateTextTrack(const chip::CharSpan & trackId) { - // Handle Activate Text Track - HandleMediaRequest(MEDIA_PLAYBACK_REQUEST_ACTIVATE_TEXT_TRACK, 0); - return true; + return HandleActivateTrack(false, trackId); } bool MediaPlaybackManager::HandleDeactivateTextTrack() { - // Handle Deactivate Text Track - HandleMediaRequest(MEDIA_PLAYBACK_REQUEST_DEACTIVATE_TEXT_TRACK, 0); - return true; + jint ret = -1; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); + + ChipLogProgress(Zcl, "MediaPlaybackManager::HandleDeactivateTextTrack"); + VerifyOrExit(mMediaPlaybackManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mDeactivateTextTrackMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + + env->ExceptionClear(); + ret = env->CallIntMethod(mMediaPlaybackManagerObject, mDeactivateTextTrackMethod); + if (env->ExceptionCheck()) + { + ChipLogError(AppServer, "Java exception in MediaPlaybackManager::HandleDeactivateTextTrack"); + env->ExceptionDescribe(); + env->ExceptionClear(); + } +exit: + return static_cast(ret) == 0; } void MediaPlaybackManager::InitializeWithObjects(jobject managerObject) @@ -241,6 +404,36 @@ void MediaPlaybackManager::InitializeWithObjects(jobject managerObject) ChipLogError(Zcl, "Failed to access MediaPlaybackManager 'getPosition' method"); env->ExceptionClear(); } + + mGetAvailableTracksMethod = + env->GetMethodID(mMediaPlaybackManagerClass, "getAvailableTracks", "(Z)[Lcom/matter/tv/server/tvapp/MediaTrack;"); // TODO + if (mGetAvailableTracksMethod == nullptr) + { + ChipLogError(Zcl, "Failed to access MediaPlaybackManager 'getAvailableTracks' method"); + env->ExceptionClear(); + } + + mActivateTrackMethod = env->GetMethodID(mMediaPlaybackManagerClass, "activateTrack", "(ZLjava/lang/String;)I"); + if (mActivateTrackMethod == nullptr) + { + ChipLogError(Zcl, "Failed to access MediaPlaybackManager 'activateTrack' method"); + env->ExceptionClear(); + } + + mDeactivateTextTrackMethod = env->GetMethodID(mMediaPlaybackManagerClass, "deactivateTextTrack", "()I"); + if (mDeactivateTextTrackMethod == nullptr) + { + ChipLogError(Zcl, "Failed to access MediaPlaybackManager 'deactivateTextTrack' method"); + env->ExceptionClear(); + } + + mGetActiveTrackMethod = + env->GetMethodID(mMediaPlaybackManagerClass, "getActiveTrack", "(Z)Lcom/matter/tv/server/tvapp/MediaTrack;"); + if (mGetActiveTrackMethod == nullptr) + { + ChipLogError(Zcl, "Failed to access MediaPlaybackManager 'getActiveTrack' method"); + env->ExceptionClear(); + } } uint64_t MediaPlaybackManager::HandleMediaRequestGetAttribute(MediaPlaybackRequestAttribute attribute) @@ -249,11 +442,12 @@ uint64_t MediaPlaybackManager::HandleMediaRequestGetAttribute(MediaPlaybackReque jlong jAttributeValue = -1; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, ret, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received MediaPlaybackManager::HandleMediaRequestGetAttribute:%d", attribute); VerifyOrExit(mMediaPlaybackManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetAttributeMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); jAttributeValue = env->CallLongMethod(mMediaPlaybackManagerObject, mGetAttributeMethod, static_cast(attribute)); if (env->ExceptionCheck()) @@ -288,11 +482,12 @@ long MediaPlaybackManager::HandleMediaRequestGetLongAttribute(MediaPlaybackReque jlong jAttributeValue = -1; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "Received MediaPlaybackManager::HandleMediaRequestGetLongAttribute:%d", attribute); VerifyOrExit(mMediaPlaybackManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetAttributeMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); jAttributeValue = env->CallLongMethod(mMediaPlaybackManagerObject, mGetAttributeMethod, static_cast(attribute)); if (env->ExceptionCheck()) @@ -323,12 +518,13 @@ Commands::PlaybackResponse::Type MediaPlaybackManager::HandleMediaRequest(MediaP jint ret = -1; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, response, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "MediaPlaybackManager::Request %d-%ld", mediaPlaybackRequest, static_cast(deltaPositionMilliseconds)); VerifyOrExit(mMediaPlaybackManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mRequestMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); env->ExceptionClear(); ret = env->CallIntMethod(mMediaPlaybackManagerObject, mRequestMethod, static_cast(mediaPlaybackRequest), @@ -361,11 +557,12 @@ CHIP_ERROR MediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncoder jobject positionObj; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NULL_OBJECT, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); ChipLogProgress(Zcl, "MediaPlaybackManager::HandleGetSampledPosition"); VerifyOrExit(mMediaPlaybackManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetPositionMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); env->ExceptionClear(); positionObj = env->CallObjectMethod(mMediaPlaybackManagerObject, mGetPositionMethod); @@ -388,7 +585,7 @@ CHIP_ERROR MediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncoder exit: if (err != CHIP_NO_ERROR) { - ChipLogError(Zcl, "MediaPlaybackManager::GetAttribute status error: %s", err.AsString()); + ChipLogError(Zcl, "MediaPlaybackManager::GetAttribute status error: %" CHIP_ERROR_FORMAT, err.Format()); } return aEncoder.Encode(response); diff --git a/examples/tv-app/android/java/MediaPlaybackManager.h b/examples/tv-app/android/java/MediaPlaybackManager.h index 507555f9937ef7..914462fea57fb2 100644 --- a/examples/tv-app/android/java/MediaPlaybackManager.h +++ b/examples/tv-app/android/java/MediaPlaybackManager.h @@ -75,6 +75,8 @@ class MediaPlaybackManager : public MediaPlaybackDelegate float HandleGetPlaybackSpeed() override; uint64_t HandleGetSeekRangeStart() override; uint64_t HandleGetSeekRangeEnd() override; + CHIP_ERROR HandleGetActiveTrack(bool audio, AttributeValueEncoder & aEncoder); + CHIP_ERROR HandleGetAvailableTracks(bool audio, AttributeValueEncoder & aEncoder); CHIP_ERROR HandleGetActiveAudioTrack(AttributeValueEncoder & aEncoder) override; CHIP_ERROR HandleGetAvailableAudioTracks(AttributeValueEncoder & aEncoder) override; CHIP_ERROR HandleGetActiveTextTrack(AttributeValueEncoder & aEncoder) override; @@ -97,15 +99,20 @@ class MediaPlaybackManager : public MediaPlaybackDelegate void HandleStartOver(CommandResponseHelper & helper) override; bool HandleActivateAudioTrack(const chip::CharSpan & trackId, const uint8_t & audioOutputIndex) override; bool HandleActivateTextTrack(const chip::CharSpan & trackId) override; + bool HandleActivateTrack(bool audio, const chip::CharSpan & trackId); bool HandleDeactivateTextTrack() override; uint32_t GetFeatureMap(chip::EndpointId endpoint) override; private: - jobject mMediaPlaybackManagerObject = nullptr; - jmethodID mRequestMethod = nullptr; - jmethodID mGetAttributeMethod = nullptr; - jmethodID mGetPositionMethod = nullptr; + jobject mMediaPlaybackManagerObject = nullptr; + jmethodID mRequestMethod = nullptr; + jmethodID mGetAttributeMethod = nullptr; + jmethodID mGetPositionMethod = nullptr; + jmethodID mGetAvailableTracksMethod = nullptr; + jmethodID mActivateTrackMethod = nullptr; + jmethodID mDeactivateTextTrackMethod = nullptr; + jmethodID mGetActiveTrackMethod = nullptr; uint64_t HandleMediaRequestGetAttribute(MediaPlaybackRequestAttribute attribute); long HandleMediaRequestGetLongAttribute(MediaPlaybackRequestAttribute attribute); diff --git a/examples/tv-app/android/java/OnOffManager.cpp b/examples/tv-app/android/java/OnOffManager.cpp index 64a02a5128add9..bf6796d4cb9542 100644 --- a/examples/tv-app/android/java/OnOffManager.cpp +++ b/examples/tv-app/android/java/OnOffManager.cpp @@ -91,7 +91,8 @@ jboolean OnOffManager::SetOnOff(jint endpoint, bool value) CHIP_ERROR OnOffManager::InitializeWithObjects(jobject managerObject) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - VerifyOrReturnLogError(env != nullptr, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NO_ENV, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); mOnOffManagerObject = env->NewGlobalRef(managerObject); VerifyOrReturnLogError(mOnOffManagerObject != nullptr, CHIP_ERROR_INVALID_ARGUMENT); @@ -115,7 +116,9 @@ void OnOffManager::HandleOnOffChanged(bool value) ChipLogProgress(Zcl, "OnOffManager::HandleOnOffChanged"); JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - VerifyOrReturn(env != NULL, ChipLogProgress(Zcl, "env null")); + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); + VerifyOrReturn(mOnOffManagerObject != nullptr, ChipLogProgress(Zcl, "mOnOffManagerObject null")); VerifyOrReturn(mHandleOnOffChangedMethod != nullptr, ChipLogProgress(Zcl, "mHandleOnOffChangedMethod null")); diff --git a/examples/tv-app/android/java/WakeOnLanManager.cpp b/examples/tv-app/android/java/WakeOnLanManager.cpp index 99b4dc089dc250..7c1a08fd37877a 100644 --- a/examples/tv-app/android/java/WakeOnLanManager.cpp +++ b/examples/tv-app/android/java/WakeOnLanManager.cpp @@ -54,12 +54,13 @@ CHIP_ERROR WakeOnLanManager::HandleGetMacAddress(chip::app::AttributeValueEncode jobject javaMac; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NO_ENV, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); chip::CharSpan macValue; ChipLogProgress(Zcl, "Received WakeOnLanManager::HandleGetMacAddress"); VerifyOrExit(mWakeOnLanManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetMacMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); env->ExceptionClear(); javaMac = env->CallObjectMethod(mWakeOnLanManagerObject, mGetMacMethod); @@ -85,7 +86,8 @@ CHIP_ERROR WakeOnLanManager::HandleGetMacAddress(chip::app::AttributeValueEncode void WakeOnLanManager::InitializeWithObjects(jobject managerObject) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Failed to GetEnvForCurrentThread for WakeOnLanManager")); + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); mWakeOnLanManagerObject = env->NewGlobalRef(managerObject); VerifyOrReturn(mWakeOnLanManagerObject != nullptr, ChipLogError(Zcl, "Failed to NewGlobalRef WakeOnLanManager")); diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelInfo.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelInfo.java index 93ad0afef5539d..6f0421c1c08f34 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelInfo.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelInfo.java @@ -19,6 +19,13 @@ public class ChannelInfo { + public enum ChannelType { + Satellite, + Cable, + Terrestrial, + OTT + } + public static final int kSuccess = 0; public static final int kMultipleMatches = 1; public static final int kNoMatches = 2; @@ -29,15 +36,25 @@ public class ChannelInfo { public String name; public String callSign; public String affiliateCallSign; + public String identifier; + public ChannelType type; public ChannelInfo( - int majorNumber, int minorNumber, String name, String callSign, String affiliateCallSign) { + int majorNumber, + int minorNumber, + String name, + String callSign, + String affiliateCallSign, + String identifier, + ChannelType type) { this.status = kSuccess; this.majorNumber = majorNumber; this.minorNumber = minorNumber; this.name = name; this.callSign = callSign; this.affiliateCallSign = affiliateCallSign; + this.identifier = identifier; + this.type = type; } public ChannelInfo(int status) { diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelManager.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelManager.java index 336bfa5340aff9..646d37ab46670e 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelManager.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelManager.java @@ -17,6 +17,8 @@ */ package com.matter.tv.server.tvapp; +import java.util.Map; + public interface ChannelManager { ChannelInfo[] getChannelList(); @@ -30,4 +32,19 @@ public interface ChannelManager { boolean changeChannelByNumber(int majorNumber, int minorNumber); boolean skipChannel(int count); + + ChannelProgramResponse getProgramGuide( + long startTime, + long endTime, + ChannelInfo[] channels, + String pageToken, + boolean series, + Map.Entry[] externalIDList, + String data); + + boolean recordProgram( + String identifier, boolean series, Map.Entry[] externalIDList, String data); + + boolean cancelRecordProgram( + String identifier, boolean series, Map.Entry[] externalIDList, String data); } diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelManagerStub.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelManagerStub.java index a90e1838778611..1320f8b295e8d9 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelManagerStub.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelManagerStub.java @@ -18,8 +18,10 @@ package com.matter.tv.server.tvapp; import android.util.Log; +import com.matter.tv.server.tvapp.ChannelInfo.ChannelType; import java.util.ArrayList; import java.util.List; +import java.util.Map; public class ChannelManagerStub implements ChannelManager { private static final String TAG = ChannelManagerStub.class.getSimpleName(); @@ -27,11 +29,31 @@ public class ChannelManagerStub implements ChannelManager { private int endpoint; private int currentChannelIndex = 0; private ChannelInfo currentChannel; + + ChannelInfo chanAbc = new ChannelInfo(6, 0, "ABC", "KAAL-TV", "KAAL", "id-1", ChannelType.Cable); + ChannelInfo chanPbs = + new ChannelInfo(9, 1, "PBS", "KCTS-TV", "KCTS", "id-2", ChannelType.Satellite); + ChannelInfo chanWor = + new ChannelInfo(9, 3, "World Channel", "KCTS-TV", "KCTS", "id-4", ChannelType.Terrestrial); + private ChannelInfo[] channelList = { - new ChannelInfo(6, 0, "ABC", "KAAL-TV", "KAAL"), - new ChannelInfo(9, 1, "PBS", "KCTS-TV", "KCTS"), - new ChannelInfo(9, 2, "PBS Kids", "KCTS-TV", "KCTS"), - new ChannelInfo(9, 3, "World Channel", "KCTS-TV", "KCTS") + chanAbc, + chanPbs, + chanWor, + new ChannelInfo(9, 2, "PBS Kids", "KCTS-TV", "KCTS", "id-3", ChannelType.OTT) + }; + + private ChannelProgramInfo[] programList = { + new ChannelProgramInfo( + "progid-abc1", chanAbc, 0, 30 * 60, "First Show", "First subtitle", "First Description"), + new ChannelProgramInfo( + "progid-pbs1", chanPbs, 0, 30 * 60, "Show 2", "subtitle 2", "Description 2"), + new ChannelProgramInfo( + "progid-abc2", chanAbc, 30 * 60, 60 * 60, "Show 3", "subtitle 3", "Description 3"), + new ChannelProgramInfo( + "progid-abc3", chanAbc, 30 * 60, 60 * 60, "Show 4", "subtitle 4", "Description 4"), + new ChannelProgramInfo( + "id-5", chanWor, 60 * 60, 90 * 60, "Show 5", "subtitle 5", "Description 5"), }; public ChannelManagerStub(int endpoint) { @@ -142,4 +164,46 @@ public boolean skipChannel(int count) { currentChannel = channelList[newChannelIndex]; return true; } + + @Override + public ChannelProgramResponse getProgramGuide( + long startTime, + long endTime, + ChannelInfo[] channels, + String pageToken, + boolean series, + Map.Entry[] externalIDList, + String data) { + ChannelProgramResponse resp = new ChannelProgramResponse(); + resp.programs = programList; + return resp; + } + + @Override + public boolean recordProgram( + String identifier, boolean series, Map.Entry[] externalIDList, String data) { + for (ChannelProgramInfo program : programList) { + if (program.identifier.equals(identifier)) { + program.recordFlagSeries = series; + program.recordFlagScheduled = true; + return true; + } + } + return false; + } + + @Override + public boolean cancelRecordProgram( + String identifier, boolean series, Map.Entry[] externalIDList, String data) { + for (ChannelProgramInfo program : programList) { + if (program.identifier.equals(identifier)) { + if (series) { + program.recordFlagSeries = false; + } + program.recordFlagScheduled = false; + return true; + } + } + return false; + } } diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelProgramInfo.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelProgramInfo.java new file mode 100644 index 00000000000000..31c9535249afc0 --- /dev/null +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelProgramInfo.java @@ -0,0 +1,52 @@ +/* + * 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. + * + */ +package com.matter.tv.server.tvapp; + +import java.util.Map; + +public class ChannelProgramInfo { + + public String identifier; + public ChannelInfo channel; + public long startTime; + public long endTime; + public String title; + public String subTitle; + public String description; + public boolean recordFlagScheduled = false; + public boolean recordFlagSeries = false; + public boolean recordFlagRecorded = false; + public Map.Entry[] externalIDList; + + public ChannelProgramInfo( + String identifier, + ChannelInfo channel, + long startTime, + long endTime, + String title, + String subTitle, + String description) { + this.identifier = identifier; + this.channel = channel; + this.startTime = startTime; + this.endTime = endTime; + this.title = title; + this.subTitle = subTitle; + this.description = description; + } +} diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelProgramResponse.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelProgramResponse.java new file mode 100644 index 00000000000000..d89b1a146a733c --- /dev/null +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/ChannelProgramResponse.java @@ -0,0 +1,28 @@ +/* + * 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. + * + */ +package com.matter.tv.server.tvapp; + +public class ChannelProgramResponse { + ChannelProgramInfo[] programs; + int previousLimit = -1; + String previousAfter; + String previousBefore; + int nextLimit = -1; + String nextAfter; + String nextBefore; +} diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaPlaybackManager.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaPlaybackManager.java index 9047e54c0d596a..6c0b04a374b442 100755 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaPlaybackManager.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaPlaybackManager.java @@ -119,4 +119,36 @@ public interface MediaPlaybackManager { /** Get the position of playback (Position field) at the time (UpdateAt field) specified */ MediaPlaybackPosition getPosition(); + + /** + * Get the available tracks + * + * @param audio true=audio, false=text + * @return list of available tracks + */ + MediaTrack[] getAvailableTracks(boolean audio); + + /** + * activate the given track + * + * @param audio true=audio, false=text + * @param id track id + * @return the response status defined in RESPONSE_STATUS_XXX + */ + int activateTrack(boolean audio, String id); + + /** + * Deactivate the current test track + * + * @return the response status defined in RESPONSE_STATUS_XXX + */ + int deactivateTextTrack(); + + /** + * Get the active track + * + * @param audio true=audio, false=text + * @return active track or null + */ + MediaTrack getActiveTrack(boolean audio); } diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaPlaybackManagerStub.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaPlaybackManagerStub.java index 062e83008677e0..a6b9afcc603338 100755 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaPlaybackManagerStub.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaPlaybackManagerStub.java @@ -35,6 +35,18 @@ public class MediaPlaybackManagerStub implements MediaPlaybackManager { private static int playbackMaxForwardSpeed = 10; private static int playbackMaxRewindSpeed = -10; + private static MediaTrack activeAudioTrack = null; + private static MediaTrack[] audioTracks = { + new MediaTrack("activeAudioTrackId_0", "languageCode1", "displayName1"), + new MediaTrack("activeAudioTrackId_1", "languageCode2", "displayName2") + }; + + private static MediaTrack activeTextTrack = null; + private static MediaTrack[] textTracks = { + new MediaTrack("activeTextTrackId_0", "languageCode1", "displayName1"), + new MediaTrack("activeTextTrackId_1", "languageCode2", "displayName2") + }; + public MediaPlaybackManagerStub(int endpoint) { this.endpoint = endpoint; } @@ -69,6 +81,8 @@ public long getAttributes(int attributesId) { case ATTRIBUTE_PLAYBACK_SEEK_RANGE_START: Log.d(TAG, "getAttributes SampledPosition SeekRangeStart " + startTime + " at " + endpoint); return startTime; + + // TODO: add audio/text track available/active attributes } return -1; @@ -183,4 +197,41 @@ public MediaPlaybackPosition getPosition() { Log.d(TAG, "getPosition " + playbackPosition); return new MediaPlaybackPosition(playbackPosition); } + + @Override + public MediaTrack[] getAvailableTracks(boolean audio) { + return (audio ? audioTracks : textTracks); + } + + @Override + public int activateTrack(boolean audio, String id) { + if (audio) { + for (MediaTrack track : audioTracks) { + if (track.id.equalsIgnoreCase(id)) { + activeAudioTrack = track; + return RESPONSE_STATUS_SUCCESS; + } + } + return RESPONSE_STATUS_NOT_ALLOWED; // TODO + } else { + for (MediaTrack track : textTracks) { + if (track.id.equalsIgnoreCase(id)) { + activeTextTrack = track; + return RESPONSE_STATUS_SUCCESS; + } + } + return RESPONSE_STATUS_NOT_ALLOWED; // TODO + } + } + + @Override + public int deactivateTextTrack() { + activeTextTrack = null; + return RESPONSE_STATUS_SUCCESS; + } + + @Override + public MediaTrack getActiveTrack(boolean audio) { + return (audio ? activeAudioTrack : activeTextTrack); + } } diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaTrack.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaTrack.java new file mode 100644 index 00000000000000..f19492e188b72b --- /dev/null +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MediaTrack.java @@ -0,0 +1,30 @@ +/* + * 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. + * + */ +package com.matter.tv.server.tvapp; + +public class MediaTrack { + public String id; + public String languageCode; + public String displayName; + + public MediaTrack(String id, String languageCode, String displayName) { + this.id = id; + this.languageCode = languageCode; + this.displayName = displayName; + } +} diff --git a/examples/tv-app/tv-common/BUILD.gn b/examples/tv-app/tv-common/BUILD.gn index b24fd24839bdb3..c522709c0a8e85 100644 --- a/examples/tv-app/tv-common/BUILD.gn +++ b/examples/tv-app/tv-common/BUILD.gn @@ -52,8 +52,6 @@ source_set("tv-common-sources") { "clusters/audio-output/AudioOutputManager.h", "clusters/channel/ChannelManager.cpp", "clusters/channel/ChannelManager.h", - "clusters/content-app-observer/ContentAppObserver.cpp", - "clusters/content-app-observer/ContentAppObserver.h", "clusters/content-control/ContentController.cpp", "clusters/content-control/ContentController.h", "clusters/content-launcher/ContentLauncherManager.cpp", diff --git a/examples/tv-app/tv-common/include/AppTv.h b/examples/tv-app/tv-common/include/AppTv.h index 0a56ebe1da8624..bd056ae6813a5f 100644 --- a/examples/tv-app/tv-common/include/AppTv.h +++ b/examples/tv-app/tv-common/include/AppTv.h @@ -33,7 +33,6 @@ #include "application-basic/ApplicationBasicManager.h" #include "application-launcher/ApplicationLauncherManager.h" #include "channel/ChannelManager.h" -#include "content-app-observer/ContentAppObserver.h" #include "content-control/ContentController.h" #include "content-launcher/ContentLauncherManager.h" #include "keypad-input/KeypadInputManager.h" @@ -60,7 +59,6 @@ using ApplicationLauncherDelegate = app::Clusters::ApplicationLauncher::Delegate using ChannelDelegate = app::Clusters::Channel::Delegate; using ContentLauncherDelegate = app::Clusters::ContentLauncher::Delegate; using ContentControllerDelegate = app::Clusters::ContentControl::Delegate; -using ContentAppObserverDelegate = app::Clusters::ContentAppObserver::Delegate; using KeypadInputDelegate = app::Clusters::KeypadInput::Delegate; using MediaPlaybackDelegate = app::Clusters::MediaPlayback::Delegate; using TargetNavigatorDelegate = app::Clusters::TargetNavigator::Delegate; @@ -90,7 +88,6 @@ class DLL_EXPORT ContentAppImpl : public ContentApp ChannelDelegate * GetChannelDelegate() override { return &mChannelDelegate; }; ContentLauncherDelegate * GetContentLauncherDelegate() override { return &mContentLauncherDelegate; }; ContentControllerDelegate * GetContentControlDelegate() override { return &mContentControlDelegate; }; - ContentAppObserverDelegate * GetContentAppObserverDelegate() override { return &mContentAppObserverDelegate; }; KeypadInputDelegate * GetKeypadInputDelegate() override { return &mKeypadInputDelegate; }; MediaPlaybackDelegate * GetMediaPlaybackDelegate() override { return &mMediaPlaybackDelegate; }; TargetNavigatorDelegate * GetTargetNavigatorDelegate() override { return &mTargetNavigatorDelegate; }; @@ -101,7 +98,6 @@ class DLL_EXPORT ContentAppImpl : public ContentApp ApplicationLauncherManager mApplicationLauncherDelegate; ChannelManager mChannelDelegate; ContentLauncherManager mContentLauncherDelegate; - ContentAppObserverManager mContentAppObserverDelegate; ContentControlManager mContentControlDelegate; KeypadInputManager mKeypadInputDelegate; MediaPlaybackManager mMediaPlaybackDelegate; diff --git a/examples/tv-app/tv-common/src/ZCLCallbacks.cpp b/examples/tv-app/tv-common/src/ZCLCallbacks.cpp index 1358ab0bba9bb1..c56a3f73e76afc 100644 --- a/examples/tv-app/tv-common/src/ZCLCallbacks.cpp +++ b/examples/tv-app/tv-common/src/ZCLCallbacks.cpp @@ -31,7 +31,6 @@ #include "application-launcher/ApplicationLauncherManager.h" #include "audio-output/AudioOutputManager.h" #include "channel/ChannelManager.h" -#include "content-app-observer/ContentAppObserver.h" #include "content-control/ContentController.h" #include "content-launcher/ContentLauncherManager.h" #include "keypad-input/KeypadInputManager.h" @@ -51,7 +50,6 @@ static ApplicationLauncherManager applicationLauncherManager(false); #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED static AudioOutputManager audioOutputManager; static ChannelManager channelManager; -static ContentAppObserverManager contentAppObserverManager; static ContentControlManager contentControlManager; static ContentLauncherManager contentLauncherManager; static KeypadInputManager keypadInputManager; @@ -130,12 +128,6 @@ void emberAfAudioOutputClusterInitCallback(EndpointId endpoint) AudioOutput::SetDefaultDelegate(endpoint, &audioOutputManager); } -void emberAfContentAppObserverClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: ContentAppObserverManager::SetDefaultDelegate"); - ContentAppObserver::SetDefaultDelegate(endpoint, &contentAppObserverManager); -} - void emberAfContentControlClusterInitCallback(EndpointId endpoint) { ChipLogProgress(Zcl, "TV Linux App: ContentControlManager::SetDefaultDelegate"); diff --git a/examples/tv-casting-app/APIs.md b/examples/tv-casting-app/APIs.md index f0fdb32484a72e..f254df1d7e2d14 100644 --- a/examples/tv-casting-app/APIs.md +++ b/examples/tv-casting-app/APIs.md @@ -67,6 +67,9 @@ Next, you're ready to: 1. [Read](#read-operations) endpoint attributes like playback state. 1. [Subscribe](#subscriptions) to playback events. +In order to illustrate these steps, refer to the figure below +![workflow of casting video player](./diagram/workflow_of_casting_video_player.png) + ## Build and Setup The Casting Client is expected to consume the Matter TV Casting library built diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp index dfcb2d8f44f69f..2c3001cf5cabea 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp @@ -32,7 +32,7 @@ CHIP_ERROR convertJAppParametersToCppAppParams(jobject appParameters, AppParams jclass jAppParametersClass; ReturnErrorOnFailure( - chip::JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/AppParameters", jAppParametersClass)); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/AppParameters", jAppParametersClass)); jmethodID getRotatingDeviceIdUniqueIdMethod = env->GetMethodID(jAppParametersClass, "getRotatingDeviceIdUniqueId", "()[B"); if (getRotatingDeviceIdUniqueIdMethod == nullptr) @@ -67,7 +67,7 @@ CHIP_ERROR convertJContentAppToTargetEndpointInfo(jobject contentApp, TargetEndp JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); jclass jContentAppClass; - ReturnErrorOnFailure(chip::JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/ContentApp", jContentAppClass)); + ReturnErrorOnFailure(chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/ContentApp", jContentAppClass)); jfieldID jEndpointIdField = env->GetFieldID(jContentAppClass, "endpointId", "S"); jshort jEndpointId = env->GetShortField(contentApp, jEndpointIdField); @@ -104,7 +104,8 @@ CHIP_ERROR convertTargetEndpointInfoToJContentApp(TargetEndpointInfo * targetEnd JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); jclass jContentAppClass; - ReturnErrorOnFailure(chip::JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/ContentApp", jContentAppClass)); + ReturnErrorOnFailure( + chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/ContentApp", jContentAppClass)); jmethodID jContentAppConstructor = env->GetMethodID(jContentAppClass, "", "(SLjava/util/List;)V"); chip::ClusterId * clusters = targetEndpointInfo->GetClusters(); jobject jClustersArrayList = nullptr; @@ -132,7 +133,8 @@ CHIP_ERROR convertJVideoPlayerToTargetVideoPlayerInfo(jobject videoPlayer, Targe JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); jclass jVideoPlayerClass; - ReturnErrorOnFailure(chip::JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/VideoPlayer", jVideoPlayerClass)); + ReturnErrorOnFailure( + chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/VideoPlayer", jVideoPlayerClass)); jfieldID jNodeIdField = env->GetFieldID(jVideoPlayerClass, "nodeId", "J"); chip::NodeId nodeId = static_cast(env->GetLongField(videoPlayer, jNodeIdField)); @@ -206,7 +208,8 @@ CHIP_ERROR convertJVideoPlayerToTargetVideoPlayerInfo(jobject videoPlayer, Targe jobject jContentApp = env->CallObjectMethod(jIterator, jNextMid); jclass jContentAppClass; - ReturnErrorOnFailure(chip::JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/ContentApp", jContentAppClass)); + ReturnErrorOnFailure( + chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/ContentApp", jContentAppClass)); jfieldID jEndpointIdField = env->GetFieldID(jContentAppClass, "endpointId", "S"); chip::EndpointId endpointId = static_cast(env->GetShortField(jContentApp, jEndpointIdField)); TargetEndpointInfo * endpoint = outTargetVideoPlayerInfo.GetOrAddEndpoint(endpointId); @@ -226,7 +229,7 @@ CHIP_ERROR convertTargetVideoPlayerInfoToJVideoPlayer(TargetVideoPlayerInfo * ta jclass jVideoPlayerClass; ReturnErrorOnFailure( - chip::JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/VideoPlayer", jVideoPlayerClass)); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/VideoPlayer", jVideoPlayerClass)); jmethodID jVideoPlayerConstructor = env->GetMethodID(jVideoPlayerClass, "", "(JBLjava/lang/String;IIILjava/util/List;ILjava/util/List;Ljava/lang/" "String;Ljava/lang/String;IJLjava/lang/String;ZZ)V"); @@ -277,7 +280,8 @@ CHIP_ERROR convertTargetVideoPlayerInfoToJVideoPlayer(TargetVideoPlayerInfo * ta jstring jIPAddressStr = env->NewStringUTF(addrCString); jclass jIPAddressClass; - ReturnErrorOnFailure(chip::JniReferences::GetInstance().GetClassRef(env, "java/net/InetAddress", jIPAddressClass)); + ReturnErrorOnFailure( + chip::JniReferences::GetInstance().GetLocalClassRef(env, "java/net/InetAddress", jIPAddressClass)); jmethodID jGetByNameMid = env->GetStaticMethodID(jIPAddressClass, "getByName", "(Ljava/lang/String;)Ljava/net/InetAddress;"); jobject jIPAddress = env->CallStaticObjectMethod(jIPAddressClass, jGetByNameMid, jIPAddressStr); @@ -306,7 +310,7 @@ CHIP_ERROR convertJDiscoveredNodeDataToCppDiscoveredNodeData(jobject jDiscovered jclass jDiscoveredNodeDataClass; ReturnErrorOnFailure( - chip::JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/DiscoveredNodeData", jDiscoveredNodeDataClass)); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/DiscoveredNodeData", jDiscoveredNodeDataClass)); jfieldID getHostNameField = env->GetFieldID(jDiscoveredNodeDataClass, "hostName", "Ljava/lang/String;"); jstring jHostName = static_cast(env->GetObjectField(jDiscoveredNodeData, getHostNameField)); @@ -392,7 +396,7 @@ CHIP_ERROR convertJDiscoveredNodeDataToCppDiscoveredNodeData(jobject jDiscovered { jobject jIPAddress = env->CallObjectMethod(jIterator, jNextMid); jclass jIPAddressClass; - ReturnErrorOnFailure(chip::JniReferences::GetInstance().GetClassRef(env, "java/net/InetAddress", jIPAddressClass)); + ReturnErrorOnFailure(chip::JniReferences::GetInstance().GetLocalClassRef(env, "java/net/InetAddress", jIPAddressClass)); jmethodID jGetHostAddressMid = env->GetMethodID(jIPAddressClass, "getHostAddress", "()Ljava/lang/String;"); jstring jIPAddressStr = static_cast(env->CallObjectMethod(jIPAddress, jGetHostAddressMid)); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp index fd99ae61a5763f..30c1e1d233c2cb 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp @@ -202,10 +202,12 @@ jobject CurrentStateSuccessHandlerJNI::ConvertToJObject( { ChipLogProgress(AppServer, "CurrentStateSuccessHandlerJNI::ConvertToJObject called"); JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, nullptr); + JniLocalReferenceScope scope(env); jclass enumClass = nullptr; CHIP_ERROR err = - JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/MediaPlaybackTypes$PlaybackStateEnum", enumClass); + JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/MediaPlaybackTypes$PlaybackStateEnum", enumClass); if (err != CHIP_NO_ERROR) { ChipLogError(AppServer, "ConvertToJObject: Class for Response Type not found!"); @@ -251,6 +253,8 @@ jobject SampledPositionSuccessHandlerJNI::ConvertToJObject( { ChipLogProgress(AppServer, "SampledPositionSuccessHandlerJNI::ConvertToJObject called"); JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, nullptr); + JniLocalReferenceScope scope(env); jobject jSampledPosition = nullptr; if (!responseData.IsNull()) @@ -259,8 +263,8 @@ jobject SampledPositionSuccessHandlerJNI::ConvertToJObject( responseData.Value(); jclass responseTypeClass = nullptr; - CHIP_ERROR err = JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/MediaPlaybackTypes$PlaybackPositionStruct", - responseTypeClass); + CHIP_ERROR err = JniReferences::GetInstance().GetLocalClassRef( + env, "com/chip/casting/MediaPlaybackTypes$PlaybackPositionStruct", responseTypeClass); if (err != CHIP_NO_ERROR) { ChipLogError(AppServer, "ConvertToJObject: Class for Response Type not found!"); @@ -318,6 +322,8 @@ jobject TargetListSuccessHandlerJNI::ConvertToJObject( ChipLogProgress(AppServer, "TargetListSuccessHandlerJNI::ConvertToJObject called"); JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnValue(env != nullptr, nullptr); + JniLocalReferenceScope scope(env); jobject jArrayList; chip::JniReferences::GetInstance().CreateArrayList(jArrayList); @@ -327,8 +333,8 @@ jobject TargetListSuccessHandlerJNI::ConvertToJObject( const chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::DecodableType & targetInfo = iter.GetValue(); jclass responseTypeClass = nullptr; - CHIP_ERROR err = - JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/TargetNavigatorTypes$TargetInfo", responseTypeClass); + CHIP_ERROR err = JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/TargetNavigatorTypes$TargetInfo", + responseTypeClass); if (err != CHIP_NO_ERROR) { ChipLogError(AppServer, "ConvertToJObject: Class for Response Type not found!"); 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 b4d9b37a422028..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 @@ -124,7 +124,8 @@ JNI_METHOD(jboolean, openBasicCommissioningWindow) CommissioningCallbacks commissioningCallbacks; jclass jCommissioningCallbacksClass; - chip::JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/CommissioningCallbacks", jCommissioningCallbacksClass); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/CommissioningCallbacks", + jCommissioningCallbacksClass); jfieldID jCommissioningCompleteField = env->GetFieldID(jCommissioningCallbacksClass, "commissioningComplete", "Ljava/lang/Object;"); @@ -458,8 +459,8 @@ CHIP_ERROR CreateContentSearch(JNIEnv * env, jobject jSearch, ListFreer & listFreer) { jclass jContentSearchClass; - ReturnErrorOnFailure( - JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/ContentLauncherTypes$ContentSearch", jContentSearchClass)); + ReturnErrorOnFailure(JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/ContentLauncherTypes$ContentSearch", + jContentSearchClass)); jfieldID jParameterListField = env->GetFieldID(jContentSearchClass, "parameterList", "Ljava/util/ArrayList;"); jobject jParameterList = env->GetObjectField(jSearch, jParameterListField); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingApp-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingApp-JNI.cpp index be8a35a195403a..e3a4c79b956822 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingApp-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingApp-JNI.cpp @@ -112,7 +112,7 @@ jobject extractJAppParameter(jobject jAppParameters, const char * methodName, co jclass jAppParametersClass; CHIP_ERROR err = - chip::JniReferences::GetInstance().GetClassRef(env, "com/matter/casting/support/AppParameters", jAppParametersClass); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/matter/casting/support/AppParameters", jAppParametersClass); VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr); // get the RotatingDeviceIdUniqueIdProvider diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingPlayer-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingPlayer-JNI.cpp index 2c0fe914232778..ba5a8e765908f1 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingPlayer-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingPlayer-JNI.cpp @@ -77,7 +77,7 @@ JNI_METHOD(jobject, VerifyOrEstablishConnection) JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(AppServer, "ConnectCallback, env == nullptr")); // Ensures proper cleanup of local references to Java objects. - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); // Ensures proper cleanup of global references to Java objects. JniGlobalRefWrapper globalRefWrapper(completableFutureObjGlobalRef); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/ErrorConverter-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/ErrorConverter-JNI.cpp index 9cec7897488103..1dce6f19d74776 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/ErrorConverter-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/ErrorConverter-JNI.cpp @@ -30,7 +30,7 @@ jobject createJMatterError(CHIP_ERROR inErr) JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); jclass jMatterErrorClass; CHIP_ERROR err = - chip::JniReferences::GetInstance().GetClassRef(env, "com/matter/casting/support/MatterError", jMatterErrorClass); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/matter/casting/support/MatterError", jMatterErrorClass); VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr); jmethodID jMatterErrorConstructor = env->GetMethodID(jMatterErrorClass, "", "(JLjava/lang/String;)V"); 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/diagram/workflow_of_casting_video_player.png b/examples/tv-casting-app/diagram/workflow_of_casting_video_player.png new file mode 100644 index 00000000000000..7b8abeb30e4068 Binary files /dev/null and b/examples/tv-casting-app/diagram/workflow_of_casting_video_player.png differ diff --git a/examples/window-app/nrfconnect/main/AppTask.cpp b/examples/window-app/nrfconnect/main/AppTask.cpp index f607114da6d031..7c50aedc97e2bb 100644 --- a/examples/window-app/nrfconnect/main/AppTask.cpp +++ b/examples/window-app/nrfconnect/main/AppTask.cpp @@ -24,8 +24,9 @@ #include +#include #include -#include +#include #include #include #include @@ -188,9 +189,12 @@ CHIP_ERROR AppTask::Init() #endif static CommonCaseDeviceServerInitParams initParams; - static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{}; + static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{}; + VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR); + VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR); (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams)); AppFabricTableDelegate::Init(); diff --git a/examples/window-app/silabs/README.md b/examples/window-app/silabs/README.md index ca63cae6760036..1464e7d4cc0ad8 100644 --- a/examples/window-app/silabs/README.md +++ b/examples/window-app/silabs/README.md @@ -54,8 +54,9 @@ Silicon Labs platform. (For Mac OS X, `commander` is located inside `Commander.app/Contents/MacOS/`.) -- Download and install a suitable ARM gcc tool chain: - [GNU Arm Embedded Toolchain 9-2019-q4-major](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) +- Download and install a suitable ARM gcc tool chain (For most Host, the + bootstrap already installs the toolchain): + [GNU Arm Embedded Toolchain 12.2 Rel1](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) - Install some additional tools(likely already present for CHIP developers): diff --git a/integrations/docker/images/base/chip-build/version b/integrations/docker/images/base/chip-build/version index 8b85550a4399e5..7c51e45e89e229 100644 --- a/integrations/docker/images/base/chip-build/version +++ b/integrations/docker/images/base/chip-build/version @@ -1 +1 @@ -32 : [Telink] Update Docker image (Zephyr update) +34 : [Telink] Update Docker image (Zephyr update) diff --git a/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile b/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile index f675ac00564999..309bc061d5fc20 100644 --- a/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile +++ b/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile @@ -24,9 +24,9 @@ RUN set -x \ RUN set -x \ && mkdir -p k32w1 \ - && wget https://cache.nxp.com/lgfiles/bsps/SDK_2_12_5_K32W148-EVK.zip \ - && unzip SDK_2_12_5_K32W148-EVK.zip -d k32w1 \ - && rm -rf SDK_2_12_5_K32W148-EVK.zip + && wget https://cache.nxp.com/lgfiles/bsps/SDK_2_12_6_K32W148-EVK.zip \ + && unzip SDK_2_12_6_K32W148-EVK.zip -d k32w1 \ + && rm -rf SDK_2_12_6_K32W148-EVK.zip FROM ghcr.io/project-chip/chip-build:${VERSION} diff --git a/integrations/docker/images/stage-2/chip-build-telink/Dockerfile b/integrations/docker/images/stage-2/chip-build-telink/Dockerfile index e67b4ef3977bea..a057044c5a1fae 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=d074f4f945919a37214a5f8ee608f4107c108c20 +ARG ZEPHYR_REVISION=5bcb564c5bec3f3ebcaf7ae9949e053ef414df1f WORKDIR /opt/telink/zephyrproject RUN set -x \ && python3 -m pip install -U --no-cache-dir west \ diff --git a/scripts/build/build_darwin_framework.py b/scripts/build/build_darwin_framework.py index 95f666a39fff29..d2d3665a1bcfd0 100644 --- a/scripts/build/build_darwin_framework.py +++ b/scripts/build/build_darwin_framework.py @@ -129,6 +129,9 @@ def build_darwin_framework(args): if args.enable_encoding_sentinel_enum_values: cflags += ["-DCHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES=1"] + if args.compdb: + cflags += ["-gen-cdb-fragment-path ", abs_path + '/compdb'] + command += ["OTHER_CFLAGS=" + ' '.join(cflags), "OTHER_LDFLAGS=" + ' '.join(ldflags)] command_result = run_command(command) print("Build Framework Result: {}".format(command_result)) @@ -172,6 +175,7 @@ def build_darwin_framework(args): parser.add_argument('--ble', action=argparse.BooleanOptionalAction) parser.add_argument('--clang', action=argparse.BooleanOptionalAction) parser.add_argument('--enable-encoding-sentinel-enum-values', action=argparse.BooleanOptionalAction) + parser.add_argument('--compdb', action=argparse.BooleanOptionalAction) args = parser.parse_args() build_darwin_framework(args) diff --git a/scripts/helpers/generate_darwin_compdb.sh b/scripts/helpers/generate_darwin_compdb.sh new file mode 100755 index 00000000000000..cc11a31569923b --- /dev/null +++ b/scripts/helpers/generate_darwin_compdb.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2020-2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +JQ=$(which jq) +if [ $? -ne 0 ]; then + echo "'jq' not detected in PATH. Install using: brew install jq" + exit 1 +fi + +set -e +set -x + +source "$(dirname "$0")/../../scripts/activate.sh" +CHIP_ROOT="$(dirname "$0")/../.." +OUTPUT_DIR=$2 + +# Build the framework +scripts/examples/gn_build_example.sh "$@" generate_compilation_database=true + +# Clean up any stale DB files +find "$OUTPUT_DIR" -iname compile_commands\*.json | xargs rm + +# Construct json from fragments generated by xcodebuild +COMPDB_FRAGMENTS_DIR=$(find "$OUTPUT_DIR" -type d -name compdb) +sed -e '1s/^/[\'$'\n''/' -e '$s/,$/\'$'\n'']/' "$COMPDB_FRAGMENTS_DIR"/*.json >"$OUTPUT_DIR"/compile_commands_darwin_framework.json + +# Get ninja to build comdb for the rest +ninja -C "$OUTPUT_DIR" -t compdb >"$OUTPUT_DIR"/compile_commands_rest.json + +# Combine the generated compdb into one +find "$OUTPUT_DIR" -iname compile_commands\*.json | xargs jq -s 'map(.[])' >"$OUTPUT_DIR"/compile_commands.json diff --git a/scripts/rules.matterlint b/scripts/rules.matterlint index d2fff0f9a53750..6e95447e1a2cda 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"; @@ -98,13 +99,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/tools/check_includes_config.py b/scripts/tools/check_includes_config.py index abe2c0ed42f5af..b4e933f193583c 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. 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/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/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/access/BUILD.gn b/src/access/BUILD.gn index 476c261bfde5e0..f1cc73c8f7262c 100644 --- a/src/access/BUILD.gn +++ b/src/access/BUILD.gn @@ -34,6 +34,7 @@ static_library("access") { public_deps = [ "${chip_root}/src/lib/core", + "${chip_root}/src/lib/core:types", "${chip_root}/src/lib/support", "${chip_root}/src/platform", ] diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index d2c97e188192ed..52f14d9f308f7f 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -13,7 +13,6 @@ # limitations under the License. import("//build_overrides/chip.gni") -import("//build_overrides/nlio.gni") import("${chip_root}/build/chip/buildconfig_header.gni") import("${chip_root}/src/lib/core/core.gni") import("${chip_root}/src/platform/device.gni") @@ -90,28 +89,25 @@ source_set("paths") { public_deps = [ ":app_config", "${chip_root}/src/lib/core", + "${chip_root}/src/lib/core:types", ] } source_set("global-attributes") { sources = [ "GlobalAttributes.h" ] - # This also depends on zap-generated code which is currently impossible to split outs - public_deps = [ "${chip_root}/src/lib/support" ] + # This also depends on zap-generated code which is currently impossible to split out + # as a dependency + public_deps = [ + ":app_config", + "${chip_root}/src/lib/support", + ] } -source_set("pre-encoded-value") { - sources = [ - "data-model/FabricScopedPreEncodedValue.cpp", - "data-model/FabricScopedPreEncodedValue.h", - "data-model/PreEncodedValue.cpp", - "data-model/PreEncodedValue.h", - ] +source_set("subscription-manager") { + sources = [ "SubscriptionsInfoProvider.h" ] - deps = [ - "${chip_root}/src/lib/core", - "${chip_root}/src/lib/support", - ] + public_deps = [ "${chip_root}/src/lib/core" ] } source_set("message-def") { @@ -247,8 +243,9 @@ static_library("interaction-model") { ":app_config", ":message-def", ":paths", - "${chip_root}/src/app/icd:icd_config", - "${chip_root}/src/app/icd:observer", + ":subscription-manager", + "${chip_root}/src/app/icd/server:icd-server-config", + "${chip_root}/src/app/icd/server:observer", "${chip_root}/src/lib/address_resolve", "${chip_root}/src/lib/support", "${chip_root}/src/protocols/interaction_model", @@ -324,15 +321,14 @@ static_library("app") { ":app_config", ":global-attributes", ":interaction-model", - ":pre-encoded-value", ":revision_info", - "${chip_root}/src/app/icd:icd_config", + "${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", "${chip_root}/src/messaging", "${chip_root}/src/protocols/interaction_model", "${chip_root}/src/system", - "${nlio_root}:nlio", ] if (chip_enable_read_client) { @@ -346,8 +342,8 @@ static_library("app") { if (chip_enable_icd_server) { public_deps += [ - "${chip_root}/src/app/icd:manager", - "${chip_root}/src/app/icd:notifier", + "${chip_root}/src/app/icd/server:manager", + "${chip_root}/src/app/icd/server:notifier", ] } diff --git a/src/app/CommandHandler.h b/src/app/CommandHandler.h index 659828cc7d9eb8..b90cb821244336 100644 --- a/src/app/CommandHandler.h +++ b/src/app/CommandHandler.h @@ -360,24 +360,7 @@ class CommandHandler template CHIP_ERROR AddResponseData(const ConcreteCommandPath & aRequestCommandPath, const CommandData & aData) { - // This method, templated with CommandData, captures all the components needs - // from CommandData with as little code as possible. This in theory should - // reduce compiled code size. - // - // TODO(#30453): Verify the accuracy of the theory outlined below. - // - // Theory on code reduction: Previously, non-essential code was unnecessarily - // templated, leading to compilation and duplication N times. The lambda - // function below mitigates this issue by isolating only the code segments - // that genuinely require templating, thereby minimizing duplicate compiled - // code. - ConcreteCommandPath responsePath = { aRequestCommandPath.mEndpointId, aRequestCommandPath.mClusterId, - CommandData::GetCommandId() }; - auto encodeCommandDataClosure = [&](TLV::TLVWriter & writer) -> CHIP_ERROR { - return DataModel::Encode(writer, TLV::ContextTag(CommandDataIB::Tag::kFields), aData); - }; - return TryAddingResponse( - [&]() -> CHIP_ERROR { return TryAddResponseData(aRequestCommandPath, responsePath, encodeCommandDataClosure); }); + return TryAddingResponse([&]() -> CHIP_ERROR { return TryAddResponseData(aRequestCommandPath, aData); }); } /** @@ -567,18 +550,21 @@ class CommandHandler CHIP_ERROR AddStatusInternal(const ConcreteCommandPath & aCommandPath, const StatusIB & aStatus); /** - * If this function fails, it may leave our TLV buffer in an inconsistent state. Callers should snapshot as needed before - * calling this function, and roll back as needed afterward. + * Non-templated function called before DataModel::Encode when attempting to add a response, + * which does all the work needed before encoding the actual type-dependent data into the buffer. * - * @param [in] aRequestCommandPath the concrete path of the command we are - * responding to. - * @param [in] aResponseCommandPath the concrete command response path. - * @param [in] encodeCommandDataFunction A lambda function responsible for - * encoding the CommandData field. + * **Important:** If this function fails, the TLV buffer may be left in an inconsistent state. + * Callers should create snapshots as necessary before invoking this function and implement + * rollback mechanisms if needed. + * + * **Usage:** This function is intended to be called exclusively by TryAddResponseData. It was + * factored out to optimize code size. + * + * @param aRequestCommandPath The concrete path of the command being responded to. + * @param aResponseCommandPath The concrete path of the command response. */ - template - CHIP_ERROR TryAddResponseData(const ConcreteCommandPath & aRequestCommandPath, const ConcreteCommandPath & aResponseCommandPath, - Function && encodeCommandDataFunction) + CHIP_ERROR TryAddResponseDataPreEncode(const ConcreteCommandPath & aRequestCommandPath, + const ConcreteCommandPath & aResponseCommandPath) { // Return early in case of requests targeted to a group, since they should not add a response. VerifyOrReturnValue(!IsGroupRequest(), CHIP_NO_ERROR); @@ -587,11 +573,39 @@ class CommandHandler prepareParams.SetStartOrEndDataStruct(false); ScopedChange internalCallToAddResponse(mInternalCallToAddResponseData, true); - ReturnErrorOnFailure(PrepareInvokeResponseCommand(aResponseCommandPath, prepareParams)); + return PrepareInvokeResponseCommand(aResponseCommandPath, prepareParams); + } + + // TODO(#31627): It would be awesome if we could remove this template all together. + /** + * If this function fails, it may leave our TLV buffer in an inconsistent state. + * Callers should snapshot as needed before calling this function, and roll back + * as needed afterward. + * + * @param [in] aRequestCommandPath the concrete path of the command we are + * responding to. + * @param [in] aData the data for the response. + */ + template + CHIP_ERROR TryAddResponseData(const ConcreteCommandPath & aRequestCommandPath, const CommandData & aData) + { + // This method, templated with CommandData, captures all the components needs + // from CommandData with as little code as possible. + // + // Previously, non-essential code was unnecessarily templated, leading to + // compilation and duplication N times. By isolating only the code segments + // that genuinely require templating, minimizes duplicate compiled code. + ConcreteCommandPath responseCommandPath = { aRequestCommandPath.mEndpointId, aRequestCommandPath.mClusterId, + CommandData::GetCommandId() }; + ReturnErrorOnFailure(TryAddResponseDataPreEncode(aRequestCommandPath, responseCommandPath)); TLV::TLVWriter * writer = GetCommandDataIBTLVWriter(); VerifyOrReturnError(writer != nullptr, CHIP_ERROR_INCORRECT_STATE); - ReturnErrorOnFailure(encodeCommandDataFunction(*writer)); + ReturnErrorOnFailure(DataModel::Encode(*writer, TLV::ContextTag(CommandDataIB::Tag::kFields), aData)); + // FinishCommand technically should be refactored out as it is not a command that needs templating. + // But, because there is only a single function call, keeping it here takes less code. If there is + // ever more code between DataModel::Encode and the end of this function, it should be broken out into + // TryAddResponseDataPostEncode. return FinishCommand(/* aEndDataStruct = */ false); } diff --git a/src/app/DeferredAttributePersistenceProvider.h b/src/app/DeferredAttributePersistenceProvider.h index c1023e9b8b8582..6c641dc17d4400 100644 --- a/src/app/DeferredAttributePersistenceProvider.h +++ b/src/app/DeferredAttributePersistenceProvider.h @@ -18,6 +18,7 @@ #include #include #include +#include namespace chip { namespace app { diff --git a/src/app/EventLogging.h b/src/app/EventLogging.h index 4711d33ac94a55..167cf6d2bf4d40 100644 --- a/src/app/EventLogging.h +++ b/src/app/EventLogging.h @@ -54,6 +54,10 @@ class EventLogger : public EventLoggingDelegate * context tags to be interpreted within the schema identified by * `ClusterID` and `EventId`. * + * The consumer has to either lock the Matter stack lock or queue the event to + * the Matter event queue when using LogEvent. This function is not safe to call + * outside of the main Matter processing context. + * * LogEvent has 2 variant, one for fabric-scoped events and one for non-fabric-scoped events. * @param[in] aEventData The event cluster object * @param[in] aEndpoint The current cluster's Endpoint Id diff --git a/src/app/FailSafeContext.cpp b/src/app/FailSafeContext.cpp index 9ecc3dea060340..699fcb8c0ce280 100644 --- a/src/app/FailSafeContext.cpp +++ b/src/app/FailSafeContext.cpp @@ -20,9 +20,9 @@ * Provides the implementation of the FailSafeContext object. */ #include "FailSafeContext.h" -#include +#include #if CHIP_CONFIG_ENABLE_ICD_SERVER -#include // nogncheck +#include // nogncheck #endif #include #include diff --git a/src/app/GlobalAttributes.h b/src/app/GlobalAttributes.h index d0b2a05a53f259..5096792309a880 100644 --- a/src/app/GlobalAttributes.h +++ b/src/app/GlobalAttributes.h @@ -18,6 +18,7 @@ #pragma once #include +#include #include namespace chip { diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index 34e2c2055e36f2..98cb6ff156a653 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -57,7 +57,7 @@ using Protocols::InteractionModel::Status; Global sInteractionModelEngine; -InteractionModelEngine::InteractionModelEngine() {} +InteractionModelEngine::InteractionModelEngine() : mReportingEngine(this) {} InteractionModelEngine * InteractionModelEngine::GetInstance() { @@ -330,7 +330,7 @@ void InteractionModelEngine::ShutdownMatchingSubscriptions(const Optional #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include #include @@ -51,10 +36,14 @@ #include #include #include +#include +#include #include #include #include #include +#include +#include #include #include #include @@ -62,6 +51,17 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -79,7 +79,8 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler, public Messaging::ExchangeDelegate, public CommandHandler::Callback, public ReadHandler::ManagementCallback, - public FabricTable::Delegate + public FabricTable::Delegate, + public SubscriptionsInfoProvider { public: /** @@ -323,8 +324,9 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler, CHIP_ERROR ResumeSubscriptions(); - // Check if a given subject (CAT or NodeId) has at least 1 active subscription - bool SubjectHasActiveSubscription(const FabricIndex aFabricIndex, const NodeId & subject); + bool SubjectHasActiveSubscription(FabricIndex aFabricIndex, NodeId subjectID) override; + + bool SubjectHasPersistedSubscription(FabricIndex aFabricIndex, NodeId subjectID) override; #if CONFIG_BUILD_FOR_HOST_UNIT_TEST // @@ -405,6 +407,8 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler, ReadHandler::ApplicationCallback * GetAppCallback() override { return mpReadHandlerApplicationCallback; } + InteractionModelEngine * GetInteractionModelEngine() override { return this; } + CHIP_ERROR OnUnsolicitedMessageReceived(const PayloadHeader & payloadHeader, ExchangeDelegate *& newDelegate) override; /** diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index c0cfbe4a829e76..bd63503a10493f 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include @@ -36,7 +36,7 @@ #include #if CHIP_CONFIG_ENABLE_ICD_SERVER -#include //nogncheck +#include //nogncheck #endif namespace chip { @@ -68,7 +68,7 @@ ReadHandler::ReadHandler(ManagementCallback & apCallback, Messaging::ExchangeCon mInteractionType = aInteractionType; mLastWrittenEventsBytes = 0; - mTransactionStartGeneration = InteractionModelEngine::GetInstance()->GetReportingEngine().GetDirtySetGeneration(); + mTransactionStartGeneration = mManagementCallback.GetInteractionModelEngine()->GetReportingEngine().GetDirtySetGeneration(); mFlags.ClearAll(); SetStateFlag(ReadHandlerFlags::PrimingReports); @@ -102,7 +102,7 @@ void ReadHandler::OnSubscriptionResumed(const SessionHandle & sessionHandle, for (size_t i = 0; i < resumptionSessionEstablisher.mSubscriptionInfo.mAttributePaths.AllocatedSize(); i++) { AttributePathParams params = resumptionSessionEstablisher.mSubscriptionInfo.mAttributePaths[i].GetParams(); - CHIP_ERROR err = InteractionModelEngine::GetInstance()->PushFrontAttributePathList(mpAttributePathList, params); + CHIP_ERROR err = mManagementCallback.GetInteractionModelEngine()->PushFrontAttributePathList(mpAttributePathList, params); if (err != CHIP_NO_ERROR) { Close(); @@ -112,7 +112,7 @@ void ReadHandler::OnSubscriptionResumed(const SessionHandle & sessionHandle, for (size_t i = 0; i < resumptionSessionEstablisher.mSubscriptionInfo.mEventPaths.AllocatedSize(); i++) { EventPathParams params = resumptionSessionEstablisher.mSubscriptionInfo.mEventPaths[i].GetParams(); - CHIP_ERROR err = InteractionModelEngine::GetInstance()->PushFrontEventPathParamsList(mpEventPathList, params); + CHIP_ERROR err = mManagementCallback.GetInteractionModelEngine()->PushFrontEventPathParamsList(mpEventPathList, params); if (err != CHIP_NO_ERROR) { Close(); @@ -137,7 +137,7 @@ void ReadHandler::OnSubscriptionResumed(const SessionHandle & sessionHandle, ObjectList * attributePath = mpAttributePathList; while (attributePath) { - InteractionModelEngine::GetInstance()->GetReportingEngine().SetDirty(attributePath->mValue); + mManagementCallback.GetInteractionModelEngine()->GetReportingEngine().SetDirty(attributePath->mValue); attributePath = attributePath->mpNext; } } @@ -156,11 +156,11 @@ ReadHandler::~ReadHandler() if (IsAwaitingReportResponse()) { - InteractionModelEngine::GetInstance()->GetReportingEngine().OnReportConfirm(); + mManagementCallback.GetInteractionModelEngine()->GetReportingEngine().OnReportConfirm(); } - InteractionModelEngine::GetInstance()->ReleaseAttributePathList(mpAttributePathList); - InteractionModelEngine::GetInstance()->ReleaseEventPathList(mpEventPathList); - InteractionModelEngine::GetInstance()->ReleaseDataVersionFilterList(mpDataVersionFilterList); + mManagementCallback.GetInteractionModelEngine()->ReleaseAttributePathList(mpAttributePathList); + mManagementCallback.GetInteractionModelEngine()->ReleaseEventPathList(mpEventPathList); + mManagementCallback.GetInteractionModelEngine()->ReleaseDataVersionFilterList(mpDataVersionFilterList); } void ReadHandler::Close(CloseOptions options) @@ -168,7 +168,7 @@ void ReadHandler::Close(CloseOptions options) #if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS if (IsType(InteractionType::Subscribe) && options == CloseOptions::kDropPersistedSubscription) { - auto * subscriptionResumptionStorage = InteractionModelEngine::GetInstance()->GetSubscriptionResumptionStorage(); + auto * subscriptionResumptionStorage = mManagementCallback.GetInteractionModelEngine()->GetSubscriptionResumptionStorage(); if (subscriptionResumptionStorage) { subscriptionResumptionStorage->Delete(GetInitiatorNodeId(), GetAccessingFabricIndex(), mSubscriptionId); @@ -285,7 +285,8 @@ CHIP_ERROR ReadHandler::SendStatusReport(Protocols::InteractionModel::Status aSt #if CHIP_CONFIG_UNSAFE_SUBSCRIPTION_EXCHANGE_MANAGER_USE auto exchange = mExchangeMgr->NewContext(mSessionHandle.Get().Value(), this); #else // CHIP_CONFIG_UNSAFE_SUBSCRIPTION_EXCHANGE_MANAGER_USE - auto exchange = InteractionModelEngine::GetInstance()->GetExchangeManager()->NewContext(mSessionHandle.Get().Value(), this); + auto exchange = + mManagementCallback.GetInteractionModelEngine()->GetExchangeManager()->NewContext(mSessionHandle.Get().Value(), this); #endif // CHIP_CONFIG_UNSAFE_SUBSCRIPTION_EXCHANGE_MANAGER_USE VerifyOrReturnLogError(exchange != nullptr, CHIP_ERROR_INCORRECT_STATE); mExchangeCtx.Grab(exchange); @@ -310,7 +311,8 @@ CHIP_ERROR ReadHandler::SendReportData(System::PacketBufferHandle && aPayload, b #if CHIP_CONFIG_UNSAFE_SUBSCRIPTION_EXCHANGE_MANAGER_USE auto exchange = mExchangeMgr->NewContext(mSessionHandle.Get().Value(), this); #else // CHIP_CONFIG_UNSAFE_SUBSCRIPTION_EXCHANGE_MANAGER_USE - auto exchange = InteractionModelEngine::GetInstance()->GetExchangeManager()->NewContext(mSessionHandle.Get().Value(), this); + auto exchange = + mManagementCallback.GetInteractionModelEngine()->GetExchangeManager()->NewContext(mSessionHandle.Get().Value(), this); #endif // CHIP_CONFIG_UNSAFE_SUBSCRIPTION_EXCHANGE_MANAGER_USE VerifyOrReturnLogError(exchange != nullptr, CHIP_ERROR_INCORRECT_STATE); mExchangeCtx.Grab(exchange); @@ -320,7 +322,8 @@ CHIP_ERROR ReadHandler::SendReportData(System::PacketBufferHandle && aPayload, b if (!IsReporting()) { - mCurrentReportsBeginGeneration = InteractionModelEngine::GetInstance()->GetReportingEngine().GetDirtySetGeneration(); + mCurrentReportsBeginGeneration = + mManagementCallback.GetInteractionModelEngine()->GetReportingEngine().GetDirtySetGeneration(); } SetStateFlag(ReadHandlerFlags::ChunkedReport, aMoreChunks); bool responseExpected = IsType(InteractionType::Subscribe) || aMoreChunks; @@ -339,7 +342,7 @@ CHIP_ERROR ReadHandler::SendReportData(System::PacketBufferHandle && aPayload, b { // Make sure we're not treated as an in-flight report waiting for a // response by the reporting engine. - InteractionModelEngine::GetInstance()->GetReportingEngine().OnReportConfirm(); + mManagementCallback.GetInteractionModelEngine()->GetReportingEngine().OnReportConfirm(); } // If we just finished a non-priming subscription report, notify our observers. @@ -353,7 +356,7 @@ CHIP_ERROR ReadHandler::SendReportData(System::PacketBufferHandle && aPayload, b { mPreviousReportsBeginGeneration = mCurrentReportsBeginGeneration; ClearForceDirtyFlag(); - InteractionModelEngine::GetInstance()->ReleaseDataVersionFilterList(mpDataVersionFilterList); + mManagementCallback.GetInteractionModelEngine()->ReleaseDataVersionFilterList(mpDataVersionFilterList); } return err; @@ -489,12 +492,13 @@ CHIP_ERROR ReadHandler::ProcessAttributePaths(AttributePathIBs::Parser & aAttrib AttributePathIB::Parser path; ReturnErrorOnFailure(path.Init(reader)); ReturnErrorOnFailure(path.ParsePath(attribute)); - ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->PushFrontAttributePathList(mpAttributePathList, attribute)); + ReturnErrorOnFailure( + mManagementCallback.GetInteractionModelEngine()->PushFrontAttributePathList(mpAttributePathList, attribute)); } // if we have exhausted this container if (CHIP_END_OF_TLV == err) { - InteractionModelEngine::GetInstance()->RemoveDuplicateConcreteAttributePath(mpAttributePathList); + mManagementCallback.GetInteractionModelEngine()->RemoveDuplicateConcreteAttributePath(mpAttributePathList); mAttributePathExpandIterator = AttributePathExpandIterator(mpAttributePathList); err = CHIP_NO_ERROR; } @@ -521,8 +525,8 @@ CHIP_ERROR ReadHandler::ProcessDataVersionFilterList(DataVersionFilterIBs::Parse ReturnErrorOnFailure(path.GetEndpoint(&(versionFilter.mEndpointId))); ReturnErrorOnFailure(path.GetCluster(&(versionFilter.mClusterId))); VerifyOrReturnError(versionFilter.IsValidDataVersionFilter(), CHIP_ERROR_IM_MALFORMED_DATA_VERSION_FILTER_IB); - ReturnErrorOnFailure( - InteractionModelEngine::GetInstance()->PushFrontDataVersionFilterList(mpDataVersionFilterList, versionFilter)); + ReturnErrorOnFailure(mManagementCallback.GetInteractionModelEngine()->PushFrontDataVersionFilterList( + mpDataVersionFilterList, versionFilter)); } if (CHIP_END_OF_TLV == err) @@ -544,7 +548,7 @@ CHIP_ERROR ReadHandler::ProcessEventPaths(EventPathIBs::Parser & aEventPathsPars EventPathIB::Parser path; ReturnErrorOnFailure(path.Init(reader)); ReturnErrorOnFailure(path.ParsePath(event)); - ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->PushFrontEventPathParamsList(mpEventPathList, event)); + ReturnErrorOnFailure(mManagementCallback.GetInteractionModelEngine()->PushFrontEventPathParamsList(mpEventPathList, event)); } // if we have exhausted this container @@ -604,7 +608,7 @@ void ReadHandler::MoveToState(const HandlerState aTargetState) if (IsAwaitingReportResponse() && aTargetState != HandlerState::AwaitingReportResponse) { - InteractionModelEngine::GetInstance()->GetReportingEngine().OnReportConfirm(); + mManagementCallback.GetInteractionModelEngine()->GetReportingEngine().OnReportConfirm(); } mState = aTargetState; @@ -618,7 +622,7 @@ void ReadHandler::MoveToState(const HandlerState aTargetState) { if (ShouldReportUnscheduled()) { - InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun(); + mManagementCallback.GetInteractionModelEngine()->GetReportingEngine().ScheduleRun(); } else { @@ -814,7 +818,7 @@ CHIP_ERROR ReadHandler::ProcessSubscribeRequest(System::PacketBufferHandle && aP void ReadHandler::PersistSubscription() { - auto * subscriptionResumptionStorage = InteractionModelEngine::GetInstance()->GetSubscriptionResumptionStorage(); + auto * subscriptionResumptionStorage = mManagementCallback.GetInteractionModelEngine()->GetSubscriptionResumptionStorage(); VerifyOrReturn(subscriptionResumptionStorage != nullptr); SubscriptionResumptionStorage::SubscriptionInfo subscriptionInfo = { .mNodeId = GetInitiatorNodeId(), @@ -843,7 +847,7 @@ void ReadHandler::AttributePathIsDirty(const AttributePathParams & aAttributeCha { ConcreteAttributePath path; - mDirtyGeneration = InteractionModelEngine::GetInstance()->GetReportingEngine().GetDirtySetGeneration(); + mDirtyGeneration = mManagementCallback.GetInteractionModelEngine()->GetReportingEngine().GetDirtySetGeneration(); // We won't reset the path iterator for every AttributePathIsDirty call to reduce the number of full data reports. // The iterator will be reset after finishing each report session. diff --git a/src/app/ReadHandler.h b/src/app/ReadHandler.h index 28097868c2f79a..d602273a8611a9 100644 --- a/src/app/ReadHandler.h +++ b/src/app/ReadHandler.h @@ -153,6 +153,11 @@ class ReadHandler : public Messaging::ExchangeDelegate * issues w.r.t the ReadHandler itself. */ virtual ApplicationCallback * GetAppCallback() = 0; + + /* + * Retrieve the InteractionalModelEngine that holds this ReadHandler. + */ + virtual InteractionModelEngine * GetInteractionModelEngine() = 0; }; // TODO (#27675) : Merge existing callback and observer into one class and have an observer pool in the Readhandler to notify diff --git a/src/app/SubscriptionsInfoProvider.h b/src/app/SubscriptionsInfoProvider.h new file mode 100644 index 00000000000000..ef792904fc4bce --- /dev/null +++ b/src/app/SubscriptionsInfoProvider.h @@ -0,0 +1,65 @@ +/* + * + * 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. + */ + +/** + * @file + * This file defines an interface that exposes all the public subscription information APIs. + * The interface is implemented by the InteractionModelEngine to avoid creating unnecessary dependencies + * since the IMEngine has more dependency than its consummers need. + * By leveraging the SubscriptionInfoProvider APIs, a consumer avoids depending on the global data model functions. + */ + +#pragma once + +#include +#include + +namespace chip { +namespace app { + +class SubscriptionsInfoProvider +{ +public: + virtual ~SubscriptionsInfoProvider(){}; + + /** + * @brief Check if a given subject (CAT or operational NodeId) has at least 1 active subscription. + * + * @param[in] aFabricIndex fabric index of the subject + * @param[in] subjectID NodeId of the subject + * + * @return true subject has at least one active subscription with the device + * false subject doesn't have any active subscription with the device + */ + virtual bool SubjectHasActiveSubscription(FabricIndex aFabricIndex, NodeId subjectID) = 0; + + /** + * @brief Check if a given subject (CAT or operational NodeId) has at least 1 persisted subscription. + * See the CHIP_CONFIG_PERSIST_SUBSCRIPTIONS for more information on persisted subscriptions. + * + * @param[in] aFabricIndex fabric index of the subject + * @param[in] subjectID NodeId of the subject + * + * @return true subject has at least one persisted subscription with the device + * false subject doesn't have any persisted subscription with the device + */ + virtual bool SubjectHasPersistedSubscription(FabricIndex aFabricIndex, NodeId subjectID) = 0; +}; + +} // namespace app +} // namespace chip diff --git a/src/app/TestEventTriggerDelegate.h b/src/app/TestEventTriggerDelegate.h index 5f72415d021104..33869d8c0903bd 100644 --- a/src/app/TestEventTriggerDelegate.h +++ b/src/app/TestEventTriggerDelegate.h @@ -18,12 +18,27 @@ #pragma once #include +#include #include #include #include namespace chip { +class TestEventTriggerHandler : public IntrusiveListNodeBase +{ +public: + virtual ~TestEventTriggerHandler() = default; + /** + * Handles the test event trigger based on `eventTrigger` provided. + * + * @param[in] eventTrigger Event trigger to handle. + * + * @return CHIP_NO_ERROR on success or another CHIP_ERROR on failure + */ + virtual CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) = 0; +}; + class TestEventTriggerDelegate { public: @@ -39,14 +54,76 @@ class TestEventTriggerDelegate virtual bool DoesEnableKeyMatch(const ByteSpan & enableKey) const = 0; /** - * Expectation is that the caller has already validated the enable key before calling this. * Handles the test event trigger based on `eventTrigger` provided. * + * By default, this iterates over handlers added via `AddEventTriggerHandler`. + * + * If more specific behavior is desired, the method can be completely overridden. + * * @param[in] eventTrigger Event trigger to handle. * * @return CHIP_NO_ERROR on success or another CHIP_ERROR on failure */ - virtual CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) = 0; + virtual CHIP_ERROR HandleEventTriggers(uint64_t eventTrigger) + { + CHIP_ERROR last_error = CHIP_ERROR_INVALID_ARGUMENT; + for (TestEventTriggerHandler & handler : mHandlerList) + { + last_error = handler.HandleEventTrigger(eventTrigger); + if (last_error == CHIP_NO_ERROR) + { + break; + } + } + + return last_error; + } + + CHIP_ERROR AddHandler(TestEventTriggerHandler * handler) + { + VerifyOrReturnError(!mHandlerList.Contains(handler), CHIP_ERROR_INVALID_ARGUMENT); + mHandlerList.PushBack(handler); + return CHIP_NO_ERROR; + } + + void RemoveHandler(TestEventTriggerHandler * handler) + { + VerifyOrReturn(mHandlerList.Contains(handler)); + mHandlerList.Remove(handler); + } + + void ClearAllHandlers() { mHandlerList.Clear(); } + +protected: + IntrusiveList mHandlerList; +}; + +/** + * @brief TestEventTriggerDelegate that owns its enable key in RAM. + * + */ +class SimpleTestEventTriggerDelegate : public TestEventTriggerDelegate +{ +public: + SimpleTestEventTriggerDelegate() { memset(&mEnableKey[0], 0, sizeof(mEnableKey)); } + + /** + * @brief Initialize the delegate with a key + * + * @param enableKey - EnableKey to use for this instance. + * @return CHIP_NO_ERROR on success, CHIP_ERROR_INVALID_ARGUMENT if enableKey is wrong size. + */ + CHIP_ERROR Init(ByteSpan enableKey) + { + VerifyOrReturnError(enableKey.size() == sizeof(mEnableKey), CHIP_ERROR_INVALID_ARGUMENT); + MutableByteSpan ourEnableKeySpan(mEnableKey); + return CopySpanToMutableSpan(enableKey, ourEnableKeySpan); + } + + bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override { return enableKey.data_equal(ByteSpan(mEnableKey)); } + +private: + uint8_t mEnableKey[TestEventTriggerDelegate::kEnableKeyLength]; }; } // namespace chip diff --git a/src/app/app-platform/ContentApp.h b/src/app/app-platform/ContentApp.h index 915e47d8672e37..6fed23cf7d64da 100644 --- a/src/app/app-platform/ContentApp.h +++ b/src/app/app-platform/ContentApp.h @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -43,7 +42,6 @@ using ApplicationBasicDelegate = app::Clusters::ApplicationBasic::Delegate; using ApplicationLauncherDelegate = app::Clusters::ApplicationLauncher::Delegate; using ChannelDelegate = app::Clusters::Channel::Delegate; using ContentLauncherDelegate = app::Clusters::ContentLauncher::Delegate; -using ContentAppObserverDelegate = app::Clusters::ContentAppObserver::Delegate; using ContentControlDelegate = app::Clusters::ContentControl::Delegate; using KeypadInputDelegate = app::Clusters::KeypadInput::Delegate; using MediaPlaybackDelegate = app::Clusters::MediaPlayback::Delegate; @@ -63,7 +61,6 @@ class DLL_EXPORT ContentApp virtual ChannelDelegate * GetChannelDelegate() = 0; virtual ContentLauncherDelegate * GetContentLauncherDelegate() = 0; virtual ContentControlDelegate * GetContentControlDelegate() = 0; - virtual ContentAppObserverDelegate * GetContentAppObserverDelegate() = 0; virtual KeypadInputDelegate * GetKeypadInputDelegate() = 0; virtual MediaPlaybackDelegate * GetMediaPlaybackDelegate() = 0; virtual TargetNavigatorDelegate * GetTargetNavigatorDelegate() = 0; diff --git a/src/app/chip_data_model.cmake b/src/app/chip_data_model.cmake index 0126836897a7a2..3e1d669a49569a 100644 --- a/src/app/chip_data_model.cmake +++ b/src/app/chip_data_model.cmake @@ -139,9 +139,9 @@ function(chip_configure_data_model APP_TARGET) ${CHIP_APP_BASE_DIR}/util/attribute-storage.cpp ${CHIP_APP_BASE_DIR}/util/attribute-table.cpp ${CHIP_APP_BASE_DIR}/util/binding-table.cpp - ${CHIP_APP_BASE_DIR}/icd/ICDMonitoringTable.cpp - ${CHIP_APP_BASE_DIR}/icd/ICDNotifier.cpp - ${CHIP_APP_BASE_DIR}/icd/ICDConfigurationData.cpp + ${CHIP_APP_BASE_DIR}/icd/server/ICDMonitoringTable.cpp + ${CHIP_APP_BASE_DIR}/icd/server/ICDNotifier.cpp + ${CHIP_APP_BASE_DIR}/icd/server/ICDConfigurationData.cpp ${CHIP_APP_BASE_DIR}/util/DataModelHandler.cpp ${CHIP_APP_BASE_DIR}/util/ember-compatibility-functions.cpp ${CHIP_APP_BASE_DIR}/util/generic-callback-stubs.cpp diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 6404eb306d2c45..bc6c48df53d742 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -255,8 +255,8 @@ template("chip_data_model") { "${_app_root}/clusters/${cluster}/DefaultOTARequestorUserConsent.h", "${_app_root}/clusters/${cluster}/ExtendedOTARequestorDriver.cpp", "${_app_root}/clusters/${cluster}/OTARequestorStorage.h", - "${_app_root}/clusters/${cluster}/OTATestEventTriggerDelegate.cpp", - "${_app_root}/clusters/${cluster}/OTATestEventTriggerDelegate.h", + "${_app_root}/clusters/${cluster}/OTATestEventTriggerHandler.cpp", + "${_app_root}/clusters/${cluster}/OTATestEventTriggerHandler.h", ] } else if (cluster == "bindings") { sources += [ @@ -300,10 +300,10 @@ template("chip_data_model") { "${_app_root}/clusters/${cluster}/${cluster}.h", ] deps += [ - "${chip_root}/src/app/icd:configuration-data", - "${chip_root}/src/app/icd:icd_config", - "${chip_root}/src/app/icd:monitoring-table", - "${chip_root}/src/app/icd:notifier", + "${chip_root}/src/app/icd/server:configuration-data", + "${chip_root}/src/app/icd/server:icd-server-config", + "${chip_root}/src/app/icd/server:monitoring-table", + "${chip_root}/src/app/icd/server:notifier", ] } else if (cluster == "resource-monitoring-server") { sources += [ @@ -322,15 +322,14 @@ template("chip_data_model") { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp", "${_app_root}/clusters/${cluster}/${cluster}.h", - "${_app_root}/clusters/${cluster}/SmokeCOTestEventTriggerDelegate.cpp", - "${_app_root}/clusters/${cluster}/SmokeCOTestEventTriggerDelegate.h", + "${_app_root}/clusters/${cluster}/SmokeCOTestEventTriggerHandler.h", ] } else if (cluster == "boolean-state-configuration-server") { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp", "${_app_root}/clusters/${cluster}/${cluster}.h", - "${_app_root}/clusters/${cluster}/BooleanStateConfigurationTestEventTriggerDelegate.cpp", - "${_app_root}/clusters/${cluster}/BooleanStateConfigurationTestEventTriggerDelegate.h", + "${_app_root}/clusters/${cluster}/BooleanStateConfigurationTestEventTriggerHandler.cpp", + "${_app_root}/clusters/${cluster}/BooleanStateConfigurationTestEventTriggerHandler.h", ] } else if (cluster == "air-quality-server") { sources += [ @@ -341,8 +340,7 @@ template("chip_data_model") { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp", "${_app_root}/clusters/${cluster}/${cluster}.h", - "${_app_root}/clusters/${cluster}/EnergyEvseTestEventTriggerDelegate.cpp", - "${_app_root}/clusters/${cluster}/EnergyEvseTestEventTriggerDelegate.h", + "${_app_root}/clusters/${cluster}/EnergyEvseTestEventTriggerHandler.h", ] } else if (cluster == "diagnostic-logs-server") { sources += [ @@ -356,8 +354,13 @@ template("chip_data_model") { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp", "${_app_root}/clusters/${cluster}/${cluster}.h", - "${_app_root}/clusters/${cluster}/EnergyReportingTestEventTriggerDelegate.cpp", - "${_app_root}/clusters/${cluster}/EnergyReportingTestEventTriggerDelegate.h", + "${_app_root}/clusters/${cluster}/EnergyReportingTestEventTriggerHandler.h", + ] + } else if (cluster == "thread-network-diagnostics-server") { + sources += [ + "${_app_root}/clusters/${cluster}/${cluster}.cpp", + "${_app_root}/clusters/${cluster}/thread-network-diagnostics-provider.cpp", + "${_app_root}/clusters/${cluster}/thread-network-diagnostics-provider.h", ] } else { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ] @@ -373,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/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.cpp b/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.cpp similarity index 66% rename from src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.cpp rename to src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.cpp index 00a42592929671..b2ffe7a1606dbe 100644 --- a/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.cpp +++ b/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.cpp @@ -15,27 +15,18 @@ * limitations under the License. */ -#include "BooleanStateConfigurationTestEventTriggerDelegate.h" +#include "BooleanStateConfigurationTestEventTriggerHandler.h" using namespace chip::app::Clusters::BooleanStateConfiguration; namespace chip { -bool BooleanStateConfigurationTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const -{ - return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); -} - -CHIP_ERROR BooleanStateConfigurationTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) +CHIP_ERROR BooleanStateConfigurationTestEventTriggerHandler::HandleEventTrigger(uint64_t eventTrigger) { if (HandleBooleanStateConfigurationTestEventTrigger(eventTrigger)) { return CHIP_NO_ERROR; } - if (mOtherDelegate != nullptr) - { - return mOtherDelegate->HandleEventTrigger(eventTrigger); - } return CHIP_ERROR_INVALID_ARGUMENT; } diff --git a/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.h b/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.h similarity index 72% rename from src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.h rename to src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.h index 43b68e284497e0..92aa2e8a86abec 100644 --- a/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.h +++ b/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.h @@ -28,21 +28,10 @@ enum class BooleanStateConfigurationTrigger : uint64_t kSensorUntrigger = 0x0080000000000001, }; -class BooleanStateConfigurationTestEventTriggerDelegate : public TestEventTriggerDelegate +class BooleanStateConfigurationTestEventTriggerHandler : public TestEventTriggerHandler { public: - explicit BooleanStateConfigurationTestEventTriggerDelegate(const ByteSpan & enableKey, - TestEventTriggerDelegate * otherDelegate) : - mEnableKey(enableKey), - mOtherDelegate(otherDelegate) - {} - - bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; - -private: - ByteSpan mEnableKey; - TestEventTriggerDelegate * mOtherDelegate; }; } // namespace chip diff --git a/src/app/clusters/color-control-server/color-control-server.cpp b/src/app/clusters/color-control-server/color-control-server.cpp index a21a44ada8d23f..0f24ccd5b01e43 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -2602,6 +2602,24 @@ void ColorControlServer::updateTempCommand(EndpointId endpoint) isColorTempTransitionDone = computeNewColor16uValue(colorTempTransitionState); + if (!isColorTempTransitionDone) + { + // Check whether our color temperature has actually changed. If not, do + // nothing, and wait for it to change. + uint16_t currentColorTemp; + if (Attributes::ColorTemperatureMireds::Get(endpoint, ¤tColorTemp) != EMBER_ZCL_STATUS_SUCCESS) + { + // Why can't we read our attribute? + return; + } + + if (currentColorTemp == colorTempTransitionState->currentValue) + { + scheduleTimerCallbackMs(configureTempEventControl(endpoint), TRANSITION_UPDATE_TIME_MS.count()); + return; + } + } + Attributes::RemainingTime::Set(endpoint, colorTempTransitionState->timeRemaining); if (isColorTempTransitionDone) diff --git a/src/app/clusters/door-lock-server/door-lock-delegate.h b/src/app/clusters/door-lock-server/door-lock-delegate.h new file mode 100644 index 00000000000000..8908926822aa02 --- /dev/null +++ b/src/app/clusters/door-lock-server/door-lock-delegate.h @@ -0,0 +1,133 @@ +/* + * + * 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 + +namespace chip { +namespace app { +namespace Clusters { +namespace DoorLock { + +static constexpr size_t kAliroReaderVerificationKeySize = 65; + +static constexpr size_t kAliroReaderGroupIdentifierSize = 16; + +static constexpr size_t kAliroReaderGroupSubIdentifierSize = 16; + +static constexpr size_t kAliroGroupResolvingKeySize = 16; + +static constexpr size_t kAliroProtocolVersionSize = 2; + +static constexpr size_t kAliroSigningKeySize = 32; + +/** @brief + * Defines methods for implementing application-specific logic for the door lock cluster. + * It defines the interfaces that a door lock should implement to support Aliro provisioning attributes. + */ + +class Delegate +{ +public: + Delegate() = default; + + virtual ~Delegate() = default; + + /** + * @brief Get the Aliro verification key component of the Reader's key pair. + * + * @param[out] verificationKey The MutableByteSpan to copy the verification key into. On success, + * the callee must update the length to the length of the copied data. If the value of + * the attribute is null, the callee must set the MutableByteSpan to empty. + */ + virtual CHIP_ERROR GetAliroReaderVerificationKey(MutableByteSpan & verificationKey) = 0; + + /** + * @brief Get the Aliro Reader's group identifier + * + * @param[out] groupIdentifier The MutableByteSpan to copy the group identifier into. On success, + * the callee must update the length to the length of the copied data. If the value of + * the attribute is null, the callee must set the MutableByteSpan to empty. + */ + virtual CHIP_ERROR GetAliroReaderGroupIdentifier(MutableByteSpan & groupIdentifier) = 0; + + /** + * @brief Get the Aliro Reader's group subidentifier + * + * @param[out] groupSubIdentifier The MutableByteSpan to copy the group subidentifier into. On success, + * the callee must update the length to the length of the copied data. The MutableByteSpan + * must not be empty since the attribute is not nullable. + */ + virtual CHIP_ERROR GetAliroReaderGroupSubIdentifier(MutableByteSpan & groupSubIdentifier) = 0; + + /** + * @brief Get the Aliro expedited transaction supported protocol version at the given index. + * + * @param[in] index The index of the protocol version in the list. + * @param[out] protocolVersion The MutableByteSpan to copy the expedited transaction supported protocol version at the given + * index into. On success, the callee must update the length to the length of the copied data. + * @return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED if the index is out of range for the attribute list. + */ + virtual CHIP_ERROR GetAliroExpeditedTransactionSupportedProtocolVersionAtIndex(size_t index, + MutableByteSpan & protocolVersion) = 0; + + /** + * @brief Get the Reader's group resolving key. + * + * @param[out] groupResolvingKey The MutableByteSpan to copy the group resolving key into. On success, + * the callee must update the length to the length of the copied data. If the value of + * the attribute is null, the callee must set the MutableByteSpan to empty. + */ + virtual CHIP_ERROR GetAliroGroupResolvingKey(MutableByteSpan & groupResolvingKey) = 0; + + /** + * @brief Get the Aliro supported BLE UWB protocol version at the given index. + * + * @param[in] index The index of the protocol version in the list. + * @param[out] protocolVersion The MutableByteSpan to copy the supported BLE UWB protocol version at the given index into. + * On success, the callee must update the length to the length of the copied data. + * @return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED if the index is out of range for the attribute list. + */ + virtual CHIP_ERROR GetAliroSupportedBLEUWBProtocolVersionAtIndex(size_t index, MutableByteSpan & protocolVersion) = 0; + + /** + * @brief Get the Aliro BLE Advertising Version. + * + * @return The BLE Advertising Version. + */ + virtual uint8_t GetAliroBLEAdvertisingVersion() = 0; + + /** + * @brief Get the maximum number of Aliro credential issuer keys supported. + * + * @return The max number of Aliro credential issuer keys supported. + */ + virtual uint16_t GetNumberOfAliroCredentialIssuerKeysSupported() = 0; + + /** + * @brief Get the maximum number of Aliro endpoint keys supported. + * + * @return The max number of Aliro endpoint keys supported. + */ + virtual uint16_t GetNumberOfAliroEndpointKeysSupported() = 0; +}; + +} // namespace DoorLock +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/door-lock-server/door-lock-server-callback.cpp b/src/app/clusters/door-lock-server/door-lock-server-callback.cpp index a1644286c1af1a..64ab48232c4f40 100644 --- a/src/app/clusters/door-lock-server/door-lock-server-callback.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server-callback.cpp @@ -243,3 +243,15 @@ emberAfPluginDoorLockGetFaceCredentialLengthConstraints(chip::EndpointId endpoin { return false; } + +bool __attribute__((weak)) +emberAfPluginDoorLockSetAliroReaderConfig(EndpointId endpointId, const ByteSpan & signingKey, const ByteSpan & verificationKey, + const ByteSpan & groupIdentifier, const Optional groupResolvingKey) +{ + return false; +} + +bool __attribute__((weak)) emberAfPluginDoorLockClearAliroReaderConfig(chip::EndpointId endpointId) +{ + return false; +} 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 b51a10e6f02744..5b975d5d88262c 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,7 @@ using namespace chip; using namespace chip::app; using namespace chip::app::DataModel; 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; @@ -47,6 +49,39 @@ static constexpr uint8_t DOOR_LOCK_SCHEDULE_MAX_MINUTE = 59; static constexpr uint32_t DOOR_LOCK_MAX_LOCK_TIMEOUT_SEC = MAX_INT32U_VALUE / MILLISECOND_TICKS_PER_SECOND; +static constexpr size_t kDoorLockDelegateTableSize = + EMBER_AF_DOOR_LOCK_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; + +static_assert(kDoorLockDelegateTableSize <= kEmberInvalidEndpointIndex, "Door Lock Delegate table size error"); + +namespace chip { +namespace app { +namespace Clusters { +namespace DoorLock { + +Delegate * gDelegateTable[kDoorLockDelegateTableSize] = { nullptr }; + +Delegate * GetDelegate(EndpointId endpoint) +{ + uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, DoorLock::Id, EMBER_AF_DOOR_LOCK_CLUSTER_SERVER_ENDPOINT_COUNT); + return (ep >= kDoorLockDelegateTableSize ? nullptr : gDelegateTable[ep]); +} + +void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate) +{ + uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, DoorLock::Id, EMBER_AF_DOOR_LOCK_CLUSTER_SERVER_ENDPOINT_COUNT); + // if endpoint is found + if (ep < ArraySize(gDelegateTable)) + { + gDelegateTable[ep] = delegate; + } +} + +} // namespace DoorLock +} // namespace Clusters +} // namespace app +} // namespace chip + DoorLockServer DoorLockServer::instance; class DoorLockClusterFabricDelegate : public chip::FabricTable::Delegate @@ -1569,9 +1604,33 @@ bool DoorLockServer::getMaxNumberOfCredentials(chip::EndpointId endpointId, Cred case CredentialTypeEnum::kFace: status = emberAfPluginDoorLockGetNumberOfFaceCredentialsSupported(endpointId, maxNumberOfCredentials); break; - case CredentialTypeEnum::kAliroCredentialIssuerKey: + case CredentialTypeEnum::kAliroCredentialIssuerKey: { + Delegate * delegate = GetDelegate(endpointId); + if (delegate == nullptr) + { + ChipLogError(Zcl, "Delegate is null"); + return false; + } + + maxNumberOfCredentials = delegate->GetNumberOfAliroCredentialIssuerKeysSupported(); + status = true; + break; + } case CredentialTypeEnum::kAliroEvictableEndpointKey: - case CredentialTypeEnum::kAliroNonEvictableEndpointKey: + case CredentialTypeEnum::kAliroNonEvictableEndpointKey: { + Delegate * delegate = GetDelegate(endpointId); + if (delegate == nullptr) + { + ChipLogError(Zcl, "Delegate is null"); + return false; + } + + // For AliroEvictableEndpointKey and AliroNonEvictableEndpointKey credential type, return the total + // number of endpoint keys supported. + maxNumberOfCredentials = delegate->GetNumberOfAliroEndpointKeysSupported(); + status = true; + break; + } default: return false; } @@ -3812,6 +3871,108 @@ bool emberAfDoorLockClusterClearHolidayScheduleCallback( return true; } +bool emberAfDoorLockClusterSetAliroReaderConfigCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const Commands::SetAliroReaderConfig::DecodableType & commandData) +{ + DoorLockServer::Instance().setAliroReaderConfigCommandHandler(commandObj, commandPath, commandData.signingKey, + commandData.verificationKey, commandData.groupIdentifier, + commandData.groupResolvingKey); + return true; +} + +bool emberAfDoorLockClusterClearAliroReaderConfigCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const Commands::ClearAliroReaderConfig::DecodableType & commandData) +{ + DoorLockServer::Instance().clearAliroReaderConfigCommandHandler(commandObj, commandPath); + return true; +} + +void DoorLockServer::setAliroReaderConfigCommandHandler(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const ByteSpan & signingKey, const ByteSpan & verificationKey, + const ByteSpan & groupIdentifier, + const Optional & groupResolvingKey) +{ + EndpointId endpointID = commandPath.mEndpointId; + ChipLogProgress(Zcl, "[SetAliroReaderConfig] Incoming command [endpointId=%d]", endpointID); + + // If Aliro Provisioning feature is not supported, return UNSUPPORTED_COMMAND. + if (!SupportsAliroProvisioning(endpointID)) + { + ChipLogProgress(Zcl, "[SetAliroReaderConfig] Aliro Provisioning is not supported [endpointId=%d]", endpointID); + commandObj->AddStatus(commandPath, Status::UnsupportedCommand); + return; + } + + Delegate * delegate = GetDelegate(endpointID); + VerifyOrReturn(delegate != nullptr, ChipLogError(Zcl, "Delegate is null")); + + // If Aliro BLE UWB feature is supported and groupResolvingKey is not provided in the command, return INVALID_COMMAND. + if (SupportsAliroBLEUWB(endpointID) && !groupResolvingKey.HasValue()) + { + ChipLogProgress(Zcl, "[SetAliroReaderConfig] Aliro BLE UWB supported but Group Resolving Key is not provided"); + commandObj->AddStatus(commandPath, Status::InvalidCommand); + return; + } + + // Check if the size of the signingKey, verificationKey, groupIdentifier, groupResolvingKey parameters conform to the spec. + // Return INVALID_COMMAND if not. + if (signingKey.size() != kAliroSigningKeySize || verificationKey.size() != kAliroReaderVerificationKeySize || + groupIdentifier.size() != kAliroReaderGroupIdentifierSize || + (groupResolvingKey.HasValue() && groupResolvingKey.Value().size() != kAliroGroupResolvingKeySize)) + { + ChipLogProgress(Zcl, + "[SetAliroReaderConfig] One or more parameters in the command do not meet the size constraint as per spec"); + commandObj->AddStatus(commandPath, Status::ConstraintError); + return; + } + + uint8_t buffer[kAliroReaderVerificationKeySize]; + MutableByteSpan readerVerificationKey(buffer); + + CHIP_ERROR err = delegate->GetAliroReaderVerificationKey(readerVerificationKey); + + // If Aliro reader verification key attribute was not read successfuly, return INVALID_IN_STATE. Or if the verification key was + // read and is not null (i.e not empty), we can't set a new reader config without clearing the previous one, return + // INVALID_IN_STATE. + if (err != CHIP_NO_ERROR || !readerVerificationKey.empty()) + { + ChipLogProgress( + Zcl, "[SetAliroReaderConfig] Aliro reader verification key was not read or is not null. Return INVALID_IN_STATE"); + commandObj->AddStatus(commandPath, Status::InvalidInState); + return; + } + + EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + if (!emberAfPluginDoorLockSetAliroReaderConfig(endpointID, signingKey, verificationKey, groupIdentifier, groupResolvingKey)) + { + ChipLogProgress(Zcl, "[SetAliroReaderConfig] Unable to set aliro reader config [endpointId=%d]", endpointID); + status = EMBER_ZCL_STATUS_FAILURE; + } + sendClusterResponse(commandObj, commandPath, status); +} + +void DoorLockServer::clearAliroReaderConfigCommandHandler(CommandHandler * commandObj, const ConcreteCommandPath & commandPath) +{ + EndpointId endpointID = commandPath.mEndpointId; + ChipLogProgress(Zcl, "[ClearAliroReaderConfig] Incoming command [endpointId=%d]", endpointID); + + // If Aliro Provisioning feature is not supported, return UNSUPPORTED_COMMAND. + if (!SupportsAliroProvisioning(endpointID)) + { + ChipLogProgress(Zcl, "[ClearAliroReaderConfig] Aliro Provisioning is not supported [endpointId=%d]", endpointID); + commandObj->AddStatus(commandPath, Status::UnsupportedCommand); + return; + } + + EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + if (!emberAfPluginDoorLockClearAliroReaderConfig(endpointID)) + { + ChipLogProgress(Zcl, "[SetAliroReaderConfig] Unable to set aliro reader config [endpointId=%d]", endpointID); + status = EMBER_ZCL_STATUS_FAILURE; + } + sendClusterResponse(commandObj, commandPath, status); +} + // ============================================================================= // SDK callbacks // ============================================================================= @@ -3932,6 +4093,8 @@ void MatterDoorLockPluginServerInitCallback() { ChipLogProgress(Zcl, "Door Lock server initialized"); Server::GetInstance().GetFabricTable().AddFabricDelegate(&gFabricDelegate); + + registerAttributeAccessOverride(&DoorLockServer::Instance()); } void MatterDoorLockClusterServerAttributeChangedCallback(const app::ConcreteAttributePath & attributePath) {} @@ -3966,3 +4129,128 @@ void DoorLockServer::DoorLockOnAutoRelockCallback(System::Layer *, void * callba ChipLogProgress(Zcl, "Door Auto relock timer expired. %s", "Already locked."); } } + +CHIP_ERROR DoorLockServer::ReadAliroExpeditedTransactionSupportedProtocolVersions(const ConcreteReadAttributePath & aPath, + AttributeValueEncoder & aEncoder, + Delegate * delegate) +{ + VerifyOrReturnValue(delegate != nullptr, aEncoder.EncodeEmptyList()); + + return aEncoder.EncodeList([delegate](const auto & encoder) -> CHIP_ERROR { + for (uint8_t i = 0; true; i++) + { + uint8_t buffer[kAliroProtocolVersionSize]; + MutableByteSpan protocolVersion(buffer); + auto err = delegate->GetAliroExpeditedTransactionSupportedProtocolVersionAtIndex(i, protocolVersion); + if (err == CHIP_ERROR_PROVIDER_LIST_EXHAUSTED) + { + return CHIP_NO_ERROR; + } + ReturnErrorOnFailure(err); + ReturnErrorOnFailure(encoder.Encode(protocolVersion)); + } + }); +} + +CHIP_ERROR DoorLockServer::ReadAliroSupportedBLEUWBProtocolVersions(const ConcreteReadAttributePath & aPath, + AttributeValueEncoder & aEncoder, Delegate * delegate) +{ + VerifyOrReturnValue(delegate != nullptr, aEncoder.EncodeEmptyList()); + + return aEncoder.EncodeList([delegate](const auto & encoder) -> CHIP_ERROR { + for (uint8_t i = 0; true; i++) + { + uint8_t buffer[kAliroProtocolVersionSize]; + MutableByteSpan protocolVersion(buffer); + auto err = delegate->GetAliroSupportedBLEUWBProtocolVersionAtIndex(i, protocolVersion); + if (err == CHIP_ERROR_PROVIDER_LIST_EXHAUSTED) + { + return CHIP_NO_ERROR; + } + ReturnErrorOnFailure(err); + ReturnErrorOnFailure(encoder.Encode(protocolVersion)); + } + }); +} + +CHIP_ERROR DoorLockServer::ReadAliroByteSpanAttribute(CHIP_ERROR (Delegate::*func)(MutableByteSpan &), MutableByteSpan & data, + Delegate * delegate, AttributeValueEncoder & aEncoder, + AttributeNullabilityType nullabilityType) +{ + VerifyOrReturnError(delegate != nullptr, CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "Delegate is null")); + + ReturnErrorOnFailure((delegate->*func)(data)); + if (nullabilityType == AttributeNullabilityType::kNullable && data.empty()) + { + ReturnErrorOnFailure(aEncoder.EncodeNull()); + } + else + { + ReturnErrorOnFailure(aEncoder.Encode(data)); + } + return CHIP_NO_ERROR; +} + +// Implements the read functionality for the AttributeAccessInterface. +CHIP_ERROR DoorLockServer::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) +{ + if (aPath.mClusterId != Clusters::DoorLock::Id) + { + // We shouldn't have been called at all. + return CHIP_ERROR_INVALID_ARGUMENT; + } + + Delegate * delegate = GetDelegate(aPath.mEndpointId); + + switch (aPath.mAttributeId) + { + case AliroReaderVerificationKey::Id: { + uint8_t buffer[kAliroReaderVerificationKeySize]; + MutableByteSpan readerVerificationKey(buffer); + return ReadAliroByteSpanAttribute(&Delegate::GetAliroReaderVerificationKey, readerVerificationKey, delegate, aEncoder, + AttributeNullabilityType::kNullable); + } + case AliroReaderGroupIdentifier::Id: { + uint8_t buffer[kAliroReaderGroupIdentifierSize]; + MutableByteSpan readerGroupIdentifier(buffer); + return ReadAliroByteSpanAttribute(&Delegate::GetAliroReaderGroupIdentifier, readerGroupIdentifier, delegate, aEncoder, + AttributeNullabilityType::kNullable); + } + case AliroReaderGroupSubIdentifier::Id: { + uint8_t buffer[kAliroReaderGroupSubIdentifierSize]; + MutableByteSpan readerGroupSubIdentifier(buffer); + return ReadAliroByteSpanAttribute(&Delegate::GetAliroReaderGroupSubIdentifier, readerGroupSubIdentifier, delegate, aEncoder, + AttributeNullabilityType::kNotNullable); + } + case AliroExpeditedTransactionSupportedProtocolVersions::Id: { + return ReadAliroExpeditedTransactionSupportedProtocolVersions(aPath, aEncoder, delegate); + } + case AliroGroupResolvingKey::Id: { + uint8_t buffer[kAliroGroupResolvingKeySize]; + MutableByteSpan groupResolvingKey(buffer); + return ReadAliroByteSpanAttribute(&Delegate::GetAliroGroupResolvingKey, groupResolvingKey, delegate, aEncoder, + AttributeNullabilityType::kNullable); + } + case AliroSupportedBLEUWBProtocolVersions::Id: { + return ReadAliroSupportedBLEUWBProtocolVersions(aPath, aEncoder, delegate); + } + case AliroBLEAdvertisingVersion::Id: { + uint8_t bleAdvertisingVersion = delegate->GetAliroBLEAdvertisingVersion(); + ReturnErrorOnFailure(aEncoder.Encode(bleAdvertisingVersion)); + return CHIP_NO_ERROR; + } + case NumberOfAliroCredentialIssuerKeysSupported::Id: { + uint16_t numberOfCredentialIssuerKeysSupported = delegate->GetNumberOfAliroCredentialIssuerKeysSupported(); + ReturnErrorOnFailure(aEncoder.Encode(numberOfCredentialIssuerKeysSupported)); + return CHIP_NO_ERROR; + } + case NumberOfAliroEndpointKeysSupported::Id: { + uint16_t numberOfEndpointKeysSupported = delegate->GetNumberOfAliroEndpointKeysSupported(); + ReturnErrorOnFailure(aEncoder.Encode(numberOfEndpointKeysSupported)); + return CHIP_NO_ERROR; + } + default: + break; + } + return CHIP_NO_ERROR; +} 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 a8007f211641a4..675a1450baf28a 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.h +++ b/src/app/clusters/door-lock-server/door-lock-server.h @@ -24,7 +24,9 @@ #pragma once +#include "door-lock-delegate.h" #include +#include #include #include #include @@ -88,9 +90,10 @@ struct EmberAfDoorLockEndpointContext /** * @brief Door Lock Server Plugin class. */ -class DoorLockServer +class DoorLockServer : public chip::app::AttributeAccessInterface { public: + DoorLockServer() : AttributeAccessInterface(chip::Optional::Missing(), chip::app::Clusters::DoorLock::Id) {} static DoorLockServer & Instance(); using Feature = chip::app::Clusters::DoorLock::Feature; @@ -203,6 +206,23 @@ class DoorLockServer inline bool SupportsUnbolt(chip::EndpointId endpointId) { return GetFeatures(endpointId).Has(Feature::kUnbolt); } + /** + * @brief Checks if Aliro Provisioning feature is supported on the given endpoint + * + * @param endpointId endpointId ID of the endpoint which contains the lock. + */ + inline bool SupportsAliroProvisioning(chip::EndpointId endpointId) + { + return GetFeatures(endpointId).Has(Feature::kAliroProvisioning); + } + + /** + * @brief Checks if Aliro BLE UWB feature is supported on the given endpoint + * + * @param endpointId endpointId ID of the endpoint which contains the lock. + */ + inline bool SupportsAliroBLEUWB(chip::EndpointId endpointId) { return GetFeatures(endpointId).Has(Feature::kAliroBLEUWB); } + /** * @brief Allows the application to register a custom callback which will be called after the default DoorLock * OnFabricRemoved implementation. At that point the door lock cluster has done any @@ -430,6 +450,13 @@ class DoorLockServer void clearHolidayScheduleCommandHandler(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, uint8_t holidayIndex); + void setAliroReaderConfigCommandHandler(chip::app::CommandHandler * commandObj, + const chip::app::ConcreteCommandPath & commandPath, const chip::ByteSpan & signingKey, + const chip::ByteSpan & verificationKey, const chip::ByteSpan & groupIdentifier, + const Optional & groupResolvingKey); + void clearAliroReaderConfigCommandHandler(chip::app::CommandHandler * commandObj, + const chip::app::ConcreteCommandPath & commandPath); + bool RemoteOperationEnabled(chip::EndpointId endpointId) const; EmberAfDoorLockEndpointContext * getContext(chip::EndpointId endpointId); @@ -521,6 +548,62 @@ class DoorLockServer bool SetAttribute(chip::EndpointId endpointId, chip::AttributeId attributeId, EmberAfStatus (*setFn)(chip::EndpointId endpointId, T value), T value); + // AttributeAccessInterface's Read API + CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & aPath, chip::app::AttributeValueEncoder & aEncoder) override; + + /** + * @brief Reads AliroExpeditedTransactionSupportedProtocolVersions attribute for door lock + * + * @param aPath attribute path. + * @param aEncoder attribute value encoder. + * @param delegate door lock cluster delegate that will provide the value + * + * @return CHIP_NO_ERROR on success + * @return CHIP_ERROR if attribute read failed + */ + CHIP_ERROR ReadAliroExpeditedTransactionSupportedProtocolVersions(const chip::app::ConcreteReadAttributePath & aPath, + chip::app::AttributeValueEncoder & aEncoder, + chip::app::Clusters::DoorLock::Delegate * delegate); + + /** + * @brief Reads AliroSupportedBLEUWBProtocolVersions attribute for door lock + * + * @param aPath attribute path. + * @param aEncoder attribute value encoder. + * @param delegate door lock cluster delegate that will provide the value + * + * @return CHIP_NO_ERROR on success + * @return CHIP_ERROR if attribute read failed + */ + CHIP_ERROR ReadAliroSupportedBLEUWBProtocolVersions(const chip::app::ConcreteReadAttributePath & aPath, + chip::app::AttributeValueEncoder & aEncoder, + chip::app::Clusters::DoorLock::Delegate * delegate); + + /** + * @brief Indicates whether an attribute can be nullable or not. + */ + enum class AttributeNullabilityType : uint8_t + { + kNullable = 0, /**< Indicates if an attribute is nullable */ + kNotNullable = 1, /**< Indicates if an attribute is not nullable */ + }; + + /** + * @brief Utility to read aliro attributes of type ByteSpan + * + * @param func getter function for the attribute. + * @param data buffer for the data. + * @param delegate door lock cluster delegate that will provide the value + * @param aEncoder attribute value encoder. + * @param nullabilityType enum value indicating whether the attribute is nullable or not. + * + * @return CHIP_NO_ERROR on success + * @return CHIP_ERROR if attribute read failed + */ + CHIP_ERROR ReadAliroByteSpanAttribute(CHIP_ERROR (chip::app::Clusters::DoorLock::Delegate::*func)(chip::MutableByteSpan & data), + chip::MutableByteSpan & data, chip::app::Clusters::DoorLock::Delegate * delegate, + chip::app::AttributeValueEncoder & aEncoder, AttributeNullabilityType nullabilityType); + friend bool emberAfDoorLockClusterLockDoorCallback(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, @@ -601,6 +684,14 @@ class DoorLockServer chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::DoorLock::Commands::ClearYearDaySchedule::DecodableType & commandData); + friend bool emberAfDoorLockClusterSetAliroReaderConfigCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::DoorLock::Commands::SetAliroReaderConfig::DecodableType & commandData); + + friend bool emberAfDoorLockClusterClearAliroReaderConfigCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::DoorLock::Commands::ClearAliroReaderConfig::DecodableType & commandData); + static constexpr size_t kDoorLockClusterServerMaxEndpointCount = EMBER_AF_DOOR_LOCK_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; static_assert(kDoorLockClusterServerMaxEndpointCount <= kEmberInvalidEndpointIndex, "DoorLock Endpoint count error"); @@ -1167,3 +1258,33 @@ bool emberAfPluginDoorLockGetFingerVeinCredentialLengthConstraints(chip::Endpoin * @return false on failure, true on success. */ bool emberAfPluginDoorLockGetFaceCredentialLengthConstraints(chip::EndpointId endpointId, uint8_t & minLen, uint8_t & maxLen); + +/** + * @brief This callback is called when Door Lock cluster needs to communicate the Aliro reader configuration to the door lock. + * + * @note This function is used for communicating the Aliro signing key, verification key, group identifier and group resolving key + * to the lock. + * + * @param endpointId ID of the endpoint which contains the lock. + * @param[in] signingKey Signing key component of the Reader's key pair. + * @param[in] verificationKey Verification key component of the Reader's key pair. + * @param[in] groupIdentifier Reader group identifier for the lock. + * @param[in] groupResolvingKey Group resolving key for the lock if Aliro BLE UWB feature is supported + * + * @retval true, if the Aliro reader config was successfully communicated to the door lock. + * @retval false, if error occurred while communicating the Aliro reader config. + */ +bool emberAfPluginDoorLockSetAliroReaderConfig(chip::EndpointId endpointId, const chip::ByteSpan & signingKey, + const chip::ByteSpan & verificationKey, const chip::ByteSpan & groupIdentifier, + const Optional & groupResolvingKey); + +/** + * @brief This callback is called when Door Lock cluster needs to clear an existing Aliro reader configuration from the door lock. + * + * + * @param endpointId ID of the endpoint which contains the lock. + * + * @retval true, if the Aliro reader config was successfully cleared from the door lock. + * @retval false, if error occurred while clearing the Aliro reader config. + */ +bool emberAfPluginDoorLockClearAliroReaderConfig(chip::EndpointId endpointId); diff --git a/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.h b/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h similarity index 64% rename from src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.h rename to src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h index a7beef6c2838ce..d254d7a2db697d 100644 --- a/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.h +++ b/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h @@ -20,6 +20,18 @@ #include #include +/** + * @brief User handler for handling the test event trigger + * + * @note If TestEventTrigger is enabled, it needs to be implemented in the app + * + * @param eventTrigger Event trigger to handle + * + * @retval true on success + * @retval false if error happened + */ +bool HandleEnergyReportingTestEventTrigger(uint64_t eventTrigger); + namespace chip { /* @@ -40,44 +52,19 @@ enum class EnergyReportingTrigger : uint64_t }; -class EnergyReportingTestEventTriggerDelegate : public TestEventTriggerDelegate +class EnergyReportingTestEventTriggerHandler : public TestEventTriggerHandler { public: - /** - * This class expects the enableKey ByteSpan to be valid forever. - * Typically this feature is only enabled in certification testing - * and uses a static secret key in the device for testing (e.g. in factory data) - */ - explicit EnergyReportingTestEventTriggerDelegate(const ByteSpan & enableKey, TestEventTriggerDelegate * otherDelegate) : - mEnableKey(enableKey), mOtherDelegate(otherDelegate) - {} - - /* This function returns True if the enableKey received in the TestEventTrigger command - * matches the value passed into the constructor. - */ - bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; + EnergyReportingTestEventTriggerHandler() {} - /** This function must return True if the eventTrigger is recognised and handled - * It must return False to allow a higher level TestEvent handler to check other - * clusters that may handle it. - */ - CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; - -private: - ByteSpan mEnableKey; - TestEventTriggerDelegate * mOtherDelegate; + CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override + { + if (HandleEnergyReportingTestEventTrigger(eventTrigger)) + { + return CHIP_NO_ERROR; + } + return CHIP_ERROR_INVALID_ARGUMENT; + } }; } // namespace chip - -/** - * @brief User handler for handling the test event trigger - * - * @note If TestEventTrigger is enabled, it needs to be implemented in the app - * - * @param eventTrigger Event trigger to handle - * - * @retval true on success - * @retval false if error happened - */ -bool HandleEnergyReportingTestEventTrigger(uint64_t eventTrigger); 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/energy-evse-server/EnergyEvseTestEventTriggerDelegate.cpp b/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.cpp deleted file mode 100644 index 78fb87085f3b10..00000000000000 --- a/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Copyright (c) 2023 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "EnergyEvseTestEventTriggerDelegate.h" - -using namespace chip::app::Clusters::EnergyEvse; - -namespace chip { - -bool EnergyEvseTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const -{ - return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); -} - -CHIP_ERROR EnergyEvseTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) -{ - if (HandleEnergyEvseTestEventTrigger(eventTrigger)) - { - return CHIP_NO_ERROR; - } - if (mOtherDelegate != nullptr) - { - return mOtherDelegate->HandleEventTrigger(eventTrigger); - } - return CHIP_ERROR_INVALID_ARGUMENT; -} - -} // namespace chip diff --git a/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h b/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h similarity index 78% rename from src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h rename to src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h index 3c1dff4f5e7f81..307156e21f1197 100644 --- a/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h +++ b/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h @@ -20,6 +20,18 @@ #include #include +/** + * @brief User handler for handling the test event trigger + * + * @note If TestEventTrigger is enabled, it needs to be implemented in the app + * + * @param eventTrigger Event trigger to handle + * + * @retval true on success + * @retval false if error happened + */ +bool HandleEnergyEvseTestEventTrigger(uint64_t eventTrigger); + namespace chip { /* @@ -55,44 +67,23 @@ enum class EnergyEvseTrigger : uint64_t kEVSEDiagnosticsComplete = 0x0099000000000020, }; -class EnergyEvseTestEventTriggerDelegate : public TestEventTriggerDelegate +class EnergyEvseTestEventTriggerHandler : public TestEventTriggerHandler { public: - /** - * This class expects the enableKey ByteSpan to be valid forever. - * Typically this feature is only enabled in certification testing - * and uses a static secret key in the device for testing (e.g. in factory data) - */ - explicit EnergyEvseTestEventTriggerDelegate(const ByteSpan & enableKey, TestEventTriggerDelegate * otherDelegate) : - mEnableKey(enableKey), mOtherDelegate(otherDelegate) - {} - - /* This function returns True if the enableKey received in the TestEventTrigger command - * matches the value passed into the constructor. - */ - bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; + explicit EnergyEvseTestEventTriggerHandler() {} /** This function must return True if the eventTrigger is recognised and handled * It must return False to allow a higher level TestEvent handler to check other * clusters that may handle it. */ - CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; - -private: - ByteSpan mEnableKey; - TestEventTriggerDelegate * mOtherDelegate; + CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override + { + if (HandleEnergyEvseTestEventTrigger(eventTrigger)) + { + return CHIP_NO_ERROR; + } + return CHIP_ERROR_INVALID_ARGUMENT; + } }; } // namespace chip - -/** - * @brief User handler for handling the test event trigger - * - * @note If TestEventTrigger is enabled, it needs to be implemented in the app - * - * @param eventTrigger Event trigger to handle - * - * @retval true on success - * @retval false if error happened - */ -bool HandleEnergyEvseTestEventTrigger(uint64_t eventTrigger); diff --git a/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp b/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp similarity index 90% rename from src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp rename to src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp index 6c50b581e397d7..b733524839d583 100644 --- a/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp +++ b/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "GenericFaultTestEventTriggerDelegate.h" +#include "GenericFaultTestEventTriggerHandler.h" #include #include @@ -25,15 +25,10 @@ using namespace ::chip::DeviceLayer; namespace chip { -bool GenericFaultTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const -{ - return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); -} - -CHIP_ERROR GenericFaultTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) +CHIP_ERROR GenericFaultTestEventTriggerHandler::HandleEventTrigger(uint64_t eventTrigger) { - if ((eventTrigger & ~kGenericFaultQueryFabricIndexMask) == kGenericFaultQueryTrigger) + if (eventTrigger == kGenericFaultQueryTrigger) { // Fault injection GeneralFaults hwFaultsPrevious; diff --git a/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.h b/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.h similarity index 65% rename from src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.h rename to src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.h index f304518c38fd75..4dea743eec1c94 100644 --- a/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.h +++ b/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.h @@ -22,19 +22,12 @@ namespace chip { -class GenericFaultTestEventTriggerDelegate : public TestEventTriggerDelegate +class GenericFaultTestEventTriggerHandler : public TestEventTriggerHandler { public: - static constexpr uint64_t kGenericFaultQueryTrigger = 0xFFFF'FFFF'10D0'0001; - static constexpr uint64_t kGenericFaultQueryFabricIndexMask = 0xff; + static constexpr uint64_t kGenericFaultQueryTrigger = 0x3333'FFFF'10D0'0001; - explicit GenericFaultTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {} - - bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; - -private: - ByteSpan mEnableKey; }; } // 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 c0130e9cd0068a..c392c963dc5bdd 100644 --- a/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp +++ b/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp @@ -380,7 +380,7 @@ bool emberAfGeneralDiagnosticsClusterTestEventTriggerCallback(CommandHandler * c return true; } - CHIP_ERROR handleEventTriggerResult = triggerDelegate->HandleEventTrigger(commandData.eventTrigger); + CHIP_ERROR handleEventTriggerResult = triggerDelegate->HandleEventTriggers(commandData.eventTrigger); // When HandleEventTrigger fails, we simply convert any error to INVALID_COMMAND commandObj->AddStatus(commandPath, (handleEventTriggerResult != CHIP_NO_ERROR) ? Status::InvalidCommand : Status::Success); 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 da4bada1482d19..e748030f1da9d3 100644 --- a/src/app/clusters/icd-management-server/icd-management-server.cpp +++ b/src/app/clusters/icd-management-server/icd-management-server.cpp @@ -23,8 +23,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/app/clusters/icd-management-server/icd-management-server.h b/src/app/clusters/icd-management-server/icd-management-server.h index 0255112d801388..308d50859d2d4b 100644 --- a/src/app/clusters/icd-management-server/icd-management-server.h +++ b/src/app/clusters/icd-management-server/icd-management-server.h @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.cpp b/src/app/clusters/ota-requestor/OTATestEventTriggerHandler.cpp similarity index 80% rename from src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.cpp rename to src/app/clusters/ota-requestor/OTATestEventTriggerHandler.cpp index a879f817ed9b86..885aced7fe9ee2 100644 --- a/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.cpp +++ b/src/app/clusters/ota-requestor/OTATestEventTriggerHandler.cpp @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "OTATestEventTriggerDelegate.h" +#include "OTATestEventTriggerHandler.h" #include "OTARequestorInterface.h" @@ -24,12 +24,7 @@ namespace chip { -bool OTATestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const -{ - return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); -} - -CHIP_ERROR OTATestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) +CHIP_ERROR OTATestEventTriggerHandler::HandleEventTrigger(uint64_t eventTrigger) { if ((eventTrigger & ~kOtaQueryFabricIndexMask) == kOtaQueryTrigger) { diff --git a/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h b/src/app/clusters/ota-requestor/OTATestEventTriggerHandler.h similarity index 73% rename from src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h rename to src/app/clusters/ota-requestor/OTATestEventTriggerHandler.h index 6c78a16a7665ff..bb49a3d23dc739 100644 --- a/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h +++ b/src/app/clusters/ota-requestor/OTATestEventTriggerHandler.h @@ -22,19 +22,15 @@ namespace chip { -class OTATestEventTriggerDelegate : public TestEventTriggerDelegate +class OTATestEventTriggerHandler : public TestEventTriggerHandler { public: - static constexpr uint64_t kOtaQueryTrigger = 0x0100'0000'0000'0100; + static constexpr uint64_t kOtaQueryTrigger = 0x002a'0000'0000'0100; static constexpr uint64_t kOtaQueryFabricIndexMask = 0xff; - explicit OTATestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {} + OTATestEventTriggerHandler() {} - bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; - -private: - ByteSpan mEnableKey; }; } // namespace chip diff --git a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.cpp b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.cpp deleted file mode 100644 index 597737b14bb768..00000000000000 --- a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Copyright (c) 2023 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "SmokeCOTestEventTriggerDelegate.h" - -using namespace chip::app::Clusters::SmokeCoAlarm; - -namespace chip { - -bool SmokeCOTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const -{ - return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); -} - -CHIP_ERROR SmokeCOTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) -{ - if (HandleSmokeCOTestEventTrigger(eventTrigger)) - { - return CHIP_NO_ERROR; - } - if (mOtherDelegate != nullptr) - { - return mOtherDelegate->HandleEventTrigger(eventTrigger); - } - return CHIP_ERROR_INVALID_ARGUMENT; -} - -} // namespace chip diff --git a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h deleted file mode 100644 index 599eb6ab2fc080..00000000000000 --- a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * 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 - -namespace chip { - -enum class SmokeCOTrigger : uint64_t -{ - // Force alarm commands - kForceSmokeWarning = 0xffffffff00000090, - kForceCOWarning = 0xffffffff00000091, - kForceSmokeInterconnect = 0xffffffff00000092, - kForceMalfunction = 0xffffffff00000093, - kForceCOInterconnect = 0xffffffff00000094, - kForceLowBatteryWarning = 0xffffffff00000095, - kForceSmokeContaminationHigh = 0xffffffff00000096, - kForceSmokeContaminationLow = 0xffffffff00000097, - kForceSmokeSensitivityHigh = 0xffffffff00000098, - kForceSmokeSensitivityLow = 0xffffffff00000099, - kForceEndOfLife = 0xffffffff0000009a, - kForceSilence = 0xffffffff0000009b, - kForceSmokeCritical = 0xffffffff0000009c, - kForceCOCritical = 0xffffffff0000009d, - kForceLowBatteryCritical = 0xffffffff0000009e, - // Clear alarm commands - kClearSmoke = 0xffffffff000000a0, - kClearCO = 0xffffffff000000a1, - kClearSmokeInterconnect = 0xffffffff000000a2, - kClearMalfunction = 0xffffffff000000a3, - kClearCOInterconnect = 0xffffffff000000a4, - kClearBatteryLevelLow = 0xffffffff000000a5, - kClearContamination = 0xffffffff000000a6, - kClearSensitivity = 0xffffffff000000a8, - kClearEndOfLife = 0xffffffff000000aa, - kClearSilence = 0xffffffff000000ab -}; - -class SmokeCOTestEventTriggerDelegate : public TestEventTriggerDelegate -{ -public: - explicit SmokeCOTestEventTriggerDelegate(const ByteSpan & enableKey, TestEventTriggerDelegate * otherDelegate) : - mEnableKey(enableKey), mOtherDelegate(otherDelegate) - {} - - bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; - CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; - -private: - ByteSpan mEnableKey; - TestEventTriggerDelegate * mOtherDelegate; -}; - -} // namespace chip - -/** - * @brief User handler for handling the test event trigger - * - * @note If TestEventTrigger is enabled, it needs to be implemented in the app - * - * @param eventTrigger Event trigger to handle - * - * @retval true on success - * @retval false if error happened - */ -bool HandleSmokeCOTestEventTrigger(uint64_t eventTrigger); diff --git a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h new file mode 100644 index 00000000000000..a64ab5fc5d5aa7 --- /dev/null +++ b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h @@ -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. + */ + +#pragma once + +#include +#include + +/** + * @brief User handler for handling the test event trigger + * + * @note If TestEventTrigger is enabled, it needs to be implemented in the app + * + * @param eventTrigger Event trigger to handle + * + * @retval true on success + * @retval false if error happened + */ +bool HandleSmokeCOTestEventTrigger(uint64_t eventTrigger); + +namespace chip { + +enum class SmokeCOTrigger : uint64_t +{ + // Force alarm commands + kForceSmokeWarning = 0x005c'0000'00000090, + kForceCOWarning = 0x005c'0000'00000091, + kForceSmokeInterconnect = 0x005c'0000'00000092, + kForceMalfunction = 0x005c'0000'00000093, + kForceCOInterconnect = 0x005c'0000'00000094, + kForceLowBatteryWarning = 0x005c'0000'00000095, + kForceSmokeContaminationHigh = 0x005c'0000'00000096, + kForceSmokeContaminationLow = 0x005c'0000'00000097, + kForceSmokeSensitivityHigh = 0x005c'0000'00000098, + kForceSmokeSensitivityLow = 0x005c'0000'00000099, + kForceEndOfLife = 0x005c'0000'0000009a, + kForceSilence = 0x005c'0000'0000009b, + kForceSmokeCritical = 0x005c'0000'0000009c, + kForceCOCritical = 0x005c'0000'0000009d, + kForceLowBatteryCritical = 0x005c'0000'0000009e, + // Clear alarm commands + kClearSmoke = 0x005c'0000'000000a0, + kClearCO = 0x005c'0000'000000a1, + kClearSmokeInterconnect = 0x005c'0000'000000a2, + kClearMalfunction = 0x005c'0000'000000a3, + kClearCOInterconnect = 0x005c'0000'000000a4, + kClearBatteryLevelLow = 0x005c'0000'000000a5, + kClearContamination = 0x005c'0000'000000a6, + kClearSensitivity = 0x005c'0000'000000a8, + kClearEndOfLife = 0x005c'0000'000000aa, + kClearSilence = 0x005c'0000'000000ab +}; + +class SmokeCOTestEventTriggerHandler : public TestEventTriggerHandler +{ +public: + SmokeCOTestEventTriggerHandler() = default; + CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override + { + return HandleSmokeCOTestEventTrigger(eventTrigger) ? CHIP_NO_ERROR : CHIP_ERROR_INVALID_ARGUMENT; + } +}; + +} // namespace chip diff --git a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.cpp b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.cpp new file mode 100644 index 00000000000000..26a988b1c51450 --- /dev/null +++ b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.cpp @@ -0,0 +1,861 @@ +/* + * 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 "thread-network-diagnostics-provider.h" + +#include +#include +#include +#include + +#if (CHIP_DEVICE_CONFIG_ENABLE_THREAD && !CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK) +#include +#include + +#if CHIP_DEVICE_CONFIG_THREAD_FTD +#include +#endif // CHIP_DEVICE_CONFIG_THREAD_FTD +#endif // (CHIP_DEVICE_CONFIG_ENABLE_THREAD && !CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK) + +using namespace chip::DeviceLayer; + +namespace chip { +namespace app { +namespace Clusters { +namespace ThreadNetworkDiagnostics { + +/* + * @brief Get runtime value from the thread network based on the given attribute ID. + * The info is encoded via the AttributeValueEncoder. + * + * @param attributeId Id of the attribute for the requested info. + * @param aEncoder Encoder to encode the attribute value. + * + * @return CHIP_NO_ERROR = Succes. + * CHIP_ERROR_NOT_IMPLEMENTED = Runtime value for this attribute not yet available to send as reply + * Use standard read. + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE = Is not a Runtime readable attribute. Use standard read + * All other errors should be treated as a read error and reported as such. + * + * @note This function implementation can compile in 3 different outcomes + * (1) CHIP_DEVICE_CONFIG_ENABLE_THREAD && !CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK: + * - Generic implementation fetching the valid thread network data from the thread stack and encoding it respectively to + * the attributeID received. + * (2) CHIP_DEVICE_CONFIG_ENABLE_THREAD && CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK: + * - Encode a NULL value for nullable attributes or 0 for the others. + * - Devices using the ot-br-posix dbus stack have not yet provided the API to fetch the needed thread informations. + * (3) None of the conditions above + * - returns CHIP_ERROR_NOT_IMPLEMENTED. + */ +CHIP_ERROR WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder) +{ + CHIP_ERROR err; +#if (CHIP_DEVICE_CONFIG_ENABLE_THREAD && !CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK) + otInstance * otInst = ThreadStackMgrImpl().OTInstance(); + + if (!otDatasetIsCommissioned(otInst)) + { + // For the following nullable attributes of the cluster, encodeNull since + // thread instance cannot provide the relevant data when it is not currently configured. + // + // Note that RoutingRole is nullable but not listed here as thread provides + // valid data even when disabled or detached + switch (attributeId) + { + case Attributes::Channel::Id: + case Attributes::NetworkName::Id: + case Attributes::PanId::Id: + case Attributes::ExtendedPanId::Id: + case Attributes::MeshLocalPrefix::Id: + case Attributes::PartitionId::Id: + case Attributes::Weighting::Id: + case Attributes::DataVersion::Id: + case Attributes::StableDataVersion::Id: + case Attributes::LeaderRouterId::Id: + case Attributes::ActiveTimestamp::Id: + case Attributes::PendingTimestamp::Id: + case Attributes::Delay::Id: + case Attributes::SecurityPolicy::Id: + case Attributes::ChannelPage0Mask::Id: + case Attributes::OperationalDatasetComponents::Id: + return encoder.EncodeNull(); + } + } + + switch (attributeId) + { + case Attributes::Channel::Id: { + uint16_t channel = otLinkGetChannel(otInst); + err = encoder.Encode(channel); + } + break; + + case Attributes::RoutingRole::Id: { + using ThreadNetworkDiagnostics::RoutingRoleEnum; + RoutingRoleEnum routingRole; + otDeviceRole otRole = otThreadGetDeviceRole(otInst); + + if (otRole == OT_DEVICE_ROLE_DISABLED) + { + routingRole = RoutingRoleEnum::kUnspecified; + } + else if (otRole == OT_DEVICE_ROLE_DETACHED) + { + routingRole = RoutingRoleEnum::kUnassigned; + } + else if (otRole == OT_DEVICE_ROLE_ROUTER) + { + routingRole = RoutingRoleEnum::kRouter; + } + else if (otRole == OT_DEVICE_ROLE_LEADER) + { + routingRole = RoutingRoleEnum::kLeader; + } + else if (otRole == OT_DEVICE_ROLE_CHILD) + { + otLinkModeConfig linkMode = otThreadGetLinkMode(otInst); + + if (linkMode.mRxOnWhenIdle) + { + routingRole = RoutingRoleEnum::kEndDevice; +#if CHIP_DEVICE_CONFIG_THREAD_FTD + if (otThreadIsRouterEligible(otInst)) + { + routingRole = RoutingRoleEnum::kReed; + } +#endif + } + else + { + routingRole = RoutingRoleEnum::kSleepyEndDevice; + } + } + + err = encoder.Encode(routingRole); + } + break; + + case Attributes::NetworkName::Id: { + const char * networkName = otThreadGetNetworkName(otInst); + err = encoder.Encode(CharSpan::fromCharString(networkName)); + } + break; + + case Attributes::PanId::Id: { + uint16_t panId = otLinkGetPanId(otInst); + err = encoder.Encode(panId); + } + break; + + case Attributes::ExtendedPanId::Id: { + const otExtendedPanId * pExtendedPanid = otThreadGetExtendedPanId(otInst); + err = encoder.Encode(Encoding::BigEndian::Get64(pExtendedPanid->m8)); + } + break; + + case Attributes::MeshLocalPrefix::Id: { + uint8_t meshLocaPrefix[OT_MESH_LOCAL_PREFIX_SIZE + 1] = { 0 }; // + 1 to encode prefix Len in the octstr + + const otMeshLocalPrefix * pMeshLocalPrefix = otThreadGetMeshLocalPrefix(otInst); + meshLocaPrefix[0] = OT_IP6_PREFIX_BITSIZE; + + memcpy(&meshLocaPrefix[1], pMeshLocalPrefix->m8, OT_MESH_LOCAL_PREFIX_SIZE); + err = encoder.Encode(ByteSpan(meshLocaPrefix)); + } + break; + + case Attributes::OverrunCount::Id: { + uint64_t overrunCount = 0; // mOverrunCount; + err = encoder.Encode(overrunCount); + } + break; + + case Attributes::NeighborTable::Id: { + err = encoder.EncodeList([otInst](const auto & aEncoder) -> CHIP_ERROR { + constexpr uint16_t kFrameErrorRate100Percent = 0xffff; + constexpr uint16_t kMessageErrorRate100Percent = 0xffff; + + otNeighborInfo neighInfo; + otNeighborInfoIterator iterator = OT_NEIGHBOR_INFO_ITERATOR_INIT; + + while (otThreadGetNextNeighborInfo(otInst, &iterator, &neighInfo) == OT_ERROR_NONE) + { + Structs::NeighborTableStruct::Type neighborTable; + app::DataModel::Nullable averageRssi; + app::DataModel::Nullable lastRssi; + + if (neighInfo.mAverageRssi == OT_RADIO_RSSI_INVALID) + { + averageRssi.SetNull(); + } + else + { + // Thread average calculation already restrict mAverageRssi to be between -128 and 0 + averageRssi.SetNonNull(neighInfo.mAverageRssi); + } + + if (neighInfo.mLastRssi == OT_RADIO_RSSI_INVALID) + { + lastRssi.SetNull(); + } + else + { + lastRssi.SetNonNull(min(static_cast(0), neighInfo.mLastRssi)); + } + + neighborTable.averageRssi = averageRssi; + neighborTable.lastRssi = lastRssi; + neighborTable.extAddress = Encoding::BigEndian::Get64(neighInfo.mExtAddress.m8); + neighborTable.age = neighInfo.mAge; + neighborTable.rloc16 = neighInfo.mRloc16; + neighborTable.linkFrameCounter = neighInfo.mLinkFrameCounter; + neighborTable.mleFrameCounter = neighInfo.mMleFrameCounter; + neighborTable.lqi = neighInfo.mLinkQualityIn; + neighborTable.frameErrorRate = + static_cast((static_cast(neighInfo.mFrameErrorRate) * 100) / kFrameErrorRate100Percent); + neighborTable.messageErrorRate = + static_cast((static_cast(neighInfo.mMessageErrorRate) * 100) / kMessageErrorRate100Percent); + neighborTable.rxOnWhenIdle = neighInfo.mRxOnWhenIdle; + neighborTable.fullThreadDevice = neighInfo.mFullThreadDevice; + neighborTable.fullNetworkData = neighInfo.mFullNetworkData; + neighborTable.isChild = neighInfo.mIsChild; + + ReturnErrorOnFailure(aEncoder.Encode(neighborTable)); + } + + return CHIP_NO_ERROR; + }); + } + break; + + case Attributes::RouteTable::Id: { + err = encoder.EncodeList([otInst](const auto & aEncoder) -> CHIP_ERROR { + otRouterInfo routerInfo; + +#if CHIP_DEVICE_CONFIG_THREAD_FTD + uint8_t maxRouterId = otThreadGetMaxRouterId(otInst); + CHIP_ERROR chipErr = CHIP_ERROR_INCORRECT_STATE; + + for (uint8_t i = 0; i <= maxRouterId; i++) + { + if (otThreadGetRouterInfo(otInst, i, &routerInfo) == OT_ERROR_NONE) + { + Structs::RouteTableStruct::Type routeTable; + + routeTable.extAddress = Encoding::BigEndian::Get64(routerInfo.mExtAddress.m8); + routeTable.rloc16 = routerInfo.mRloc16; + routeTable.routerId = routerInfo.mRouterId; + routeTable.nextHop = routerInfo.mNextHop; + routeTable.pathCost = routerInfo.mPathCost; + routeTable.LQIIn = routerInfo.mLinkQualityIn; + routeTable.LQIOut = routerInfo.mLinkQualityOut; + routeTable.age = routerInfo.mAge; + routeTable.allocated = routerInfo.mAllocated; + routeTable.linkEstablished = routerInfo.mLinkEstablished; + + ReturnErrorOnFailure(aEncoder.Encode(routeTable)); + chipErr = CHIP_NO_ERROR; + } + } + + return chipErr; + +#else // OPENTHREAD_MTD + otError otErr = otThreadGetParentInfo(otInst, &routerInfo); + ReturnErrorOnFailure(Internal::MapOpenThreadError(otErr)); + + Structs::RouteTableStruct::Type routeTable; + + routeTable.extAddress = Encoding::BigEndian::Get64(routerInfo.mExtAddress.m8); + routeTable.rloc16 = routerInfo.mRloc16; + routeTable.routerId = routerInfo.mRouterId; + routeTable.nextHop = routerInfo.mNextHop; + routeTable.pathCost = routerInfo.mPathCost; + routeTable.LQIIn = routerInfo.mLinkQualityIn; + routeTable.LQIOut = routerInfo.mLinkQualityOut; + routeTable.age = routerInfo.mAge; + routeTable.allocated = routerInfo.mAllocated; + routeTable.linkEstablished = routerInfo.mLinkEstablished; + + ReturnErrorOnFailure(aEncoder.Encode(routeTable)); + return CHIP_NO_ERROR; +#endif + }); + } + break; + + case Attributes::PartitionId::Id: { + uint32_t partitionId = otThreadGetPartitionId(otInst); + err = encoder.Encode(partitionId); + } + break; + + case Attributes::Weighting::Id: { + uint8_t weight = otThreadGetLeaderWeight(otInst); + err = encoder.Encode(weight); + } + break; + + case Attributes::DataVersion::Id: { + uint8_t dataVersion = otNetDataGetVersion(otInst); + err = encoder.Encode(dataVersion); + } + break; + + case Attributes::StableDataVersion::Id: { + uint8_t stableVersion = otNetDataGetStableVersion(otInst); + err = encoder.Encode(stableVersion); + } + break; + + case Attributes::LeaderRouterId::Id: { + uint8_t leaderRouterId = otThreadGetLeaderRouterId(otInst); + err = encoder.Encode(leaderRouterId); + } + break; + + case Attributes::DetachedRoleCount::Id: { + uint16_t detachedRole = otThreadGetMleCounters(otInst)->mDetachedRole; + err = encoder.Encode(detachedRole); + } + break; + + case Attributes::ChildRoleCount::Id: { + uint16_t childRole = otThreadGetMleCounters(otInst)->mChildRole; + err = encoder.Encode(childRole); + } + break; + + case Attributes::RouterRoleCount::Id: { + uint16_t routerRole = otThreadGetMleCounters(otInst)->mRouterRole; + err = encoder.Encode(routerRole); + } + break; + + case Attributes::LeaderRoleCount::Id: { + uint16_t leaderRole = otThreadGetMleCounters(otInst)->mLeaderRole; + err = encoder.Encode(leaderRole); + } + break; + + case Attributes::AttachAttemptCount::Id: { + uint16_t attachAttempts = otThreadGetMleCounters(otInst)->mAttachAttempts; + err = encoder.Encode(attachAttempts); + } + break; + + case Attributes::PartitionIdChangeCount::Id: { + uint16_t partitionIdChanges = otThreadGetMleCounters(otInst)->mPartitionIdChanges; + err = encoder.Encode(partitionIdChanges); + } + break; + + case Attributes::BetterPartitionAttachAttemptCount::Id: { + uint16_t betterPartitionAttachAttempts = otThreadGetMleCounters(otInst)->mBetterPartitionAttachAttempts; + err = encoder.Encode(betterPartitionAttachAttempts); + } + break; + + case Attributes::ParentChangeCount::Id: { + uint16_t parentChanges = otThreadGetMleCounters(otInst)->mParentChanges; + err = encoder.Encode(parentChanges); + } + break; + + case Attributes::TxTotalCount::Id: { + uint32_t txTotal = otLinkGetCounters(otInst)->mTxTotal; + err = encoder.Encode(txTotal); + } + break; + + case Attributes::TxUnicastCount::Id: { + uint32_t txUnicast = otLinkGetCounters(otInst)->mTxUnicast; + err = encoder.Encode(txUnicast); + } + break; + + case Attributes::TxBroadcastCount::Id: { + uint32_t txBroadcast = otLinkGetCounters(otInst)->mTxBroadcast; + err = encoder.Encode(txBroadcast); + } + break; + + case Attributes::TxAckRequestedCount::Id: { + uint32_t txAckRequested = otLinkGetCounters(otInst)->mTxAckRequested; + err = encoder.Encode(txAckRequested); + } + break; + + case Attributes::TxAckedCount::Id: { + uint32_t txAcked = otLinkGetCounters(otInst)->mTxAcked; + err = encoder.Encode(txAcked); + } + break; + + case Attributes::TxNoAckRequestedCount::Id: { + uint32_t txNoAckRequested = otLinkGetCounters(otInst)->mTxNoAckRequested; + err = encoder.Encode(txNoAckRequested); + } + break; + + case Attributes::TxDataCount::Id: { + uint32_t txData = otLinkGetCounters(otInst)->mTxData; + err = encoder.Encode(txData); + } + break; + + case Attributes::TxDataPollCount::Id: { + uint32_t txDataPoll = otLinkGetCounters(otInst)->mTxDataPoll; + err = encoder.Encode(txDataPoll); + } + break; + + case Attributes::TxBeaconCount::Id: { + uint32_t txBeacon = otLinkGetCounters(otInst)->mTxBeacon; + err = encoder.Encode(txBeacon); + } + break; + + case Attributes::TxBeaconRequestCount::Id: { + uint32_t txBeaconRequest = otLinkGetCounters(otInst)->mTxBeaconRequest; + err = encoder.Encode(txBeaconRequest); + } + break; + + case Attributes::TxOtherCount::Id: { + uint32_t txOther = otLinkGetCounters(otInst)->mTxOther; + err = encoder.Encode(txOther); + } + break; + + case Attributes::TxRetryCount::Id: { + uint32_t txRetry = otLinkGetCounters(otInst)->mTxRetry; + err = encoder.Encode(txRetry); + } + break; + + case Attributes::TxDirectMaxRetryExpiryCount::Id: { + uint32_t txDirectMaxRetryExpiry = otLinkGetCounters(otInst)->mTxDirectMaxRetryExpiry; + err = encoder.Encode(txDirectMaxRetryExpiry); + } + break; + + case Attributes::TxIndirectMaxRetryExpiryCount::Id: { + uint32_t txIndirectMaxRetryExpiry = otLinkGetCounters(otInst)->mTxIndirectMaxRetryExpiry; + err = encoder.Encode(txIndirectMaxRetryExpiry); + } + break; + + case Attributes::TxErrCcaCount::Id: { + uint32_t txErrCca = otLinkGetCounters(otInst)->mTxErrCca; + err = encoder.Encode(txErrCca); + } + break; + + case Attributes::TxErrAbortCount::Id: { + uint32_t TxErrAbort = otLinkGetCounters(otInst)->mTxErrAbort; + err = encoder.Encode(TxErrAbort); + } + break; + + case Attributes::TxErrBusyChannelCount::Id: { + uint32_t TxErrBusyChannel = otLinkGetCounters(otInst)->mTxErrBusyChannel; + err = encoder.Encode(TxErrBusyChannel); + } + break; + + case Attributes::RxTotalCount::Id: { + uint32_t rxTotal = otLinkGetCounters(otInst)->mRxTotal; + err = encoder.Encode(rxTotal); + } + break; + + case Attributes::RxUnicastCount::Id: { + uint32_t rxUnicast = otLinkGetCounters(otInst)->mRxUnicast; + err = encoder.Encode(rxUnicast); + } + break; + + case Attributes::RxBroadcastCount::Id: { + uint32_t rxBroadcast = otLinkGetCounters(otInst)->mRxBroadcast; + err = encoder.Encode(rxBroadcast); + } + break; + + case Attributes::RxDataCount::Id: { + uint32_t rxData = otLinkGetCounters(otInst)->mRxData; + err = encoder.Encode(rxData); + } + break; + + case Attributes::RxDataPollCount::Id: { + uint32_t rxDataPoll = otLinkGetCounters(otInst)->mRxDataPoll; + err = encoder.Encode(rxDataPoll); + } + break; + + case Attributes::RxBeaconCount::Id: { + uint32_t rxBeacon = otLinkGetCounters(otInst)->mRxBeacon; + err = encoder.Encode(rxBeacon); + } + break; + + case Attributes::RxBeaconRequestCount::Id: { + uint32_t rxBeaconRequest = otLinkGetCounters(otInst)->mRxBeaconRequest; + err = encoder.Encode(rxBeaconRequest); + } + break; + + case Attributes::RxOtherCount::Id: { + uint32_t rxOther = otLinkGetCounters(otInst)->mRxOther; + err = encoder.Encode(rxOther); + } + break; + + case Attributes::RxAddressFilteredCount::Id: { + uint32_t rxAddressFiltered = otLinkGetCounters(otInst)->mRxAddressFiltered; + err = encoder.Encode(rxAddressFiltered); + } + break; + + case Attributes::RxDestAddrFilteredCount::Id: { + uint32_t rxDestAddrFiltered = otLinkGetCounters(otInst)->mRxDestAddrFiltered; + err = encoder.Encode(rxDestAddrFiltered); + } + break; + + case Attributes::RxDuplicatedCount::Id: { + uint32_t rxDuplicated = otLinkGetCounters(otInst)->mRxDuplicated; + err = encoder.Encode(rxDuplicated); + } + break; + + case Attributes::RxErrNoFrameCount::Id: { + uint32_t rxErrNoFrame = otLinkGetCounters(otInst)->mRxErrNoFrame; + err = encoder.Encode(rxErrNoFrame); + } + break; + + case Attributes::RxErrUnknownNeighborCount::Id: { + uint32_t rxErrUnknownNeighbor = otLinkGetCounters(otInst)->mRxErrUnknownNeighbor; + err = encoder.Encode(rxErrUnknownNeighbor); + } + break; + + case Attributes::RxErrInvalidSrcAddrCount::Id: { + uint32_t rxErrInvalidSrcAddr = otLinkGetCounters(otInst)->mRxErrInvalidSrcAddr; + err = encoder.Encode(rxErrInvalidSrcAddr); + } + break; + + case Attributes::RxErrSecCount::Id: { + uint32_t rxErrSec = otLinkGetCounters(otInst)->mRxErrSec; + err = encoder.Encode(rxErrSec); + } + break; + + case Attributes::RxErrFcsCount::Id: { + uint32_t rxErrFcs = otLinkGetCounters(otInst)->mRxErrFcs; + err = encoder.Encode(rxErrFcs); + } + break; + + case Attributes::RxErrOtherCount::Id: { + uint32_t rxErrOther = otLinkGetCounters(otInst)->mRxErrOther; + err = encoder.Encode(rxErrOther); + } + break; + + case Attributes::ActiveTimestamp::Id: { + otOperationalDataset activeDataset; + otError otErr = otDatasetGetActive(otInst, &activeDataset); + VerifyOrReturnError(otErr == OT_ERROR_NONE, Internal::MapOpenThreadError(otErr)); + uint64_t activeTimestamp = (activeDataset.mActiveTimestamp.mSeconds << 16) | (activeDataset.mActiveTimestamp.mTicks << 1) | + activeDataset.mActiveTimestamp.mAuthoritative; + err = encoder.Encode(activeTimestamp); + } + break; + + case Attributes::PendingTimestamp::Id: { + otOperationalDataset activeDataset; + otError otErr = otDatasetGetActive(otInst, &activeDataset); + VerifyOrReturnError(otErr == OT_ERROR_NONE, Internal::MapOpenThreadError(otErr)); + uint64_t pendingTimestamp = (activeDataset.mPendingTimestamp.mSeconds << 16) | + (activeDataset.mPendingTimestamp.mTicks << 1) | activeDataset.mPendingTimestamp.mAuthoritative; + err = encoder.Encode(pendingTimestamp); + } + break; + + case Attributes::Delay::Id: { + otOperationalDataset activeDataset; + otError otErr = otDatasetGetActive(otInst, &activeDataset); + VerifyOrReturnError(otErr == OT_ERROR_NONE, Internal::MapOpenThreadError(otErr)); + uint32_t delay = activeDataset.mDelay; + err = encoder.Encode(delay); + } + break; + + case Attributes::SecurityPolicy::Id: { + otOperationalDataset activeDataset; + otError otErr = otDatasetGetActive(otInst, &activeDataset); + VerifyOrReturnError(otErr == OT_ERROR_NONE, Internal::MapOpenThreadError(otErr)); + + Structs::SecurityPolicy::Type securityPolicy; + static_assert(sizeof(securityPolicy) == sizeof(activeDataset.mSecurityPolicy), + "securityPolicy Struct do not match otSecurityPolicy"); + uint16_t policyAsInts[2]; + static_assert(sizeof(policyAsInts) == sizeof(activeDataset.mSecurityPolicy), + "We're missing some members of otSecurityPolicy?"); + memcpy(&policyAsInts, &activeDataset.mSecurityPolicy, sizeof(policyAsInts)); + securityPolicy.rotationTime = policyAsInts[0]; + securityPolicy.flags = policyAsInts[1]; + err = encoder.Encode(securityPolicy); + } + break; + + case Attributes::ChannelPage0Mask::Id: { + otOperationalDataset activeDataset; + otError otErr = otDatasetGetActive(otInst, &activeDataset); + VerifyOrReturnError(otErr == OT_ERROR_NONE, Internal::MapOpenThreadError(otErr)); + + // In the resultant Octet string, the most significant bit of the left-most byte indicates channel 0 + // We have to bitswap the entire uint32_t before converting to octet string + uint32_t bitSwappedChannelMask = 0; + for (int i = 0, j = 31; i < 32; i++, j--) + { + bitSwappedChannelMask |= ((activeDataset.mChannelMask >> j) & 1) << i; + } + + uint8_t buffer[sizeof(uint32_t)] = { 0 }; + Encoding::BigEndian::Put32(buffer, bitSwappedChannelMask); + err = encoder.Encode(ByteSpan(buffer)); + } + break; + + case Attributes::OperationalDatasetComponents::Id: { + otOperationalDataset activeDataset; + otError otErr = otDatasetGetActive(otInst, &activeDataset); + VerifyOrReturnError(otErr == OT_ERROR_NONE, Internal::MapOpenThreadError(otErr)); + Structs::OperationalDatasetComponents::Type OpDatasetComponents; + + OpDatasetComponents.activeTimestampPresent = activeDataset.mComponents.mIsActiveTimestampPresent; + OpDatasetComponents.pendingTimestampPresent = activeDataset.mComponents.mIsPendingTimestampPresent; + OpDatasetComponents.masterKeyPresent = activeDataset.mComponents.mIsNetworkKeyPresent; + OpDatasetComponents.networkNamePresent = activeDataset.mComponents.mIsNetworkNamePresent; + OpDatasetComponents.extendedPanIdPresent = activeDataset.mComponents.mIsExtendedPanIdPresent; + OpDatasetComponents.meshLocalPrefixPresent = activeDataset.mComponents.mIsMeshLocalPrefixPresent; + OpDatasetComponents.delayPresent = activeDataset.mComponents.mIsDelayPresent; + OpDatasetComponents.panIdPresent = activeDataset.mComponents.mIsPanIdPresent; + OpDatasetComponents.channelPresent = activeDataset.mComponents.mIsChannelPresent; + OpDatasetComponents.pskcPresent = activeDataset.mComponents.mIsPskcPresent; + OpDatasetComponents.securityPolicyPresent = activeDataset.mComponents.mIsSecurityPolicyPresent; + OpDatasetComponents.channelMaskPresent = activeDataset.mComponents.mIsChannelMaskPresent; + + err = encoder.Encode(OpDatasetComponents); + } + break; + + case Attributes::ActiveNetworkFaultsList::Id: { + err = encoder.EncodeList([](const auto & aEncoder) -> CHIP_ERROR { + // TODO activeNetworkFaultsList isn't tracked. Encode the list of 4 entries at 0 none the less + NetworkFaultEnum activeNetworkFaultsList[4] = { NetworkFaultEnum(0) }; + for (auto fault : activeNetworkFaultsList) + { + ReturnErrorOnFailure(aEncoder.Encode(fault)); + } + + return CHIP_NO_ERROR; + }); + } + break; + + default: { + err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; + } + break; + } + +#elif (CHIP_DEVICE_CONFIG_ENABLE_THREAD && CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK) + switch (attributeId) + { + case Attributes::NeighborTable::Id: + case Attributes::RouteTable::Id: + case Attributes::ActiveNetworkFaultsList::Id: + err = encoder.EncodeEmptyList(); + break; + case Attributes::Channel::Id: + case Attributes::RoutingRole::Id: + case Attributes::NetworkName::Id: + case Attributes::PanId::Id: + case Attributes::ExtendedPanId::Id: + case Attributes::MeshLocalPrefix::Id: + case Attributes::PartitionId::Id: + case Attributes::Weighting::Id: + case Attributes::DataVersion::Id: + case Attributes::StableDataVersion::Id: + case Attributes::LeaderRouterId::Id: + case Attributes::ActiveTimestamp::Id: + case Attributes::PendingTimestamp::Id: + case Attributes::Delay::Id: + case Attributes::ChannelPage0Mask::Id: + case Attributes::SecurityPolicy::Id: + case Attributes::OperationalDatasetComponents::Id: + err = encoder.EncodeNull(); + break; + case Attributes::OverrunCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::DetachedRoleCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::ChildRoleCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RouterRoleCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::LeaderRoleCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::AttachAttemptCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::PartitionIdChangeCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::BetterPartitionAttachAttemptCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::ParentChangeCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxTotalCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxUnicastCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxBroadcastCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxAckRequestedCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxAckedCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxNoAckRequestedCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxDataCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxDataPollCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxBeaconCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxBeaconRequestCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxOtherCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxRetryCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxDirectMaxRetryExpiryCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxIndirectMaxRetryExpiryCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxErrCcaCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxErrAbortCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::TxErrBusyChannelCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxTotalCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxUnicastCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxBroadcastCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxDataCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxDataPollCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxBeaconCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxBeaconRequestCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxOtherCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxAddressFilteredCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxDestAddrFilteredCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxDuplicatedCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxErrNoFrameCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxErrUnknownNeighborCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxErrInvalidSrcAddrCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxErrSecCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxErrFcsCount::Id: + err = encoder.Encode(static_cast(0)); + break; + case Attributes::RxErrOtherCount::Id: + err = encoder.Encode(static_cast(0)); + break; + default: + err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; + break; + } +#else + err = CHIP_ERROR_NOT_IMPLEMENTED; +#endif // (CHIP_DEVICE_CONFIG_ENABLE_THREAD && !CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK) + return err; +} + +} // namespace ThreadNetworkDiagnostics +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.cpp b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.h similarity index 53% rename from src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.cpp rename to src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.h index 210ab401bc2221..8b1a2a5640ce38 100644 --- a/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.cpp +++ b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.h @@ -1,6 +1,6 @@ /* - * * 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. @@ -15,26 +15,21 @@ * limitations under the License. */ -#include "EnergyReportingTestEventTriggerDelegate.h" +#pragma once -namespace chip { +#include +#include +#include +#include -bool EnergyReportingTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const -{ - return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); -} +namespace chip { +namespace app { +namespace Clusters { +namespace ThreadNetworkDiagnostics { -CHIP_ERROR EnergyReportingTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) -{ - if (HandleEnergyReportingTestEventTrigger(eventTrigger)) - { - return CHIP_NO_ERROR; - } - if (mOtherDelegate != nullptr) - { - return mOtherDelegate->HandleEventTrigger(eventTrigger); - } - return CHIP_ERROR_INVALID_ARGUMENT; -} +CHIP_ERROR WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); +} // namespace ThreadNetworkDiagnostics +} // namespace Clusters +} // namespace app } // namespace chip diff --git a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp index 9908fc77c91334..cae2948e8e970e 100644 --- a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp +++ b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include #include -#include using namespace chip; using namespace chip::app; @@ -125,7 +125,7 @@ CHIP_ERROR ThreadDiagosticsAttrAccess::Read(const ConcreteReadAttributePath & aP case ThreadNetworkDiagnostics::Attributes::PendingTimestamp::Id: case ThreadNetworkDiagnostics::Attributes::Delay::Id: case ThreadNetworkDiagnostics::Attributes::ChannelPage0Mask::Id: - return ConnectivityMgr().WriteThreadNetworkDiagnosticAttributeToTlv(aPath.mAttributeId, aEncoder); + return WriteThreadNetworkDiagnosticAttributeToTlv(aPath.mAttributeId, aEncoder); default: break; } diff --git a/src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.cpp b/src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.cpp index 0f6968f98e5826..30481d8ddf5cbc 100644 --- a/src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.cpp +++ b/src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.cpp @@ -40,6 +40,7 @@ #include #include #include +#include using namespace chip; using namespace chip::app; @@ -335,7 +336,7 @@ CHIP_ERROR SetValveLevel(EndpointId ep, DataModel::Nullable level, Data VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == AutoCloseTime::SetNull(ep), attribute_error); } #else - return CHIP_FAILURE; + return CHIP_ERROR_NOT_IMPLEMENTED; #endif // ZCL_USING_TIME_SYNCHRONIZATION_CLUSTER_SERVER } diff --git a/src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.h b/src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.h index 6f46e8cc6356e4..5e94c000aeab27 100644 --- a/src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.h +++ b/src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.h @@ -40,7 +40,7 @@ void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate); Delegate * GetDefaultDelegate(EndpointId endpoint); CHIP_ERROR CloseValve(chip::EndpointId ep); -CHIP_ERROR SetValveLevel(chip::EndpointId ep, chip::Percent level, DataModel::Nullable openDuration); +CHIP_ERROR SetValveLevel(chip::EndpointId ep, DataModel::Nullable level, DataModel::Nullable openDuration); CHIP_ERROR UpdateCurrentLevel(chip::EndpointId ep, chip::Percent currentLevel); CHIP_ERROR UpdateCurrentState(chip::EndpointId ep, ValveConfigurationAndControl::ValveStateEnum currentState); CHIP_ERROR EmitValveFault(chip::EndpointId ep, chip::BitMask fault); 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/DefaultICDClientStorage.h b/src/app/icd/client/DefaultICDClientStorage.h index 1f6c2f8eb14a2c..7306dbafdf65d2 100644 --- a/src/app/icd/client/DefaultICDClientStorage.h +++ b/src/app/icd/client/DefaultICDClientStorage.h @@ -53,6 +53,28 @@ class DefaultICDClientStorage : public ICDClientStorage public: using ICDClientInfoIterator = CommonIterator; + // ICDClientInfoIterator wrapper to release ICDClientInfoIterator when it is out of scope + class ICDClientInfoIteratorWrapper + { + public: + ICDClientInfoIteratorWrapper(ICDClientInfoIterator * apICDClientInfoIterator) + { + mpICDClientInfoIterator = apICDClientInfoIterator; + } + + ~ICDClientInfoIteratorWrapper() + { + if (mpICDClientInfoIterator != nullptr) + { + mpICDClientInfoIterator->Release(); + mpICDClientInfoIterator = nullptr; + } + } + + private: + ICDClientInfoIterator * mpICDClientInfoIterator = nullptr; + }; + static constexpr size_t kIteratorsMax = CHIP_CONFIG_MAX_ICD_CLIENTS_INFO_STORAGE_CONCURRENT_ITERATORS; CHIP_ERROR Init(PersistentStorageDelegate * clientInfoStore, Crypto::SymmetricKeystore * keyStore); diff --git a/src/app/icd/BUILD.gn b/src/app/icd/server/BUILD.gn similarity index 84% rename from src/app/icd/BUILD.gn rename to src/app/icd/server/BUILD.gn index ba72052fffbffa..ee2b2be0034c5c 100644 --- a/src/app/icd/BUILD.gn +++ b/src/app/icd/server/BUILD.gn @@ -14,13 +14,13 @@ import("//build_overrides/chip.gni") import("${chip_root}/build/chip/buildconfig_header.gni") -import("icd.gni") +import("${chip_root}/src/app/icd/icd.gni") # ICD Server sources and configurations -buildconfig_header("icd_buildconfig") { - header = "ICDBuildConfig.h" - header_dir = "app/icd" +buildconfig_header("icd-server-buildconfig") { + header = "ICDServerBuildConfig.h" + header_dir = "app/icd/server" defines = [ "CHIP_CONFIG_ENABLE_ICD_SERVER=${chip_enable_icd_server}", @@ -29,13 +29,13 @@ buildconfig_header("icd_buildconfig") { "ICD_ENFORCE_SIT_SLOW_POLL_LIMIT=${icd_enforce_sit_slow_poll_limit}", ] - visibility = [ ":icd_config" ] + visibility = [ ":icd-server-config" ] } -source_set("icd_config") { - sources = [ "ICDConfig.h" ] +source_set("icd-server-config") { + sources = [ "ICDServerConfig.h" ] - deps = [ ":icd_buildconfig" ] + deps = [ ":icd-server-buildconfig" ] } source_set("observer") { @@ -49,7 +49,7 @@ source_set("notifier") { ] deps = [ - ":icd_config", + ":icd-server-config", "${chip_root}/src/lib/core", ] } @@ -62,7 +62,7 @@ source_set("manager") { "ICDManager.h", ] - deps = [ ":icd_config" ] + deps = [ ":icd-server-config" ] public_deps = [ ":configuration-data", @@ -70,7 +70,7 @@ source_set("manager") { ":notifier", ":observer", ":sender", - "${chip_root}/src/app:interaction-model", + "${chip_root}/src/app:subscription-manager", "${chip_root}/src/credentials:credentials", ] } @@ -112,7 +112,8 @@ source_set("configuration-data") { ] deps = [ - ":icd_config", + ":icd-server-config", "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", ] } diff --git a/src/app/icd/ICDCheckInSender.cpp b/src/app/icd/server/ICDCheckInSender.cpp similarity index 97% rename from src/app/icd/ICDCheckInSender.cpp rename to src/app/icd/server/ICDCheckInSender.cpp index 69f47137cdec4f..21bcc336b0d357 100644 --- a/src/app/icd/ICDCheckInSender.cpp +++ b/src/app/icd/server/ICDCheckInSender.cpp @@ -15,9 +15,9 @@ * limitations under the License. */ -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/app/icd/ICDCheckInSender.h b/src/app/icd/server/ICDCheckInSender.h similarity index 97% rename from src/app/icd/ICDCheckInSender.h rename to src/app/icd/server/ICDCheckInSender.h index a9d7919aaaaf28..b681bec149f667 100644 --- a/src/app/icd/ICDCheckInSender.h +++ b/src/app/icd/server/ICDCheckInSender.h @@ -16,7 +16,7 @@ */ #pragma once -#include +#include #include #include diff --git a/src/app/icd/ICDConfigurationData.cpp b/src/app/icd/server/ICDConfigurationData.cpp similarity index 54% rename from src/app/icd/ICDConfigurationData.cpp rename to src/app/icd/server/ICDConfigurationData.cpp index 4df2ca75f217b9..332e7bbebc88b4 100644 --- a/src/app/icd/ICDConfigurationData.cpp +++ b/src/app/icd/server/ICDConfigurationData.cpp @@ -16,7 +16,8 @@ */ #include "ICDConfigurationData.h" -#include +#include +#include namespace chip { @@ -36,4 +37,22 @@ System::Clock::Milliseconds32 ICDConfigurationData::GetSlowPollingInterval() return mSlowPollingInterval; } +CHIP_ERROR ICDConfigurationData::SetModeDurations(Optional activeModeDuration_ms, Optional idleModeDuration_ms) +{ + VerifyOrReturnError(activeModeDuration_ms.HasValue() || idleModeDuration_ms.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; + + 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); + + mIdleModeDuration_s = tmpIdleModeDuration_s; + mActiveModeDuration_ms = tmpActiveModeDuration_ms; + + return CHIP_NO_ERROR; +} + } // namespace chip diff --git a/src/app/icd/ICDConfigurationData.h b/src/app/icd/server/ICDConfigurationData.h similarity index 72% rename from src/app/icd/ICDConfigurationData.h rename to src/app/icd/server/ICDConfigurationData.h index 48f3966a5e5948..6668bdd216f0ca 100644 --- a/src/app/icd/ICDConfigurationData.h +++ b/src/app/icd/server/ICDConfigurationData.h @@ -17,14 +17,21 @@ #pragma once +#include +#include #include #include namespace chip { namespace app { -// Forward declaration of ICDManager to allow it to be friend with ICDConfigurationData +// Forward declaration of ICDManager to allow it to be friend with ICDConfigurationData. class ICDManager; + +// Forward declaration of TestICDManager to allow it to be friend with the ICDConfigurationData. +// Used in unit tests +class TestICDManager; + } // namespace app /** @@ -47,9 +54,9 @@ class ICDConfigurationData static ICDConfigurationData & GetInstance() { return instance; }; - uint32_t GetIdleModeDurationSec() { return mIdleInterval_s; } + uint32_t GetIdleModeDurationSec() { return mIdleModeDuration_s; } - uint32_t GetActiveModeDurationMs() { return mActiveInterval_ms; } + uint32_t GetActiveModeDurationMs() { return mActiveModeDuration_ms; } uint16_t GetActiveModeThresholdMs() { return mActiveThreshold_ms; } @@ -87,8 +94,9 @@ class ICDConfigurationData // ICD related information is managed by the ICDManager but stored in the ICDConfigurationData to enable consummers to access it // without creating a circular dependency. To avoid allowing consummers changing the state of the ICD mode without going through // the ICDManager, the ICDManager is a friend that can access the private setters. If a consummer needs to be notified when a - // value is changed, they can leverage the Observer events the ICDManager generates. See src/app/icd/ICDStateObserver.h + // value is changed, they can leverage the Observer events the ICDManager generates. See src/app/icd/server/ICDStateObserver.h friend class chip::app::ICDManager; + friend class chip::app::TestICDManager; void SetICDMode(ICDMode mode) { mICDMode = mode; }; void SetICDCounter(uint32_t count) { mICDCounter = count; } @@ -97,15 +105,33 @@ class ICDConfigurationData static constexpr uint32_t kMinLitActiveModeThreshold_ms = 5000; - static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) <= 64800, + /** + * @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 + * 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 + * is returned if idleModeDuration_ms is smaller than 1000 ms + * 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); + + static constexpr uint32_t kMaxIdleModeDuration_s = (18 * kSecondsPerHour); + static constexpr uint32_t kMinIdleModeDuration_s = 1; + + static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) <= kMaxIdleModeDuration_s, "Spec requires the IdleModeDuration to be equal or inferior to 64800s."); - static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) >= 1, + static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) >= kMinIdleModeDuration_s, "Spec requires the IdleModeDuration to be equal or greater to 1s."); - uint32_t mIdleInterval_s = CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC; + uint32_t mIdleModeDuration_s = CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC; static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS) <= (CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC * kMillisecondsPerSecond), "Spec requires the IdleModeDuration be equal or greater to the ActiveModeDuration."); - uint32_t mActiveInterval_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS; + uint32_t mActiveModeDuration_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS; uint16_t mActiveThreshold_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS; diff --git a/src/app/icd/ICDManager.cpp b/src/app/icd/server/ICDManager.cpp similarity index 90% rename from src/app/icd/ICDManager.cpp rename to src/app/icd/server/ICDManager.cpp index 99e8e950dd853f..2fbf7ae8fb39b9 100644 --- a/src/app/icd/ICDManager.cpp +++ b/src/app/icd/server/ICDManager.cpp @@ -18,11 +18,10 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -41,12 +40,13 @@ static_assert(UINT8_MAX >= CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS, "ICDManager::mOpenExchangeContextCount cannot hold count for the max exchange count"); void ICDManager::Init(PersistentStorageDelegate * storage, FabricTable * fabricTable, Crypto::SymmetricKeystore * symmetricKeystore, - Messaging::ExchangeManager * exchangeManager) + Messaging::ExchangeManager * exchangeManager, SubscriptionsInfoProvider * manager) { VerifyOrDie(storage != nullptr); VerifyOrDie(fabricTable != nullptr); VerifyOrDie(symmetricKeystore != nullptr); VerifyOrDie(exchangeManager != nullptr); + VerifyOrDie(manager != nullptr); // LIT ICD Verification Checks if (SupportsFeature(Feature::kLongIdleTimeSupport)) @@ -63,11 +63,13 @@ void ICDManager::Init(PersistentStorageDelegate * storage, FabricTable * fabricT // "LIT support is required for slow polling intervals superior to 15 seconds"); } - mStorage = storage; - mFabricTable = fabricTable; VerifyOrDie(ICDNotifier::GetInstance().Subscribe(this) == CHIP_NO_ERROR); + + mStorage = storage; + mFabricTable = fabricTable; mSymmetricKeystore = symmetricKeystore; mExchangeManager = exchangeManager; + mSubManager = manager; VerifyOrDie(InitCounter() == CHIP_NO_ERROR); @@ -78,14 +80,19 @@ void ICDManager::Init(PersistentStorageDelegate * storage, FabricTable * fabricT void ICDManager::Shutdown() { ICDNotifier::GetInstance().Unsubscribe(this); + // cancel any running timer of the icd DeviceLayer::SystemLayer().CancelTimer(OnIdleModeDone, this); DeviceLayer::SystemLayer().CancelTimer(OnActiveModeDone, this); DeviceLayer::SystemLayer().CancelTimer(OnTransitionToIdle, this); + ICDConfigurationData::GetInstance().SetICDMode(ICDConfigurationData::ICDMode::SIT); mOperationalState = OperationalState::ActiveMode; - mStorage = nullptr; - mFabricTable = nullptr; + + mStorage = nullptr; + mFabricTable = nullptr; + mSubManager = nullptr; + mStateObserverPool.ReleaseAll(); mICDSenderPool.ReleaseAll(); } @@ -137,8 +144,7 @@ void ICDManager::SendCheckInMsgs() continue; } - bool active = - InteractionModelEngine::GetInstance()->SubjectHasActiveSubscription(entry.fabricIndex, entry.monitoredSubject); + bool active = mSubManager->SubjectHasActiveSubscription(entry.fabricIndex, entry.monitoredSubject); if (active) { continue; @@ -272,7 +278,9 @@ void ICDManager::UpdateOperationState(OperationalState state) mOperationalState = OperationalState::IdleMode; // When the active mode interval is 0, we stay in idleMode until a notification brings the icd into active mode - if (ICDConfigurationData::GetInstance().GetActiveModeDurationMs() > 0) + // 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()) { uint32_t idleModeDuration = ICDConfigurationData::GetInstance().GetIdleModeDurationSec(); DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds32(idleModeDuration), OnIdleModeDone, this); @@ -538,5 +546,44 @@ void ICDManager::postObserverEvent(ObserverEventType event) } }); } + +bool ICDManager::CheckInMessagesWouldBeSent() +{ + for (const auto & fabricInfo : *mFabricTable) + { + uint16_t supported_clients = ICDConfigurationData::GetInstance().GetClientsSupportedPerFabric(); + + ICDMonitoringTable table(*mStorage, fabricInfo.GetFabricIndex(), supported_clients /*Table entry limit*/, + mSymmetricKeystore); + if (table.IsEmpty()) + { + continue; + } + + for (uint16_t i = 0; i < table.Limit(); i++) + { + ICDMonitoringEntry entry(mSymmetricKeystore); + CHIP_ERROR err = table.Get(i, entry); + if (err == CHIP_ERROR_NOT_FOUND) + { + break; + } + + if (err != CHIP_NO_ERROR) + { + // Try to fetch the next entry upon failure (should not happen). + ChipLogError(AppServer, "Failed to retrieved ICDMonitoring entry, will try next entry."); + continue; + } + + // At least one registration would require a Check-In message + VerifyOrReturnValue(mSubManager->SubjectHasActiveSubscription(entry.fabricIndex, entry.monitoredSubject), true); + } + } + + // None of the registrations would require a Check-In message + return false; +} + } // namespace app } // namespace chip diff --git a/src/app/icd/ICDManager.h b/src/app/icd/server/ICDManager.h similarity index 83% rename from src/app/icd/ICDManager.h rename to src/app/icd/server/ICDManager.h index 81011c688858c3..12ae535ce2ed47 100644 --- a/src/app/icd/ICDManager.h +++ b/src/app/icd/server/ICDManager.h @@ -17,11 +17,12 @@ #pragma once #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -66,7 +67,7 @@ class ICDManager : public ICDListener ICDManager() {} void Init(PersistentStorageDelegate * storage, FabricTable * fabricTable, Crypto::SymmetricKeystore * symmetricKeyStore, - Messaging::ExchangeManager * exchangeManager); + Messaging::ExchangeManager * exchangeManager, SubscriptionsInfoProvider * manager); void Shutdown(); void UpdateICDMode(); void UpdateOperationState(OperationalState state); @@ -100,7 +101,7 @@ class ICDManager : public ICDListener #endif // Implementation of ICDListener functions. - // Callers must origin from the chip task context or be holding the ChipStack lock. + // Callers must origin from the chip task context or hold the ChipStack lock. void OnNetworkActivity() override; void OnKeepActiveRequest(KeepActiveFlags request) override; void OnActiveRequestWithdrawal(KeepActiveFlags request) override; @@ -129,15 +130,28 @@ class ICDManager : public ICDListener uint8_t mCheckInRequestCount = 0; private: + /** + * @brief Function checks if at least one client registration would require a Check-In message + * + * @return true At least one registration would require an Check-In message if we were entering ActiveMode. + * @return false None of the registration would require a Check-In message either because there are no registration or because + * they all have associated subscriptions. + */ + bool CheckInMessagesWouldBeSent(); + KeepActiveFlags mKeepActiveFlags{ 0 }; // Initialize mOperationalState to ActiveMode so the init sequence at bootup triggers the IdleMode behaviour first. - OperationalState mOperationalState = OperationalState::ActiveMode; + OperationalState mOperationalState = OperationalState::ActiveMode; + PersistentStorageDelegate * mStorage = nullptr; FabricTable * mFabricTable = nullptr; Messaging::ExchangeManager * mExchangeManager = nullptr; - bool mTransitionToIdleCalled = false; Crypto::SymmetricKeystore * mSymmetricKeystore = nullptr; + SubscriptionsInfoProvider * mSubManager = nullptr; + + bool mTransitionToIdleCalled = false; + ObjectPool mStateObserverPool; ObjectPool mICDSenderPool; diff --git a/src/app/icd/ICDMonitoringTable.cpp b/src/app/icd/server/ICDMonitoringTable.cpp similarity index 100% rename from src/app/icd/ICDMonitoringTable.cpp rename to src/app/icd/server/ICDMonitoringTable.cpp diff --git a/src/app/icd/ICDMonitoringTable.h b/src/app/icd/server/ICDMonitoringTable.h similarity index 100% rename from src/app/icd/ICDMonitoringTable.h rename to src/app/icd/server/ICDMonitoringTable.h diff --git a/src/app/icd/ICDNotifier.cpp b/src/app/icd/server/ICDNotifier.cpp similarity index 98% rename from src/app/icd/ICDNotifier.cpp rename to src/app/icd/server/ICDNotifier.cpp index 8266c2a2ea6e87..4df2379d065131 100644 --- a/src/app/icd/ICDNotifier.cpp +++ b/src/app/icd/server/ICDNotifier.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/src/app/icd/ICDNotifier.h b/src/app/icd/server/ICDNotifier.h similarity index 99% rename from src/app/icd/ICDNotifier.h rename to src/app/icd/server/ICDNotifier.h index bde16ff53f984e..1223732e3fc05f 100644 --- a/src/app/icd/ICDNotifier.h +++ b/src/app/icd/server/ICDNotifier.h @@ -16,7 +16,7 @@ */ #pragma once -#include +#include #include #include diff --git a/src/app/icd/ICDConfig.h b/src/app/icd/server/ICDServerConfig.h similarity index 93% rename from src/app/icd/ICDConfig.h rename to src/app/icd/server/ICDServerConfig.h index 4c85d39f83e9cf..aca74dac301efa 100644 --- a/src/app/icd/ICDConfig.h +++ b/src/app/icd/server/ICDServerConfig.h @@ -18,5 +18,5 @@ #pragma once #if CHIP_HAVE_CONFIG_H -#include +#include #endif diff --git a/src/app/icd/ICDStateObserver.h b/src/app/icd/server/ICDStateObserver.h similarity index 100% rename from src/app/icd/ICDStateObserver.h rename to src/app/icd/server/ICDStateObserver.h diff --git a/src/app/reporting/Engine.cpp b/src/app/reporting/Engine.cpp index f230e307544358..80dec7ed6d3cd1 100644 --- a/src/app/reporting/Engine.cpp +++ b/src/app/reporting/Engine.cpp @@ -23,9 +23,9 @@ * */ -#include +#include #if CHIP_CONFIG_ENABLE_ICD_SERVER -#include // nogncheck +#include // nogncheck #endif #include #include @@ -38,6 +38,9 @@ using namespace chip::Access; namespace chip { namespace app { namespace reporting { + +Engine::Engine(InteractionModelEngine * apImEngine) : mpImEngine(apImEngine) {} + CHIP_ERROR Engine::Init() { mNumReportsInFlight = 0; @@ -616,7 +619,7 @@ CHIP_ERROR Engine::ScheduleRun() return CHIP_NO_ERROR; } - Messaging::ExchangeManager * exchangeManager = InteractionModelEngine::GetInstance()->GetExchangeManager(); + Messaging::ExchangeManager * exchangeManager = mpImEngine->GetExchangeManager(); if (exchangeManager == nullptr) { return CHIP_ERROR_INCORRECT_STATE; @@ -640,17 +643,16 @@ void Engine::Run() { uint32_t numReadHandled = 0; - InteractionModelEngine * imEngine = InteractionModelEngine::GetInstance(); - // We may be deallocating read handlers as we go. Track how many we had // initially, so we make sure to go through all of them. - size_t initialAllocated = imEngine->mReadHandlers.Allocated(); + size_t initialAllocated = mpImEngine->mReadHandlers.Allocated(); while ((mNumReportsInFlight < CHIP_IM_MAX_REPORTS_IN_FLIGHT) && (numReadHandled < initialAllocated)) { - ReadHandler * readHandler = imEngine->ActiveHandlerAt(mCurReadHandlerIdx % (uint32_t) imEngine->mReadHandlers.Allocated()); + ReadHandler * readHandler = + mpImEngine->ActiveHandlerAt(mCurReadHandlerIdx % (uint32_t) mpImEngine->mReadHandlers.Allocated()); VerifyOrDie(readHandler != nullptr); - if (readHandler->ShouldReportUnscheduled() || imEngine->GetReportScheduler()->IsReportableNow(readHandler)) + if (readHandler->ShouldReportUnscheduled() || mpImEngine->GetReportScheduler()->IsReportableNow(readHandler)) { mRunningReadHandler = readHandler; @@ -674,14 +676,14 @@ void Engine::Run() // This isn't strictly necessary, but does make it easier to debug issues in this code if they // do arise. // - if (mCurReadHandlerIdx >= imEngine->mReadHandlers.Allocated()) + if (mCurReadHandlerIdx >= mpImEngine->mReadHandlers.Allocated()) { mCurReadHandlerIdx = 0; } bool allReadClean = true; - imEngine->mReadHandlers.ForEachActiveObject([&allReadClean](ReadHandler * handler) { + mpImEngine->mReadHandlers.ForEachActiveObject([&allReadClean](ReadHandler * handler) { if (handler->IsDirty()) { allReadClean = false; @@ -839,26 +841,25 @@ CHIP_ERROR Engine::SetDirty(AttributePathParams & aAttributePath) BumpDirtySetGeneration(); bool intersectsInterestPath = false; - InteractionModelEngine::GetInstance()->mReadHandlers.ForEachActiveObject( - [&aAttributePath, &intersectsInterestPath](ReadHandler * handler) { - // We call AttributePathIsDirty for both read interactions and subscribe interactions, since we may send inconsistent - // attribute data between two chunks. AttributePathIsDirty will not schedule a new run for read handlers which are - // waiting for a response to the last message chunk for read interactions. - if (handler->CanStartReporting() || handler->IsAwaitingReportResponse()) + mpImEngine->mReadHandlers.ForEachActiveObject([&aAttributePath, &intersectsInterestPath](ReadHandler * handler) { + // We call AttributePathIsDirty for both read interactions and subscribe interactions, since we may send inconsistent + // attribute data between two chunks. AttributePathIsDirty will not schedule a new run for read handlers which are + // waiting for a response to the last message chunk for read interactions. + if (handler->CanStartReporting() || handler->IsAwaitingReportResponse()) + { + for (auto object = handler->GetAttributePathList(); object != nullptr; object = object->mpNext) { - for (auto object = handler->GetAttributePathList(); object != nullptr; object = object->mpNext) + if (object->mValue.Intersects(aAttributePath)) { - if (object->mValue.Intersects(aAttributePath)) - { - handler->AttributePathIsDirty(aAttributePath); - intersectsInterestPath = true; - break; - } + handler->AttributePathIsDirty(aAttributePath); + intersectsInterestPath = true; + break; } } + } - return Loop::Continue; - }); + return Loop::Continue; + }); if (!intersectsInterestPath) { @@ -899,7 +900,7 @@ void Engine::OnReportConfirm() void Engine::GetMinEventLogPosition(uint32_t & aMinLogPosition) { - InteractionModelEngine::GetInstance()->mReadHandlers.ForEachActiveObject([&aMinLogPosition](ReadHandler * handler) { + mpImEngine->mReadHandlers.ForEachActiveObject([&aMinLogPosition](ReadHandler * handler) { if (handler->IsType(ReadHandler::InteractionType::Read)) { return Loop::Continue; @@ -934,13 +935,13 @@ CHIP_ERROR Engine::ScheduleEventDelivery(ConcreteEventPath & aPath, uint32_t aBy // we don't need to call schedule run for event. // If schedule run is called, actually we would not delivery events as well. // Just wanna save one schedule run here - if (InteractionModelEngine::GetInstance()->mEventPathPool.Allocated() == 0) + if (mpImEngine->mEventPathPool.Allocated() == 0) { return CHIP_NO_ERROR; } bool isUrgentEvent = false; - InteractionModelEngine::GetInstance()->mReadHandlers.ForEachActiveObject([&aPath, &isUrgentEvent](ReadHandler * handler) { + mpImEngine->mReadHandlers.ForEachActiveObject([&aPath, &isUrgentEvent](ReadHandler * handler) { if (handler->IsType(ReadHandler::InteractionType::Read)) { return Loop::Continue; @@ -971,7 +972,7 @@ CHIP_ERROR Engine::ScheduleEventDelivery(ConcreteEventPath & aPath, uint32_t aBy void Engine::ScheduleUrgentEventDeliverySync(Optional fabricIndex) { - InteractionModelEngine::GetInstance()->mReadHandlers.ForEachActiveObject([fabricIndex](ReadHandler * handler) { + mpImEngine->mReadHandlers.ForEachActiveObject([fabricIndex](ReadHandler * handler) { if (handler->IsType(ReadHandler::InteractionType::Read)) { return Loop::Continue; diff --git a/src/app/reporting/Engine.h b/src/app/reporting/Engine.h index 5a8638185549f3..01115b96d6f1a7 100644 --- a/src/app/reporting/Engine.h +++ b/src/app/reporting/Engine.h @@ -25,6 +25,7 @@ #pragma once #include +#include #include #include #include @@ -56,6 +57,11 @@ namespace reporting { class Engine { public: + /** + * Constructor Engine with a valid InteractionModelEngine pointer. + */ + Engine(InteractionModelEngine * apImEngine); + /** * Initializes the reporting engine. Should only be called once. * @@ -279,6 +285,8 @@ class Engine uint32_t mReservedSize = 0; uint32_t mMaxAttributesPerChunk = UINT32_MAX; #endif + + InteractionModelEngine * mpImEngine = nullptr; }; }; // namespace reporting diff --git a/src/app/reporting/ReportScheduler.h b/src/app/reporting/ReportScheduler.h index d823c2f18114c9..622a10a80c3bd2 100644 --- a/src/app/reporting/ReportScheduler.h +++ b/src/app/reporting/ReportScheduler.h @@ -19,7 +19,7 @@ #pragma once #include -#include +#include #include #include diff --git a/src/app/server/BUILD.gn b/src/app/server/BUILD.gn index 60f88cf08cae8f..7e441518c9b133 100644 --- a/src/app/server/BUILD.gn +++ b/src/app/server/BUILD.gn @@ -51,8 +51,8 @@ static_library("server") { public_deps = [ "${chip_root}/src/app", - "${chip_root}/src/app/icd:icd_config", - "${chip_root}/src/app/icd:observer", + "${chip_root}/src/app/icd/server:icd-server-config", + "${chip_root}/src/app/icd/server:observer", "${chip_root}/src/lib/address_resolve", "${chip_root}/src/lib/dnssd", "${chip_root}/src/messaging", @@ -62,7 +62,12 @@ 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:notifier" ] + public_deps += [ "${chip_root}/src/app/icd/server:notifier" ] } } diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index 8e37d0aa0d76e5..01509a41a2acd0 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -15,10 +15,10 @@ * limitations under the License. */ -#include +#include #include #if CHIP_CONFIG_ENABLE_ICD_SERVER -#include // nogncheck +#include // nogncheck #endif #include #include diff --git a/src/app/server/Dnssd.h b/src/app/server/Dnssd.h index 6a9af18cda1dea..559cac6a464b2f 100644 --- a/src/app/server/Dnssd.h +++ b/src/app/server/Dnssd.h @@ -17,11 +17,11 @@ #pragma once -#include +#include #if CHIP_CONFIG_ENABLE_ICD_SERVER -#include // nogncheck +#include // nogncheck #endif -#include +#include #include #include #include diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 4a0fa91f56d520..3c33c45537d5ef 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -339,7 +339,8 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams) mICDManager.RegisterObserver(mReportScheduler); mICDManager.RegisterObserver(&app::DnssdServer::Instance()); - mICDManager.Init(mDeviceStorage, &GetFabricTable(), mSessionKeystore, &mExchangeMgr); + mICDManager.Init(mDeviceStorage, &GetFabricTable(), mSessionKeystore, &mExchangeMgr, + chip::app::InteractionModelEngine::GetInstance()); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER // This code is necessary to restart listening to existing groups after a reboot diff --git a/src/app/server/Server.h b/src/app/server/Server.h index e574b52b159957..5e51254e76753e 100644 --- a/src/app/server/Server.h +++ b/src/app/server/Server.h @@ -18,7 +18,7 @@ #pragma once #include -#include +#include #include #include @@ -70,7 +70,7 @@ #include #if CHIP_CONFIG_ENABLE_ICD_SERVER -#include // nogncheck +#include // nogncheck #endif namespace chip { diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn index d0f9a73178ccb0..245e939fc39799 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -153,6 +153,7 @@ chip_test_suite_using_nltest("tests") { "TestReportingEngine.cpp", "TestStatusIB.cpp", "TestStatusResponseMessage.cpp", + "TestTestEventTriggerDelegate.cpp", "TestTimeSyncDataProvider.cpp", "TestTimedHandler.cpp", "TestWriteInteraction.cpp", @@ -206,12 +207,13 @@ chip_test_suite_using_nltest("tests") { ":time-sync-data-provider-test-srcs", "${chip_root}/src/app", "${chip_root}/src/app/common:cluster-objects", - "${chip_root}/src/app/icd:manager", "${chip_root}/src/app/icd/client:manager", + "${chip_root}/src/app/icd/server:manager", "${chip_root}/src/app/tests:helpers", "${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", ] @@ -230,7 +232,7 @@ chip_test_suite_using_nltest("tests") { # Do not run TestCommissionManager when running ICD specific unit tests. # ICDManager has a dependency on the Accessors.h file which causes a link error # when building the TestCommissionManager - if (!chip_enable_icd_server && chip_config_network_layer_ble && + if (chip_config_network_layer_ble && (chip_device_platform == "linux" || chip_device_platform == "darwin")) { test_sources += [ "TestCommissionManager.cpp" ] public_deps += [ "${chip_root}/src/app/server" ] diff --git a/src/app/tests/TestDefaultICDClientStorage.cpp b/src/app/tests/TestDefaultICDClientStorage.cpp index e5e0024c0022f0..62787a2c9e4144 100644 --- a/src/app/tests/TestDefaultICDClientStorage.cpp +++ b/src/app/tests/TestDefaultICDClientStorage.cpp @@ -179,6 +179,8 @@ void TestClientInfoCountMultipleFabric(nlTestSuite * apSuite, void * apContext) err = manager.DeleteEntry(ScopedNodeId(nodeId1, fabricId1)); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); iterator = manager.IterateICDClientInfo(); + NL_TEST_ASSERT(apSuite, iterator != nullptr); + DefaultICDClientStorage::ICDClientInfoIteratorWrapper clientInfoIteratorWrapper(iterator); NL_TEST_ASSERT(apSuite, iterator->Count() == 2); err = manager.DeleteEntry(ScopedNodeId(nodeId2, fabricId1)); @@ -196,7 +198,7 @@ void TestClientInfoCountMultipleFabric(nlTestSuite * apSuite, void * apContext) { count++; } - iterator->Release(); + NL_TEST_ASSERT(apSuite, count == 0); } diff --git a/src/app/tests/TestICDManager.cpp b/src/app/tests/TestICDManager.cpp index f4ff46fd713556..823a98a490df7c 100644 --- a/src/app/tests/TestICDManager.cpp +++ b/src/app/tests/TestICDManager.cpp @@ -16,11 +16,14 @@ * limitations under the License. */ #include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include +#include +#include #include #include #include @@ -68,6 +71,21 @@ class TestICDStateObserver : public app::ICDStateObserver void OnICDModeChange() {} }; +class TestSubscriptionsInfoProvider : public SubscriptionsInfoProvider +{ +public: + TestSubscriptionsInfoProvider() = default; + ~TestSubscriptionsInfoProvider(){}; + + void SetReturnValue(bool value) { mReturnValue = value; }; + + bool SubjectHasActiveSubscription(FabricIndex aFabricIndex, NodeId subject) { return mReturnValue; }; + bool SubjectHasPersistedSubscription(FabricIndex aFabricIndex, NodeId subject) { return mReturnValue; }; + +private: + bool mReturnValue = false; +}; + class TestContext : public chip::Test::AppContext { public: @@ -93,7 +111,7 @@ class TestContext : public chip::Test::AppContext CHIP_ERROR SetUp() override { ReturnErrorOnFailure(chip::Test::AppContext::SetUp()); - mICDManager.Init(&testStorage, &GetFabricTable(), &mKeystore, &GetExchangeManager()); + mICDManager.Init(&testStorage, &GetFabricTable(), &mKeystore, &GetExchangeManager(), &mSubManager); mICDManager.RegisterObserver(&mICDStateObserver); return CHIP_NO_ERROR; } @@ -108,6 +126,7 @@ class TestContext : public chip::Test::AppContext System::Clock::Internal::MockClock mMockClock; TestSessionKeystoreImpl mKeystore; app::ICDManager mICDManager; + TestSubscriptionsInfoProvider mSubManager; TestPersistentStorageDelegate testStorage; private: @@ -142,17 +161,17 @@ 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); - // Idle mode interval expired, ICDManager transitioned to the ActiveMode. + // 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); - // Active mode interval expired, ICDManager transitioned to the IdleMode. + // 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); - // Idle mode interval expired, ICDManager transitioned to the ActiveMode. + // 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 Active interval and validate that the active mode is extended. + // 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); ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeThresholdMs() / 2); @@ -161,6 +180,175 @@ class TestICDManager NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); } + /** + * @brief Test verifies that the ICDManager starts its timers correctly based on if it will have any messages to send + * when the IdleModeDuration expires + */ + static void TestICDModeDurationsWith0ActiveModeDurationWithoutActiveSub(nlTestSuite * aSuite, void * aContext) + { + TestContext * ctx = static_cast(aContext); + typedef ICDListener::ICDManagementEvents ICDMEvent; + ICDConfigurationData & icdConfigData = ICDConfigurationData::GetInstance(); + + // Set FeatureMap - Configures CIP, UAT and LITS to 1 + ctx->mICDManager.SetTestFeatureMapValue(0x07); + + // Set that there are no matching subscriptions + ctx->mSubManager.SetReturnValue(false); + + // Set New durations for test case + uint32_t oldActiveModeDuration_ms = icdConfigData.GetActiveModeDurationMs(); + icdConfigData.SetModeDurations(MakeOptional(static_cast(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); + 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); + 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); + NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); + + // Add an entry to the ICDMonitoringTable + ICDMonitoringTable table(ctx->testStorage, kTestFabricIndex1, kMaxTestClients, &(ctx->mKeystore)); + + ICDMonitoringEntry entry(&(ctx->mKeystore)); + entry.checkInNodeID = kClientNodeId11; + entry.monitoredSubject = kClientNodeId11; + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == entry.SetKey(ByteSpan(kKeyBuffer1a))); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == table.Set(0, entry)); + + // Trigger register event after first entry was added + ICDNotifier::GetInstance().NotifyICDManagementEvent(ICDMEvent::kTableUpdated); + + // Check ICDManager is now in the LIT operating mode + NL_TEST_ASSERT(aSuite, icdConfigData.GetICDMode() == ICDConfigurationData::ICDMode::LIT); + + // Kick an ActiveModeThreshold since a Registration can only happen from an incoming message that would transition the ICD + // to ActiveMode + ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); + 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); + 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); + NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); + + // Remove entry from the fabric - ICDManager won't have any messages to send + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == table.Remove(0)); + 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); + 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); + NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); + + // Reset Old durations + icdConfigData.SetModeDurations(MakeOptional(oldActiveModeDuration_ms), NullOptional); + } + + /** + * @brief Test verifies that the ICDManager remains in IdleMode since it will not have any messages to send + * when the IdleModeDuration expires + */ + static void TestICDModeDurationsWith0ActiveModeDurationWithActiveSub(nlTestSuite * aSuite, void * aContext) + { + TestContext * ctx = static_cast(aContext); + typedef ICDListener::ICDManagementEvents ICDMEvent; + ICDConfigurationData & icdConfigData = ICDConfigurationData::GetInstance(); + + // Set FeatureMap - Configures CIP, UAT and LITS to 1 + ctx->mICDManager.SetTestFeatureMapValue(0x07); + + // Set that there are not matching subscriptions + ctx->mSubManager.SetReturnValue(true); + + // Set New durations for test case + uint32_t oldActiveModeDuration_ms = icdConfigData.GetActiveModeDurationMs(); + icdConfigData.SetModeDurations(MakeOptional(static_cast(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); + 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); + 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); + NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); + + // Add an entry to the ICDMonitoringTable + ICDMonitoringTable table(ctx->testStorage, kTestFabricIndex1, kMaxTestClients, &(ctx->mKeystore)); + + ICDMonitoringEntry entry(&(ctx->mKeystore)); + entry.checkInNodeID = kClientNodeId11; + entry.monitoredSubject = kClientNodeId11; + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == entry.SetKey(ByteSpan(kKeyBuffer1a))); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == table.Set(0, entry)); + + // Trigger register event after first entry was added + ICDNotifier::GetInstance().NotifyICDManagementEvent(ICDMEvent::kTableUpdated); + + // Check ICDManager is now in the LIT operating mode + NL_TEST_ASSERT(aSuite, icdConfigData.GetICDMode() == ICDConfigurationData::ICDMode::LIT); + + // Kick an ActiveModeThreshold since a Registration can only happen from an incoming message that would transition the ICD + // to ActiveMode + ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); + 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); + 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); + NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); + + // Remove entry from the fabric + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == table.Remove(0)); + NL_TEST_ASSERT(aSuite, table.IsEmpty()); + + // Trigger unregister event after last entry was removed + ICDNotifier::GetInstance().NotifyICDManagementEvent(ICDMEvent::kTableUpdated); + + // Check ICDManager is now in the LIT operating mode + NL_TEST_ASSERT(aSuite, icdConfigData.GetICDMode() == ICDConfigurationData::ICDMode::SIT); + + // Kick an ActiveModeThreshold since a Unregistration can only happen from an incoming message that would transition the ICD + // to ActiveMode + ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); + 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); + 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); + NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); + + // Reset Old durations + icdConfigData.SetModeDurations(MakeOptional(oldActiveModeDuration_ms), NullOptional); + } + static void TestKeepActivemodeRequests(nlTestSuite * aSuite, void * aContext) { TestContext * ctx = static_cast(aContext); @@ -170,7 +358,7 @@ class TestICDManager // Setting a requirement will transition the ICD to active mode. notifier.NotifyActiveRequestNotification(ActiveFlag::kCommissioningWindowOpen); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); - // Advance time so active mode interval expires. + // Advance time so active mode duration expires. AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDurationMs() + 1); // Requirement flag still set. We stay in active mode NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); @@ -183,13 +371,13 @@ class TestICDManager // Requirement will transition us to active mode. NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); - // Advance time, but by less than the active mode interval and remove the requirement. + // 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); notifier.NotifyActiveRequestWithdrawal(ActiveFlag::kFailSafeArmed); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); - // Advance time again, The activemode interval is completed. + // Advance time again, The activemode duration is completed. AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDurationMs() + 1); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); @@ -197,7 +385,7 @@ class TestICDManager notifier.NotifyActiveRequestNotification(ActiveFlag::kFailSafeArmed); notifier.NotifyActiveRequestNotification(ActiveFlag::kExchangeContextOpen); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); - // advance time so the active mode interval expires. + // advance time so the active mode duration expires. AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDurationMs() + 1); // A requirement flag is still set. We stay in active mode. NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); @@ -352,6 +540,10 @@ namespace { static const nlTest sTests[] = { NL_TEST_DEF("TestICDModeDurations", TestICDManager::TestICDModeDurations), NL_TEST_DEF("TestOnSubscriptionReport", TestICDManager::TestOnSubscriptionReport), + NL_TEST_DEF("TestICDModeDurationsWith0ActiveModeDurationWithoutActiveSub", + TestICDManager::TestICDModeDurationsWith0ActiveModeDurationWithoutActiveSub), + NL_TEST_DEF("TestICDModeDurationsWith0ActiveModeDurationWithActiveSub", + TestICDManager::TestICDModeDurationsWith0ActiveModeDurationWithActiveSub), NL_TEST_DEF("TestKeepActivemodeRequests", TestICDManager::TestKeepActivemodeRequests), NL_TEST_DEF("TestICDMRegisterUnregisterEvents", TestICDManager::TestICDMRegisterUnregisterEvents), NL_TEST_DEF("TestICDCounter", TestICDManager::TestICDCounter), diff --git a/src/app/tests/TestICDMonitoringTable.cpp b/src/app/tests/TestICDMonitoringTable.cpp index 1a6460e31640e3..f5de7ed59ba3e1 100644 --- a/src/app/tests/TestICDMonitoringTable.cpp +++ b/src/app/tests/TestICDMonitoringTable.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include +#include #include #include #include diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index 4f26604542b118..9e8bc58e5d87da 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -285,6 +285,10 @@ class NullReadHandlerCallback : public chip::app::ReadHandler::ManagementCallbac public: void OnDone(chip::app::ReadHandler & apReadHandlerObj) override {} chip::app::ReadHandler::ApplicationCallback * GetAppCallback() override { return nullptr; } + chip::app::InteractionModelEngine * GetInteractionModelEngine() override + { + return chip::app::InteractionModelEngine::GetInstance(); + } }; } // namespace diff --git a/src/app/tests/TestReportScheduler.cpp b/src/app/tests/TestReportScheduler.cpp index af6f367af8ccc6..5219943136847d 100644 --- a/src/app/tests/TestReportScheduler.cpp +++ b/src/app/tests/TestReportScheduler.cpp @@ -34,6 +34,10 @@ class NullReadHandlerCallback : public chip::app::ReadHandler::ManagementCallbac public: void OnDone(chip::app::ReadHandler & apReadHandlerObj) override {} chip::app::ReadHandler::ApplicationCallback * GetAppCallback() override { return nullptr; } + chip::app::InteractionModelEngine * GetInteractionModelEngine() override + { + return chip::app::InteractionModelEngine::GetInstance(); + } }; } // namespace diff --git a/src/app/tests/TestReportingEngine.cpp b/src/app/tests/TestReportingEngine.cpp index 5a198455dfe579..618a2e892e789b 100644 --- a/src/app/tests/TestReportingEngine.cpp +++ b/src/app/tests/TestReportingEngine.cpp @@ -120,6 +120,10 @@ class DummyDelegate : public ReadHandler::ManagementCallback public: void OnDone(ReadHandler & apHandler) override {} chip::app::ReadHandler::ApplicationCallback * GetAppCallback() override { return nullptr; } + chip::app::InteractionModelEngine * GetInteractionModelEngine() override + { + return chip::app::InteractionModelEngine::GetInstance(); + } }; void TestReportingEngine::TestBuildAndSendSingleReportData(nlTestSuite * apSuite, void * apContext) diff --git a/src/app/tests/TestTestEventTriggerDelegate.cpp b/src/app/tests/TestTestEventTriggerDelegate.cpp new file mode 100644 index 00000000000000..cd7f3ae9cd7be3 --- /dev/null +++ b/src/app/tests/TestTestEventTriggerDelegate.cpp @@ -0,0 +1,192 @@ +/* + * + * 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 + +using namespace chip; + +namespace { + +class TestEventHandler : public TestEventTriggerHandler +{ +public: + TestEventHandler() = delete; + + explicit TestEventHandler(uint64_t supportedEventTriggerValue) : mSupportedEventTriggerValue(supportedEventTriggerValue) {} + + CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override + { + if (eventTrigger == mSupportedEventTriggerValue) + { + ++mCount; + return CHIP_NO_ERROR; + } + return CHIP_ERROR_INVALID_ARGUMENT; + } + + int GetCount() const { return mCount; } + void ClearCount() { mCount = 0; } + +private: + uint64_t mSupportedEventTriggerValue; + int mCount = 0; +}; + +class TestEventDelegate : public TestEventTriggerDelegate +{ +public: + explicit TestEventDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {} + + bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override + { + return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); + } + +private: + ByteSpan mEnableKey; +}; + +void TestKeyChecking(nlTestSuite * aSuite, void * aContext) +{ + const uint8_t kTestKey[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + const uint8_t kBadKey[16] = { 255, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + const uint8_t kDiffLenBadKey[17] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; + TestEventDelegate delegate{ ByteSpan{ kTestKey } }; + + NL_TEST_ASSERT(aSuite, delegate.DoesEnableKeyMatch(ByteSpan{ kTestKey }) == true); + NL_TEST_ASSERT(aSuite, delegate.DoesEnableKeyMatch(ByteSpan{ kBadKey }) == false); + NL_TEST_ASSERT(aSuite, delegate.DoesEnableKeyMatch(ByteSpan{ kDiffLenBadKey }) == false); + NL_TEST_ASSERT(aSuite, delegate.DoesEnableKeyMatch(ByteSpan{}) == false); +} + +void TestHandlerManagement(nlTestSuite * aSuite, void * aContext) +{ + const uint8_t kTestKey[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + + TestEventDelegate delegate{ ByteSpan{ kTestKey } }; + + TestEventHandler event1Handler{ 1 }; + TestEventHandler event2Handler{ 2 }; + + // Add 2, check 2 works 1 doesn't. + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) != CHIP_NO_ERROR); + + NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event2Handler) == CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event2Handler) != CHIP_NO_ERROR); + + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) == CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) != CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) == CHIP_NO_ERROR); + + NL_TEST_ASSERT(aSuite, event1Handler.GetCount() == 0); + NL_TEST_ASSERT(aSuite, event2Handler.GetCount() == 2); + + event1Handler.ClearCount(); + event2Handler.ClearCount(); + + // Add 1, check 1 and 2 work. + NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event1Handler) == CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event1Handler) != CHIP_NO_ERROR); + + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) == CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) == CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) == CHIP_NO_ERROR); + + NL_TEST_ASSERT(aSuite, event1Handler.GetCount() == 2); + NL_TEST_ASSERT(aSuite, event2Handler.GetCount() == 1); + + event1Handler.ClearCount(); + event2Handler.ClearCount(); + + // Remove 2, check 1 works. + delegate.RemoveHandler(&event2Handler); + + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) == CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) != CHIP_NO_ERROR); + + NL_TEST_ASSERT(aSuite, event1Handler.GetCount() == 1); + NL_TEST_ASSERT(aSuite, event2Handler.GetCount() == 0); + + // Remove again, should be NO-OP. + delegate.RemoveHandler(&event2Handler); + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) != CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, event2Handler.GetCount() == 0); + + event1Handler.ClearCount(); + event2Handler.ClearCount(); + + // Add 2 again, check 1 and 2 work. + NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event2Handler) == CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event2Handler) != CHIP_NO_ERROR); + + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) == CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) == CHIP_NO_ERROR); + + NL_TEST_ASSERT(aSuite, event1Handler.GetCount() == 1); + NL_TEST_ASSERT(aSuite, event2Handler.GetCount() == 1); + + event1Handler.ClearCount(); + event2Handler.ClearCount(); + + // Remove all handlers, check neither works. + delegate.ClearAllHandlers(); + + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) != CHIP_NO_ERROR); + NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) != CHIP_NO_ERROR); + + NL_TEST_ASSERT(aSuite, event1Handler.GetCount() == 0); + NL_TEST_ASSERT(aSuite, event2Handler.GetCount() == 0); + + // Add a handler at the end: having it remaining should not cause crashes/leaks. + NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event2Handler) == CHIP_NO_ERROR); +} + +int TestSetup(void * inContext) +{ + return SUCCESS; +} + +int TestTeardown(void * inContext) +{ + return SUCCESS; +} + +} // namespace + +int TestTestEventTriggerDelegate() +{ + static nlTest sTests[] = { NL_TEST_DEF("TestKeyChecking", TestKeyChecking), + NL_TEST_DEF("TestHandlerManagement", TestHandlerManagement), NL_TEST_SENTINEL() }; + + nlTestSuite theSuite = { + "TestTestEventTriggerDelegate", + &sTests[0], + TestSetup, + TestTeardown, + }; + + nlTestRunner(&theSuite, nullptr); + return (nlTestRunnerStats(&theSuite)); +} + +CHIP_REGISTER_TEST_SUITE(TestTestEventTriggerDelegate) diff --git a/src/app/tests/suites/TestAccessControlConstraints.yaml b/src/app/tests/suites/TestAccessControlConstraints.yaml index 78d3d0941b4d90..82e66b8d347c10 100644 --- a/src/app/tests/suites/TestAccessControlConstraints.yaml +++ b/src/app/tests/suites/TestAccessControlConstraints.yaml @@ -28,6 +28,14 @@ tests: - name: "nodeId" value: nodeId + - label: "Read the commissioner node ID from the alpha fabric" + cluster: "CommissionerCommands" + command: "GetCommissionerNodeId" + response: + values: + - name: "nodeId" + saveAs: commissionerNodeIdAlpha + - label: "Constraint error: PASE reserved for future (TC-ACL-2.4 step 29)" cluster: "Access Control" command: "writeAttribute" @@ -35,14 +43,14 @@ tests: arguments: value: [ { - FabricIndex: 1, + FabricIndex: 0, Privilege: 5, # Administer AuthMode: 2, # CASE - Subjects: [112233], + Subjects: [commissionerNodeIdAlpha], Targets: null, }, { - FabricIndex: 1, + FabricIndex: 0, Privilege: 3, AuthMode: 1, # PASE Subjects: [], @@ -61,14 +69,14 @@ tests: arguments: value: [ { - FabricIndex: 1, + FabricIndex: 0, Privilege: 5, # Administer AuthMode: 2, # CASE - Subjects: [112233], + Subjects: [commissionerNodeIdAlpha], Targets: null, }, { - FabricIndex: 1, + FabricIndex: 0, Privilege: 5, # Administer AuthMode: 3, # Group Subjects: [], @@ -89,14 +97,14 @@ tests: arguments: value: [ { - FabricIndex: 1, + FabricIndex: 0, Privilege: 5, # Administer AuthMode: 2, # CASE - Subjects: [112233], + Subjects: [commissionerNodeIdAlpha], Targets: null, }, { - FabricIndex: 1, + FabricIndex: 0, Privilege: 6, AuthMode: 2, Subjects: null, @@ -113,14 +121,14 @@ tests: arguments: value: [ { - FabricIndex: 1, + FabricIndex: 0, Privilege: 5, # Administer AuthMode: 2, # CASE - Subjects: [112233], + Subjects: [commissionerNodeIdAlpha], Targets: null, }, { - FabricIndex: 1, + FabricIndex: 0, Privilege: 3, AuthMode: 4, # INVALID Subjects: [], @@ -137,14 +145,14 @@ tests: arguments: value: [ { - FabricIndex: 1, + FabricIndex: 0, Privilege: 5, # Administer AuthMode: 2, # CASE - Subjects: [112233], + Subjects: [commissionerNodeIdAlpha], Targets: null, }, { - FabricIndex: 1, + FabricIndex: 0, Privilege: 3, AuthMode: 2, Subjects: [0], @@ -161,14 +169,14 @@ tests: arguments: value: [ { - FabricIndex: 1, + FabricIndex: 0, Privilege: 5, # Administer AuthMode: 2, # CASE - Subjects: [112233], + Subjects: [commissionerNodeIdAlpha], Targets: null, }, { - FabricIndex: 1, + FabricIndex: 0, Privilege: 3, AuthMode: 2, Subjects: null, @@ -189,14 +197,14 @@ tests: arguments: value: [ { - FabricIndex: 1, + FabricIndex: 0, Privilege: 5, # Administer AuthMode: 2, # CASE - Subjects: [112233], + Subjects: [commissionerNodeIdAlpha], Targets: null, }, { - FabricIndex: 1, + FabricIndex: 0, Privilege: 3, AuthMode: 2, Subjects: null, @@ -215,14 +223,14 @@ tests: arguments: value: [ { - FabricIndex: 1, + FabricIndex: 0, Privilege: 5, # Administer AuthMode: 2, # CASE - Subjects: [112233], + Subjects: [commissionerNodeIdAlpha], Targets: null, }, { - FabricIndex: 1, + FabricIndex: 0, Privilege: 6, # INVALID AuthMode: 2, # CASE Subjects: null, @@ -241,14 +249,14 @@ tests: arguments: value: [ { - FabricIndex: 1, + FabricIndex: 0, Privilege: 5, # Administer AuthMode: 2, # CASE - Subjects: [112233], + Subjects: [commissionerNodeIdAlpha], Targets: null, }, { - FabricIndex: 1, + FabricIndex: 0, Privilege: 3, # Operate AuthMode: 2, # CASE Subjects: ["18446744073709551615"], @@ -269,14 +277,14 @@ tests: arguments: value: [ { - FabricIndex: 1, + FabricIndex: 0, Privilege: 5, # Administer AuthMode: 2, # CASE - Subjects: [112233], + Subjects: [commissionerNodeIdAlpha], Targets: null, }, { - FabricIndex: 1, + FabricIndex: 0, Privilege: 3, # Operate AuthMode: 2, # CASE Subjects: ["18446744060824649728"], @@ -295,14 +303,14 @@ tests: arguments: value: [ { - FabricIndex: 1, + FabricIndex: 0, Privilege: 5, # Administer AuthMode: 2, # CASE - Subjects: [112233], + Subjects: [commissionerNodeIdAlpha], Targets: null, }, { - FabricIndex: 1, + FabricIndex: 0, Privilege: 3, # Operate AuthMode: 2, # CASE Subjects: ["18446744073709486080"], diff --git a/src/app/tests/suites/TestRVCOperationalState.yaml b/src/app/tests/suites/TestRVCOperationalState.yaml index de40e7f6088be1..239e770abc216b 100644 --- a/src/app/tests/suites/TestRVCOperationalState.yaml +++ b/src/app/tests/suites/TestRVCOperationalState.yaml @@ -73,11 +73,6 @@ tests: response: value: 0 - - label: "Start Command" - command: "Start" - response: - error: UNSUPPORTED_COMMAND - - label: "Read current Operational State" command: "readAttribute" attribute: "OperationalState" @@ -110,11 +105,6 @@ tests: response: value: 0 - - label: "Stop Command" - command: "Stop" - response: - error: UNSUPPORTED_COMMAND - - label: "Read current Operational State" command: "readAttribute" attribute: "OperationalState" diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index 93cfe963c6bc13..09d55dff5881b3 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -9497,6 +9497,9 @@ PICS: - label: "Does the device implement receiving the Resume command?" id: RVCOPSTATE.S.C03.Rsp + - label: "Does the device implement receiving the GoHome command?" + id: RVCOPSTATE.S.C128.Rsp + #Commands generated - label: "Does the device implement generating the OperationalCommandResponse diff --git a/src/app/tests/suites/certification/Test_TC_DD_2_2.yaml b/src/app/tests/suites/certification/Test_TC_DD_2_2.yaml index 264478e788acab..f0a2403b36506e 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_2_2.yaml @@ -63,8 +63,6 @@ tests: [1657221603.350739][368108:368108] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 [1657221603.350773][368108:368108] CHIP:SVR: Manual pairing code: [749701123365521327694] [1657221603.350846][368108:368108] CHIP:DMG: Endpoint 0, Cluster 0x0000_001D update version to 4dd11284 - [1657221603.353048][368108:368113] CHIP:DL: TRACE: Bluez mainloop starting Thread - [1657221603.353167][368108:368111] CHIP:DL: TRACE: Bus acquired for name MATTER-3841 disabled: true - label: diff --git a/src/app/tests/suites/certification/Test_TC_DD_3_11.yaml b/src/app/tests/suites/certification/Test_TC_DD_3_11.yaml index 5f03477f1a09fa..fe6c2f5ce75911 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_3_11.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_3_11.yaml @@ -85,7 +85,6 @@ tests: [1667888323.967841][3151:3151] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J042C00KA0648G00 [1667888323.967940][3151:3151] CHIP:SVR: Manual pairing code: [34970112332] [1667888323.968031][3151:3151] CHIP:DMG: Endpoint 0, Cluster 0x0000_001D update version to ea7ea7b8 - [1667888323.981832][3151:3153] CHIP:DL: TRACE: Bus acquired for name MATTER-3840 disabled: true - label: "Step 1b: Scan the QR code from the previous step using the DUT." 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_SMOKECO_2_2.yaml b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_2.yaml index 37b3eb074031ac..4d26172d49d5c6 100644 --- a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_2.yaml @@ -29,13 +29,13 @@ config: defaultValue: "hex:00112233445566778899aabbccddeeff" TEST_EVENT_TRIGGER_WARNING_SMOKE_ALARM: type: int64u - defaultValue: "0xffffffff00000090" + defaultValue: "0x005c000000000090" TEST_EVENT_TRIGGER_CRITICAL_SMOKE_ALARM: type: int64u - defaultValue: "0xffffffff0000009c" + defaultValue: "0x005c00000000009c" TEST_EVENT_TRIGGER_SMOKE_ALARM_CLEAR: type: int64u - defaultValue: "0xffffffff000000a0" + defaultValue: "0x005c0000000000a0" tests: - label: "Step 1: Commission DUT to TH" diff --git a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_5.yaml b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_5.yaml index c9de09f10e4314..21aa0d7481c7c5 100644 --- a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_5.yaml +++ b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_5.yaml @@ -29,58 +29,58 @@ config: defaultValue: "hex:00112233445566778899aabbccddeeff" TEST_EVENT_TRIGGER_WARNING_SMOKE_ALARM: type: int64u - defaultValue: "0xffffffff00000090" + defaultValue: "0x005c000000000090" TEST_EVENT_TRIGGER_CRITICAL_SMOKE_ALARM: type: int64u - defaultValue: "0xffffffff0000009c" + defaultValue: "0x005c00000000009c" TEST_EVENT_TRIGGER_SMOKE_ALARM_CLEAR: type: int64u - defaultValue: "0xffffffff000000a0" + defaultValue: "0x005c0000000000a0" TEST_EVENT_TRIGGER_WARNING_CO_ALARM: type: int64u - defaultValue: "0xffffffff00000091" + defaultValue: "0x005c000000000091" TEST_EVENT_TRIGGER_CRITICAL_CO_ALARM: type: int64u - defaultValue: "0xffffffff0000009d" + defaultValue: "0x005c00000000009d" TEST_EVENT_TRIGGER_CO_ALARM_CLEAR: type: int64u - defaultValue: "0xffffffff000000a1" + defaultValue: "0x005c0000000000a1" TEST_EVENT_TRIGGER_DEVICE_MUTED: type: int64u - defaultValue: "0xffffffff0000009b" + defaultValue: "0x005c00000000009b" TEST_EVENT_TRIGGER_DEVICE_MUTED_CLEAR: type: int64u - defaultValue: "0xffffffff000000ab" + defaultValue: "0x005c0000000000ab" TEST_EVENT_TRIGGER_INTERCONNECT_SMOKE_ALARM: type: int64u - defaultValue: "0xffffffff00000092" + defaultValue: "0x005c000000000092" TEST_EVENT_TRIGGER_INTERCONNECT_SMOKE_ALARM_CLEAR: type: int64u - defaultValue: "0xffffffff000000a2" + defaultValue: "0x005c0000000000a2" TEST_EVENT_TRIGGER_INTERCONNECT_CO_ALARM: type: int64u - defaultValue: "0xffffffff00000094" + defaultValue: "0x005c000000000094" TEST_EVENT_TRIGGER_INTERCONNECT_CO_ALARM_CLEAR: type: int64u - defaultValue: "0xffffffff000000a4" + defaultValue: "0x005c0000000000a4" TEST_EVENT_TRIGGER_CONTAMINATION_STATE_HIGH: type: int64u - defaultValue: "0xffffffff00000096" + defaultValue: "0x005c000000000096" TEST_EVENT_TRIGGER_CONTAMINATION_STATE_LOW: type: int64u - defaultValue: "0xffffffff00000097" + defaultValue: "0x005c000000000097" TTEST_EVENT_TRIGGER_CONTAMINATION_STATE_CLEAR: type: int64u - defaultValue: "0xffffffff000000a6" + defaultValue: "0x005c0000000000a6" TEST_EVENT_TRIGGER_SENSITIVITY_LEVEL_HIGH: type: int64u - defaultValue: "0xffffffff00000098" + defaultValue: "0x005c000000000098" TEST_EVENT_TRIGGER_SENSITIVITY_LEVEL_LOW: type: int64u - defaultValue: "0xffffffff00000099" + defaultValue: "0x005c000000000099" TTEST_EVENT_TRIGGER_SENSITIVITY_LEVEL_CLEAR: type: int64u - defaultValue: "0xffffffff000000a8" + defaultValue: "0x005c0000000000a8" tests: - label: "Step 1: Commission DUT to TH" diff --git a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_6.yaml b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_6.yaml index 00ecd8b85a63b2..288933602dc872 100644 --- a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_6.yaml +++ b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_6.yaml @@ -29,34 +29,34 @@ config: defaultValue: "hex:00112233445566778899aabbccddeeff" TEST_EVENT_TRIGGER_WARNING_SMOKE_ALARM: type: int64u - defaultValue: "0xffffffff00000090" + defaultValue: "0x005c000000000090" TEST_EVENT_TRIGGER_SMOKE_ALARM_CLEAR: type: int64u - defaultValue: "0xffffffff000000a0" + defaultValue: "0x005c0000000000a0" TEST_EVENT_TRIGGER_WARNING_CO_ALARM: type: int64u - defaultValue: "0xffffffff00000091" + defaultValue: "0x005c000000000091" TEST_EVENT_TRIGGER_CO_ALARM_CLEAR: type: int64u - defaultValue: "0xffffffff000000a1" + defaultValue: "0x005c0000000000a1" TEST_EVENT_TRIGGER_WARNING_BATTERY_ALERT: type: int64u - defaultValue: "0xffffffff00000095" + defaultValue: "0x005c000000000095" TEST_EVENT_TRIGGER_BATTERY_ALERT_CLEAR: type: int64u - defaultValue: "0xffffffff000000a5" + defaultValue: "0x005c0000000000a5" TEST_EVENT_TRIGGER_INTERCONNECT_SMOKE_ALARM: type: int64u - defaultValue: "0xffffffff00000092" + defaultValue: "0x005c000000000092" TEST_EVENT_TRIGGER_INTERCONNECT_SMOKE_ALARM_CLEAR: type: int64u - defaultValue: "0xffffffff000000a2" + defaultValue: "0x005c0000000000a2" TEST_EVENT_TRIGGER_INTERCONNECT_CO_ALARM: type: int64u - defaultValue: "0xffffffff00000094" + defaultValue: "0x005c000000000094" TEST_EVENT_TRIGGER_INTERCONNECT_CO_ALARM_CLEAR: type: int64u - defaultValue: "0xffffffff000000a4" + defaultValue: "0x005c0000000000a4" HIEST_PRI_ALARM: type: int8u defaultValue: 1 diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 4c4df4cef22a9a..907b0024709c4c 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -2457,26 +2457,27 @@ RVCOPSTATE.S=1 RVCOPSTATE.C=1 #ManuallyControlled +# These are the PICS supported by the all-clusters-app RVCOPSTATE.S.M.ST_STOPPED=1 RVCOPSTATE.S.M.ST_RUNNING=1 RVCOPSTATE.S.M.ST_PAUSED=1 -RVCOPSTATE.S.M.ST_ERROR=1 -RVCOPSTATE.S.M.ST_SEEKING_CHARGER=1 -RVCOPSTATE.S.M.ST_CHARGING=1 -RVCOPSTATE.S.M.ST_DOCKED=1 +RVCOPSTATE.S.M.ST_ERROR=0 +RVCOPSTATE.S.M.ST_SEEKING_CHARGER=0 +RVCOPSTATE.S.M.ST_CHARGING=0 +RVCOPSTATE.S.M.ST_DOCKED=0 RVCOPSTATE.S.M.ERR_NO_ERROR=1 -RVCOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME=1 -RVCOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION=1 -RVCOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE=1 -RVCOPSTATE.S.M.ERR_FAILED_TO_FIND_CHARGING_DOCK=1 -RVCOPSTATE.S.M.ERR_STUCK=1 -RVCOPSTATE.S.M.ERR_DUST_BIN_MISSING=1 -RVCOPSTATE.S.M.ERR_DUST_BIN_FULL=1 -RVCOPSTATE.S.M.ERR_WATER_TANK_EMPTY=1 -RVCOPSTATE.S.M.ERR_WATER_TANK_MISSING=1 -RVCOPSTATE.S.M.ERR_WATER_TANK_LID_OPEN=1 -RVCOPSTATE.S.M.ERR_MOP_CLEANING_PAD_MISSING=1 +RVCOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME=0 +RVCOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION=0 +RVCOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE=0 +RVCOPSTATE.S.M.ERR_FAILED_TO_FIND_CHARGING_DOCK=0 +RVCOPSTATE.S.M.ERR_STUCK=0 +RVCOPSTATE.S.M.ERR_DUST_BIN_MISSING=0 +RVCOPSTATE.S.M.ERR_DUST_BIN_FULL=0 +RVCOPSTATE.S.M.ERR_WATER_TANK_EMPTY=0 +RVCOPSTATE.S.M.ERR_WATER_TANK_MISSING=0 +RVCOPSTATE.S.M.ERR_WATER_TANK_LID_OPEN=0 +RVCOPSTATE.S.M.ERR_MOP_CLEANING_PAD_MISSING=0 #Events RVCOPSTATE.S.E00=1 @@ -2496,6 +2497,7 @@ RVCOPSTATE.S.C01.Rsp=0 RVCOPSTATE.S.C02.Rsp=0 RVCOPSTATE.S.C03.Rsp=1 RVCOPSTATE.S.C04.Tx=1 +RVCOPSTATE.S.C128.Rsp=1 RVCOPSTATE.C.C00.Tx=1 RVCOPSTATE.C.C01.Tx=1 RVCOPSTATE.C.C02.Tx=1 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/interaction_model/InteractionModel.cpp b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp index a2c418435990e4..04e658f18cc188 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp @@ -350,6 +350,7 @@ CHIP_ERROR InteractionModelReports::ReportAttribute(DeviceProxy * device, std::v { params.mKeepSubscriptions = mKeepSubscriptions.Value(); } + params.mIsPeerLIT = mIsPeerLIT; } auto client = std::make_unique(InteractionModelEngine::GetInstance(), device->GetExchangeManager(), @@ -479,6 +480,7 @@ CHIP_ERROR InteractionModelReports::ReportEvent(DeviceProxy * device, std::vecto { params.mKeepSubscriptions = mKeepSubscriptions.Value(); } + params.mIsPeerLIT = mIsPeerLIT; } auto client = std::make_unique(InteractionModelEngine::GetInstance(), device->GetExchangeManager(), @@ -652,6 +654,7 @@ CHIP_ERROR InteractionModelReports::ReportAll(chip::DeviceProxy * device, std::v { params.mKeepSubscriptions = mKeepSubscriptions.Value(); } + params.mIsPeerLIT = mIsPeerLIT; } auto client = std::make_unique(InteractionModelEngine::GetInstance(), device->GetExchangeManager(), diff --git a/src/app/tests/suites/commands/interaction_model/InteractionModel.h b/src/app/tests/suites/commands/interaction_model/InteractionModel.h index da3c3378a45d90..dbbf4246680c5f 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.h +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.h @@ -205,6 +205,12 @@ class InteractionModelReports return *this; } + InteractionModelReports & SetPeerLIT(bool isPeerLIT) + { + mIsPeerLIT = isPeerLIT; + return *this; + } + void ResetOptions() { mDataVersions = chip::NullOptional; @@ -213,6 +219,7 @@ class InteractionModelReports mFabricFiltered = chip::Optional(true); mKeepSubscriptions = chip::NullOptional; mAutoResubscribe = chip::NullOptional; + mIsPeerLIT = false; mMinInterval = 0; mMaxInterval = 0; } @@ -223,6 +230,7 @@ class InteractionModelReports chip::Optional mFabricFiltered; chip::Optional mKeepSubscriptions; chip::Optional mAutoResubscribe; + bool mIsPeerLIT; uint16_t mMinInterval; uint16_t mMaxInterval; }; 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/af.h b/src/app/util/af.h index 0af5d755f8ca9b..c186699cbc68a7 100644 --- a/src/app/util/af.h +++ b/src/app/util/af.h @@ -22,17 +22,6 @@ #endif #include CONFIGURATION_HEADER -#ifdef EZSP_HOST -// Includes needed for ember related functions for the EZSP host -#include "app/util/ezsp/ezsp-protocol.h" -#include "app/util/ezsp/ezsp-utils.h" -#include "app/util/ezsp/ezsp.h" -#include "app/util/ezsp/serial-interface.h" -#include "stack/include/ember-random-api.h" -#include "stack/include/ember-types.h" -#include "stack/include/error.h" -#endif // EZSP_HOST - #include #include @@ -101,6 +90,10 @@ bool emberAfContainsClient(chip::EndpointId endpoint, chip::ClusterId clusterId) * over the air. Because this function is being called locally * it assumes that the device knows what it is doing and has permission * to perform the given operation. + * + * This function also does NOT check that the input dataType matches the expected + * data type (as Accessors.h/cpp have this correct by default). + * TODO: this not checking seems off - what if this is run without Accessors.h ? */ EmberAfStatus emberAfWriteAttribute(chip::EndpointId endpoint, chip::ClusterId cluster, chip::AttributeId attributeID, uint8_t * dataPtr, EmberAfAttributeType dataType); diff --git a/src/app/util/attribute-metadata.h b/src/app/util/attribute-metadata.h index f957e51c0ad14a..0f9c9b26258758 100644 --- a/src/app/util/attribute-metadata.h +++ b/src/app/util/attribute-metadata.h @@ -105,17 +105,6 @@ union EmberAfDefaultOrMinMaxAttributeValue const EmberAfAttributeMinMaxValue * ptrToMinMaxValue; }; -enum class EmberAfAttributeWritePermission -{ - DenyWrite = 0, - AllowWriteNormal = 1, - AllowWriteOfReadOnly = 2, - UnsupportedAttribute = 0x86, // Protocols::InteractionModel::Status::UnsupportedAttribute - InvalidValue = 0x87, // Protocols::InteractionModel::Status::ConstraintError - ReadOnly = 0x88, // Protocols::InteractionModel::Status::UnsupportedWrite - InvalidDataType = 0x8d, // Protocols::InteractionModel::Status::InvalidDataType -}; - // Attribute masks modify how attributes are used by the framework // // Attribute that has this mask is NOT read-only diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 1faf74aeba6966..9b9129f1b018a1 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -938,10 +938,6 @@ bool emberAfEndpointEnableDisable(EndpointId endpoint, bool enable) emAfEndpoints[index].bitmask.Set(EmberAfEndpointOptions::isEnabled); } -#if defined(EZSP_HOST) - ezspSetEndpointFlags(endpoint, (enable ? EZSP_ENDPOINT_ENABLED : EZSP_ENDPOINT_DISABLED)); -#endif - if (currentlyEnabled != enable) { if (enable) diff --git a/src/app/util/attribute-table.cpp b/src/app/util/attribute-table.cpp index c16cad8811dbcf..4c36d759c3a5ed 100644 --- a/src/app/util/attribute-table.cpp +++ b/src/app/util/attribute-table.cpp @@ -32,36 +32,16 @@ using namespace chip; -EmberAfStatus emberAfWriteAttributeExternal(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr, - EmberAfAttributeType dataType) +EmberAfStatus emAfWriteAttributeExternal(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr, + EmberAfAttributeType dataType) { - EmberAfAttributeWritePermission extWritePermission = - emberAfAllowNetworkWriteAttributeCallback(endpoint, cluster, attributeID, dataPtr, dataType); - switch (extWritePermission) - { - case EmberAfAttributeWritePermission::DenyWrite: - return EMBER_ZCL_STATUS_FAILURE; - case EmberAfAttributeWritePermission::AllowWriteNormal: - case EmberAfAttributeWritePermission::AllowWriteOfReadOnly: - return emAfWriteAttribute(endpoint, cluster, attributeID, dataPtr, dataType, - (extWritePermission == EmberAfAttributeWritePermission::AllowWriteOfReadOnly), false); - default: - return (EmberAfStatus) extWritePermission; - } + return emAfWriteAttribute(endpoint, cluster, attributeID, dataPtr, dataType, false /* override read-only */); } EmberAfStatus emberAfWriteAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr, EmberAfAttributeType dataType) { - return emAfWriteAttribute(endpoint, cluster, attributeID, dataPtr, dataType, - true, // override read-only? - false); // just test? -} - -EmberAfStatus emberAfReadAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr, - uint16_t readLength) -{ - return emAfReadAttribute(endpoint, cluster, attributeID, dataPtr, readLength, nullptr); + return emAfWriteAttribute(endpoint, cluster, attributeID, dataPtr, dataType, true /* override read-only */); } //------------------------------------------------------------------------------ @@ -123,30 +103,8 @@ static bool IsNullValue(const uint8_t * data, uint16_t dataLen, bool isAttribute return false; } -// writes an attribute (identified by clusterID and attrID to the given value. -// this returns: -// - EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT: if endpoint isn't supported by the device. -// - EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER: if cluster isn't supported on the endpoint. -// - EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE: if attribute isn't supported in the cluster. -// - EMBER_ZCL_STATUS_INVALID_DATA_TYPE: if the data type passed in doesnt match the type -// stored in the attribute table -// - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE: if the attribute isnt writable -// - EMBER_ZCL_STATUS_CONSTRAINT_ERROR: if the value is set out of the allowable range for -// the attribute -// - EMBER_ZCL_STATUS_SUCCESS: if the attribute was found and successfully written -// -// if true is passed in for overrideReadOnlyAndDataType then the data type is -// not checked and the read-only flag is ignored. This mode is meant for -// testing or setting the initial value of the attribute on the device. -// -// if true is passed for justTest, then the type is not written but all -// checks are done to see if the type could be written -// reads the attribute specified, returns false if the attribute is not in -// the table or the data is too large, returns true and writes to dataPtr -// if the attribute is supported and the readLength specified is less than -// the length of the data. EmberAfStatus emAfWriteAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * data, - EmberAfAttributeType dataType, bool overrideReadOnlyAndDataType, bool justTest) + EmberAfAttributeType dataType, bool overrideReadOnlyAndDataType) { const EmberAfAttributeMetadata * metadata = nullptr; EmberAfAttributeSearchRecord record; @@ -224,77 +182,63 @@ EmberAfStatus emAfWriteAttribute(EndpointId endpoint, ClusterId cluster, Attribu } } - // write the data unless this is only a test - if (!justTest) - { - const app::ConcreteAttributePath attributePath(endpoint, cluster, attributeID); + const app::ConcreteAttributePath attributePath(endpoint, cluster, attributeID); - // Pre write attribute callback for all attribute changes, - // regardless of cluster. - Protocols::InteractionModel::Status imStatus = - MatterPreAttributeChangeCallback(attributePath, dataType, emberAfAttributeSize(metadata), data); - if (imStatus != Protocols::InteractionModel::Status::Success) - { - return app::ToEmberAfStatus(imStatus); - } + // Pre write attribute callback for all attribute changes, + // regardless of cluster. + Protocols::InteractionModel::Status imStatus = + MatterPreAttributeChangeCallback(attributePath, dataType, emberAfAttributeSize(metadata), data); + if (imStatus != Protocols::InteractionModel::Status::Success) + { + return app::ToEmberAfStatus(imStatus); + } - // Pre-write attribute callback specific - // to the cluster that the attribute lives in. - status = emAfClusterPreAttributeChangedCallback(attributePath, dataType, emberAfAttributeSize(metadata), data); + // Pre-write attribute callback specific + // to the cluster that the attribute lives in. + status = emAfClusterPreAttributeChangedCallback(attributePath, dataType, emberAfAttributeSize(metadata), data); - // Ignore the following write operation and return success - if (status == EMBER_ZCL_STATUS_WRITE_IGNORED) - { - return EMBER_ZCL_STATUS_SUCCESS; - } + // Ignore the following write operation and return success + if (status == EMBER_ZCL_STATUS_WRITE_IGNORED) + { + return EMBER_ZCL_STATUS_SUCCESS; + } - if (status != EMBER_ZCL_STATUS_SUCCESS) - { - return status; - } + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + return status; + } - // write the attribute - status = emAfReadOrWriteAttribute(&record, - nullptr, // metadata - data, - 0, // buffer size - unused - true); // write? + // write the attribute + status = emAfReadOrWriteAttribute(&record, + nullptr, // metadata + data, + 0, // buffer size - unused + true); // write? - if (status != EMBER_ZCL_STATUS_SUCCESS) - { - return status; - } + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + return status; + } - // Save the attribute to persistent storage if needed - // The callee will weed out attributes that do not need to be stored. - emAfSaveAttributeToStorageIfNeeded(data, endpoint, cluster, metadata); + // Save the attribute to persistent storage if needed + // The callee will weed out attributes that do not need to be stored. + emAfSaveAttributeToStorageIfNeeded(data, endpoint, cluster, metadata); - MatterReportingAttributeChangeCallback(endpoint, cluster, attributeID); + MatterReportingAttributeChangeCallback(endpoint, cluster, attributeID); - // Post write attribute callback for all attributes changes, regardless - // of cluster. - MatterPostAttributeChangeCallback(attributePath, dataType, emberAfAttributeSize(metadata), data); + // Post write attribute callback for all attributes changes, regardless + // of cluster. + MatterPostAttributeChangeCallback(attributePath, dataType, emberAfAttributeSize(metadata), data); - // Post-write attribute callback specific - // to the cluster that the attribute lives in. - emAfClusterAttributeChangedCallback(attributePath); - } - else - { - // bug: 11618, we are not handling properly external attributes - // in this case... We need to do something. We don't really - // know if it will succeed. - ChipLogProgress(Zcl, "WRITE: no write, just a test"); - } + // Post-write attribute callback specific + // to the cluster that the attribute lives in. + emAfClusterAttributeChangedCallback(attributePath); return EMBER_ZCL_STATUS_SUCCESS; } -// If dataPtr is NULL, no data is copied to the caller. -// readLength should be 0 in that case. - -EmberAfStatus emAfReadAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr, - uint16_t readLength, EmberAfAttributeType * dataType) +EmberAfStatus emberAfReadAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr, + uint16_t readLength) { const EmberAfAttributeMetadata * metadata = nullptr; EmberAfAttributeSearchRecord record; @@ -305,20 +249,10 @@ EmberAfStatus emAfReadAttribute(EndpointId endpoint, ClusterId cluster, Attribut status = emAfReadOrWriteAttribute(&record, &metadata, dataPtr, readLength, false); // write? - if (status == EMBER_ZCL_STATUS_SUCCESS) + // failed, print debug info + if (status == EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED) { - // It worked! If the user asked for the type, set it before returning. - if (dataType != nullptr) - { - (*dataType) = metadata->attributeType; - } - } - else - { // failed, print debug info - if (status == EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED) - { - ChipLogProgress(Zcl, "READ: attribute size too large for caller"); - } + ChipLogProgress(Zcl, "READ: attribute size too large for caller"); } return status; diff --git a/src/app/util/attribute-table.h b/src/app/util/attribute-table.h index e18c21bf349052..1f08d80dbd1353 100644 --- a/src/app/util/attribute-table.h +++ b/src/app/util/attribute-table.h @@ -19,12 +19,44 @@ #include -// Remote devices writing attributes of local device -EmberAfStatus emberAfWriteAttributeExternal(chip::EndpointId endpoint, chip::ClusterId cluster, chip::AttributeId attributeID, - uint8_t * dataPtr, EmberAfAttributeType dataType); +/** + * Write an attribute for a request arriving from external sources. + * + * This will check attribute writeability and that + * the provided data type matches the expected data type. + */ +EmberAfStatus emAfWriteAttributeExternal(chip::EndpointId endpoint, chip::ClusterId cluster, chip::AttributeId attributeID, + uint8_t * dataPtr, EmberAfAttributeType dataType); +/** + * @brief write an attribute, performing all the checks. + * + * This function will attempt to write the attribute value from + * the provided pointer. This function will only check that the + * attribute exists. If it does it will write the value into + * the attribute table for the given attribute. + * + * This function will not check to see if the attribute is + * writable since the read only / writable characteristic + * of an attribute only pertains to external devices writing + * over the air. Because this function is being called locally + * it assumes that the device knows what it is doing and has permission + * to perform the given operation. + * + * if true is passed in for overrideReadOnlyAndDataType then the data type is + * not checked and the read-only flag is ignored. This mode is meant for + * testing or setting the initial value of the attribute on the device. + * + * this returns: + * - EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT: if endpoint isn't supported by the device. + * - EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER: if cluster isn't supported on the endpoint. + * - EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE: if attribute isn't supported in the cluster. + * - EMBER_ZCL_STATUS_INVALID_DATA_TYPE: if the data type passed in doesnt match the type + * stored in the attribute table + * - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE: if the attribute isnt writable + * - EMBER_ZCL_STATUS_CONSTRAINT_ERROR: if the value is set out of the allowable range for + * the attribute + * - EMBER_ZCL_STATUS_SUCCESS: if the attribute was found and successfully written + */ EmberAfStatus emAfWriteAttribute(chip::EndpointId endpoint, chip::ClusterId cluster, chip::AttributeId attributeID, uint8_t * data, - EmberAfAttributeType dataType, bool overrideReadOnlyAndDataType, bool justTest); - -EmberAfStatus emAfReadAttribute(chip::EndpointId endpoint, chip::ClusterId cluster, chip::AttributeId attributeID, - uint8_t * dataPtr, uint16_t readLength, EmberAfAttributeType * dataType); + EmberAfAttributeType dataType, bool overrideReadOnlyAndDataType); diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index 8ce6c7bbc2a674..76daa77ea13fa7 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -1051,8 +1051,8 @@ CHIP_ERROR WriteSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, return apWriteHandler->AddStatus(aPath, Protocols::InteractionModel::Status::InvalidValue); } - auto status = ToInteractionModelStatus(emberAfWriteAttributeExternal(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId, - attributeData, attributeMetadata->attributeType)); + auto status = ToInteractionModelStatus(emAfWriteAttributeExternal(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId, + attributeData, attributeMetadata->attributeType)); return apWriteHandler->AddStatus(aPath, status); } diff --git a/src/app/util/generic-callback-stubs.cpp b/src/app/util/generic-callback-stubs.cpp index 2e442b9626b9b8..11e705c7382b1c 100644 --- a/src/app/util/generic-callback-stubs.cpp +++ b/src/app/util/generic-callback-stubs.cpp @@ -24,13 +24,6 @@ using namespace chip; // This file contains overridable callbacks that are not cluster specific. -EmberAfAttributeWritePermission __attribute__((weak)) -emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t * value, - uint8_t type) -{ - return EmberAfAttributeWritePermission::AllowWriteNormal; // Default -} - bool __attribute__((weak)) emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId) { return true; diff --git a/src/app/util/generic-callbacks.h b/src/app/util/generic-callbacks.h index 4b46c64511a24a..4f0fc6661af92c 100644 --- a/src/app/util/generic-callbacks.h +++ b/src/app/util/generic-callbacks.h @@ -39,35 +39,6 @@ */ void emberAfClusterInitCallback(chip::EndpointId endpoint, chip::ClusterId clusterId); -/** @brief Allow Network Write Attribute - * - * This function is called by the application framework before it writes an - * attribute in response to a write attribute request from an external device. - * The value passed into this callback is the value to which the attribute is to - * be set by the framework. - Example: In mirroring simple metering data - * on an Energy Services Interface (ESI) (formerly called Energy Service Portal - * (ESP) in SE 1.0).), a mirrored simple meter needs to write read-only - * attributes on its mirror. The-meter-mirror sample application, located in - * app/framework/sample-apps, uses this callback to allow the mirrored device to - * write simple metering attributes on the mirror regardless of the fact that - * most simple metering attributes are defined as read-only by the ZigBee - * specification. - Note: The ZCL specification does not (as of this - * writing) specify any permission-level security for writing writeable - * attributes. As far as the ZCL specification is concerned, if an attribute is - * writeable, any device that has a link key for the device should be able to - * write that attribute. Furthermore if an attribute is read only, it should not - * be written over the air. Thus, if you implement permissions for writing - * attributes as a feature, you MAY be operating outside the specification. This - * is unlikely to be a problem for writing read-only attributes, but it may be a - * problem for attributes that are writeable according to the specification but - * restricted by the application implementing this callback. - */ -EmberAfAttributeWritePermission emberAfAllowNetworkWriteAttributeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, - chip::AttributeId attributeId, uint8_t * value, - uint8_t type); - /** @brief Attribute Read Access * * This function is called whenever the Application Framework needs to check 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..c2a57f2c936d14 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 static_cast({{first_unused_enum_value mode="first_unused"}}); + } +} +{{/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) { @@ -23,6 +43,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue({{asUpperCamelCase ../n } } {{/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/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/ethernet-network-diagnostics-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/ethernet-network-diagnostics-cluster.xml index 3dd3e9d814aa02..830814b55dd2f3 100644 --- a/src/app/zap-templates/zcl/data-model/chip/ethernet-network-diagnostics-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/ethernet-network-diagnostics-cluster.xml @@ -48,8 +48,8 @@ limitations under the License. CollisionCount OverrunCount CarrierDetect - TimeSinceReset - + TimeSinceReset + Reception of this command SHALL reset the attributes: PacketRxCount, PacketTxCount, TxErrCount, CollisionCount, OverrunCount to 0 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..9943bc6992a016 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 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/messages-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/messages-cluster.xml index 0029e1066f96f0..28b3eb975594a0 100644 --- a/src/app/zap-templates/zcl/data-model/chip/messages-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/messages-cluster.xml @@ -84,7 +84,13 @@ limitations under the License. Command for requesting messages be presented - + + + + + + + diff --git a/src/app/zap-templates/zcl/data-model/chip/mode-base-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/mode-base-cluster.xml index bcf6e2b4e72555..abacba4bafe631 100644 --- a/src/app/zap-templates/zcl/data-model/chip/mode-base-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/mode-base-cluster.xml @@ -90,8 +90,8 @@ This is because zap does not currently support generating code for clusters that - - + + diff --git a/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml index 41a0c64e4af169..27817054967fb5 100644 --- a/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml @@ -64,13 +64,9 @@ both values from this cluster and from the base cluster. Upon receipt, the device SHALL pause its operation if it is possible based on the current function of the server. - - Upon receipt, the device SHALL stop its operation if it is at a position where it is safe to do so and/or permitted. - + - - Upon receipt, the device SHALL start its operation if it is safe to do so and the device is in an operational state from which it can be started. - + Upon receipt, the device SHALL resume its operation from the point it was at when it received the Pause command, or from the point when it was paused by means outside of this cluster (for example by manual button press). diff --git a/src/app/zap-templates/zcl/data-model/chip/rvc-clean-mode-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/rvc-clean-mode-cluster.xml index 03725f92756c56..3c8686b6d90fb3 100644 --- a/src/app/zap-templates/zcl/data-model/chip/rvc-clean-mode-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/rvc-clean-mode-cluster.xml @@ -41,7 +41,7 @@ limitations under the License. SupportedModes CurrentMode - OnMode + @@ -60,4 +60,11 @@ limitations under the License. + + + + + + + diff --git a/src/app/zap-templates/zcl/data-model/chip/rvc-run-mode-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/rvc-run-mode-cluster.xml index 9f102dd8b63b15..f2d24e62ede0f4 100644 --- a/src/app/zap-templates/zcl/data-model/chip/rvc-run-mode-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/rvc-run-mode-cluster.xml @@ -48,7 +48,7 @@ limitations under the License. SupportedModes CurrentMode - OnMode + @@ -67,4 +67,11 @@ limitations under the License. + + + + + + + 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 ebf77014acc5b3..18c21d04851dce 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", @@ -414,18 +416,8 @@ "OnMode", "FeatureMap" ], - "RVC Clean Mode": [ - "SupportedModes", - "CurrentMode", - "OnMode", - "FeatureMap" - ], - "RVC Run Mode": [ - "SupportedModes", - "CurrentMode", - "OnMode", - "FeatureMap" - ], + "RVC Clean Mode": ["SupportedModes", "CurrentMode", "FeatureMap"], + "RVC Run Mode": ["SupportedModes", "CurrentMode", "FeatureMap"], "Operational State": [ "OperationalState", "OperationalError", @@ -609,7 +601,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 b0d50dc7ba2c44..7d6ae97ac990b2 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", @@ -412,18 +414,8 @@ "OnMode", "FeatureMap" ], - "RVC Clean Mode": [ - "SupportedModes", - "CurrentMode", - "OnMode", - "FeatureMap" - ], - "RVC Run Mode": [ - "SupportedModes", - "CurrentMode", - "OnMode", - "FeatureMap" - ], + "RVC Clean Mode": ["SupportedModes", "CurrentMode", "FeatureMap"], + "RVC Run Mode": ["SupportedModes", "CurrentMode", "FeatureMap"], "Operational State": [ "OperationalState", "OperationalError", @@ -607,7 +599,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..3d60b7279bd61c 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": [], @@ -182,6 +183,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": [ 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/ble/BUILD.gn b/src/ble/BUILD.gn index a9f2f07419f77f..bfdc3db2548044 100644 --- a/src/ble/BUILD.gn +++ b/src/ble/BUILD.gn @@ -73,7 +73,9 @@ if (chip_config_network_layer_ble) { "BleError.h", "BleLayer.cpp", "BleLayer.h", + "BleLayerDelegate.h", "BlePlatformDelegate.h", + "BleRole.h", "BleUUID.cpp", "BleUUID.h", "BtpEngine.cpp", diff --git a/src/controller/BUILD.gn b/src/controller/BUILD.gn index 435e405c299c97..9742bf05684b3c 100644 --- a/src/controller/BUILD.gn +++ b/src/controller/BUILD.gn @@ -81,5 +81,10 @@ static_library("controller") { deps = [ "${chip_root}/src/lib/address_resolve" ] + if (chip_controller && chip_build_controller) { + # ExampleOperationalCredentialsIssuer uses TestGroupData + deps += [ "${chip_root}/src/lib/support:testing" ] + } + defines = [] } diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 925f665448bd53..96a2f775df3b85 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -3117,7 +3117,7 @@ cluster RvcRunMode = 84 { } bitmap Feature : bitmap32 { - kOnOff = 0x1; + kNoFeatures = 0x0; } struct ModeTagStruct { @@ -3133,7 +3133,6 @@ cluster RvcRunMode = 84 { readonly attribute ModeOptionStruct supportedModes[] = 0; readonly attribute int8u currentMode = 1; - attribute optional nullable int8u onMode = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3170,7 +3169,7 @@ cluster RvcCleanMode = 85 { } bitmap Feature : bitmap32 { - kOnOff = 0x1; + kNoFeatures = 0x0; } struct ModeTagStruct { @@ -3186,7 +3185,6 @@ cluster RvcCleanMode = 85 { readonly attribute ModeOptionStruct supportedModes[] = 0; readonly attribute int8u currentMode = 1; - attribute optional nullable int8u onMode = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3712,10 +3710,6 @@ cluster RvcOperationalState = 97 { /** Upon receipt, the device SHALL pause its operation if it is possible based on the current function of the server. */ command Pause(): OperationalCommandResponse = 0; - /** Upon receipt, the device SHALL stop its operation if it is at a position where it is safe to do so and/or permitted. */ - command Stop(): OperationalCommandResponse = 1; - /** Upon receipt, the device SHALL start its operation if it is safe to do so and the device is in an operational state from which it can be started. */ - command Start(): OperationalCommandResponse = 2; /** Upon receipt, the device SHALL resume its operation from the point it was at when it received the Pause command, or from the point when it was paused by means outside of this cluster (for example by manual button press). */ command Resume(): OperationalCommandResponse = 3; /** On receipt of this command, the device SHALL start seeking the charging dock, if possible in the current state of the device. */ @@ -4097,6 +4091,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; @@ -4145,8 +4244,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; @@ -4168,6 +4274,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; @@ -4446,7 +4553,13 @@ cluster Messages = 151 { readonly attribute int16u clusterRevision = 65533; request struct PresentMessagesRequestRequest { - MessageStruct messages[] = 0; + 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 { 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/AndroidCallbacks.cpp b/src/controller/java/AndroidCallbacks.cpp index 2a275f7394a125..f4f62b6b0ec4c7 100644 --- a/src/controller/java/AndroidCallbacks.cpp +++ b/src/controller/java/AndroidCallbacks.cpp @@ -91,7 +91,7 @@ void GetConnectedDeviceCallback::OnDeviceConnectedFn(void * context, Messaging:: VerifyOrReturn(self->mJavaCallbackRef.HasValidObjectRef(), ChipLogError(Controller, "mJavaCallbackRef is not valid in %s", __func__)); jobject javaCallback = self->mJavaCallbackRef.ObjectRef(); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); // Release wrapper's global ref so application can clean up the actual callback underneath. VerifyOrReturn(self->mWrapperCallbackRef.HasValidObjectRef(), ChipLogError(Controller, "mWrapperCallbackRef is not valid in %s", __func__)); @@ -124,7 +124,7 @@ void GetConnectedDeviceCallback::OnDeviceConnectionFailureFn(void * context, VerifyOrReturn(self->mJavaCallbackRef.HasValidObjectRef(), ChipLogError(Controller, "mJavaCallbackRef is not valid in %s", __func__)); jobject javaCallback = self->mJavaCallbackRef.ObjectRef(); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); jclass getConnectedDeviceCallbackCls = nullptr; JniReferences::GetInstance().GetLocalClassRef( @@ -185,7 +185,7 @@ void ReportCallback::OnReportBegin() { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); jclass nodeStateCls = nullptr; CHIP_ERROR err = JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/model/NodeState", nodeStateCls); VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Controller, "Could not get NodeState class")); @@ -229,7 +229,7 @@ void ReportCallback::OnReportEnd() CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); VerifyOrReturn(mReportCallbackRef.HasValidObjectRef(), ChipLogError(Controller, "mReportCallbackRef is not valid in %s", __func__)); jobject reportCallback = mReportCallbackRef.ObjectRef(); @@ -276,7 +276,7 @@ void ReportCallback::OnAttributeData(const app::ConcreteDataAttributePath & aPat CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); jobject attributePathObj = nullptr; err = CreateChipAttributePath(env, aPath, attributePathObj); @@ -562,7 +562,7 @@ void ReportCallback::OnDone(app::ReadClient *) CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); VerifyOrReturn(mWrapperCallbackRef.HasValidObjectRef(), ChipLogError(Controller, "mWrapperCallbackRef is not valid in %s", __func__)); JniGlobalReference globalRef(std::move(mWrapperCallbackRef)); @@ -588,7 +588,7 @@ void ReportCallback::OnSubscriptionEstablished(SubscriptionId aSubscriptionId) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); DeviceLayer::StackUnlock unlock; VerifyOrReturn(mSubscriptionEstablishedCallbackRef.HasValidObjectRef(), ChipLogError(Controller, " mSubscriptionEstablishedCallbackRef is not valid in %s", __func__)); @@ -600,7 +600,7 @@ CHIP_ERROR ReportCallback::OnResubscriptionNeeded(app::ReadClient * apReadClient JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NULL_OBJECT); ReturnErrorOnFailure(app::ReadClient::Callback::OnResubscriptionNeeded(apReadClient, aTerminationCause)); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); jmethodID onResubscriptionAttemptMethod; VerifyOrReturnLogError(mResubscriptionAttemptCallbackRef.HasValidObjectRef(), CHIP_ERROR_INCORRECT_STATE); jobject resubscriptionAttemptCallbackRef = mResubscriptionAttemptCallbackRef.ObjectRef(); @@ -631,7 +631,7 @@ void ReportCallback::ReportError(jobject attributePath, jobject eventPath, const CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); VerifyOrReturn(mReportCallbackRef.HasValidObjectRef(), ChipLogError(Controller, "mReportCallbackRef is not valid in %s", __func__)); jobject reportCallback = mReportCallbackRef.ObjectRef(); @@ -674,7 +674,7 @@ void WriteAttributesCallback::OnResponse(const app::WriteClient * apWriteClient, CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); jobject attributePathObj = nullptr; err = CreateChipAttributePath(env, aPath, attributePathObj); @@ -708,7 +708,7 @@ void WriteAttributesCallback::OnDone(app::WriteClient *) CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); VerifyOrReturn(mWrapperCallbackRef.HasValidObjectRef(), ChipLogError(Controller, "mWrapperCallbackRef is not valid in %s", __func__)); JniGlobalReference globalRef(std::move(mWrapperCallbackRef)); @@ -738,7 +738,7 @@ void WriteAttributesCallback::ReportError(jobject attributePath, const char * me CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); ChipLogError(Controller, "WriteAttributesCallback::ReportError is called with %u", errorCode); jthrowable exception; err = AndroidControllerExceptions::GetInstance().CreateAndroidControllerException(env, message, errorCode, exception); @@ -782,7 +782,7 @@ void InvokeCallback::OnResponse(app::CommandSender * apCommandSender, const app: VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); jobject invokeElementObj = nullptr; jmethodID onResponseMethod; - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); err = CreateInvokeElement(env, aPath, apData, invokeElementObj); VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Controller, "Unable to create Java InvokeElement: %s", ErrorStr(err))); VerifyOrReturn(mJavaCallbackRef.HasValidObjectRef(), ChipLogError(Controller, "mJavaCallbackRef is not valid in %s", __func__)); @@ -814,7 +814,7 @@ void InvokeCallback::OnDone(app::CommandSender * apCommandSender) CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); VerifyOrReturn(mWrapperCallbackRef.HasValidObjectRef(), ChipLogError(Controller, "mWrapperCallbackRef is not valid in %s", __func__)); JniGlobalReference globalRef(std::move(mWrapperCallbackRef)); @@ -844,7 +844,7 @@ void InvokeCallback::ReportError(const char * message, ChipError::StorageType er CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); ChipLogError(Controller, "InvokeCallback::ReportError is called with %u", errorCode); jthrowable exception; err = AndroidControllerExceptions::GetInstance().CreateAndroidControllerException(env, message, errorCode, exception); diff --git a/src/controller/java/AndroidClusterExceptions.cpp b/src/controller/java/AndroidClusterExceptions.cpp index 4a757588b94414..863faef1a01c0b 100644 --- a/src/controller/java/AndroidClusterExceptions.cpp +++ b/src/controller/java/AndroidClusterExceptions.cpp @@ -30,76 +30,17 @@ CHIP_ERROR AndroidClusterExceptions::CreateChipClusterException(JNIEnv * env, ui jmethodID exceptionConstructor; jclass clusterExceptionCls; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipClusterException", clusterExceptionCls); + err = + chip::JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ChipClusterException", clusterExceptionCls); VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_JNI_ERROR_TYPE_NOT_FOUND); - chip::JniClass clusterExceptionJniCls(clusterExceptionCls); exceptionConstructor = env->GetMethodID(clusterExceptionCls, "", "(J)V"); VerifyOrReturnError(exceptionConstructor != nullptr, CHIP_JNI_ERROR_TYPE_NOT_FOUND); - outEx = (jthrowable) env->NewObject(clusterExceptionCls, exceptionConstructor, static_cast(errorCode)); + outEx = static_cast(env->NewObject(clusterExceptionCls, exceptionConstructor, static_cast(errorCode))); VerifyOrReturnError(outEx != nullptr, CHIP_JNI_ERROR_TYPE_NOT_FOUND); return err; } -CHIP_ERROR AndroidClusterExceptions::CreateIllegalStateException(JNIEnv * env, const char message[], ChipError errorCode, - jthrowable & outEx) -{ - return CreateIllegalStateException(env, message, errorCode.AsInteger(), outEx); -} - -CHIP_ERROR AndroidClusterExceptions::CreateIllegalStateException(JNIEnv * env, const char message[], - ChipError::StorageType errorCode, jthrowable & outEx) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - jmethodID exceptionConstructor; - jclass exceptionClass; - jstring errStr; - - err = JniReferences::GetInstance().GetClassRef(env, "java/lang/IllegalStateException", exceptionClass); - VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_JNI_ERROR_TYPE_NOT_FOUND); - JniClass exceptionJniClass(exceptionClass); - - exceptionConstructor = env->GetMethodID(exceptionClass, "", "(Ljava/lang/String;)V"); - VerifyOrReturnError(exceptionConstructor != nullptr, CHIP_JNI_ERROR_TYPE_NOT_FOUND); - - char buf[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; - snprintf(buf, sizeof(buf), "%s: %d", message, errorCode); - errStr = env->NewStringUTF(buf); - - outEx = static_cast(env->NewObject(exceptionClass, exceptionConstructor, errStr)); - VerifyOrReturnError(outEx != nullptr, CHIP_JNI_ERROR_TYPE_NOT_FOUND); - - return err; -} - -void AndroidClusterExceptions::ReturnIllegalStateException(JNIEnv * env, jobject callback, const char message[], ChipError error) -{ - ReturnIllegalStateException(env, callback, message, error.AsInteger()); -} - -void AndroidClusterExceptions::ReturnIllegalStateException(JNIEnv * env, jobject callback, const char message[], - ChipError::StorageType errorCode) -{ - VerifyOrReturn(callback != nullptr, ChipLogDetail(Zcl, "Callback is null in ReturnIllegalStateException(), exiting early")); - CHIP_ERROR err = CHIP_NO_ERROR; - jmethodID method; - err = JniReferences::GetInstance().FindMethod(env, callback, "onError", "(Ljava/lang/Exception;)V", &method); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error throwing IllegalStateException %d", err.AsInteger()); - return; - } - - jthrowable exception; - err = CreateIllegalStateException(env, message, errorCode, exception); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error throwing IllegalStateException %d", err.AsInteger()); - return; - } - env->CallVoidMethod(callback, method, exception); -} - } // namespace chip diff --git a/src/controller/java/AndroidClusterExceptions.h b/src/controller/java/AndroidClusterExceptions.h index 716076d1d81bdf..ead4901e7e352c 100644 --- a/src/controller/java/AndroidClusterExceptions.h +++ b/src/controller/java/AndroidClusterExceptions.h @@ -39,21 +39,6 @@ class AndroidClusterExceptions */ CHIP_ERROR CreateChipClusterException(JNIEnv * env, uint32_t errorCode, jthrowable & outEx); - /** - * Creates a Java IllegalStateException in outEx. - */ - CHIP_ERROR CreateIllegalStateException(JNIEnv * env, const char message[], ChipError errorCode, jthrowable & outEx); - - CHIP_ERROR CreateIllegalStateException(JNIEnv * env, const char message[], ChipError::StorageType errorCode, - jthrowable & outEx); - - /** - * Creates an IllegalStateException and passes it to the Java onError() function of the provided callback object. - */ - void ReturnIllegalStateException(JNIEnv * env, jobject callback, const char message[], ChipError errorCode); - - void ReturnIllegalStateException(JNIEnv * env, jobject callback, const char message[], ChipError::StorageType errorCode); - private: AndroidClusterExceptions() {} }; diff --git a/src/controller/java/AndroidCommissioningWindowOpener.cpp b/src/controller/java/AndroidCommissioningWindowOpener.cpp index 222edcb441f9c8..0429c72bf12ad5 100644 --- a/src/controller/java/AndroidCommissioningWindowOpener.cpp +++ b/src/controller/java/AndroidCommissioningWindowOpener.cpp @@ -121,7 +121,7 @@ void AndroidCommissioningWindowOpener::OnOpenCommissioningWindowResponse(void * auto * self = static_cast(context); JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); VerifyOrExit(self->mJavaCallback != nullptr, ChipLogError(Controller, "mJavaCallback is not allocated.")); @@ -160,7 +160,7 @@ void AndroidCommissioningWindowOpener::OnOpenBasicCommissioningWindowResponse(vo { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); if (status == CHIP_NO_ERROR) { if (self->mOnSuccessMethod != nullptr) diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index 39feef3f704177..29f055560527d6 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -543,7 +543,8 @@ CHIP_ERROR AndroidDeviceControllerWrapper::UpdateDeviceAttestationDelegateBridge return err; } -CHIP_ERROR AndroidDeviceControllerWrapper::UpdateAttestationTrustStoreBridge(jobject attestationTrustStoreDelegate) +CHIP_ERROR AndroidDeviceControllerWrapper::UpdateAttestationTrustStoreBridge(jobject attestationTrustStoreDelegate, + jobject cdTrustKeys) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -566,6 +567,29 @@ CHIP_ERROR AndroidDeviceControllerWrapper::UpdateAttestationTrustStoreBridge(job } mDeviceAttestationVerifier = deviceAttestationVerifier; + if (cdTrustKeys != nullptr) + { + WellKnownKeysTrustStore * cdTrustStore = mDeviceAttestationVerifier->GetCertificationDeclarationTrustStore(); + VerifyOrExit(cdTrustStore != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + + jint size; + err = JniReferences::GetInstance().GetListSize(cdTrustKeys, size); + VerifyOrExit(err == CHIP_NO_ERROR, err = CHIP_ERROR_INVALID_ARGUMENT); + + for (jint i = 0; i < size; i++) + { + jobject jTrustKey = nullptr; + err = JniReferences::GetInstance().GetListItem(cdTrustKeys, i, jTrustKey); + + VerifyOrExit(err == CHIP_NO_ERROR, err = CHIP_ERROR_INVALID_ARGUMENT); + + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + JniByteArray jniTrustKey(env, static_cast(jTrustKey)); + err = cdTrustStore->AddTrustedKey(jniTrustKey.byteSpan()); + VerifyOrExit(err == CHIP_NO_ERROR, err = CHIP_ERROR_INVALID_ARGUMENT); + } + } + mController->SetDeviceAttestationVerifier(mDeviceAttestationVerifier); exit: @@ -692,7 +716,7 @@ void AndroidDeviceControllerWrapper::OnCommissioningStatusUpdate(PeerId peerId, chip::DeviceLayer::StackUnlock unlock; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); jmethodID onCommissioningStatusUpdateMethod; CHIP_ERROR err = JniReferences::GetInstance().FindMethod(env, mJavaObjectRef, "onCommissioningStatusUpdate", "(JLjava/lang/String;I)V", &onCommissioningStatusUpdateMethod); @@ -727,8 +751,10 @@ void AndroidDeviceControllerWrapper::OnScanNetworksSuccess( { chip::DeviceLayer::StackUnlock unlock; CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); jmethodID javaMethod; + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); @@ -798,8 +824,8 @@ void AndroidDeviceControllerWrapper::OnScanNetworksSuccess( chip::JniReferences::GetInstance().CreateBoxedObject("java/lang/Integer", "(I)V", jniRssi, newElement_rssi); jclass wiFiInterfaceScanResultStructClass; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/WiFiScanResult", - wiFiInterfaceScanResultStructClass); + err = chip::JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/WiFiScanResult", + wiFiInterfaceScanResultStructClass); if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "Could not find class WiFiScanResult"); @@ -863,8 +889,8 @@ void AndroidDeviceControllerWrapper::OnScanNetworksSuccess( chip::JniReferences::GetInstance().CreateBoxedObject("java/lang/Integer", "(I)V", jniLqi, newElement_lqi); jclass threadInterfaceScanResultStructClass; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ThreadScanResult", - threadInterfaceScanResultStructClass); + err = chip::JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ThreadScanResult", + threadInterfaceScanResultStructClass); if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "Could not find class ThreadScanResult"); @@ -944,7 +970,7 @@ void AndroidDeviceControllerWrapper::OnICDRegistrationComplete(chip::NodeId icdN JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); jmethodID onICDRegistrationCompleteMethod; jclass icdDeviceInfoClass = nullptr; jmethodID icdDeviceInfoStructCtor = nullptr; diff --git a/src/controller/java/AndroidDeviceControllerWrapper.h b/src/controller/java/AndroidDeviceControllerWrapper.h index 4e9a541fa29564..69a7fe75c0bf0b 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.h +++ b/src/controller/java/AndroidDeviceControllerWrapper.h @@ -202,7 +202,7 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel CHIP_ERROR UpdateDeviceAttestationDelegateBridge(jobject deviceAttestationDelegate, chip::Optional expiryTimeoutSecs, bool shouldWaitAfterDeviceAttestation); - CHIP_ERROR UpdateAttestationTrustStoreBridge(jobject attestationTrustStoreDelegate); + CHIP_ERROR UpdateAttestationTrustStoreBridge(jobject attestationTrustStoreDelegate, jobject cdTrustKeys); CHIP_ERROR StartOTAProvider(jobject otaProviderDelegate); diff --git a/src/controller/java/AndroidOperationalCredentialsIssuer.cpp b/src/controller/java/AndroidOperationalCredentialsIssuer.cpp index 290f682e1252aa..f63f1a46ecbbe3 100644 --- a/src/controller/java/AndroidOperationalCredentialsIssuer.cpp +++ b/src/controller/java/AndroidOperationalCredentialsIssuer.cpp @@ -127,6 +127,10 @@ CHIP_ERROR AndroidOperationalCredentialsIssuer::GenerateNOCChain(const ByteSpan const ByteSpan & PAI, Callback::Callback * onCompletion) { + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnError(env != nullptr, CHIP_ERROR_INCORRECT_STATE); + JniLocalReferenceScope scope(env); + if (mUseJavaCallbackForNOCRequest) { return CallbackGenerateNOCChain(csrElements, csrNonce, attestationSignature, attestationChallenge, DAC, PAI, onCompletion); @@ -464,8 +468,7 @@ CHIP_ERROR N2J_CSRInfo(JNIEnv * env, jbyteArray nonce, jbyteArray elements, jbyt jmethodID constructor; jclass infoClass; - err = JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/CSRInfo", infoClass); - JniClass attestationInfoClass(infoClass); + err = JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/CSRInfo", infoClass); SuccessOrExit(err); env->ExceptionClear(); @@ -487,8 +490,7 @@ CHIP_ERROR N2J_AttestationInfo(JNIEnv * env, jbyteArray challenge, jbyteArray no jmethodID constructor; jclass infoClass; - err = JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/AttestationInfo", infoClass); - JniClass attestationInfoClass(infoClass); + err = JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/AttestationInfo", infoClass); SuccessOrExit(err); env->ExceptionClear(); diff --git a/src/controller/java/AttestationTrustStoreBridge.cpp b/src/controller/java/AttestationTrustStoreBridge.cpp index d5915543fa0be0..056c87c4d1b464 100644 --- a/src/controller/java/AttestationTrustStoreBridge.cpp +++ b/src/controller/java/AttestationTrustStoreBridge.cpp @@ -65,15 +65,17 @@ CHIP_ERROR AttestationTrustStoreBridge::GetProductAttestationAuthorityCert(const CHIP_ERROR AttestationTrustStoreBridge::GetPaaCertFromJava(const chip::ByteSpan & skid, chip::MutableByteSpan & outPaaDerBuffer) const { - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); jclass attestationTrustStoreDelegateCls = nullptr; jbyteArray javaSkid = nullptr; jmethodID getProductAttestationAuthorityCertMethod = nullptr; - JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/AttestationTrustStoreDelegate", - attestationTrustStoreDelegateCls); + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnError(env != nullptr, CHIP_ERROR_INCORRECT_STATE); + JniLocalReferenceScope scope(env); + + JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/AttestationTrustStoreDelegate", + attestationTrustStoreDelegateCls); VerifyOrReturnError(attestationTrustStoreDelegateCls != nullptr, CHIP_JNI_ERROR_TYPE_NOT_FOUND); - JniClass attestationTrustStoreDelegateJniCls(attestationTrustStoreDelegateCls); JniReferences::GetInstance().FindMethod(env, mAttestationTrustStoreDelegate, "getProductAttestationAuthorityCert", "([B)[B", &getProductAttestationAuthorityCertMethod); diff --git a/src/controller/java/BdxOTASender.cpp b/src/controller/java/BdxOTASender.cpp index 41f116762f9f8b..119789ce4ad8b9 100644 --- a/src/controller/java/BdxOTASender.cpp +++ b/src/controller/java/BdxOTASender.cpp @@ -179,7 +179,7 @@ CHIP_ERROR BdxOTASender::OnTransferSessionBegin(TransferSession::OutputEvent & e JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); UtfString fileDesignator(env, fileDesignatorSpan); uint64_t offset = mTransfer.GetStartOffset(); @@ -269,7 +269,7 @@ CHIP_ERROR BdxOTASender::OnBlockQuery(TransferSession::OutputEvent & event) JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); jmethodID handleBDXQueryMethod; CHIP_ERROR err = JniReferences::GetInstance().FindMethod( env, mOtaDelegate, "handleBDXQuery", "(JIJJ)Lchip/devicecontroller/OTAProviderDelegate$BDXData;", &handleBDXQueryMethod); diff --git a/src/controller/java/CHIPDefaultCallbacks.cpp b/src/controller/java/CHIPDefaultCallbacks.cpp index 95363535a2247f..4600c5c9877a14 100644 --- a/src/controller/java/CHIPDefaultCallbacks.cpp +++ b/src/controller/java/CHIPDefaultCallbacks.cpp @@ -103,6 +103,9 @@ void chip::CHIPDefaultFailureCallback::CallbackFn(void * context, CHIP_ERROR err 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; diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index 48e2192c1d5281..b32c207fcf92f9 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -533,7 +532,7 @@ JNI_METHOD(void, setDeviceAttestationDelegate) } JNI_METHOD(void, setAttestationTrustStoreDelegate) -(JNIEnv * env, jobject self, jlong handle, jobject attestationTrustStoreDelegate) +(JNIEnv * env, jobject self, jlong handle, jobject attestationTrustStoreDelegate, jobject cdTrustKeys) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; @@ -544,7 +543,7 @@ JNI_METHOD(void, setAttestationTrustStoreDelegate) if (attestationTrustStoreDelegate != nullptr) { jobject attestationTrustStoreDelegateRef = env->NewGlobalRef(attestationTrustStoreDelegate); - err = wrapper->UpdateAttestationTrustStoreBridge(attestationTrustStoreDelegateRef); + err = wrapper->UpdateAttestationTrustStoreBridge(attestationTrustStoreDelegateRef, cdTrustKeys); SuccessOrExit(err); } @@ -2176,10 +2175,12 @@ JNI_METHOD(jobject, getICDClientInfo)(JNIEnv * env, jobject self, jlong handle, ChipLogError(Controller, "CreateArrayList failed!: %" CHIP_ERROR_FORMAT, err.Format())); auto iter = wrapper->getICDClientStorage()->IterateICDClientInfo(); + VerifyOrReturnValue(iter != nullptr, nullptr, ChipLogError(Controller, "IterateICDClientInfo failed!")); + app::DefaultICDClientStorage::ICDClientInfoIteratorWrapper clientInfoIteratorWrapper(iter); jmethodID constructor; jclass infoClass; - JniLocalReferenceManager manager(env); + JniLocalReferenceScope scope(env); err = JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ICDClientInfo", infoClass); VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, @@ -2219,8 +2220,6 @@ JNI_METHOD(jobject, getICDClientInfo)(JNIEnv * env, jobject self, jlong handle, ChipLogError(Controller, "AddToList error!: %" CHIP_ERROR_FORMAT, err.Format())); } - iter->Release(); - return jInfo; } @@ -3073,8 +3072,7 @@ CHIP_ERROR N2J_PaseVerifierParams(JNIEnv * env, jlong setupPincode, jbyteArray p jmethodID constructor; jclass paramsClass; - err = JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/PaseVerifierParams", paramsClass); - JniClass paseVerifierParamsClass(paramsClass); + err = JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/PaseVerifierParams", paramsClass); SuccessOrExit(err); env->ExceptionClear(); @@ -3094,8 +3092,7 @@ CHIP_ERROR N2J_NetworkLocation(JNIEnv * env, jstring ipAddress, jint port, jint jmethodID constructor; jclass locationClass; - err = JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/NetworkLocation", locationClass); - JniClass networkLocationClass(locationClass); + err = JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/NetworkLocation", locationClass); SuccessOrExit(err); env->ExceptionClear(); diff --git a/src/controller/java/DeviceAttestationDelegateBridge.cpp b/src/controller/java/DeviceAttestationDelegateBridge.cpp index b201a073661b9a..5c695da3b4f9bb 100644 --- a/src/controller/java/DeviceAttestationDelegateBridge.cpp +++ b/src/controller/java/DeviceAttestationDelegateBridge.cpp @@ -37,8 +37,7 @@ CHIP_ERROR N2J_AttestationInfo(JNIEnv * env, const chip::Credentials::DeviceAtte const ByteSpan PAI = info.paiDerBuffer(); const Optional certificationDeclarationSpan = info.cdBuffer(); - err = JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/AttestationInfo", infoClass); - JniClass attestationInfoClass(infoClass); + err = JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/AttestationInfo", infoClass); SuccessOrExit(err); env->ExceptionClear(); @@ -71,17 +70,15 @@ void DeviceAttestationDelegateBridge::OnDeviceAttestationCompleted( mResult = attestationResult; if (mDeviceAttestationDelegate != nullptr) { - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); jclass deviceAttestationDelegateCls = nullptr; - - JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/DeviceAttestationDelegate", - deviceAttestationDelegateCls); + JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/DeviceAttestationDelegate", + deviceAttestationDelegateCls); VerifyOrReturn(deviceAttestationDelegateCls != nullptr, ChipLogError(Controller, "Could not find device attestation delegate class.")); - // Auto delete deviceAttestationDelegateCls object when exit from the local scope - JniClass deviceAttestationDelegateJniCls(deviceAttestationDelegateCls); - if (env->IsInstanceOf(mDeviceAttestationDelegate, deviceAttestationDelegateCls)) { jmethodID onDeviceAttestationCompletedMethod; diff --git a/src/controller/java/OTAProviderDelegateBridge.cpp b/src/controller/java/OTAProviderDelegateBridge.cpp index 905741acf58648..10f9ae12801558 100644 --- a/src/controller/java/OTAProviderDelegateBridge.cpp +++ b/src/controller/java/OTAProviderDelegateBridge.cpp @@ -109,7 +109,8 @@ void OTAProviderDelegateBridge::HandleQueryImage(CommandHandler * commandObj, co CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - chip::JniLocalReferenceManager manager(env); + VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); + chip::JniLocalReferenceScope scope(env); jobject otaProviderDelegate = nullptr; jmethodID handleQueryImageMethod = nullptr; @@ -374,7 +375,7 @@ void OTAProviderDelegateBridge::HandleApplyUpdateRequest(CommandHandler * comman jmethodID getActionMethod; jmethodID getDelayedActionTimeMethod; - chip::JniLocalReferenceManager manager(env); + chip::JniLocalReferenceScope scope(env); Commands::ApplyUpdateResponse::Type response; Commands::ApplyUpdateResponse::Type errorResponse; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java index d5de31ddb4ceea..57853e1eed76c4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java @@ -21433,7 +21433,6 @@ public static class RvcRunModeCluster extends BaseChipCluster { private static final long SUPPORTED_MODES_ATTRIBUTE_ID = 0L; private static final long CURRENT_MODE_ATTRIBUTE_ID = 1L; - private static final long ON_MODE_ATTRIBUTE_ID = 3L; 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; @@ -21496,10 +21495,6 @@ public interface SupportedModesAttributeCallback extends BaseAttributeCallback { void onSuccess(List value); } - public interface OnModeAttributeCallback extends BaseAttributeCallback { - void onSuccess(@Nullable Integer value); - } - public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { void onSuccess(List value); } @@ -21566,40 +21561,6 @@ public void onSuccess(byte[] tlv) { }, CURRENT_MODE_ATTRIBUTE_ID, minInterval, maxInterval); } - public void readOnModeAttribute( - OnModeAttributeCallback callback) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ON_MODE_ATTRIBUTE_ID); - - readAttribute(new ReportCallbackImpl(callback, path) { - @Override - public void onSuccess(byte[] tlv) { - @Nullable Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); - callback.onSuccess(value); - } - }, ON_MODE_ATTRIBUTE_ID, true); - } - - public void writeOnModeAttribute(DefaultClusterCallback callback, Integer value) { - writeOnModeAttribute(callback, value, 0); - } - - public void writeOnModeAttribute(DefaultClusterCallback callback, Integer value, int timedWriteTimeoutMs) { - BaseTLVType tlvValue = value != null ? new UIntType(value) : new NullType(); - writeAttribute(new WriteAttributesCallbackImpl(callback), ON_MODE_ATTRIBUTE_ID, tlvValue, timedWriteTimeoutMs); - } - - public void subscribeOnModeAttribute( - OnModeAttributeCallback callback, int minInterval, int maxInterval) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ON_MODE_ATTRIBUTE_ID); - - subscribeAttribute(new ReportCallbackImpl(callback, path) { - @Override - public void onSuccess(byte[] tlv) { - @Nullable Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); - } - }, ON_MODE_ATTRIBUTE_ID, minInterval, maxInterval); - } - public void readGeneratedCommandListAttribute( GeneratedCommandListAttributeCallback callback) { ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID); @@ -21756,7 +21717,6 @@ public static class RvcCleanModeCluster extends BaseChipCluster { private static final long SUPPORTED_MODES_ATTRIBUTE_ID = 0L; private static final long CURRENT_MODE_ATTRIBUTE_ID = 1L; - private static final long ON_MODE_ATTRIBUTE_ID = 3L; 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; @@ -21819,10 +21779,6 @@ public interface SupportedModesAttributeCallback extends BaseAttributeCallback { void onSuccess(List value); } - public interface OnModeAttributeCallback extends BaseAttributeCallback { - void onSuccess(@Nullable Integer value); - } - public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { void onSuccess(List value); } @@ -21889,40 +21845,6 @@ public void onSuccess(byte[] tlv) { }, CURRENT_MODE_ATTRIBUTE_ID, minInterval, maxInterval); } - public void readOnModeAttribute( - OnModeAttributeCallback callback) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ON_MODE_ATTRIBUTE_ID); - - readAttribute(new ReportCallbackImpl(callback, path) { - @Override - public void onSuccess(byte[] tlv) { - @Nullable Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); - callback.onSuccess(value); - } - }, ON_MODE_ATTRIBUTE_ID, true); - } - - public void writeOnModeAttribute(DefaultClusterCallback callback, Integer value) { - writeOnModeAttribute(callback, value, 0); - } - - public void writeOnModeAttribute(DefaultClusterCallback callback, Integer value, int timedWriteTimeoutMs) { - BaseTLVType tlvValue = value != null ? new UIntType(value) : new NullType(); - writeAttribute(new WriteAttributesCallbackImpl(callback), ON_MODE_ATTRIBUTE_ID, tlvValue, timedWriteTimeoutMs); - } - - public void subscribeOnModeAttribute( - OnModeAttributeCallback callback, int minInterval, int maxInterval) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ON_MODE_ATTRIBUTE_ID); - - subscribeAttribute(new ReportCallbackImpl(callback, path) { - @Override - public void onSuccess(byte[] tlv) { - @Nullable Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); - } - }, ON_MODE_ATTRIBUTE_ID, minInterval, maxInterval); - } - public void readGeneratedCommandListAttribute( GeneratedCommandListAttributeCallback callback) { ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID); @@ -25413,58 +25335,6 @@ public void onResponse(StructType invokeStructValue) { }}, commandId, value, timedInvokeTimeoutMs); } - public void stop(OperationalCommandResponseCallback callback) { - stop(callback, 0); - } - - public void stop(OperationalCommandResponseCallback callback, int timedInvokeTimeoutMs) { - final long commandId = 1L; - - ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); - invoke(new InvokeCallbackImpl(callback) { - @Override - public void onResponse(StructType invokeStructValue) { - final long commandResponseStateFieldID = 0L; - ChipStructs.RvcOperationalStateClusterErrorStateStruct commandResponseState = null; - for (StructElement element: invokeStructValue.value()) { - if (element.contextTagNum() == commandResponseStateFieldID) { - if (element.value(BaseTLVType.class).type() == TLVType.Struct) { - StructType castingValue = element.value(StructType.class); - commandResponseState = ChipStructs.RvcOperationalStateClusterErrorStateStruct.decodeTlv(castingValue); - } - } - } - callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); - } - - public void start(OperationalCommandResponseCallback callback) { - start(callback, 0); - } - - public void start(OperationalCommandResponseCallback callback, int timedInvokeTimeoutMs) { - final long commandId = 2L; - - ArrayList elements = new ArrayList<>(); - StructType value = new StructType(elements); - invoke(new InvokeCallbackImpl(callback) { - @Override - public void onResponse(StructType invokeStructValue) { - final long commandResponseStateFieldID = 0L; - ChipStructs.RvcOperationalStateClusterErrorStateStruct commandResponseState = null; - for (StructElement element: invokeStructValue.value()) { - if (element.contextTagNum() == commandResponseStateFieldID) { - if (element.value(BaseTLVType.class).type() == TLVType.Struct) { - StructType castingValue = element.value(StructType.class); - commandResponseState = ChipStructs.RvcOperationalStateClusterErrorStateStruct.decodeTlv(castingValue); - } - } - } - callback.onSuccess(commandResponseState); - }}, commandId, value, timedInvokeTimeoutMs); - } - public void resume(OperationalCommandResponseCallback callback) { resume(callback, 0); } @@ -28324,14 +28194,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; @@ -28339,7 +28223,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); } @@ -28350,23 +28234,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 { @@ -28385,134 +28317,851 @@ public interface AttributeListAttributeCallback extends BaseAttributeCallback { void onSuccess(List value); } - public void readAccuracyAttribute( - AccuracyAttributeCallback callback) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCURACY_ATTRIBUTE_ID); + 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) { - ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } - }, ACCURACY_ATTRIBUTE_ID, true); + }, POWER_MODE_ATTRIBUTE_ID, true); } - public void subscribeAccuracyAttribute( - AccuracyAttributeCallback callback, int minInterval, int maxInterval) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCURACY_ATTRIBUTE_ID); + 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) { - ChipStructs.ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); } - }, ACCURACY_ATTRIBUTE_ID, minInterval, maxInterval); + }, POWER_MODE_ATTRIBUTE_ID, minInterval, maxInterval); } - public void readCumulativeEnergyImportedAttribute( - CumulativeEnergyImportedAttributeCallback callback) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID); + 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) { - @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } - }, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID, true); + }, NUMBER_OF_MEASUREMENT_TYPES_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 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) { - @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); } - }, CUMULATIVE_ENERGY_IMPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + }, NUMBER_OF_MEASUREMENT_TYPES_ATTRIBUTE_ID, minInterval, maxInterval); } - public void readCumulativeEnergyExportedAttribute( - CumulativeEnergyExportedAttributeCallback callback) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID); + 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) { - @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } - }, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID, true); + }, ACCURACY_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 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) { - @Nullable ChipStructs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); } - }, CUMULATIVE_ENERGY_EXPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + }, ACCURACY_ATTRIBUTE_ID, minInterval, maxInterval); } - public void readPeriodicEnergyImportedAttribute( - PeriodicEnergyImportedAttributeCallback callback) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_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); } - }, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID, true); + }, RANGES_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 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); } - }, PERIODIC_ENERGY_IMPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + }, RANGES_ATTRIBUTE_ID, minInterval, maxInterval); } - public void readPeriodicEnergyExportedAttribute( - PeriodicEnergyExportedAttributeCallback callback) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PERIODIC_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); } - }, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID, true); + }, VOLTAGE_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 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); } - }, PERIODIC_ENERGY_EXPORTED_ATTRIBUTE_ID, minInterval, maxInterval); + }, VOLTAGE_ATTRIBUTE_ID, minInterval, maxInterval); } - public void readGeneratedCommandListAttribute( - GeneratedCommandListAttributeCallback callback) { - ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_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 Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, ACTIVE_CURRENT_ATTRIBUTE_ID, true); + } + + 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 Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, ACTIVE_CURRENT_ATTRIBUTE_ID, minInterval, maxInterval); + } + + 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 Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, REACTIVE_CURRENT_ATTRIBUTE_ID, true); + } + + 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 Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, 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( + GeneratedCommandListAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID); readAttribute(new ReportCallbackImpl(callback, path) { @Override @@ -29208,17 +29857,41 @@ public long initWithDevice(long devicePtr, int endpointId) { return 0L; } - public void presentMessagesRequest(DefaultClusterCallback callback, ArrayList messages) { - presentMessagesRequest(callback, messages, 0); + public void presentMessagesRequest(DefaultClusterCallback callback, byte[] messageID, Integer priority, Integer messageControl, @Nullable Long startTime, @Nullable Integer duration, String messageText, Optional> responses) { + presentMessagesRequest(callback, messageID, priority, messageControl, startTime, duration, messageText, responses, 0); } - public void presentMessagesRequest(DefaultClusterCallback callback, ArrayList messages, int timedInvokeTimeoutMs) { + public void presentMessagesRequest(DefaultClusterCallback callback, byte[] messageID, Integer priority, Integer messageControl, @Nullable Long startTime, @Nullable Integer duration, String messageText, Optional> responses, int timedInvokeTimeoutMs) { final long commandId = 0L; ArrayList elements = new ArrayList<>(); - final long messagesFieldID = 0L; - BaseTLVType messagestlvValue = ArrayType.generateArrayType(messages, (elementmessages) -> elementmessages.encodeTlv()); - elements.add(new StructElement(messagesFieldID, messagestlvValue)); + final long messageIDFieldID = 0L; + BaseTLVType messageIDtlvValue = new ByteArrayType(messageID); + elements.add(new StructElement(messageIDFieldID, messageIDtlvValue)); + + final long priorityFieldID = 1L; + BaseTLVType prioritytlvValue = new UIntType(priority); + elements.add(new StructElement(priorityFieldID, prioritytlvValue)); + + final long messageControlFieldID = 2L; + BaseTLVType messageControltlvValue = new UIntType(messageControl); + elements.add(new StructElement(messageControlFieldID, messageControltlvValue)); + + final long startTimeFieldID = 3L; + BaseTLVType startTimetlvValue = startTime != null ? new UIntType(startTime) : new NullType(); + elements.add(new StructElement(startTimeFieldID, startTimetlvValue)); + + final long durationFieldID = 4L; + BaseTLVType durationtlvValue = duration != null ? new UIntType(duration) : new NullType(); + elements.add(new StructElement(durationFieldID, durationtlvValue)); + + final long messageTextFieldID = 5L; + BaseTLVType messageTexttlvValue = new StringType(messageText); + elements.add(new StructElement(messageTextFieldID, messageTexttlvValue)); + + final long responsesFieldID = 6L; + 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); invoke(new InvokeCallbackImpl(callback) { 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 92a679fe443b26..8e8e0d91c5d23d 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(); } @@ -6862,7 +6865,6 @@ public long getID() { public enum Attribute { SupportedModes(0L), CurrentMode(1L), - OnMode(3L), GeneratedCommandList(65528L), AcceptedCommandList(65529L), EventList(65530L), @@ -6983,7 +6985,6 @@ public long getID() { public enum Attribute { SupportedModes(0L), CurrentMode(1L), - OnMode(3L), GeneratedCommandList(65528L), AcceptedCommandList(65529L), EventList(65530L), @@ -8233,8 +8234,6 @@ public static Event value(long id) throws NoSuchFieldError { public enum Command { Pause(0L), - Stop(1L), - Start(2L), Resume(3L), GoHome(128L),; private final long id; @@ -9023,6 +9022,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() { @@ -9035,6 +9154,7 @@ public enum Attribute { CumulativeEnergyExported(2L), PeriodicEnergyImported(3L), PeriodicEnergyExported(4L), + CumulativeEnergyReset(5L), GeneratedCommandList(65528L), AcceptedCommandList(65529L), EventList(65530L), @@ -9389,7 +9509,7 @@ public static Command value(long id) throws NoSuchFieldError { } throw new NoSuchFieldError(); } - }public enum PresentMessagesRequestCommandField {Messages(0),; + }public enum PresentMessagesRequestCommandField {MessageID(0),Priority(1),MessageControl(2),StartTime(3),Duration(4),MessageText(5),Responses(6),; private final int id; PresentMessagesRequestCommandField(int id) { this.id = id; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java index 70c1e3f12787d7..3f01a08cb3a911 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java @@ -7567,27 +7567,6 @@ public void onError(Exception ex) { } } - public static class DelegatedRvcRunModeClusterOnModeAttributeCallback implements ChipClusters.RvcRunModeCluster.OnModeAttributeCallback, 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 DelegatedRvcRunModeClusterGeneratedCommandListAttributeCallback implements ChipClusters.RvcRunModeCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override @@ -7717,27 +7696,6 @@ public void onError(Exception ex) { } } - public static class DelegatedRvcCleanModeClusterOnModeAttributeCallback implements ChipClusters.RvcCleanModeCluster.OnModeAttributeCallback, 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 DelegatedRvcCleanModeClusterGeneratedCommandListAttributeCallback implements ChipClusters.RvcCleanModeCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override @@ -9970,6 +9928,447 @@ public void onError(Exception ex) { } } + public static class DelegatedElectricalPowerMeasurementClusterAccuracyAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.AccuracyAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterRangesAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.RangesAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterVoltageAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.VoltageAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterActiveCurrentAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.ActiveCurrentAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterReactiveCurrentAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.ReactiveCurrentAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterApparentCurrentAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.ApparentCurrentAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterActivePowerAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.ActivePowerAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterReactivePowerAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.ReactivePowerAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterApparentPowerAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.ApparentPowerAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterRMSVoltageAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.RMSVoltageAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterRMSCurrentAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.RMSCurrentAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterRMSPowerAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.RMSPowerAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterFrequencyAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.FrequencyAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterHarmonicCurrentsAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.HarmonicCurrentsAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable 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 DelegatedElectricalPowerMeasurementClusterHarmonicPhasesAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.HarmonicPhasesAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable 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 DelegatedElectricalPowerMeasurementClusterPowerFactorAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.PowerFactorAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterNeutralCurrentAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.NeutralCurrentAttributeCallback, 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 DelegatedElectricalPowerMeasurementClusterGeneratedCommandListAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.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 DelegatedElectricalPowerMeasurementClusterAcceptedCommandListAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.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 DelegatedElectricalPowerMeasurementClusterEventListAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.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 DelegatedElectricalPowerMeasurementClusterAttributeListAttributeCallback implements ChipClusters.ElectricalPowerMeasurementCluster.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 DelegatedElectricalEnergyMeasurementClusterAccuracyAttributeCallback implements ChipClusters.ElectricalEnergyMeasurementCluster.AccuracyAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override @@ -10075,6 +10474,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 @@ -20469,6 +20889,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); @@ -20742,6 +21166,7 @@ public void combineCommand(Map destination, Map> getCommandMap() { ); rvcOperationalStateClusterInteractionInfoMap.put("pause", rvcOperationalStatepauseInteractionInfo); - Map rvcOperationalStatestopCommandParams = new LinkedHashMap(); - InteractionInfo rvcOperationalStatestopInteractionInfo = new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.RvcOperationalStateCluster) cluster) - .stop((ChipClusters.RvcOperationalStateCluster.OperationalCommandResponseCallback) callback - ); - }, - () -> new DelegatedRvcOperationalStateClusterOperationalCommandResponseCallback(), - rvcOperationalStatestopCommandParams - ); - rvcOperationalStateClusterInteractionInfoMap.put("stop", rvcOperationalStatestopInteractionInfo); - - Map rvcOperationalStatestartCommandParams = new LinkedHashMap(); - InteractionInfo rvcOperationalStatestartInteractionInfo = new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.RvcOperationalStateCluster) cluster) - .start((ChipClusters.RvcOperationalStateCluster.OperationalCommandResponseCallback) callback - ); - }, - () -> new DelegatedRvcOperationalStateClusterOperationalCommandResponseCallback(), - rvcOperationalStatestartCommandParams - ); - rvcOperationalStateClusterInteractionInfoMap.put("start", rvcOperationalStatestartInteractionInfo); - Map rvcOperationalStateresumeCommandParams = new LinkedHashMap(); InteractionInfo rvcOperationalStateresumeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { @@ -23632,6 +24033,10 @@ public Map> getCommandMap() { commandMap.put("valveConfigurationAndControl", valveConfigurationAndControlClusterInteractionInfoMap); + Map electricalPowerMeasurementClusterInteractionInfoMap = new LinkedHashMap<>(); + + commandMap.put("electricalPowerMeasurement", electricalPowerMeasurementClusterInteractionInfoMap); + Map electricalEnergyMeasurementClusterInteractionInfoMap = new LinkedHashMap<>(); commandMap.put("electricalEnergyMeasurement", electricalEnergyMeasurementClusterInteractionInfoMap); @@ -23725,12 +24130,42 @@ public Map> getCommandMap() { Map messagespresentMessagesRequestCommandParams = new LinkedHashMap(); + CommandParameterInfo messagespresentMessagesRequestmessageIDCommandParameterInfo = new CommandParameterInfo("messageID", byte[].class, byte[].class); + messagespresentMessagesRequestCommandParams.put("messageID",messagespresentMessagesRequestmessageIDCommandParameterInfo); + + CommandParameterInfo messagespresentMessagesRequestpriorityCommandParameterInfo = new CommandParameterInfo("priority", Integer.class, Integer.class); + messagespresentMessagesRequestCommandParams.put("priority",messagespresentMessagesRequestpriorityCommandParameterInfo); + + CommandParameterInfo messagespresentMessagesRequestmessageControlCommandParameterInfo = new CommandParameterInfo("messageControl", Integer.class, Integer.class); + messagespresentMessagesRequestCommandParams.put("messageControl",messagespresentMessagesRequestmessageControlCommandParameterInfo); + + CommandParameterInfo messagespresentMessagesRequeststartTimeCommandParameterInfo = new CommandParameterInfo("startTime", Long.class, Long.class); + messagespresentMessagesRequestCommandParams.put("startTime",messagespresentMessagesRequeststartTimeCommandParameterInfo); + + CommandParameterInfo messagespresentMessagesRequestdurationCommandParameterInfo = new CommandParameterInfo("duration", Integer.class, Integer.class); + messagespresentMessagesRequestCommandParams.put("duration",messagespresentMessagesRequestdurationCommandParameterInfo); + + CommandParameterInfo messagespresentMessagesRequestmessageTextCommandParameterInfo = new CommandParameterInfo("messageText", String.class, String.class); + messagespresentMessagesRequestCommandParams.put("messageText",messagespresentMessagesRequestmessageTextCommandParameterInfo); + InteractionInfo messagespresentMessagesRequestInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.MessagesCluster) cluster) .presentMessagesRequest((DefaultClusterCallback) callback - , (ArrayList) - commandArguments.get("messages") + , (byte[]) + commandArguments.get("messageID") + , (Integer) + commandArguments.get("priority") + , (Integer) + commandArguments.get("messageControl") + , (Long) + commandArguments.get("startTime") + , (Integer) + commandArguments.get("duration") + , (String) + commandArguments.get("messageText") + , (Optional>) + commandArguments.get("responses") ); }, () -> new DelegatedDefaultClusterCallback(), diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java index a7fe287e152a5b..5835a37623934a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java @@ -6807,17 +6807,6 @@ private static Map readRvcRunModeInteractionInfo() { readRvcRunModeCurrentModeCommandParams ); result.put("readCurrentModeAttribute", readRvcRunModeCurrentModeAttributeInteractionInfo); - Map readRvcRunModeOnModeCommandParams = new LinkedHashMap(); - InteractionInfo readRvcRunModeOnModeAttributeInteractionInfo = new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.RvcRunModeCluster) cluster).readOnModeAttribute( - (ChipClusters.RvcRunModeCluster.OnModeAttributeCallback) callback - ); - }, - () -> new ClusterInfoMapping.DelegatedRvcRunModeClusterOnModeAttributeCallback(), - readRvcRunModeOnModeCommandParams - ); - result.put("readOnModeAttribute", readRvcRunModeOnModeAttributeInteractionInfo); Map readRvcRunModeGeneratedCommandListCommandParams = new LinkedHashMap(); InteractionInfo readRvcRunModeGeneratedCommandListAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { @@ -6910,17 +6899,6 @@ private static Map readRvcCleanModeInteractionInfo() { readRvcCleanModeCurrentModeCommandParams ); result.put("readCurrentModeAttribute", readRvcCleanModeCurrentModeAttributeInteractionInfo); - Map readRvcCleanModeOnModeCommandParams = new LinkedHashMap(); - InteractionInfo readRvcCleanModeOnModeAttributeInteractionInfo = new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.RvcCleanModeCluster) cluster).readOnModeAttribute( - (ChipClusters.RvcCleanModeCluster.OnModeAttributeCallback) callback - ); - }, - () -> new ClusterInfoMapping.DelegatedRvcCleanModeClusterOnModeAttributeCallback(), - readRvcCleanModeOnModeCommandParams - ); - result.put("readOnModeAttribute", readRvcCleanModeOnModeAttributeInteractionInfo); Map readRvcCleanModeGeneratedCommandListCommandParams = new LinkedHashMap(); InteractionInfo readRvcCleanModeGeneratedCommandListAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { @@ -8986,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( @@ -20204,6 +20461,7 @@ public Map> getReadAttributeMap() { put("activatedCarbonFilterMonitoring", readActivatedCarbonFilterMonitoringInteractionInfo()); put("booleanStateConfiguration", readBooleanStateConfigurationInteractionInfo()); put("valveConfigurationAndControl", readValveConfigurationAndControlInteractionInfo()); + put("electricalPowerMeasurement", readElectricalPowerMeasurementInteractionInfo()); put("electricalEnergyMeasurement", readElectricalEnergyMeasurementInteractionInfo()); put("demandResponseLoadControl", readDemandResponseLoadControlInteractionInfo()); put("messages", readMessagesInteractionInfo()); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java index f9357edc588b82..fe23d32c236579 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java @@ -981,52 +981,8 @@ public Map> getWriteAttributeMap() { writeLaundryWasherControlsInteractionInfo.put("writeNumberOfRinsesAttribute", writeLaundryWasherControlsNumberOfRinsesAttributeInteractionInfo); writeAttributeMap.put("laundryWasherControls", writeLaundryWasherControlsInteractionInfo); Map writeRvcRunModeInteractionInfo = new LinkedHashMap<>(); - Map writeRvcRunModeOnModeCommandParams = new LinkedHashMap(); - CommandParameterInfo rvcRunModeonModeCommandParameterInfo = - new CommandParameterInfo( - "value", - Integer.class, - Integer.class - ); - writeRvcRunModeOnModeCommandParams.put( - "value", - rvcRunModeonModeCommandParameterInfo - ); - InteractionInfo writeRvcRunModeOnModeAttributeInteractionInfo = new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.RvcRunModeCluster) cluster).writeOnModeAttribute( - (DefaultClusterCallback) callback, - (Integer) commandArguments.get("value") - ); - }, - () -> new ClusterInfoMapping.DelegatedDefaultClusterCallback(), - writeRvcRunModeOnModeCommandParams - ); - writeRvcRunModeInteractionInfo.put("writeOnModeAttribute", writeRvcRunModeOnModeAttributeInteractionInfo); writeAttributeMap.put("rvcRunMode", writeRvcRunModeInteractionInfo); Map writeRvcCleanModeInteractionInfo = new LinkedHashMap<>(); - Map writeRvcCleanModeOnModeCommandParams = new LinkedHashMap(); - CommandParameterInfo rvcCleanModeonModeCommandParameterInfo = - new CommandParameterInfo( - "value", - Integer.class, - Integer.class - ); - writeRvcCleanModeOnModeCommandParams.put( - "value", - rvcCleanModeonModeCommandParameterInfo - ); - InteractionInfo writeRvcCleanModeOnModeAttributeInteractionInfo = new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.RvcCleanModeCluster) cluster).writeOnModeAttribute( - (DefaultClusterCallback) callback, - (Integer) commandArguments.get("value") - ); - }, - () -> new ClusterInfoMapping.DelegatedDefaultClusterCallback(), - writeRvcCleanModeOnModeCommandParams - ); - writeRvcCleanModeInteractionInfo.put("writeOnModeAttribute", writeRvcCleanModeOnModeAttributeInteractionInfo); writeAttributeMap.put("rvcCleanMode", writeRvcCleanModeInteractionInfo); Map writeTemperatureControlInteractionInfo = new LinkedHashMap<>(); writeAttributeMap.put("temperatureControl", writeTemperatureControlInteractionInfo); @@ -1234,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<>(); 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/MessagesCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MessagesCluster.kt index 7793725b8d9cce..5ce55e2e0dd21b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MessagesCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MessagesCluster.kt @@ -102,7 +102,13 @@ class MessagesCluster(private val controller: MatterController, private val endp } suspend fun presentMessagesRequest( - messages: List, + messageID: ByteArray, + priority: UByte, + messageControl: UByte, + startTime: UInt?, + duration: UShort?, + messageText: String, + responses: List?, timedInvokeTimeout: Duration? = null ) { val commandId: UInt = 0u @@ -110,12 +116,32 @@ class MessagesCluster(private val controller: MatterController, private val endp val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) - val TAG_MESSAGES_REQ: Int = 0 - tlvWriter.startArray(ContextSpecificTag(TAG_MESSAGES_REQ)) - for (item in messages.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) + val TAG_MESSAGE_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_MESSAGE_I_D_REQ), messageID) + + val TAG_PRIORITY_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_PRIORITY_REQ), priority) + + val TAG_MESSAGE_CONTROL_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_MESSAGE_CONTROL_REQ), messageControl) + + val TAG_START_TIME_REQ: Int = 3 + startTime?.let { tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) } + + val TAG_DURATION_REQ: Int = 4 + duration?.let { tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) } + + val TAG_MESSAGE_TEXT_REQ: Int = 5 + tlvWriter.put(ContextSpecificTag(TAG_MESSAGE_TEXT_REQ), messageText) + + val TAG_RESPONSES_REQ: Int = 6 + responses?.let { + tlvWriter.startArray(ContextSpecificTag(TAG_RESPONSES_REQ)) + for (item in responses.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() } - tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt index fc06787142bc87..cf21074dc5fefb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt @@ -32,9 +32,6 @@ import matter.controller.SubscriptionState import matter.controller.UByteSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath @@ -60,16 +57,6 @@ class RvcCleanModeCluster( object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() } - class OnModeAttribute(val value: UByte?) - - sealed class OnModeAttributeSubscriptionState { - data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() - - data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } - class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { @@ -352,147 +339,6 @@ class RvcCleanModeCluster( } } - suspend fun readOnModeAttribute(): OnModeAttribute { - 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) { "Onmode attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - return OnModeAttribute(decodedValue) - } - - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { - val ATTRIBUTE_ID: UInt = 3u - - val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) - - val writeRequests: WriteRequests = - WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), - timedRequest = timedWriteTimeout - ) - - val response: WriteResponse = controller.write(writeRequests) - - when (response) { - is WriteResponse.Success -> { - logger.log(Level.FINE, "Write command succeeded") - } - is WriteResponse.PartialWriteFailure -> { - val aggregatedErrorMessage = - response.failures.joinToString("\n") { failure -> - "Error at ${failure.attributePath}: ${failure.ex.message}" - } - - response.failures.forEach { failure -> - logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") - } - - throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") - } - } - } - - suspend fun subscribeOnModeAttribute( - 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( - OnModeAttributeSubscriptionState.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) { "Onmode attribute not found in Node State update" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } - } - SubscriptionState.SubscriptionEstablished -> { - emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) - } - } - } - } - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { val ATTRIBUTE_ID: UInt = 65528u diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt index d2a53548665600..3c46632bac37f1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt @@ -184,90 +184,6 @@ class RvcOperationalStateCluster( return OperationalCommandResponse(commandResponseState_decoded) } - suspend fun stop(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { - val commandId: UInt = 1u - - val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) - 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_COMMAND_RESPONSE_STATE: Int = 0 - var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null - - while (!tlvReader.isEndOfContainer()) { - val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { - tlvReader.skipElement() - } - } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") - } - - tlvReader.exitContainer() - - return OperationalCommandResponse(commandResponseState_decoded) - } - - suspend fun start(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { - val commandId: UInt = 2u - - val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) - 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_COMMAND_RESPONSE_STATE: Int = 0 - var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null - - while (!tlvReader.isEndOfContainer()) { - val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { - tlvReader.skipElement() - } - } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") - } - - tlvReader.exitContainer() - - return OperationalCommandResponse(commandResponseState_decoded) - } - suspend fun resume(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 3u diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt index 2297e2fb439d4e..05237cd481e136 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt @@ -32,9 +32,6 @@ import matter.controller.SubscriptionState import matter.controller.UByteSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath @@ -57,16 +54,6 @@ class RvcRunModeCluster(private val controller: MatterController, private val en object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() } - class OnModeAttribute(val value: UByte?) - - sealed class OnModeAttributeSubscriptionState { - data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() - - data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } - class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { @@ -349,147 +336,6 @@ class RvcRunModeCluster(private val controller: MatterController, private val en } } - suspend fun readOnModeAttribute(): OnModeAttribute { - 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) { "Onmode attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - return OnModeAttribute(decodedValue) - } - - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { - val ATTRIBUTE_ID: UInt = 3u - - val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) - - val writeRequests: WriteRequests = - WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), - timedRequest = timedWriteTimeout - ) - - val response: WriteResponse = controller.write(writeRequests) - - when (response) { - is WriteResponse.Success -> { - logger.log(Level.FINE, "Write command succeeded") - } - is WriteResponse.PartialWriteFailure -> { - val aggregatedErrorMessage = - response.failures.joinToString("\n") { failure -> - "Error at ${failure.attributePath}: ${failure.ex.message}" - } - - response.failures.forEach { failure -> - logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") - } - - throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") - } - } - } - - suspend fun subscribeOnModeAttribute( - 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( - OnModeAttributeSubscriptionState.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) { "Onmode attribute not found in Node State update" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } - } - SubscriptionState.SubscriptionEstablished -> { - emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) - } - } - } - } - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { val ATTRIBUTE_ID: UInt = 65528u 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..a5ca9a57966e49 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", 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 e4b59ac387429e..6f70ad885ec9b7 100644 --- a/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java +++ b/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java @@ -19,6 +19,7 @@ import android.bluetooth.BluetoothGatt; import android.util.Log; +import chip.devicecontroller.ChipDeviceController.CompletionListener; import chip.devicecontroller.GetConnectedDeviceCallbackJni.GetConnectedDeviceCallback; import chip.devicecontroller.model.AttributeWriteRequest; import chip.devicecontroller.model.ChipAttributePath; @@ -117,10 +118,18 @@ public void setDeviceAttestationDelegate( * paa certificates before commissioning. * * @param attestationTrustStoreDelegate Delegate for attestation trust store + * @param cdTrustKeys certification Declaration Trust Keys */ + public void setAttestationTrustStoreDelegate( + AttestationTrustStoreDelegate attestationTrustStoreDelegate, + @Nullable List cdTrustKeys) { + setAttestationTrustStoreDelegate( + deviceControllerPtr, attestationTrustStoreDelegate, cdTrustKeys); + } + public void setAttestationTrustStoreDelegate( AttestationTrustStoreDelegate attestationTrustStoreDelegate) { - setAttestationTrustStoreDelegate(deviceControllerPtr, attestationTrustStoreDelegate); + setAttestationTrustStoreDelegate(deviceControllerPtr, attestationTrustStoreDelegate, null); } /** @@ -1367,7 +1376,9 @@ private native void setDeviceAttestationDelegate( long deviceControllerPtr, int failSafeExpiryTimeoutSecs, DeviceAttestationDelegate delegate); private native void setAttestationTrustStoreDelegate( - long deviceControllerPtr, AttestationTrustStoreDelegate delegate); + long deviceControllerPtr, + AttestationTrustStoreDelegate delegate, + @Nullable List cdTrustKeys); private native void startOTAProvider(long deviceControllerPtr, OTAProviderDelegate delegate); diff --git a/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt b/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt index 76b0104dd3ac85..aa885b6b5decf1 100644 --- a/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt +++ b/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt @@ -55,7 +55,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & {{/zcl_event_fields}} jclass {{asLowerCamelCase name}}StructClass; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipEventStructs${{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Event", {{asLowerCamelCase name}}StructClass); + err = chip::JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ChipEventStructs${{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Event", {{asLowerCamelCase name}}StructClass); if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "Could not find class ChipEventStructs${{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Event"); return nullptr; diff --git a/src/controller/java/templates/partials/decode_value.zapt b/src/controller/java/templates/partials/decode_value.zapt index 092c720edc74c9..1562309b13cd34 100644 --- a/src/controller/java/templates/partials/decode_value.zapt +++ b/src/controller/java/templates/partials/decode_value.zapt @@ -32,7 +32,7 @@ if ({{source}}.IsNull()) { {{/zcl_struct_items_by_struct_and_cluster_name}} jclass {{asLowerCamelCase type}}StructClass_{{depth}}; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}", {{asLowerCamelCase type}}StructClass_{{depth}}); + err = chip::JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}", {{asLowerCamelCase type}}StructClass_{{depth}}); if (err != CHIP_NO_ERROR) { ChipLogError(Zcl, "Could not find class ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}"); return {{earlyReturn}}; diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index 8afc7c33e1da24..bd6071e1d4eb43 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -1632,7 +1632,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_revision, newElement_0_revision); jclass deviceTypeStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DescriptorClusterDeviceTypeStruct", deviceTypeStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -1796,7 +1796,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass semanticTagStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DescriptorClusterSemanticTagStruct", semanticTagStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -2054,7 +2054,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_fabricIndex, newElement_0_fabricIndex); jclass targetStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$BindingClusterTargetStruct", targetStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -2332,7 +2332,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass accessControlTargetStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$AccessControlClusterAccessControlTargetStruct", accessControlTargetStructStructClass_4); if (err != CHIP_NO_ERROR) @@ -2366,7 +2366,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_fabricIndex, newElement_0_fabricIndex); jclass accessControlEntryStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$AccessControlClusterAccessControlEntryStruct", accessControlEntryStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -2423,7 +2423,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_fabricIndex, newElement_0_fabricIndex); jclass accessControlExtensionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$AccessControlClusterAccessControlExtensionStruct", accessControlExtensionStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -2693,7 +2693,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_state, newElement_0_state); jclass actionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ActionsClusterActionStruct", actionStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -2769,7 +2769,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass endpointListStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ActionsClusterEndpointListStruct", endpointListStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -3230,7 +3230,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jnivalue_subscriptionsPerFabric, value_subscriptionsPerFabric); jclass capabilityMinimaStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$BasicInformationClusterCapabilityMinimaStruct", capabilityMinimaStructStructClass_0); if (err != CHIP_NO_ERROR) @@ -3284,7 +3284,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass productAppearanceStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$BasicInformationClusterProductAppearanceStruct", productAppearanceStructStructClass_0); if (err != CHIP_NO_ERROR) @@ -3662,7 +3662,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_fabricIndex, newElement_0_fabricIndex); jclass providerLocationStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$OtaSoftwareUpdateRequestorClusterProviderLocation", providerLocationStructClass_1); if (err != CHIP_NO_ERROR) @@ -5354,7 +5354,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jnivalue_maxCumulativeFailsafeSeconds, value_maxCumulativeFailsafeSeconds); jclass basicCommissioningInfoStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$GeneralCommissioningClusterBasicCommissioningInfo", basicCommissioningInfoStructClass_0); if (err != CHIP_NO_ERROR) @@ -5661,7 +5661,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass networkInfoStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$NetworkCommissioningClusterNetworkInfoStruct", networkInfoStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -6245,7 +6245,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_type, newElement_0_type); jclass networkInterfaceStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$GeneralDiagnosticsClusterNetworkInterface", networkInterfaceStructClass_1); if (err != CHIP_NO_ERROR) @@ -6660,7 +6660,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass threadMetricsStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$SoftwareDiagnosticsClusterThreadMetricsStruct", threadMetricsStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -7156,7 +7156,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_isChild, newElement_0_isChild); jclass neighborTableStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ThreadNetworkDiagnosticsClusterNeighborTableStruct", neighborTableStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -7275,7 +7275,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_linkEstablished, newElement_0_linkEstablished); jclass routeTableStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ThreadNetworkDiagnosticsClusterRouteTableStruct", routeTableStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -8190,7 +8190,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR value_flagsClassName.c_str(), value_flagsCtorSignature.c_str(), jnivalue_flags, value_flags); jclass securityPolicyStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ThreadNetworkDiagnosticsClusterSecurityPolicy", securityPolicyStructClass_1); if (err != CHIP_NO_ERROR) @@ -8336,7 +8336,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jnivalue_channelMaskPresent, value_channelMaskPresent); jclass operationalDatasetComponentsStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ThreadNetworkDiagnosticsClusterOperationalDatasetComponents", operationalDatasetComponentsStructClass_1); if (err != CHIP_NO_ERROR) @@ -9373,7 +9373,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR value_endpointClassName.c_str(), value_endpointCtorSignature.c_str(), jnivalue_endpoint, value_endpoint); jclass trustedTimeSourceStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$TimeSynchronizationClusterTrustedTimeSourceStruct", trustedTimeSourceStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -9460,7 +9460,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass timeZoneStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$TimeSynchronizationClusterTimeZoneStruct", timeZoneStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -9530,7 +9530,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass DSTOffsetStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$TimeSynchronizationClusterDSTOffsetStruct", DSTOffsetStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -10027,7 +10027,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass productAppearanceStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$BridgedDeviceBasicInformationClusterProductAppearanceStruct", productAppearanceStructStructClass_0); if (err != CHIP_NO_ERROR) @@ -10629,7 +10629,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_fabricIndex, newElement_0_fabricIndex); jclass NOCStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$OperationalCredentialsClusterNOCStruct", NOCStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -10706,7 +10706,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_fabricIndex, newElement_0_fabricIndex); jclass fabricDescriptorStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$OperationalCredentialsClusterFabricDescriptorStruct", fabricDescriptorStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -10986,7 +10986,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_fabricIndex, newElement_0_fabricIndex); jclass groupKeyMapStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$GroupKeyManagementClusterGroupKeyMapStruct", groupKeyMapStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -11070,7 +11070,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_fabricIndex, newElement_0_fabricIndex); jclass groupInfoMapStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$GroupKeyManagementClusterGroupInfoMapStruct", groupInfoMapStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -11292,7 +11292,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.value, newElement_0_value)); jclass labelStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$FixedLabelClusterLabelStruct", labelStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -11479,7 +11479,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.value, newElement_0_value)); jclass labelStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$UserLabelClusterLabelStruct", labelStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -12315,7 +12315,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_fabricIndex, newElement_0_fabricIndex); jclass monitoringRegistrationStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$IcdManagementClusterMonitoringRegistrationStruct", monitoringRegistrationStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -12860,7 +12860,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass operationalStateStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$OvenCavityOperationalStateClusterOperationalStateStruct", operationalStateStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -12944,7 +12944,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass errorStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); if (err != CHIP_NO_ERROR) @@ -13168,7 +13168,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_2_value, newElement_2_value); jclass modeTagStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$OvenModeClusterModeTagStruct", modeTagStructStructClass_3); if (err != CHIP_NO_ERROR) { @@ -13192,7 +13192,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass modeOptionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$OvenModeClusterModeOptionStruct", modeOptionStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -13694,7 +13694,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_2_value, newElement_2_value); jclass semanticTagStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ModeSelectClusterSemanticTagStruct", semanticTagStructStructClass_3); if (err != CHIP_NO_ERROR) @@ -13719,7 +13719,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass modeOptionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ModeSelectClusterModeOptionStruct", modeOptionStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -14006,7 +14006,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_2_value, newElement_2_value); jclass modeTagStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$LaundryWasherModeClusterModeTagStruct", modeTagStructStructClass_3); if (err != CHIP_NO_ERROR) { @@ -14030,7 +14030,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass modeOptionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$LaundryWasherModeClusterModeOptionStruct", modeOptionStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -14318,7 +14318,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_2_value, newElement_2_value); jclass modeTagStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct", modeTagStructStructClass_3); @@ -14348,7 +14348,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass modeOptionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct", modeOptionStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -14867,7 +14867,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_2_value, newElement_2_value); jclass modeTagStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$RvcRunModeClusterModeTagStruct", modeTagStructStructClass_3); if (err != CHIP_NO_ERROR) { @@ -14891,7 +14891,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass modeOptionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$RvcRunModeClusterModeOptionStruct", modeOptionStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -14931,29 +14931,6 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR value); return value; } - case Attributes::OnMode::Id: { - using TypeInfo = Attributes::OnMode::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/Integer"; - std::string valueCtorSignature = "(I)V"; - jint 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; @@ -15155,7 +15132,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_2_value, newElement_2_value); jclass modeTagStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$RvcCleanModeClusterModeTagStruct", modeTagStructStructClass_3); if (err != CHIP_NO_ERROR) { @@ -15179,7 +15156,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass modeOptionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$RvcCleanModeClusterModeOptionStruct", modeOptionStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -15219,29 +15196,6 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR value); return value; } - case Attributes::OnMode::Id: { - using TypeInfo = Attributes::OnMode::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/Integer"; - std::string valueCtorSignature = "(I)V"; - jint 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; @@ -15876,7 +15830,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_2_value, newElement_2_value); jclass modeTagStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DishwasherModeClusterModeTagStruct", modeTagStructStructClass_3); if (err != CHIP_NO_ERROR) { @@ -15900,7 +15854,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass modeOptionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DishwasherModeClusterModeOptionStruct", modeOptionStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -16901,7 +16855,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_2_value, newElement_2_value); jclass modeTagStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MicrowaveOvenModeClusterModeTagStruct", modeTagStructStructClass_3); if (err != CHIP_NO_ERROR) { @@ -16925,7 +16879,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass modeOptionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MicrowaveOvenModeClusterModeOptionStruct", modeOptionStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -17515,7 +17469,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass operationalStateStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$OperationalStateClusterOperationalStateStruct", operationalStateStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -17598,7 +17552,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass errorStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$OperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); if (err != CHIP_NO_ERROR) { @@ -17874,7 +17828,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass operationalStateStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$RvcOperationalStateClusterOperationalStateStruct", operationalStateStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -17957,7 +17911,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass errorStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$RvcOperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); if (err != CHIP_NO_ERROR) { @@ -18220,7 +18174,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_fabricIndex, newElement_0_fabricIndex); jclass sceneInfoStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ScenesManagementClusterSceneInfoStruct", sceneInfoStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -18504,7 +18458,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_productIdentifierValue)); jclass replacementProductStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$HepaFilterMonitoringClusterReplacementProductStruct", replacementProductStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -18786,7 +18740,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_productIdentifierValue)); jclass replacementProductStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ActivatedCarbonFilterMonitoringClusterReplacementProductStruct", replacementProductStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -19272,192 +19226,1266 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } return value; } - case Attributes::AutoCloseTime::Id: { - using TypeInfo = Attributes::AutoCloseTime::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::RemainingDuration::Id: { - using TypeInfo = Attributes::RemainingDuration::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::CurrentState::Id: { - using TypeInfo = Attributes::CurrentState::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/Integer"; - std::string valueCtorSignature = "(I)V"; - jint jnivalue = static_cast(cppValue.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - jnivalue, value); - } - return value; - } - case Attributes::TargetState::Id: { - using TypeInfo = Attributes::TargetState::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/Integer"; - std::string valueCtorSignature = "(I)V"; - jint jnivalue = static_cast(cppValue.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - jnivalue, value); - } - return value; - } - case Attributes::CurrentLevel::Id: { - using TypeInfo = Attributes::CurrentLevel::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/Integer"; - std::string valueCtorSignature = "(I)V"; - jint jnivalue = static_cast(cppValue.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - jnivalue, value); - } - return value; - } - case Attributes::TargetLevel::Id: { - using TypeInfo = Attributes::TargetLevel::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/Integer"; - std::string valueCtorSignature = "(I)V"; - jint jnivalue = static_cast(cppValue.Value()); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - jnivalue, value); - } - return value; - } - case Attributes::DefaultOpenLevel::Id: { - using TypeInfo = Attributes::DefaultOpenLevel::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::ValveFault::Id: { - using TypeInfo = Attributes::ValveFault::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.Raw()); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, - value); - return value; - } - case Attributes::LevelStep::Id: { - using TypeInfo = Attributes::LevelStep::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::AutoCloseTime::Id: { + using TypeInfo = Attributes::AutoCloseTime::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::RemainingDuration::Id: { + using TypeInfo = Attributes::RemainingDuration::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::CurrentState::Id: { + using TypeInfo = Attributes::CurrentState::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/Integer"; + std::string valueCtorSignature = "(I)V"; + jint jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::TargetState::Id: { + using TypeInfo = Attributes::TargetState::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/Integer"; + std::string valueCtorSignature = "(I)V"; + jint jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::CurrentLevel::Id: { + using TypeInfo = Attributes::CurrentLevel::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/Integer"; + std::string valueCtorSignature = "(I)V"; + jint jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::TargetLevel::Id: { + using TypeInfo = Attributes::TargetLevel::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/Integer"; + std::string valueCtorSignature = "(I)V"; + jint jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::DefaultOpenLevel::Id: { + using TypeInfo = Attributes::DefaultOpenLevel::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::ValveFault::Id: { + using TypeInfo = Attributes::ValveFault::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.Raw()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, + value); + return value; + } + case Attributes::LevelStep::Id: { + using TypeInfo = Attributes::LevelStep::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::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::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; @@ -19766,7 +20794,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass measurementAccuracyRangeStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct", measurementAccuracyRangeStructStructClass_2); if (err != CHIP_NO_ERROR) @@ -19798,7 +20826,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass measurementAccuracyStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct", measurementAccuracyStructStructClass_0); if (err != CHIP_NO_ERROR) @@ -19912,7 +20940,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass energyMeasurementStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", energyMeasurementStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -20026,7 +21054,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass energyMeasurementStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", energyMeasurementStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -20140,7 +21168,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass energyMeasurementStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", energyMeasurementStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -20254,7 +21282,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass energyMeasurementStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", energyMeasurementStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -20280,6 +21308,156 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } 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_exportedResetTimestamp); + } + else + { + 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_importedResetSystime; + if (!cppValue.Value().importedResetSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_importedResetSystime); + } + else + { + 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_exportedResetSystime; + if (!cppValue.Value().exportedResetSystime.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_exportedResetSystime); + } + else + { + 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 cumulativeEnergyResetStructStructClass_1; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct", + cumulativeEnergyResetStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, + "Could not find class ChipStructs$ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct"); + return nullptr; + } + + jmethodID cumulativeEnergyResetStructStructCtor_1; + err = chip::JniReferences::GetInstance().FindMethod( + 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$ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct constructor"); + return nullptr; + } + + value = env->NewObject(cumulativeEnergyResetStructStructClass_1, cumulativeEnergyResetStructStructCtor_1, + value_importedResetTimestamp, value_exportedResetTimestamp, value_importedResetSystime, + value_exportedResetSystime); + } + return value; + } case Attributes::GeneratedCommandList::Id: { using TypeInfo = Attributes::GeneratedCommandList::TypeInfo; TypeInfo::DecodableType cppValue; @@ -20490,7 +21668,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass loadControlProgramStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterLoadControlProgramStruct", loadControlProgramStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -20791,7 +21969,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass temperatureControlStructStructClass_5; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterTemperatureControlStruct", temperatureControlStructStructClass_5); if (err != CHIP_NO_ERROR) @@ -20843,7 +22021,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_2_averageLoadControlInsideOptional_loadAdjustment); jclass averageLoadControlStructStructClass_5; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterAverageLoadControlStruct", averageLoadControlStructStructClass_5); if (err != CHIP_NO_ERROR) @@ -20891,7 +22069,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_2_dutyCycleControlInsideOptional_dutyCycle); jclass dutyCycleControlStructStructClass_5; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterDutyCycleControlStruct", dutyCycleControlStructStructClass_5); if (err != CHIP_NO_ERROR) @@ -20939,7 +22117,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_2_powerSavingsControlInsideOptional_powerSavings); jclass powerSavingsControlStructStructClass_5; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterPowerSavingsControlStruct", powerSavingsControlStructStructClass_5); if (err != CHIP_NO_ERROR) @@ -20987,7 +22165,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_2_heatingSourceControlInsideOptional_heatingSource); jclass heatingSourceControlStructStructClass_5; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterHeatingSourceControlStruct", heatingSourceControlStructStructClass_5); if (err != CHIP_NO_ERROR) @@ -21017,7 +22195,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass loadControlEventTransitionStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterLoadControlEventTransitionStruct", loadControlEventTransitionStructStructClass_3); if (err != CHIP_NO_ERROR) @@ -21051,7 +22229,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass loadControlEventStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterLoadControlEventStruct", loadControlEventStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -21338,7 +22516,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass temperatureControlStructStructClass_5; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterTemperatureControlStruct", temperatureControlStructStructClass_5); if (err != CHIP_NO_ERROR) @@ -21390,7 +22568,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_2_averageLoadControlInsideOptional_loadAdjustment); jclass averageLoadControlStructStructClass_5; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterAverageLoadControlStruct", averageLoadControlStructStructClass_5); if (err != CHIP_NO_ERROR) @@ -21438,7 +22616,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_2_dutyCycleControlInsideOptional_dutyCycle); jclass dutyCycleControlStructStructClass_5; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterDutyCycleControlStruct", dutyCycleControlStructStructClass_5); if (err != CHIP_NO_ERROR) @@ -21486,7 +22664,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_2_powerSavingsControlInsideOptional_powerSavings); jclass powerSavingsControlStructStructClass_5; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterPowerSavingsControlStruct", powerSavingsControlStructStructClass_5); if (err != CHIP_NO_ERROR) @@ -21534,7 +22712,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_2_heatingSourceControlInsideOptional_heatingSource); jclass heatingSourceControlStructStructClass_5; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterHeatingSourceControlStruct", heatingSourceControlStructStructClass_5); if (err != CHIP_NO_ERROR) @@ -21564,7 +22742,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass loadControlEventTransitionStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterLoadControlEventTransitionStruct", loadControlEventTransitionStructStructClass_3); if (err != CHIP_NO_ERROR) @@ -21598,7 +22776,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass loadControlEventStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterLoadControlEventStruct", loadControlEventStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -21948,7 +23126,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass messageResponseOptionStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MessagesClusterMessageResponseOptionStruct", messageResponseOptionStructStructClass_4); if (err != CHIP_NO_ERROR) @@ -21976,7 +23154,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass messageStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MessagesClusterMessageStruct", messageStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -22301,7 +23479,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_1_maxDuration, newElement_1_maxDuration); jclass powerAdjustStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DeviceEnergyManagementClusterPowerAdjustStruct", powerAdjustStructStructClass_2); if (err != CHIP_NO_ERROR) @@ -22670,7 +23848,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass costStructStructClass_6; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DeviceEnergyManagementClusterCostStruct", costStructStructClass_6); if (err != CHIP_NO_ERROR) @@ -22774,7 +23952,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass slotStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DeviceEnergyManagementClusterSlotStruct", slotStructStructClass_3); if (err != CHIP_NO_ERROR) { @@ -22814,7 +23992,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jnivalue_forecastUpdateReason, value_forecastUpdateReason); jclass forecastStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DeviceEnergyManagementClusterForecastStruct", forecastStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -23647,7 +24825,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass balanceStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$EnergyPreferenceClusterBalanceStruct", balanceStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -23749,7 +24927,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass balanceStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$EnergyPreferenceClusterBalanceStruct", balanceStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -23990,7 +25168,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_2_value, newElement_2_value); jclass modeTagStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$EnergyEvseModeClusterModeTagStruct", modeTagStructStructClass_3); if (err != CHIP_NO_ERROR) { @@ -24014,7 +25192,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass modeOptionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$EnergyEvseModeClusterModeOptionStruct", modeOptionStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -24301,7 +25479,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_2_value, newElement_2_value); jclass modeTagStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DeviceEnergyManagementModeClusterModeTagStruct", modeTagStructStructClass_3); if (err != CHIP_NO_ERROR) @@ -24326,7 +25504,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass modeOptionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DeviceEnergyManagementModeClusterModeOptionStruct", modeOptionStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -27848,7 +29026,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_presetTypeFeatures, newElement_0_presetTypeFeatures); jclass presetTypeStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ThermostatClusterPresetTypeStruct", presetTypeStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -27912,7 +29090,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_scheduleTypeFeatures, newElement_0_scheduleTypeFeatures); jclass scheduleTypeStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ThermostatClusterScheduleTypeStruct", scheduleTypeStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -28160,7 +29338,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass presetStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ThermostatClusterPresetStruct", presetStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -28347,7 +29525,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass scheduleTransitionStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ThermostatClusterScheduleTransitionStruct", scheduleTransitionStructStructClass_3); if (err != CHIP_NO_ERROR) @@ -28400,7 +29578,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass scheduleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ThermostatClusterScheduleStruct", scheduleStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -28526,7 +29704,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass queuedPresetStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ThermostatClusterQueuedPresetStruct", queuedPresetStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -36058,7 +37236,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass channelInfoStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ChannelClusterChannelInfoStruct", channelInfoStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -36137,7 +37315,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jnivalue_lineupInfoType, value_lineupInfoType); jclass lineupInfoStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ChannelClusterLineupInfoStruct", lineupInfoStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -36257,7 +37435,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass channelInfoStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ChannelClusterChannelInfoStruct", channelInfoStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -36452,7 +37630,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jclass targetInfoStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$TargetNavigatorClusterTargetInfoStruct", targetInfoStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -36732,7 +37910,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass playbackPositionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MediaPlaybackClusterPlaybackPositionStruct", playbackPositionStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -36868,7 +38046,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass trackAttributesStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MediaPlaybackClusterTrackAttributesStruct", trackAttributesStructStructClass_3); if (err != CHIP_NO_ERROR) @@ -36892,7 +38070,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass trackStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MediaPlaybackClusterTrackStruct", trackStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -36972,7 +38150,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass trackAttributesStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MediaPlaybackClusterTrackAttributesStruct", trackAttributesStructStructClass_4); if (err != CHIP_NO_ERROR) @@ -36997,7 +38175,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass trackStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MediaPlaybackClusterTrackStruct", trackStructStructClass_2); if (err != CHIP_NO_ERROR) { @@ -37073,7 +38251,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass trackAttributesStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MediaPlaybackClusterTrackAttributesStruct", trackAttributesStructStructClass_3); if (err != CHIP_NO_ERROR) @@ -37097,7 +38275,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass trackStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MediaPlaybackClusterTrackStruct", trackStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -37177,7 +38355,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass trackAttributesStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MediaPlaybackClusterTrackAttributesStruct", trackAttributesStructStructClass_4); if (err != CHIP_NO_ERROR) @@ -37202,7 +38380,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass trackStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MediaPlaybackClusterTrackStruct", trackStructStructClass_2); if (err != CHIP_NO_ERROR) { @@ -37407,7 +38585,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR chip::JniReferences::GetInstance().CharToStringUTF(entry_0.description, newElement_0_description)); jclass inputInfoStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MediaInputClusterInputInfoStruct", inputInfoStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -38086,7 +39264,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jclass outputInfoStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$AudioOutputClusterOutputInfoStruct", outputInfoStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -38321,7 +39499,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR value_application_applicationID)); jclass applicationStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ApplicationLauncherClusterApplicationStruct", applicationStructStructClass_2); if (err != CHIP_NO_ERROR) @@ -38360,7 +39538,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass applicationEPStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ApplicationLauncherClusterApplicationEPStruct", applicationEPStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -38603,7 +39781,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.applicationID, value_applicationID)); jclass applicationStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ApplicationBasicClusterApplicationStruct", applicationStructStructClass_0); if (err != CHIP_NO_ERROR) { @@ -39011,7 +40189,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass ratingNameStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ContentControlClusterRatingNameStruct", ratingNameStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -39080,7 +40258,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass ratingNameStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ContentControlClusterRatingNameStruct", ratingNameStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -42132,7 +43310,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_member2 = newElement_0_member2ByteArray; jclass testListStructOctetStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$UnitTestingClusterTestListStructOctet", testListStructOctetStructClass_1); if (err != CHIP_NO_ERROR) @@ -42421,7 +43599,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_nullableStruct_h, newElement_0_nullableStruct_h); jclass simpleStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_3); if (err != CHIP_NO_ERROR) { @@ -42516,7 +43694,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_optionalStructInsideOptional_h, newElement_0_optionalStructInsideOptional_h); jclass simpleStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_3); if (err != CHIP_NO_ERROR) { @@ -42633,7 +43811,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_nullableOptionalStructInsideOptional_h); jclass simpleStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_4); if (err != CHIP_NO_ERROR) { @@ -42750,7 +43928,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } jclass nullablesAndOptionalsStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$UnitTestingClusterNullablesAndOptionalsStruct", nullablesAndOptionalsStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -42852,7 +44030,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jnivalue_h, value_h); jclass simpleStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_0); if (err != CHIP_NO_ERROR) { @@ -43115,7 +44293,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_fabricSensitiveStruct_h); jclass simpleStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_2); if (err != CHIP_NO_ERROR) { @@ -43165,7 +44343,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jninewElement_0_fabricIndex, newElement_0_fabricIndex); jclass testFabricScopedStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$UnitTestingClusterTestFabricScoped", testFabricScopedStructClass_1); if (err != CHIP_NO_ERROR) { @@ -43957,7 +45135,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR value_hCtorSignature.c_str(), jnivalue_h, value_h); jclass simpleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); if (err != CHIP_NO_ERROR) { diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index 4795647b3e242f..b2818ebf632539 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -276,7 +276,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass accessControlTargetStructStructClass_4; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$AccessControlClusterAccessControlTargetStruct", accessControlTargetStructStructClass_4); if (err != CHIP_NO_ERROR) @@ -310,7 +310,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_latestValue_fabricIndex, value_latestValue_fabricIndex); jclass accessControlEntryStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$AccessControlClusterAccessControlEntryStruct", accessControlEntryStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -345,7 +345,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_fabricIndex); jclass accessControlEntryChangedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$AccessControlClusterAccessControlEntryChangedEvent", accessControlEntryChangedStructClass); if (err != CHIP_NO_ERROR) @@ -439,7 +439,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_latestValue_fabricIndex, value_latestValue_fabricIndex); jclass accessControlExtensionStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$AccessControlClusterAccessControlExtensionStruct", accessControlExtensionStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -472,7 +472,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_fabricIndex); jclass accessControlExtensionChangedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$AccessControlClusterAccessControlExtensionChangedEvent", accessControlExtensionChangedStructClass); if (err != CHIP_NO_ERROR) @@ -539,7 +539,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_newStateClassName.c_str(), value_newStateCtorSignature.c_str(), jnivalue_newState, value_newState); jclass stateChangedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$ActionsClusterStateChangedEvent", stateChangedStructClass); if (err != CHIP_NO_ERROR) { @@ -598,7 +598,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_errorClassName.c_str(), value_errorCtorSignature.c_str(), jnivalue_error, value_error); jclass actionFailedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$ActionsClusterActionFailedEvent", actionFailedStructClass); if (err != CHIP_NO_ERROR) { @@ -647,7 +647,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_softwareVersion, value_softwareVersion); jclass startUpStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$BasicInformationClusterStartUpEvent", startUpStructClass); if (err != CHIP_NO_ERROR) { @@ -676,7 +676,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass shutDownStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$BasicInformationClusterShutDownEvent", shutDownStructClass); if (err != CHIP_NO_ERROR) { @@ -712,7 +712,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_fabricIndex); jclass leaveStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$BasicInformationClusterLeaveEvent", leaveStructClass); if (err != CHIP_NO_ERROR) { @@ -749,7 +749,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_reachableNewValue, value_reachableNewValue); jclass reachableChangedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$BasicInformationClusterReachableChangedEvent", reachableChangedStructClass); if (err != CHIP_NO_ERROR) @@ -836,7 +836,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass stateTransitionStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$OtaSoftwareUpdateRequestorClusterStateTransitionEvent", stateTransitionStructClass); if (err != CHIP_NO_ERROR) @@ -884,7 +884,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_productIDClassName.c_str(), value_productIDCtorSignature.c_str(), jnivalue_productID, value_productID); jclass versionAppliedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$OtaSoftwareUpdateRequestorClusterVersionAppliedEvent", versionAppliedStructClass); if (err != CHIP_NO_ERROR) @@ -962,7 +962,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass downloadErrorStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$OtaSoftwareUpdateRequestorClusterDownloadErrorEvent", downloadErrorStructClass); if (err != CHIP_NO_ERROR) @@ -1077,7 +1077,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass wiredFaultChangeStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PowerSourceClusterWiredFaultChangeEvent", wiredFaultChangeStructClass); if (err != CHIP_NO_ERROR) { @@ -1139,7 +1139,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass batFaultChangeStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PowerSourceClusterBatFaultChangeEvent", batFaultChangeStructClass); if (err != CHIP_NO_ERROR) { @@ -1201,7 +1201,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass batChargeFaultChangeStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PowerSourceClusterBatChargeFaultChangeEvent", batChargeFaultChangeStructClass); if (err != CHIP_NO_ERROR) @@ -1305,7 +1305,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass hardwareFaultChangeStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$GeneralDiagnosticsClusterHardwareFaultChangeEvent", hardwareFaultChangeStructClass); if (err != CHIP_NO_ERROR) @@ -1369,7 +1369,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass radioFaultChangeStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$GeneralDiagnosticsClusterRadioFaultChangeEvent", radioFaultChangeStructClass); if (err != CHIP_NO_ERROR) @@ -1432,7 +1432,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass networkFaultChangeStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$GeneralDiagnosticsClusterNetworkFaultChangeEvent", networkFaultChangeStructClass); if (err != CHIP_NO_ERROR) @@ -1471,7 +1471,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_bootReasonClassName.c_str(), value_bootReasonCtorSignature.c_str(), jnivalue_bootReason, value_bootReason); jclass bootReasonStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$GeneralDiagnosticsClusterBootReasonEvent", bootReasonStructClass); if (err != CHIP_NO_ERROR) { @@ -1547,7 +1547,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass softwareFaultStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SoftwareDiagnosticsClusterSoftwareFaultEvent", softwareFaultStructClass); if (err != CHIP_NO_ERROR) @@ -1597,7 +1597,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_connectionStatus, value_connectionStatus); jclass connectionStatusStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$ThreadNetworkDiagnosticsClusterConnectionStatusEvent", connectionStatusStructClass); if (err != CHIP_NO_ERROR) @@ -1660,7 +1660,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass networkFaultChangeStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent", networkFaultChangeStructClass); if (err != CHIP_NO_ERROR) @@ -1710,7 +1710,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_reasonCodeClassName.c_str(), value_reasonCodeCtorSignature.c_str(), jnivalue_reasonCode, value_reasonCode); jclass disconnectionStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$WiFiNetworkDiagnosticsClusterDisconnectionEvent", disconnectionStructClass); if (err != CHIP_NO_ERROR) @@ -1755,7 +1755,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_statusClassName.c_str(), value_statusCtorSignature.c_str(), jnivalue_status, value_status); jclass associationFailureStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$WiFiNetworkDiagnosticsClusterAssociationFailureEvent", associationFailureStructClass); if (err != CHIP_NO_ERROR) @@ -1796,7 +1796,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_connectionStatus, value_connectionStatus); jclass connectionStatusStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$WiFiNetworkDiagnosticsClusterConnectionStatusEvent", connectionStatusStructClass); if (err != CHIP_NO_ERROR) @@ -1846,7 +1846,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass DSTTableEmptyStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$TimeSynchronizationClusterDSTTableEmptyEvent", DSTTableEmptyStructClass); if (err != CHIP_NO_ERROR) @@ -1884,7 +1884,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_DSTOffsetActive, value_DSTOffsetActive); jclass DSTStatusStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$TimeSynchronizationClusterDSTStatusEvent", DSTStatusStructClass); if (err != CHIP_NO_ERROR) { @@ -1933,7 +1933,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass timeZoneStatusStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$TimeSynchronizationClusterTimeZoneStatusEvent", timeZoneStatusStructClass); if (err != CHIP_NO_ERROR) @@ -1963,7 +1963,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass timeFailureStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$TimeSynchronizationClusterTimeFailureEvent", timeFailureStructClass); if (err != CHIP_NO_ERROR) { @@ -1992,7 +1992,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass missingTrustedTimeSourceStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$TimeSynchronizationClusterMissingTrustedTimeSourceEvent", missingTrustedTimeSourceStructClass); if (err != CHIP_NO_ERROR) @@ -2041,7 +2041,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_softwareVersion, value_softwareVersion); jclass startUpStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$BridgedDeviceBasicInformationClusterStartUpEvent", startUpStructClass); if (err != CHIP_NO_ERROR) { @@ -2070,7 +2070,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass shutDownStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$BridgedDeviceBasicInformationClusterShutDownEvent", shutDownStructClass); if (err != CHIP_NO_ERROR) @@ -2099,7 +2099,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass leaveStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$BridgedDeviceBasicInformationClusterLeaveEvent", leaveStructClass); if (err != CHIP_NO_ERROR) { @@ -2135,7 +2135,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_reachableNewValue, value_reachableNewValue); jclass reachableChangedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$BridgedDeviceBasicInformationClusterReachableChangedEvent", reachableChangedStructClass); if (err != CHIP_NO_ERROR) @@ -2185,7 +2185,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_newPosition); jclass switchLatchedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SwitchClusterSwitchLatchedEvent", switchLatchedStructClass); if (err != CHIP_NO_ERROR) { @@ -2222,7 +2222,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_newPosition); jclass initialPressStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SwitchClusterInitialPressEvent", initialPressStructClass); if (err != CHIP_NO_ERROR) { @@ -2259,7 +2259,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_newPosition); jclass longPressStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SwitchClusterLongPressEvent", longPressStructClass); if (err != CHIP_NO_ERROR) { @@ -2296,7 +2296,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_previousPosition, value_previousPosition); jclass shortReleaseStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SwitchClusterShortReleaseEvent", shortReleaseStructClass); if (err != CHIP_NO_ERROR) { @@ -2333,7 +2333,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_previousPosition, value_previousPosition); jclass longReleaseStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SwitchClusterLongReleaseEvent", longReleaseStructClass); if (err != CHIP_NO_ERROR) { @@ -2378,7 +2378,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_currentNumberOfPressesCounted, value_currentNumberOfPressesCounted); jclass multiPressOngoingStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SwitchClusterMultiPressOngoingEvent", multiPressOngoingStructClass); if (err != CHIP_NO_ERROR) { @@ -2425,7 +2425,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_totalNumberOfPressesCounted, value_totalNumberOfPressesCounted); jclass multiPressCompleteStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SwitchClusterMultiPressCompleteEvent", multiPressCompleteStructClass); if (err != CHIP_NO_ERROR) { @@ -2553,7 +2553,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_stateValueClassName.c_str(), value_stateValueCtorSignature.c_str(), jnivalue_stateValue, value_stateValue); jclass stateChangeStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$BooleanStateClusterStateChangeEvent", stateChangeStructClass); if (err != CHIP_NO_ERROR) { @@ -2647,7 +2647,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass errorStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); if (err != CHIP_NO_ERROR) @@ -2671,7 +2671,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_errorState_errorStateLabel, value_errorState_errorStateDetails); jclass operationalErrorStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$OvenCavityOperationalStateClusterOperationalErrorEvent", operationalErrorStructClass); if (err != CHIP_NO_ERROR) @@ -2763,7 +2763,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass operationCompletionStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$OvenCavityOperationalStateClusterOperationCompletionEvent", operationCompletionStructClass); if (err != CHIP_NO_ERROR) @@ -2925,7 +2925,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_maskCtorSignature.c_str(), jnivalue_mask, value_mask); jclass notifyStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$RefrigeratorAlarmClusterNotifyEvent", notifyStructClass); if (err != CHIP_NO_ERROR) { @@ -2994,7 +2994,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_alarmSeverityLevel, value_alarmSeverityLevel); jclass smokeAlarmStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SmokeCoAlarmClusterSmokeAlarmEvent", smokeAlarmStructClass); if (err != CHIP_NO_ERROR) { @@ -3031,7 +3031,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_alarmSeverityLevel, value_alarmSeverityLevel); jclass COAlarmStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SmokeCoAlarmClusterCOAlarmEvent", COAlarmStructClass); if (err != CHIP_NO_ERROR) { @@ -3068,7 +3068,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_alarmSeverityLevel, value_alarmSeverityLevel); jclass lowBatteryStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SmokeCoAlarmClusterLowBatteryEvent", lowBatteryStructClass); if (err != CHIP_NO_ERROR) { @@ -3097,7 +3097,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass hardwareFaultStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SmokeCoAlarmClusterHardwareFaultEvent", hardwareFaultStructClass); if (err != CHIP_NO_ERROR) { @@ -3126,7 +3126,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass endOfServiceStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SmokeCoAlarmClusterEndOfServiceEvent", endOfServiceStructClass); if (err != CHIP_NO_ERROR) { @@ -3155,7 +3155,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass selfTestCompleteStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SmokeCoAlarmClusterSelfTestCompleteEvent", selfTestCompleteStructClass); if (err != CHIP_NO_ERROR) @@ -3185,7 +3185,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass alarmMutedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SmokeCoAlarmClusterAlarmMutedEvent", alarmMutedStructClass); if (err != CHIP_NO_ERROR) { @@ -3213,7 +3213,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass muteEndedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SmokeCoAlarmClusterMuteEndedEvent", muteEndedStructClass); if (err != CHIP_NO_ERROR) { @@ -3249,7 +3249,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_alarmSeverityLevel, value_alarmSeverityLevel); jclass interconnectSmokeAlarmStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SmokeCoAlarmClusterInterconnectSmokeAlarmEvent", interconnectSmokeAlarmStructClass); if (err != CHIP_NO_ERROR) @@ -3288,7 +3288,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_alarmSeverityLevel, value_alarmSeverityLevel); jclass interconnectCOAlarmStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SmokeCoAlarmClusterInterconnectCOAlarmEvent", interconnectCOAlarmStructClass); if (err != CHIP_NO_ERROR) @@ -3318,7 +3318,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass allClearStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SmokeCoAlarmClusterAllClearEvent", allClearStructClass); if (err != CHIP_NO_ERROR) { @@ -3384,7 +3384,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_maskCtorSignature.c_str(), jnivalue_mask, value_mask); jclass notifyStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$DishwasherAlarmClusterNotifyEvent", notifyStructClass); if (err != CHIP_NO_ERROR) { @@ -3480,7 +3480,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass errorStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$OperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); if (err != CHIP_NO_ERROR) { @@ -3503,7 +3503,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_errorState_errorStateLabel, value_errorState_errorStateDetails); jclass operationalErrorStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$OperationalStateClusterOperationalErrorEvent", operationalErrorStructClass); if (err != CHIP_NO_ERROR) @@ -3593,7 +3593,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass operationCompletionStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$OperationalStateClusterOperationCompletionEvent", operationCompletionStructClass); if (err != CHIP_NO_ERROR) @@ -3670,7 +3670,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass errorStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$RvcOperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); if (err != CHIP_NO_ERROR) { @@ -3693,7 +3693,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_errorState_errorStateLabel, value_errorState_errorStateDetails); jclass operationalErrorStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$RvcOperationalStateClusterOperationalErrorEvent", operationalErrorStructClass); if (err != CHIP_NO_ERROR) @@ -3783,7 +3783,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass operationCompletionStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$RvcOperationalStateClusterOperationCompletionEvent", operationCompletionStructClass); if (err != CHIP_NO_ERROR) @@ -3881,7 +3881,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass alarmsStateChangedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$BooleanStateConfigurationClusterAlarmsStateChangedEvent", alarmsStateChangedStructClass); if (err != CHIP_NO_ERROR) @@ -3922,7 +3922,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_sensorFault); jclass sensorFaultStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$BooleanStateConfigurationClusterSensorFaultEvent", sensorFaultStructClass); if (err != CHIP_NO_ERROR) @@ -3986,7 +3986,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass valveStateChangedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$ValveConfigurationAndControlClusterValveStateChangedEvent", valveStateChangedStructClass); if (err != CHIP_NO_ERROR) @@ -4027,7 +4027,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_valveFaultClassName.c_str(), value_valveFaultCtorSignature.c_str(), jnivalue_valveFault, value_valveFault); jclass valveFaultStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$ValveConfigurationAndControlClusterValveFaultEvent", valveFaultStructClass); if (err != CHIP_NO_ERROR) @@ -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) @@ -4165,7 +4414,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass energyMeasurementStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", energyMeasurementStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -4293,7 +4542,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass energyMeasurementStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", energyMeasurementStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -4323,7 +4572,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass cumulativeEnergyMeasuredStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent", cumulativeEnergyMeasuredStructClass); if (err != CHIP_NO_ERROR) @@ -4456,7 +4705,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass energyMeasurementStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", energyMeasurementStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -4584,7 +4833,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass energyMeasurementStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$ElectricalEnergyMeasurementClusterEnergyMeasurementStruct", energyMeasurementStructStructClass_1); if (err != CHIP_NO_ERROR) @@ -4614,7 +4863,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass periodicEnergyMeasuredStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent", periodicEnergyMeasuredStructClass); if (err != CHIP_NO_ERROR) @@ -4841,7 +5090,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass temperatureControlStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterTemperatureControlStruct", temperatureControlStructStructClass_2); if (err != CHIP_NO_ERROR) @@ -4899,7 +5148,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_averageLoadControlInsideOptional_loadAdjustment); jclass averageLoadControlStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterAverageLoadControlStruct", averageLoadControlStructStructClass_2); if (err != CHIP_NO_ERROR) @@ -4952,7 +5201,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_dutyCycleControlInsideOptional_dutyCycle, value_dutyCycleControlInsideOptional_dutyCycle); jclass dutyCycleControlStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterDutyCycleControlStruct", dutyCycleControlStructStructClass_2); if (err != CHIP_NO_ERROR) @@ -5006,7 +5255,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_powerSavingsControlInsideOptional_powerSavings); jclass powerSavingsControlStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterPowerSavingsControlStruct", powerSavingsControlStructStructClass_2); if (err != CHIP_NO_ERROR) @@ -5062,7 +5311,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_heatingSourceControlInsideOptional_heatingSource); jclass heatingSourceControlStructStructClass_2; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DemandResponseLoadControlClusterHeatingSourceControlStruct", heatingSourceControlStructStructClass_2); if (err != CHIP_NO_ERROR) @@ -5093,7 +5342,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass loadControlEventStatusChangeStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent", loadControlEventStatusChangeStructClass); if (err != CHIP_NO_ERROR) @@ -5148,7 +5397,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_messageID = value_messageIDByteArray; jclass messageQueuedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$MessagesClusterMessageQueuedEvent", messageQueuedStructClass); if (err != CHIP_NO_ERROR) { @@ -5183,7 +5432,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_messageID = value_messageIDByteArray; jclass messagePresentedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$MessagesClusterMessagePresentedEvent", messagePresentedStructClass); if (err != CHIP_NO_ERROR) { @@ -5277,7 +5526,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass messageCompleteStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$MessagesClusterMessageCompleteEvent", messageCompleteStructClass); if (err != CHIP_NO_ERROR) { @@ -5318,7 +5567,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass powerAdjustStartStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$DeviceEnergyManagementClusterPowerAdjustStartEvent", powerAdjustStartStructClass); if (err != CHIP_NO_ERROR) @@ -5369,7 +5618,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_energyUseClassName.c_str(), value_energyUseCtorSignature.c_str(), jnivalue_energyUse, value_energyUse); jclass powerAdjustEndStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$DeviceEnergyManagementClusterPowerAdjustEndEvent", powerAdjustEndStructClass); if (err != CHIP_NO_ERROR) @@ -5401,7 +5650,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass pausedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$DeviceEnergyManagementClusterPausedEvent", pausedStructClass); if (err != CHIP_NO_ERROR) { @@ -5436,7 +5685,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_causeClassName.c_str(), value_causeCtorSignature.c_str(), jnivalue_cause, value_cause); jclass resumedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$DeviceEnergyManagementClusterResumedEvent", resumedStructClass); if (err != CHIP_NO_ERROR) { @@ -5482,7 +5731,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_sessionIDClassName.c_str(), value_sessionIDCtorSignature.c_str(), jnivalue_sessionID, value_sessionID); jclass EVConnectedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$EnergyEvseClusterEVConnectedEvent", EVConnectedStructClass); if (err != CHIP_NO_ERROR) { @@ -5560,7 +5809,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass EVNotDetectedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$EnergyEvseClusterEVNotDetectedEvent", EVNotDetectedStructClass); if (err != CHIP_NO_ERROR) { @@ -5614,7 +5863,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_maximumCurrent, value_maximumCurrent); jclass energyTransferStartedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$EnergyEvseClusterEnergyTransferStartedEvent", energyTransferStartedStructClass); if (err != CHIP_NO_ERROR) @@ -5675,7 +5924,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_energyTransferred, value_energyTransferred); jclass energyTransferStoppedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$EnergyEvseClusterEnergyTransferStoppedEvent", energyTransferStoppedStructClass); if (err != CHIP_NO_ERROR) @@ -5744,7 +5993,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_faultStateCurrentState, value_faultStateCurrentState); jclass faultStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$EnergyEvseClusterFaultEvent", faultStructClass); if (err != CHIP_NO_ERROR) { @@ -5781,7 +6030,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_uid = value_uidByteArray; jclass rfidStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$EnergyEvseClusterRfidEvent", rfidStructClass); if (err != CHIP_NO_ERROR) { @@ -5856,7 +6105,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_alarmCodeClassName.c_str(), value_alarmCodeCtorSignature.c_str(), jnivalue_alarmCode, value_alarmCode); jclass doorLockAlarmStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$DoorLockClusterDoorLockAlarmEvent", doorLockAlarmStructClass); if (err != CHIP_NO_ERROR) { @@ -5892,7 +6141,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_doorStateClassName.c_str(), value_doorStateCtorSignature.c_str(), jnivalue_doorState, value_doorState); jclass doorStateChangeStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$DoorLockClusterDoorStateChangeEvent", doorStateChangeStructClass); if (err != CHIP_NO_ERROR) { @@ -6017,7 +6266,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jninewElement_2_credentialIndex, newElement_2_credentialIndex); jclass credentialStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DoorLockClusterCredentialStruct", credentialStructStructClass_3); if (err != CHIP_NO_ERROR) @@ -6045,7 +6294,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass lockOperationStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$DoorLockClusterLockOperationEvent", lockOperationStructClass); if (err != CHIP_NO_ERROR) { @@ -6182,7 +6431,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jninewElement_2_credentialIndex, newElement_2_credentialIndex); jclass credentialStructStructClass_3; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$DoorLockClusterCredentialStruct", credentialStructStructClass_3); if (err != CHIP_NO_ERROR) @@ -6210,7 +6459,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass lockOperationErrorStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$DoorLockClusterLockOperationErrorEvent", lockOperationErrorStructClass); if (err != CHIP_NO_ERROR) @@ -6327,7 +6576,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass lockUserChangeStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$DoorLockClusterLockUserChangeEvent", lockUserChangeStructClass); if (err != CHIP_NO_ERROR) { @@ -6391,7 +6640,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass supplyVoltageLowStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterSupplyVoltageLowEvent", supplyVoltageLowStructClass); if (err != CHIP_NO_ERROR) @@ -6422,7 +6671,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass supplyVoltageHighStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterSupplyVoltageHighEvent", supplyVoltageHighStructClass); if (err != CHIP_NO_ERROR) @@ -6453,7 +6702,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass powerMissingPhaseStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterPowerMissingPhaseEvent", powerMissingPhaseStructClass); if (err != CHIP_NO_ERROR) @@ -6484,7 +6733,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass systemPressureLowStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterSystemPressureLowEvent", systemPressureLowStructClass); if (err != CHIP_NO_ERROR) @@ -6515,7 +6764,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass systemPressureHighStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterSystemPressureHighEvent", systemPressureHighStructClass); if (err != CHIP_NO_ERROR) @@ -6547,7 +6796,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass dryRunningStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterDryRunningEvent", dryRunningStructClass); if (err != CHIP_NO_ERROR) @@ -6576,7 +6825,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass motorTemperatureHighStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterMotorTemperatureHighEvent", motorTemperatureHighStructClass); if (err != CHIP_NO_ERROR) @@ -6608,7 +6857,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass pumpMotorFatalFailureStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterPumpMotorFatalFailureEvent", pumpMotorFatalFailureStructClass); if (err != CHIP_NO_ERROR) @@ -6641,7 +6890,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass electronicTemperatureHighStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterElectronicTemperatureHighEvent", electronicTemperatureHighStructClass); if (err != CHIP_NO_ERROR) @@ -6674,7 +6923,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass pumpBlockedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterPumpBlockedEvent", pumpBlockedStructClass); if (err != CHIP_NO_ERROR) @@ -6704,7 +6953,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass sensorFailureStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterSensorFailureEvent", sensorFailureStructClass); if (err != CHIP_NO_ERROR) @@ -6735,7 +6984,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass electronicNonFatalFailureStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterElectronicNonFatalFailureEvent", electronicNonFatalFailureStructClass); if (err != CHIP_NO_ERROR) @@ -6768,7 +7017,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass electronicFatalFailureStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterElectronicFatalFailureEvent", electronicFatalFailureStructClass); if (err != CHIP_NO_ERROR) @@ -6801,7 +7050,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass generalFaultStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterGeneralFaultEvent", generalFaultStructClass); if (err != CHIP_NO_ERROR) @@ -6832,7 +7081,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass leakageStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterLeakageEvent", leakageStructClass); if (err != CHIP_NO_ERROR) { @@ -6860,7 +7109,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass airDetectionStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterAirDetectionEvent", airDetectionStructClass); if (err != CHIP_NO_ERROR) @@ -6891,7 +7140,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass turbineOperationStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$PumpConfigurationAndControlClusterTurbineOperationEvent", turbineOperationStructClass); if (err != CHIP_NO_ERROR) @@ -7180,7 +7429,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jclass targetInfoStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$TargetNavigatorClusterTargetInfoStruct", targetInfoStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -7218,7 +7467,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_data = value_dataByteArray; jclass targetUpdatedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$TargetNavigatorClusterTargetUpdatedEvent", targetUpdatedStructClass); if (err != CHIP_NO_ERROR) { @@ -7303,7 +7552,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass playbackPositionStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$MediaPlaybackClusterPlaybackPositionStruct", playbackPositionStructStructClass_0); if (err != CHIP_NO_ERROR) @@ -7373,7 +7622,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_audioAdvanceUnmuted, value_audioAdvanceUnmuted); jclass stateChangedStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$MediaPlaybackClusterStateChangedEvent", stateChangedStructClass); if (err != CHIP_NO_ERROR) { @@ -7505,7 +7754,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass loggedOutStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$AccountLoginClusterLoggedOutEvent", loggedOutStructClass); if (err != CHIP_NO_ERROR) { @@ -7544,7 +7793,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jclass remainingScreenTimeExpiredStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$ContentControlClusterRemainingScreenTimeExpiredEvent", remainingScreenTimeExpiredStructClass); if (err != CHIP_NO_ERROR) @@ -7671,7 +7920,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_arg4_hClassName.c_str(), value_arg4_hCtorSignature.c_str(), jnivalue_arg4_h, value_arg4_h); jclass simpleStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_0); if (err != CHIP_NO_ERROR) { @@ -7747,7 +7996,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & newElement_0_hClassName.c_str(), newElement_0_hCtorSignature.c_str(), jninewElement_0_h, newElement_0_h); jclass simpleStructStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); if (err != CHIP_NO_ERROR) { @@ -7790,7 +8039,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jclass testEventStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$UnitTestingClusterTestEventEvent", testEventStructClass); if (err != CHIP_NO_ERROR) { @@ -7831,7 +8080,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_fabricIndex); jclass testFabricScopedEventStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$UnitTestingClusterTestFabricScopedEventEvent", testFabricScopedEventStructClass); if (err != CHIP_NO_ERROR) @@ -7868,7 +8117,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jnivalue_arg1, value_arg1); jclass testDifferentVendorMeiEventStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$UnitTestingClusterTestDifferentVendorMeiEventEvent", testDifferentVendorMeiEventStructClass); if (err != CHIP_NO_ERROR) @@ -7934,7 +8183,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_fabricIndex); jclass pingCountEventStructClass; - err = chip::JniReferences::GetInstance().GetClassRef( + err = chip::JniReferences::GetInstance().GetLocalClassRef( env, "chip/devicecontroller/ChipEventStructs$SampleMeiClusterPingCountEventEvent", pingCountEventStructClass); if (err != CHIP_NO_ERROR) { 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/ChipDeviceController-Discovery.cpp b/src/controller/python/ChipDeviceController-Discovery.cpp index a9fc93b2fbc40b..7b502140a36bb6 100644 --- a/src/controller/python/ChipDeviceController-Discovery.cpp +++ b/src/controller/python/ChipDeviceController-Discovery.cpp @@ -89,6 +89,11 @@ PyChipError pychip_DeviceController_DiscoverCommissionableNodes(Controller::Devi return ToPyChipError(devCtrl->DiscoverCommissionableNodes(filter)); } +PyChipError pychip_DeviceController_StopCommissionableDiscovery(Controller::DeviceCommissioner * devCtrl) +{ + return ToPyChipError(devCtrl->StopCommissionableDiscovery()); +} + void pychip_DeviceController_IterateDiscoveredCommissionableNodes(Controller::DeviceCommissioner * devCtrl, IterateDiscoveredCommissionableNodesFunct cb) { diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 20e21177fe2b1d..402f2b7cea694d 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -594,6 +594,9 @@ def DiscoverCommissionableNodes(self, filterType: discovery.FilterType = discove else: time.sleep(timeoutSecond) + self._ChipStack.Call( + lambda: self._dmLib.pychip_DeviceController_StopCommissionableDiscovery(self.devCtrl)).raise_on_error() + return self.GetDiscoveredDevices() def DiscoverCommissionableNodesLongDiscriminator(self, long_discriminator): @@ -1567,6 +1570,10 @@ def _InitLib(self): c_void_p, c_uint8, c_char_p] self._dmLib.pychip_DeviceController_DiscoverCommissionableNodes.restype = PyChipError + self._dmLib.pychip_DeviceController_StopCommissionableDiscovery.argtypes = [ + c_void_p] + self._dmLib.pychip_DeviceController_StopCommissionableDiscovery.restype = PyChipError + self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesLongDiscriminator.argtypes = [ c_void_p, c_uint16] self._dmLib.pychip_DeviceController_DiscoverCommissionableNodesLongDiscriminator.restype = PyChipError diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 3d2d8ead23e721..260f0badf6dce0 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -4830,13 +4830,6 @@ class ChipClusters: "type": "int", "reportable": True, }, - 0x00000003: { - "attributeName": "OnMode", - "attributeId": 0x00000003, - "type": "int", - "reportable": True, - "writable": True, - }, 0x0000FFF8: { "attributeName": "GeneratedCommandList", "attributeId": 0x0000FFF8, @@ -4900,13 +4893,6 @@ class ChipClusters: "type": "int", "reportable": True, }, - 0x00000003: { - "attributeName": "OnMode", - "attributeId": 0x00000003, - "type": "int", - "reportable": True, - "writable": True, - }, 0x0000FFF8: { "attributeName": "GeneratedCommandList", "attributeId": 0x0000FFF8, @@ -5719,18 +5705,6 @@ class ChipClusters: "args": { }, }, - 0x00000001: { - "commandId": 0x00000001, - "commandName": "Stop", - "args": { - }, - }, - 0x00000002: { - "commandId": 0x00000002, - "commandName": "Start", - "args": { - }, - }, 0x00000003: { "commandId": 0x00000003, "commandName": "Resume", @@ -6357,6 +6331,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, @@ -6393,6 +6525,12 @@ class ChipClusters: "type": "", "reportable": True, }, + 0x00000005: { + "attributeName": "CumulativeEnergyReset", + "attributeId": 0x00000005, + "type": "", + "reportable": True, + }, 0x0000FFF8: { "attributeName": "GeneratedCommandList", "attributeId": 0x0000FFF8, @@ -6568,7 +6706,13 @@ class ChipClusters: "commandId": 0x00000000, "commandName": "PresentMessagesRequest", "args": { - "messages": "MessageStruct", + "messageID": "bytes", + "priority": "int", + "messageControl": "int", + "startTime": "int", + "duration": "int", + "messageText": "str", + "responses": "MessageResponseOptionStruct", }, }, 0x00000001: { @@ -14393,6 +14537,7 @@ 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, @@ -14512,6 +14657,7 @@ 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, diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index cd71b6ea9c03fd..71f77cd384bc55 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -16660,7 +16660,6 @@ def descriptor(cls) -> ClusterObjectDescriptor: Fields=[ ClusterObjectFieldDescriptor(Label="supportedModes", Tag=0x00000000, Type=typing.List[RvcRunMode.Structs.ModeOptionStruct]), ClusterObjectFieldDescriptor(Label="currentMode", Tag=0x00000001, Type=uint), - ClusterObjectFieldDescriptor(Label="onMode", Tag=0x00000003, Type=typing.Union[None, Nullable, 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]), @@ -16671,7 +16670,6 @@ def descriptor(cls) -> ClusterObjectDescriptor: supportedModes: 'typing.List[RvcRunMode.Structs.ModeOptionStruct]' = None currentMode: 'uint' = None - onMode: 'typing.Union[None, Nullable, uint]' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None eventList: 'typing.List[uint]' = None @@ -16707,7 +16705,7 @@ class StatusCode(MatterIntEnum): class Bitmaps: class Feature(IntFlag): - kOnOff = 0x1 + kNoFeatures = 0x0 class Structs: @dataclass @@ -16806,22 +16804,6 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'uint' = 0 - @dataclass - class OnMode(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0x00000054 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0x00000003 - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, uint]) - - value: 'typing.Union[None, Nullable, uint]' = None - @dataclass class GeneratedCommandList(ClusterAttributeDescriptor): @ChipUtility.classproperty @@ -16929,7 +16911,6 @@ def descriptor(cls) -> ClusterObjectDescriptor: Fields=[ ClusterObjectFieldDescriptor(Label="supportedModes", Tag=0x00000000, Type=typing.List[RvcCleanMode.Structs.ModeOptionStruct]), ClusterObjectFieldDescriptor(Label="currentMode", Tag=0x00000001, Type=uint), - ClusterObjectFieldDescriptor(Label="onMode", Tag=0x00000003, Type=typing.Union[None, Nullable, 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]), @@ -16940,7 +16921,6 @@ def descriptor(cls) -> ClusterObjectDescriptor: supportedModes: 'typing.List[RvcCleanMode.Structs.ModeOptionStruct]' = None currentMode: 'uint' = None - onMode: 'typing.Union[None, Nullable, uint]' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None eventList: 'typing.List[uint]' = None @@ -16969,7 +16949,7 @@ class StatusCode(MatterIntEnum): class Bitmaps: class Feature(IntFlag): - kOnOff = 0x1 + kNoFeatures = 0x0 class Structs: @dataclass @@ -17068,22 +17048,6 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'uint' = 0 - @dataclass - class OnMode(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0x00000055 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0x00000003 - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, uint]) - - value: 'typing.Union[None, Nullable, uint]' = None - @dataclass class GeneratedCommandList(ClusterAttributeDescriptor): @ChipUtility.classproperty @@ -19996,32 +19960,6 @@ def descriptor(cls) -> ClusterObjectDescriptor: Fields=[ ]) - @dataclass - class Stop(ClusterCommand): - cluster_id: typing.ClassVar[int] = 0x00000061 - command_id: typing.ClassVar[int] = 0x00000001 - is_client: typing.ClassVar[bool] = True - response_type: typing.ClassVar[str] = 'OperationalCommandResponse' - - @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ]) - - @dataclass - class Start(ClusterCommand): - cluster_id: typing.ClassVar[int] = 0x00000061 - command_id: typing.ClassVar[int] = 0x00000002 - is_client: typing.ClassVar[bool] = True - response_type: typing.ClassVar[str] = 'OperationalCommandResponse' - - @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ]) - @dataclass class Resume(ClusterCommand): cluster_id: typing.ClassVar[int] = 0x00000061 @@ -22200,18 +22138,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]), @@ -22220,11 +22172,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 @@ -22255,12 +22221,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 @@ -22294,44 +22271,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: @@ -22339,15 +22341,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: @@ -22355,15 +22357,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: @@ -22371,15 +22373,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: @@ -22387,15 +22389,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: @@ -22403,181 +22405,765 @@ 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 + value: 'typing.Union[None, Nullable, int]' = None + + @dataclass + class Frequency(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000090 + + @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 @@ -23269,10 +23855,22 @@ class PresentMessagesRequest(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="messages", Tag=0, Type=typing.List[Messages.Structs.MessageStruct]), + ClusterObjectFieldDescriptor(Label="messageID", Tag=0, Type=bytes), + ClusterObjectFieldDescriptor(Label="priority", Tag=1, Type=Messages.Enums.MessagePriorityEnum), + ClusterObjectFieldDescriptor(Label="messageControl", Tag=2, Type=uint), + ClusterObjectFieldDescriptor(Label="startTime", Tag=3, Type=typing.Union[Nullable, uint]), + ClusterObjectFieldDescriptor(Label="duration", Tag=4, Type=typing.Union[Nullable, uint]), + ClusterObjectFieldDescriptor(Label="messageText", Tag=5, Type=str), + ClusterObjectFieldDescriptor(Label="responses", Tag=6, Type=typing.Optional[typing.List[Messages.Structs.MessageResponseOptionStruct]]), ]) - messages: 'typing.List[Messages.Structs.MessageStruct]' = field(default_factory=lambda: []) + messageID: 'bytes' = b"" + priority: 'Messages.Enums.MessagePriorityEnum' = 0 + messageControl: 'uint' = 0 + startTime: 'typing.Union[Nullable, uint]' = NullValue + duration: 'typing.Union[Nullable, uint]' = NullValue + messageText: 'str' = "" + responses: 'typing.Optional[typing.List[Messages.Structs.MessageResponseOptionStruct]]' = None @dataclass class CancelMessagesRequest(ClusterCommand): 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/credentials/BUILD.gn b/src/credentials/BUILD.gn index 6aa10311560fa5..cd12f485e32009 100644 --- a/src/credentials/BUILD.gn +++ b/src/credentials/BUILD.gn @@ -125,6 +125,7 @@ static_library("credentials") { "${chip_root}/src/crypto", "${chip_root}/src/lib/asn1", "${chip_root}/src/lib/core", + "${chip_root}/src/lib/core:types", "${chip_root}/src/lib/support", "${chip_root}/src/platform", "${chip_root}/src/protocols:type_definitions", diff --git a/src/credentials/CHIPCert.h b/src/credentials/CHIPCert.h index f59c6c36a59a27..5c8372d34954e4 100644 --- a/src/credentials/CHIPCert.h +++ b/src/credentials/CHIPCert.h @@ -40,6 +40,7 @@ #include #include #include +#include namespace chip { namespace Credentials { 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/BUILD.gn b/src/crypto/BUILD.gn index 8cc7ba400f0ef0..bfd633947c903d 100644 --- a/src/crypto/BUILD.gn +++ b/src/crypto/BUILD.gn @@ -68,6 +68,7 @@ source_set("public_headers") { ":crypto_buildconfig", "${chip_root}/src/lib/asn1", "${chip_root}/src/lib/core", + "${chip_root}/src/lib/core:types", "${chip_root}/src/lib/support", "${nlassert_root}:nlassert", ] diff --git a/src/crypto/tests/BUILD.gn b/src/crypto/tests/BUILD.gn index e8ce4221ba27c7..1599b942269ae6 100644 --- a/src/crypto/tests/BUILD.gn +++ b/src/crypto/tests/BUILD.gn @@ -24,7 +24,6 @@ chip_test_suite_using_nltest("tests") { sources = [ "AES_CCM_128_test_vectors.h", - "CHIPCryptoPALTest.cpp", "DacValidationExplicitVectors.h", "DerSigConversion_test_vectors.h", "ECDH_P256_test_vectors.h", @@ -46,6 +45,7 @@ chip_test_suite_using_nltest("tests") { ] test_sources = [ + "TestChipCryptoPAL.cpp", "TestGroupOperationalCredentials.cpp", "TestSessionKeystore.cpp", ] @@ -69,10 +69,9 @@ 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", ] - - tests = [ "CHIPCryptoPALTest" ] } diff --git a/src/crypto/tests/CHIPCryptoPALTest.cpp b/src/crypto/tests/TestChipCryptoPAL.cpp similarity index 99% rename from src/crypto/tests/CHIPCryptoPALTest.cpp rename to src/crypto/tests/TestChipCryptoPAL.cpp index 4a3af662853172..124a64ba7032c6 100644 --- a/src/crypto/tests/CHIPCryptoPALTest.cpp +++ b/src/crypto/tests/TestChipCryptoPAL.cpp @@ -3070,7 +3070,7 @@ int TestCHIPCryptoPAL_Teardown(void * inContext) return SUCCESS; } -int TestCHIPCryptoPAL(void) +int TestChipCryptoPal() { // clang-format off nlTestSuite theSuite = @@ -3088,4 +3088,4 @@ int TestCHIPCryptoPAL(void) return (nlTestRunnerStats(&theSuite)); } -CHIP_REGISTER_TEST_SUITE(TestCHIPCryptoPAL) +CHIP_REGISTER_TEST_SUITE(TestChipCryptoPal) diff --git a/src/darwin/Framework/CHIP/MTRDevice.h b/src/darwin/Framework/CHIP/MTRDevice.h index 32a4593a2e40fc..9d3b0768ff4061 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.h +++ b/src/darwin/Framework/CHIP/MTRDevice.h @@ -348,6 +348,8 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) MTR_NEWLY_AVAILABLE; @end +MTR_EXTERN NSString * const MTRPreviousDataKey MTR_NEWLY_AVAILABLE; + @protocol MTRDeviceDelegate @required /** @@ -359,6 +361,10 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) * Notifies delegate of attribute reports from the MTRDevice * * @param attributeReport An array of response-value objects as described in MTRDeviceResponseHandler + * + * In addition to MTRDataKey, each response-value dictionary in the array may also have this key: + * + * MTRPreviousDataKey : Same data-value dictionary format as the object for MTRDataKey. This is included when the previous value is known for an attribute. */ - (void)device:(MTRDevice *)device receivedAttributeReport:(NSArray *> *)attributeReport; diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index f25ac5b9564187..22f1de7e4c18a0 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -45,6 +45,8 @@ typedef void (^MTRDeviceAttributeReportHandler)(NSArray * _Nonnull); +NSString * const MTRPreviousDataKey = @"previousData"; + // Consider moving utility classes to their own file #pragma mark - Utility Classes // This class is for storing weak references in a container @@ -1413,7 +1415,7 @@ - (void)_checkExpiredExpectedValues NSDictionary * cachedAttributeDataValue = _readCache[attributePath]; if (cachedAttributeDataValue && ![self _attributeDataValue:attributeDataValue isEqualToDataValue:cachedAttributeDataValue]) { - [attributesToReport addObject:@{ MTRAttributePathKey : attributePath, MTRDataKey : cachedAttributeDataValue }]; + [attributesToReport addObject:@{ MTRAttributePathKey : attributePath, MTRDataKey : cachedAttributeDataValue, MTRPreviousDataKey : attributeDataValue }]; [attributePathsToReport addObject:attributePath]; } @@ -1505,6 +1507,7 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray *)expectedAttributeValue attributePath:(MTRAttributePath *)attributePath expirationTime:(NSDate *)expirationTime shouldReportValue:(BOOL *)shouldReportValue attributeValueToReport:(NSDictionary **)attributeValueToReport expectedValueID:(uint64_t)expectedValueID + previousValue:(NSDictionary **)previousValue { os_unfair_lock_assert_owner(&self->_lock); @@ -1604,6 +1618,7 @@ - (void)_setExpectedValue:(NSDictionary *)expectedAttributeValue // Case where new expected value overrides previous expected value - report new expected value *shouldReportValue = YES; *attributeValueToReport = expectedAttributeValue; + *previousValue = previousExpectedValue[MTRDeviceExpectedValueFieldValueIndex]; } else if (!expectedAttributeValue) { // Remove previous expected value only if it's from the same setExpectedValues operation NSNumber * previousExpectedValueID = previousExpectedValue[MTRDeviceExpectedValueFieldIDIndex]; @@ -1613,6 +1628,7 @@ - (void)_setExpectedValue:(NSDictionary *)expectedAttributeValue // Case of removing expected value that is different than read cache - report read cache value *shouldReportValue = YES; *attributeValueToReport = _readCache[attributePath]; + *previousValue = previousExpectedValue[MTRDeviceExpectedValueFieldValueIndex]; _expectedValueCache[attributePath] = nil; } } @@ -1623,6 +1639,9 @@ - (void)_setExpectedValue:(NSDictionary *)expectedAttributeValue // Case where new expected value is different than read cache - report new expected value *shouldReportValue = YES; *attributeValueToReport = expectedAttributeValue; + *previousValue = _readCache[attributePath]; + } else { + *previousValue = nil; } // No need to report if new and previous expected value are both nil @@ -1649,15 +1668,21 @@ - (NSArray *)_getAttributesToReportWithNewExpectedValues:(NSArray * attributeValueToReport; + NSDictionary * previousValue; [self _setExpectedValue:attributeDataValue attributePath:attributePath expirationTime:expirationTime shouldReportValue:&shouldReportValue attributeValueToReport:&attributeValueToReport - expectedValueID:expectedValueIDToReturn]; + expectedValueID:expectedValueIDToReturn + previousValue:&previousValue]; if (shouldReportValue) { - [attributesToReport addObject:@{ MTRAttributePathKey : attributePath, MTRDataKey : attributeValueToReport }]; + if (previousValue) { + [attributesToReport addObject:@{ MTRAttributePathKey : attributePath, MTRDataKey : attributeValueToReport, MTRPreviousDataKey : previousValue }]; + } else { + [attributesToReport addObject:@{ MTRAttributePathKey : attributePath, MTRDataKey : attributeValueToReport }]; + } [attributePathsToReport addObject:attributePath]; } } @@ -1721,21 +1746,26 @@ - (void)_removeExpectedValueForAttributePath:(MTRAttributePath *)attributePath e BOOL shouldReportValue; NSDictionary * attributeValueToReport; + NSDictionary * previousValue; [self _setExpectedValue:nil attributePath:attributePath expirationTime:nil shouldReportValue:&shouldReportValue attributeValueToReport:&attributeValueToReport - expectedValueID:expectedValueID]; + expectedValueID:expectedValueID + previousValue:&previousValue]; MTR_LOG_INFO("%@ remove expected value for path %@ should report %@", self, attributePath, shouldReportValue ? @"YES" : @"NO"); if (shouldReportValue) { + NSMutableDictionary * attribute = [NSMutableDictionary dictionaryWithObject:attributePath forKey:MTRAttributePathKey]; if (attributeValueToReport) { - [self _reportAttributes:@[ @{ MTRAttributePathKey : attributePath, MTRDataKey : attributeValueToReport } ]]; - } else { - [self _reportAttributes:@[ @{ MTRAttributePathKey : attributePath } ]]; + attribute[MTRDataKey] = attributeValueToReport; + } + if (previousValue) { + attribute[MTRPreviousDataKey] = previousValue; } + [self _reportAttributes:@[ attribute ]]; } } diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h index 59b28583728aab..063e01d79924bc 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h @@ -43,6 +43,7 @@ MTR_AVAILABLE(ios(17.0), macos(14.0), watchos(10.0), tvos(17.0)) @end @class MTRDeviceController; +@class MTRMetrics; /** * The protocol definition for the MTRDeviceControllerDelegate. @@ -82,6 +83,20 @@ MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) commissioningComplete:(NSError * _Nullable)error nodeID:(NSNumber * _Nullable)nodeID MTR_AVAILABLE(ios(17.0), macos(14.0), watchos(10.0), tvos(17.0)); +/** + * Notify the delegate when commissioning is completed. + * + * Exactly one of error and nodeID will be nil. + * + * If nodeID is not nil, then it represents the node id the node was assigned, as encoded in its operational certificate. + * + * The metrics object contains information corresponding to the commissioning session. + */ +- (void)controller:(MTRDeviceController *)controller + commissioningComplete:(NSError * _Nullable)error + nodeID:(NSNumber * _Nullable)nodeID + metrics:(MTRMetrics *)metrics MTR_NEWLY_AVAILABLE; + /** * Notify the delegate when commissioning infomation has been read from the Basic * Information cluster of the commissionee. diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm index 71ca534e67ddff..e1c49031e3abb2 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm @@ -19,6 +19,7 @@ #import "MTRDeviceController.h" #import "MTRError_Internal.h" #import "MTRLogging_Internal.h" +#import "MTRMetrics_Internal.h" MTRDeviceControllerDelegateBridge::MTRDeviceControllerDelegateBridge(void) : mDelegate(nil) @@ -120,14 +121,28 @@ id strongDelegate = mDelegate; MTRDeviceController * strongController = mController; if (strongDelegate && mQueue && strongController) { - if ([strongDelegate respondsToSelector:@selector(controller:commissioningComplete:nodeID:)]) { + if ([strongDelegate respondsToSelector:@selector(controller:commissioningComplete:nodeID:)] || + [strongDelegate respondsToSelector:@selector(controller:commissioningComplete:nodeID:metrics:)]) { dispatch_async(mQueue, ^{ NSError * nsError = [MTRError errorForCHIPErrorCode:error]; NSNumber * nodeID = nil; if (error == CHIP_NO_ERROR) { nodeID = @(nodeId); } - [strongDelegate controller:strongController commissioningComplete:nsError nodeID:nodeID]; + + if ([strongDelegate respondsToSelector:@selector(controller:commissioningComplete:nodeID:metrics:)]) { + MTRMetrics * metrics = [MTRMetrics new]; + + if (nsError) { + [metrics setValue:nsError forKey:MTRMetricCommissioningStatusKey]; + } else { + auto * error = [NSError errorWithDomain:MTRErrorDomain code:0 userInfo:nil]; + [metrics setValue:error forKey:MTRMetricCommissioningStatusKey]; + } + [strongDelegate controller:strongController commissioningComplete:nsError nodeID:nodeID metrics:metrics]; + } else { + [strongDelegate controller:strongController commissioningComplete:nsError nodeID:nodeID]; + } }); return; } diff --git a/src/crypto/tests/CHIPCryptoPALTestDriver.cpp b/src/darwin/Framework/CHIP/MTRMetrics.h similarity index 58% rename from src/crypto/tests/CHIPCryptoPALTestDriver.cpp rename to src/darwin/Framework/CHIP/MTRMetrics.h index ef7b243c50ef1b..81161ee049bedd 100644 --- a/src/crypto/tests/CHIPCryptoPALTestDriver.cpp +++ b/src/darwin/Framework/CHIP/MTRMetrics.h @@ -1,6 +1,6 @@ -/* +/** * - * 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. @@ -15,22 +15,20 @@ * limitations under the License. */ +#import +#import + +NS_ASSUME_NONNULL_BEGIN + /** - * @file - * This file implements a standalone/native program executable - * test driver for the CHIP system layer library error string - * library unit tests. - * + * A representation of metrics data for an operation. */ +MTR_NEWLY_AVAILABLE +@interface MTRMetrics : NSObject -#include "TestCryptoLayer.h" - -#include +@property (nonatomic, readonly, copy) NSArray * allKeys; -int main() -{ - // Generate machine-readable, comma-separated value (CSV) output. - nlTestSetOutputStyle(OUTPUT_CSV); +- (nullable id)valueForKey:(NSString *)key; - return (TestCHIPCryptoPAL()); -} +@end +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/MTRMetrics.mm b/src/darwin/Framework/CHIP/MTRMetrics.mm new file mode 100644 index 00000000000000..c1135c1cfbc0b6 --- /dev/null +++ b/src/darwin/Framework/CHIP/MTRMetrics.mm @@ -0,0 +1,73 @@ +/** + * + * 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 "MTRLogging_Internal.h" +#import "MTRMetrics_Internal.h" +#import + +@implementation MTRMetrics { + NSMutableDictionary * _metricsData; +} + +- (instancetype)init +{ + if (self = [super init]) { + _metricsData = [NSMutableDictionary dictionary]; + } + return self; +} + +- (NSArray *)allKeys +{ + return [_metricsData allKeys]; +} + +- (nullable id)valueForKey:(NSString *)key +{ + if (!key) { + MTR_LOG_ERROR("Cannot get metrics value for nil key"); + return nil; + } + + return _metricsData[key]; +} + +- (void)setValue:(id _Nullable)value forKey:(NSString *)key +{ + if (!key) { + MTR_LOG_ERROR("Cannot set metrics value for nil key"); + return; + } + + [_metricsData setValue:value forKey:key]; +} + +- (void)removeValueForKey:(NSString *)key +{ + if (!key) { + MTR_LOG_ERROR("Cannot remove metrics value for nil key"); + return; + } + + [_metricsData removeObjectForKey:key]; +} + +- (NSString *)description +{ + return [_metricsData description]; +} + +@end diff --git a/src/darwin/Framework/CHIP/MTRMetrics_Internal.h b/src/darwin/Framework/CHIP/MTRMetrics_Internal.h new file mode 100644 index 00000000000000..3e69c79dd53802 --- /dev/null +++ b/src/darwin/Framework/CHIP/MTRMetrics_Internal.h @@ -0,0 +1,31 @@ +/** + * + * 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 "MTRMetrics.h" + +NS_ASSUME_NONNULL_BEGIN + +#define MTRMetricCommissioningStatusKey @"com.matter.metric.commissioningStatus" + +@interface MTRMetrics () + +- (void)setValue:(id _Nullable)value forKey:(NSString *)key; + +- (void)removeValueForKey:(NSString *)key; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/Matter.h b/src/darwin/Framework/CHIP/Matter.h index 85f1399268f1a1..37b72902281b1c 100644 --- a/src/darwin/Framework/CHIP/Matter.h +++ b/src/darwin/Framework/CHIP/Matter.h @@ -19,6 +19,7 @@ #define MTR_INCLUDED_FROM_UMBRELLA_HEADER +#import #import #import #import @@ -45,17 +46,22 @@ #import #import #import +#import #import #import #import #import #import #import +#import #import #import #import #import #import +#import +#import +#import #import #import #import diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRAccessGrant.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRAccessGrant.h new file mode 100644 index 00000000000000..e0b25449755f16 --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRAccessGrant.h @@ -0,0 +1,80 @@ +/** + * 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 +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * An access grant, which can be represented as an entry in the Matter Access + * Control cluster. + */ +MTR_NEWLY_AVAILABLE +@interface MTRAccessGrant : NSObject + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +/** + * Grant access at the provided level to a specific node on the fabric. The + * provided nodeID must be an operational node identifier. + */ ++ (nullable MTRAccessGrant *)accessGrantForNodeID:(NSNumber *)nodeID privilege:(MTRAccessControlEntryPrivilege)privilege; + +/** + * Grant access to any node on the fabric that has a matching CASE Authenticated + * Tag in its operational certificate. The provided caseAuthenticatedTag must + * be a 32-bit unsigned integer with lower 16 bits not 0, per the Matter + * specification. + */ ++ (nullable MTRAccessGrant *)accessGrantForCASEAuthenticatedTag:(NSNumber *)caseAuthenticatedTag privilege:(MTRAccessControlEntryPrivilege)privilege; + +/** + * Grant access to any node on the fabric that is communicating with us via + * group messages sent to the given group. The provided groupID must be a valid + * group identifier in the range 1-65535. + */ ++ (nullable MTRAccessGrant *)accessGrantForGroupID:(NSNumber *)groupID privilege:(MTRAccessControlEntryPrivilege)privilege; + +/** + * Grant access to any node on the fabric, as long as it's communicating with us + * over a unicast authenticated channel. + */ ++ (MTRAccessGrant *)accessGrantForAllNodesWithPrivilege:(MTRAccessControlEntryPrivilege)privilege; + +/** + * The matter access control subject ID that access has been granted for. Nil + * when access has been granted for all subjects (e.g. via initForAllNodesWithPrivilege). + */ +@property (nonatomic, copy, readonly, nullable) NSNumber * subjectID; + +/** + * The privilege that has been granted + */ +@property (nonatomic, assign, readonly) MTRAccessControlEntryPrivilege grantedPrivilege; + +/** + * The type of authentication mode the access grant is + * for. MTRAccessControlEntryAuthModeCASE for unicast messages and + * MTRAccessControlEntryAuthModeGroup for groupcast ones. + */ +@property (nonatomic, assign, readonly) MTRAccessControlEntryAuthMode authenticationMode; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRAccessGrant.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRAccessGrant.mm new file mode 100644 index 00000000000000..a4c0eebf17794a --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRAccessGrant.mm @@ -0,0 +1,155 @@ +/** + * 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 "MTRDefines_Internal.h" +#import "MTRLogging_Internal.h" +#import + +#include +#include +#include +#include + +using namespace chip; + +MTR_DIRECT_MEMBERS +@implementation MTRAccessGrant + ++ (nullable MTRAccessGrant *)accessGrantForNodeID:(NSNumber *)nodeID privilege:(MTRAccessControlEntryPrivilege)privilege +{ + NodeId id = nodeID.unsignedLongLongValue; + if (!IsOperationalNodeId(id)) { + MTR_LOG_ERROR("MTRAccessGrant provided non-operational node ID: 0x%llx", id); + return nil; + } + + return [[MTRAccessGrant alloc] initWithSubject:[nodeID copy] privilege:privilege authenticationMode:MTRAccessControlEntryAuthModeCASE]; +} + ++ (nullable MTRAccessGrant *)accessGrantForCASEAuthenticatedTag:(NSNumber *)caseAuthenticatedTag privilege:(MTRAccessControlEntryPrivilege)privilege +{ + auto value = caseAuthenticatedTag.unsignedLongLongValue; + if (!CanCastTo(value)) { + MTR_LOG_ERROR("MTRAccessGrant provided too-large CAT value: 0x%llx", value); + return nil; + } + + CASEAuthTag tag = static_cast(value); + if (!IsValidCASEAuthTag(tag)) { + MTR_LOG_ERROR("MTRAccessGrant provided invalid CAT value: 0x%" PRIx32, tag); + return nil; + } + + return [[MTRAccessGrant alloc] initWithSubject:@(NodeIdFromCASEAuthTag(tag)) privilege:privilege authenticationMode:MTRAccessControlEntryAuthModeCASE]; +} + ++ (nullable MTRAccessGrant *)accessGrantForGroupID:(NSNumber *)groupID privilege:(MTRAccessControlEntryPrivilege)privilege +{ + auto value = groupID.unsignedLongLongValue; + if (!CanCastTo(value)) { + MTR_LOG_ERROR("MTRAccessGrant provided too-large group id: 0x%llx", value); + return nil; + } + + GroupId id = static_cast(value); + if (!IsValidGroupId(id)) { + MTR_LOG_ERROR("MTRAccessGrant provided invalid group id: 0x%" PRIx32, id); + return nil; + } + + return [[MTRAccessGrant alloc] initWithSubject:@(NodeIdFromGroupId(id)) privilege:privilege authenticationMode:MTRAccessControlEntryAuthModeGroup]; +} + ++ (MTRAccessGrant *)accessGrantForAllNodesWithPrivilege:(MTRAccessControlEntryPrivilege)privilege +{ + return [[MTRAccessGrant alloc] initWithSubject:nil privilege:privilege authenticationMode:MTRAccessControlEntryAuthModeCASE]; +} + +// initWithSubject assumes that the subject has already been validated and, if +// needed, copied from the input. +- (nullable instancetype)initWithSubject:(nullable NSNumber *)subject privilege:(MTRAccessControlEntryPrivilege)privilege authenticationMode:(MTRAccessControlEntryAuthMode)authenticationMode +{ + if (!(self = [super init])) { + return nil; + } + + _subjectID = subject; + _grantedPrivilege = privilege; + _authenticationMode = authenticationMode; + return self; +} + +- (id)copyWithZone:(NSZone *)zone +{ + // We have no mutable state. + return self; +} + +- (BOOL)isEqual:(id)object +{ + if ([object class] != [self class]) { + return NO; + } + + MTRAccessGrant * other = object; + + BOOL sameSubjectID = (_subjectID == nil && other.subjectID == nil) || [_subjectID isEqual:other.subjectID]; + return sameSubjectID && _grantedPrivilege == other.grantedPrivilege && _authenticationMode == other.authenticationMode; +} + +- (NSUInteger)hash +{ + return _subjectID.unsignedLongLongValue ^ _grantedPrivilege ^ _authenticationMode; +} + +- (NSString *)description +{ + NSString * privilege = @"Unknown"; + switch (_grantedPrivilege) { + case MTRAccessControlEntryPrivilegeView: + privilege = @"View"; + break; + case MTRAccessControlEntryPrivilegeProxyView: + privilege = @"ProxyView"; + break; + case MTRAccessControlEntryPrivilegeOperate: + privilege = @"Operate"; + break; + case MTRAccessControlEntryPrivilegeManage: + privilege = @"Manage"; + break; + case MTRAccessControlEntryPrivilegeAdminister: + privilege = @"Administer"; + break; + } + + if (_subjectID == nil) { + return [NSString stringWithFormat:@"<%@ all nodes can %@>", self.class, privilege]; + } + + NodeId nodeId = static_cast(_subjectID.unsignedLongLongValue); + if (IsGroupId(nodeId)) { + return [NSString stringWithFormat:@"<%@ group 0x%x can %@>", self.class, GroupIdFromNodeId(nodeId), privilege]; + } + + if (IsCASEAuthTag(nodeId)) { + return [NSString stringWithFormat:@"<%@ nodes with CASE Authenticated Tag 0x%08x can %@>", self.class, CASEAuthTagFromNodeId(nodeId), privilege]; + } + + return [NSString stringWithFormat:@"<%@ node 0x%016llx can %@>", self.class, nodeId, privilege]; +} + +@end diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRDeviceTypeRevision.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRDeviceTypeRevision.h new file mode 100644 index 00000000000000..7f4f88b0cfd643 --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRDeviceTypeRevision.h @@ -0,0 +1,45 @@ +/** + * 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 +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * A representation of a "device type revision" in the sense used in the Matter + * specification. This has an identifier and a version number. + */ +MTR_NEWLY_AVAILABLE +@interface MTRDeviceTypeRevision : NSObject + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +/** + * The provided deviceTypeID must be in the range 0xVVVV0000-0xVVVVBFFF, where + * VVVV is the vendor identifier (0 for standard device types). + * + * The provided deviceTypeRevision must be in the range 1-65535. + */ +- (nullable instancetype)initWithDeviceTypeID:(NSNumber *)deviceTypeID revision:(NSNumber *)revision; + +@property (nonatomic, copy, readonly) NSNumber * deviceTypeID; +@property (nonatomic, copy, readonly) NSNumber * deviceTypeRevision; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRDeviceTypeRevision.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRDeviceTypeRevision.mm new file mode 100644 index 00000000000000..de5782c92e4aeb --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRDeviceTypeRevision.mm @@ -0,0 +1,88 @@ +/** + * 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 "MTRDefines_Internal.h" +#import "MTRLogging_Internal.h" +#import + +#include +#include +#include + +using namespace chip; + +MTR_DIRECT_MEMBERS +@implementation MTRDeviceTypeRevision + +- (nullable instancetype)initWithDeviceTypeID:(NSNumber *)deviceTypeID revision:(NSNumber *)revision +{ + auto deviceTypeIDValue = deviceTypeID.unsignedLongLongValue; + if (!CanCastTo(deviceTypeIDValue)) { + MTR_LOG_ERROR("MTRDeviceTypeRevision provided too-large device type ID: 0x%llx", deviceTypeIDValue); + return nil; + } + + auto id = static_cast(deviceTypeIDValue); + if (!IsValidDeviceTypeId(id)) { + MTR_LOG_ERROR("MTRDeviceTypeRevision provided invalid device type ID: 0x%" PRIx32, id); + return nil; + } + + auto revisionValue = revision.unsignedLongLongValue; + if (!CanCastTo(revisionValue) || revisionValue < 1) { + MTR_LOG_ERROR("MTRDeviceTypeRevision provided invalid device type revision: 0x%llx", revisionValue); + return nil; + } + + return [self initInternalWithDeviceTypeID:[deviceTypeID copy] revision:[revision copy]]; +} + +// initInternalWithDeviceTypeID:revision assumes that the device type ID and device +// revision have already been validated and, if needed, copied from the input. +- (instancetype)initInternalWithDeviceTypeID:(NSNumber *)deviceTypeID revision:(NSNumber *)revision +{ + if (!(self = [super init])) { + return nil; + } + + _deviceTypeID = deviceTypeID; + _deviceTypeRevision = revision; + return self; +} + +- (id)copyWithZone:(NSZone *)zone +{ + // We have no mutable state. + return self; +} + +- (BOOL)isEqual:(id)object +{ + if ([object class] != [self class]) { + return NO; + } + + MTRDeviceTypeRevision * other = object; + + return [_deviceTypeID isEqual:other.deviceTypeID] && [_deviceTypeRevision isEqual:other.deviceTypeRevision]; +} + +- (NSUInteger)hash +{ + return _deviceTypeID.unsignedLongValue ^ _deviceTypeRevision.unsignedShortValue; +} + +@end diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.h new file mode 100644 index 00000000000000..46e95bfb39a7bd --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.h @@ -0,0 +1,63 @@ +/** + * 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 +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * A representation of an attribute implemented on a server cluster by an + * MTRDeviceController. An attribute has an identifier and a value, and may or + * may not be writable. + */ +MTR_NEWLY_AVAILABLE +@interface MTRServerAttribute : NSObject + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +/** + * Initialize as a readonly attribute. The value is a data-value as documented + * in MTRBaseDevice.h. + * + * Will fail if the attribute ID is not valid per the Matter specification or + * the attribute value is not a valid data-value. + * + * requiredPrivilege is the privilege required to read the attribute. + */ +- (nullable instancetype)initReadonlyAttributeWithID:(NSNumber *)attributeID initialValue:(NSDictionary *)value requiredPrivilege:(MTRAccessControlEntryPrivilege)requiredPrivilege; + +/** + * Change the value of the attribute to a new value. The value is a data-value as documented + * in MTRBaseDevice.h. + * + * Will fail if the attribute is not a valid data-value. + */ +- (BOOL)setValue:(NSDictionary *)value; + +@property (nonatomic, copy, readonly) NSNumber * attributeID; +@property (nonatomic, copy, readonly) NSDictionary * value; +/** + * The privilege level necessary to read this attribute. + */ +@property (nonatomic, assign, readonly) MTRAccessControlEntryPrivilege requiredReadPrivilege; +@property (nonatomic, assign, readonly, getter=isWritable) BOOL writable; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.mm new file mode 100644 index 00000000000000..0337d555d02f2a --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.mm @@ -0,0 +1,158 @@ +/** + * 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 "MTRBaseDevice_Internal.h" +#import "MTRDefines_Internal.h" +#import "MTRDeviceController_Internal.h" +#import "MTRLogging_Internal.h" +#import "MTRServerAttribute_Internal.h" +#import "MTRServerEndpoint_Internal.h" +#import "NSDataSpanConversion.h" +#import + +#include +#include +#include +#include + +using namespace chip; + +MTR_DIRECT_MEMBERS +@implementation MTRServerAttribute { + MTRDeviceController * __weak _deviceController; +} + +- (nullable instancetype)initAttributeWithID:(NSNumber *)attributeID initialValue:(NSDictionary *)value requiredReadPrivilege:(MTRAccessControlEntryPrivilege)requiredReadPrivilege writable:(BOOL)writable +{ + auto attrIDValue = attributeID.unsignedLongLongValue; + if (!CanCastTo(attrIDValue)) { + MTR_LOG_ERROR("MTRServerAttribute provided too-large attribute ID: 0x%llx", attrIDValue); + return nil; + } + + auto attrId = static_cast(attrIDValue); + if (!IsValidAttributeId(attrId)) { + MTR_LOG_ERROR("MTRServerAttribute provided invalid attribute ID: 0x%" PRIx32, attrId); + return nil; + } + + return [self initWithAttributeID:[attributeID copy] value:[value copy] requiredReadPrivilege:requiredReadPrivilege writable:writable]; +} + +- (nullable instancetype)initReadonlyAttributeWithID:(NSNumber *)attributeID initialValue:(NSDictionary *)value requiredPrivilege:(MTRAccessControlEntryPrivilege)requiredPrivilege +{ + return [self initAttributeWithID:attributeID initialValue:value requiredReadPrivilege:requiredPrivilege writable:NO]; +} + +// initWithAttributeID:value:serializedValue:requiredReadPrivilege:writable: +// assumes that the attribute ID, value, serializedValue, have already been +// validated and, if needed, copied from the input. +- (nullable instancetype)initWithAttributeID:(NSNumber *)attributeID value:(NSDictionary *)value requiredReadPrivilege:(MTRAccessControlEntryPrivilege)requiredReadPrivilege writable:(BOOL)writable +{ + if (!(self = [super init])) { + return nil; + } + + _attributeID = attributeID; + _requiredReadPrivilege = requiredReadPrivilege; + _writable = writable; + _parentCluster = app::ConcreteClusterPath(kInvalidEndpointId, kInvalidClusterId); + + // Now call setValue to store the value and its serialization. + if ([self setValue:value] == NO) { + return nil; + } + + return self; +} + +- (BOOL)setValue:(NSDictionary *)value +{ + id serializedValue; + id dataType = value[MTRTypeKey]; + if ([MTRArrayValueType isEqual:dataType]) { + id dataValue = value[MTRValueKey]; + if (![dataValue isKindOfClass:NSArray.class]) { + MTR_LOG_ERROR("MTRServerAttribute value claims to be a list but isn't: %@", value); + return NO; + } + NSArray * dataValueList = dataValue; + auto * listValue = [NSMutableArray arrayWithCapacity:dataValueList.count]; + if (listValue == nil) { + return NO; + } + for (id item in dataValueList) { + NSError * encodingError; + NSData * encodedItem = MTREncodeTLVFromDataValueDictionary(item, &encodingError); + if (encodedItem == nil) { + return NO; + } + [listValue addObject:encodedItem]; + } + serializedValue = listValue; + } else { + NSError * encodingError; + serializedValue = MTREncodeTLVFromDataValueDictionary(value, &encodingError); + if (serializedValue == nil) { + return NO; + } + } + + // We serialized properly, so should be good to go on the value. + _value = [value copy]; + + MTRDeviceController * deviceController = _deviceController; + if (deviceController == nil) { + // We're not bound to a controller, so safe to directly update _serializedValue. + _serializedValue = serializedValue; + } else { + [deviceController asyncDispatchToMatterQueue:^{ + auto changed = ![self->_serializedValue isEqual:serializedValue]; + self->_serializedValue = serializedValue; + if (changed) { + MatterReportingAttributeChangeCallback(self->_parentCluster.mEndpointId, self->_parentCluster.mClusterId, static_cast(self->_attributeID.unsignedLongLongValue)); + } + } + errorHandler:nil]; + } + + return YES; +} + +- (BOOL)associateWithController:(MTRDeviceController *)controller +{ + MTRDeviceController * existingController = _deviceController; + if (existingController != nil) { +#if MTR_PER_CONTROLLER_STORAGE_ENABLED + MTR_LOG_ERROR("Cannot associate MTRServerAttribute with controller %@; already associated with controller %@", + controller.uniqueIdentifier, existingController.uniqueIdentifier); +#else + MTR_LOG_ERROR("Cannot associate MTRServerAttribute with controller; already associated with a different controller"); +#endif + return NO; + } + + _deviceController = controller; + + return YES; +} + +- (void)invalidate +{ + _deviceController = nil; +} + +@end diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute_Internal.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute_Internal.h new file mode 100644 index 00000000000000..dbc7cebb857a88 --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute_Internal.h @@ -0,0 +1,48 @@ +/** + * 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 + +#import +#import + +#include + +@interface MTRServerAttribute () + +/** + * Mark this attribute as associated with a particular controller. + */ +- (BOOL)associateWithController:(MTRDeviceController *)controller; + +/** + * Mark this attribute as part of an Defunct-state endpoint. + */ +- (void)invalidate; + +/** + * serializedValue is either an NSData or an NSArray, depending on + * whether the attribute is list-typed. + */ +@property (nonatomic, strong, readonly) id serializedValue; + +/** + * parentCluster will have kInvalidClusterId for the cluster ID until the + * attribute is added to a cluster. + */ +@property (nonatomic, assign) chip::app::ConcreteClusterPath parentCluster; + +@end diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.h new file mode 100644 index 00000000000000..48604dd2a76797 --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.h @@ -0,0 +1,111 @@ +/** + * 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 +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * A representation of a server cluster implemented by an MTRDeviceController. + */ +MTR_NEWLY_AVAILABLE +@interface MTRServerCluster : NSObject + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +/** + * The provided clusterID must not be MTRClusterIDTypeDescriptorID; see + * newDescriptorCluster. + * + * Otherwise, it must be a valid cluster identifier. That means: + * + * * In the range 0-0x7FFF for standard clusters. + * * In the range 0xVVVVFC00-0xVVVVFFFE for vendor-specific clusters, where VVVV + * is the vendor identifier. + * + * The provided revision must be in the range 1-65535. + * + */ +- (nullable instancetype)initWithClusterID:(NSNumber *)clusterID revision:(NSNumber *)revision; + +/** + * Add an access grant to the cluster. If the same access grant is added + * multiple times, it will be treated as if it were added once (and removing + * it once will remove it). + */ +- (void)addAccessGrant:(MTRAccessGrant *)accessGrant; + +/** + * Remove an access grant from the cluster. + */ +- (void)removeAccessGrant:(MTRAccessGrant *)accessGrant; + +/** + * Add an attribute to the cluster. This can only be done before the endpoint + * the cluster is a part of has been added to a controller. + * + * The attribute must not have the same attribute ID as another attribute in + * this cluster. + * + * The attribute must not already be added to another cluster. + * + * If this cluster is the Descriptor cluster (id MTRClusterIDTypeDescriptorID), + * it must not define any values for DeviceTypeList, ServerList, ClientList, PartsList; + * those values will be determined automatically. + * + * For all clusters, the global AttributeList, AcceptedCommandList, + * GeneratedCommandList attributes will be determined automatically and must not + * be included in the attributes added on the cluster. + * + * For all clusters, the FeatureMap attribute will be assumed to be 0 unless + * otherwise specified and may be omitted from the attributes added to the cluster. + * + * For all clusters, ClusterRevision will be determined automatically based on + * this object's clusterRevision property, and must not be explicitly added to + * the cluster. + */ +- (BOOL)addAttribute:(MTRServerAttribute *)attribute; + +/** + * Create a cluster description for the descriptor cluster. This will set + * clusterRevision to the current version implemented by Matter.framework. + */ ++ (MTRServerCluster *)newDescriptorCluster; + +@property (nonatomic, copy, readonly) NSNumber * clusterID; + +@property (nonatomic, copy, readonly) NSNumber * clusterRevision; + +/** + * The list of entities that are allowed to access this cluster instance. This + * list is in addition to any endpoint-wide access grants that exist. + * + * Defaults to empty list, which means no additional access grants. + */ +@property (nonatomic, copy, readonly) NSArray * accessGrants; + +/** + * The list of attributes supported by the cluster. + */ +@property (nonatomic, copy, readonly) NSArray * attributes; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm new file mode 100644 index 00000000000000..8af4ca975ffb3d --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm @@ -0,0 +1,228 @@ +/** + * 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 "MTRDefines_Internal.h" +#import "MTRDeviceController_Internal.h" +#import "MTRLogging_Internal.h" +#import "MTRServerAttribute_Internal.h" +#import "MTRServerCluster_Internal.h" +#import "MTRServerEndpoint_Internal.h" +#import +#import + +#include +#include +#include +#include + +using namespace chip; + +MTR_DIRECT_MEMBERS +@implementation MTRServerCluster { + /** + * The access grants our API consumer can manipulate directly. Never + * touched on the Matter queue. + */ + NSMutableSet * _accessGrants; + NSMutableArray * _attributes; + MTRDeviceController * __weak _deviceController; +} + +- (nullable instancetype)initWithClusterID:(NSNumber *)clusterID revision:(NSNumber *)revision +{ + auto clusterIDValue = clusterID.unsignedLongLongValue; + if (!CanCastTo(clusterIDValue)) { + MTR_LOG_ERROR("MTRServerCluster provided too-large cluster ID: 0x%llx", clusterIDValue); + return nil; + } + + auto id = static_cast(clusterIDValue); + if (!IsValidClusterId(id)) { + MTR_LOG_ERROR("MTRServerCluster provided invalid cluster ID: 0x%" PRIx32, id); + return nil; + } + + if (id == MTRClusterIDTypeDescriptorID) { + MTR_LOG_ERROR("Should be using newDescriptorCluster to initialize an MTRServerCluster for Descriptor"); + return nil; + } + + auto revisionValue = revision.unsignedLongLongValue; + if (revisionValue < 1 || revisionValue > 0xFFFF) { + MTR_LOG_ERROR("MTRServerCluster provided invalid cluster revision: 0x%llx", revisionValue); + return nil; + } + + return [self initInternalWithClusterID:clusterID revision:revision accessGrants:[NSSet set] attributes:@[]]; +} + ++ (MTRServerCluster *)newDescriptorCluster +{ + return [[MTRServerCluster alloc] initInternalWithClusterID:@(MTRClusterIDTypeDescriptorID) revision:@(app::Clusters::Descriptor::kClusterRevision) accessGrants:[NSSet set] attributes:@[]]; +} + +- (instancetype)initInternalWithClusterID:(NSNumber *)clusterID revision:(NSNumber *)revision accessGrants:(NSSet *)accessGrants attributes:(NSArray *)attributes +{ + if (!(self = [super init])) { + return nil; + } + + _clusterID = [clusterID copy]; + _clusterRevision = [revision copy]; + _accessGrants = [[NSMutableSet alloc] init]; + _attributes = [[NSMutableArray alloc] init]; + _matterAccessGrants = [NSSet set]; + _parentEndpoint = kInvalidEndpointId; + + for (MTRAccessGrant * grant in accessGrants) { + // Since our state is MTRServerEndpointStateInitializing, we know this + // will succeed. + [self addAccessGrant:grant]; + } + + for (MTRServerAttribute * attr in attributes) { + // Since our state is MTRServerEndpointStateInitializing and the initial + // attribute array was valid, we know this will succeed. + [self addAttribute:attr]; + } + + return self; +} + +- (void)updateMatterAccessGrants +{ + MTRDeviceController * deviceController = _deviceController; + if (deviceController == nil) { + // _matterAccessGrants will be updated when we get bound to a controller. + return; + } + + NSSet * grants = [_accessGrants copy]; + [deviceController asyncDispatchToMatterQueue:^{ + self->_matterAccessGrants = grants; + } + errorHandler:nil]; +} + +- (void)addAccessGrant:(MTRAccessGrant *)accessGrant +{ + [_accessGrants addObject:accessGrant]; + + [self updateMatterAccessGrants]; +} + +- (void)removeAccessGrant:(MTRAccessGrant *)accessGrant; +{ + [_accessGrants removeObject:accessGrant]; + + [self updateMatterAccessGrants]; +} + +- (BOOL)addAttribute:(MTRServerAttribute *)attribute +{ + MTRDeviceController * deviceController = _deviceController; + if (deviceController != nil) { + MTR_LOG_ERROR("Cannot add attribute on cluster %llx which is already in use", _clusterID.unsignedLongLongValue); + return NO; + } + + if (attribute.parentCluster.mClusterId != kInvalidClusterId) { + MTR_LOG_ERROR("Cannot add attribute to cluster %llu; already added to cluster %" PRIu32, _clusterID.unsignedLongLongValue, attribute.parentCluster.mClusterId); + return NO; + } + + auto attributeID = attribute.attributeID.unsignedLongLongValue; + if (attributeID == MTRAttributeIDTypeGlobalAttributeAttributeListID || attributeID == MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID || attributeID == MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID || attributeID == MTRAttributeIDTypeGlobalAttributeClusterRevisionID) { + MTR_LOG_ERROR("Cannot add global attribute %llx on cluster %llx", attributeID, _clusterID.unsignedLongLongValue); + return NO; + } + + if ([_clusterID isEqual:@(MTRClusterIDTypeDescriptorID)]) { + if (attributeID == MTRAttributeIDTypeClusterDescriptorAttributeDeviceTypeListID || attributeID == MTRAttributeIDTypeClusterDescriptorAttributeServerListID || attributeID == MTRAttributeIDTypeClusterDescriptorAttributeClientListID || attributeID == MTRAttributeIDTypeClusterDescriptorAttributePartsListID) { + MTR_LOG_ERROR("Cannot add attribute with id %llx on descriptor cluster", attributeID); + return NO; + } + } + + for (MTRServerAttribute * existingAttr in _attributes) { + if (existingAttr.attributeID.unsignedLongLongValue == attributeID) { + MTR_LOG_ERROR("Cannot add second attribute with ID %llx on cluster %llx", attributeID, _clusterID.unsignedLongLongValue); + return NO; + } + } + + [_attributes addObject:attribute]; + attribute.parentCluster = app::ConcreteClusterPath(_parentEndpoint, static_cast(_clusterID.unsignedLongLongValue)); + return YES; +} + +- (BOOL)associateWithController:(MTRDeviceController *)controller +{ + MTRDeviceController * existingController = _deviceController; + if (existingController != nil) { +#if MTR_PER_CONTROLLER_STORAGE_ENABLED + MTR_LOG_ERROR("Cannot associate MTRServerCluster with controller %@; already associated with controller %@", + controller.uniqueIdentifier, existingController.uniqueIdentifier); +#else + MTR_LOG_ERROR("Cannot associate MTRServerCluster with controller; already associated with a different controller"); +#endif + return NO; + } + + for (MTRServerAttribute * attr in _attributes) { + if (![attr associateWithController:controller]) { + return NO; + } + } + + // Snapshot _matterAccessGrants now; after this point it will only be + // updated on the Matter queue. + _matterAccessGrants = [_accessGrants copy]; + _deviceController = controller; + + return YES; +} + +- (void)invalidate +{ + for (MTRServerAttribute * attr in _attributes) { + [attr invalidate]; + } + + _deviceController = nil; +} + +- (NSArray *)accessGrants +{ + return [_accessGrants allObjects]; +} + +- (NSArray *)attributes +{ + return [_attributes copy]; +} + +- (void)setParentEndpoint:(EndpointId)endpoint +{ + _parentEndpoint = 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)); + } +} + +@end diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster_Internal.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster_Internal.h new file mode 100644 index 00000000000000..5bd9ba0692ed4a --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster_Internal.h @@ -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 + +#import +#import + +#include + +@interface MTRServerCluster () + +/** + * Mark this cluster as associated with a particular controller. + */ +- (BOOL)associateWithController:(MTRDeviceController *)controller; + +/** + * Mark this cluster as part of an Defunct-state endpoint. + */ +- (void)invalidate; + +/** + * The access grants the Matter stack can observe. Only modified while in + * Initializing state or on the Matter queue. + */ +@property (nonatomic, strong, readonly) NSSet * matterAccessGrants; + +/** + * parentEndpoint will be kInvalidEndpointId until the cluster is added to an endpoint. + */ +@property (nonatomic, assign) chip::EndpointId parentEndpoint; + +@end diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.h new file mode 100644 index 00000000000000..642dc5fb4ec658 --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.h @@ -0,0 +1,87 @@ +/** + * 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 +#import +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * A representation of an endpoint implemented by an MTRDeviceController. + */ +MTR_NEWLY_AVAILABLE +@interface MTRServerEndpoint : NSObject + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +/** + * The provided endpointID must be in the range 1-65535. The list of device + * types provided must be nonempty (but may include vendor-specific device + * types). + */ +- (nullable instancetype)initWithEndpointID:(NSNumber *)endpointID deviceTypes:(NSArray *)deviceTypes; + +/** + * Add an access grant to the endpoint. If the same access grant is added + * multiple times, it will be treated as if it were added once (and removing + * it once will remove it). + */ +- (void)addAccessGrant:(MTRAccessGrant *)accessGrant; + +/** + * Remove an access grant from the endpoint. + */ +- (void)removeAccessGrant:(MTRAccessGrant *)accessGrant; + +/** + * Add a server cluster to the endpoint. This can only be done before the + * endpoint has been added to a controller. + * + * The cluster must not have the same cluster ID as another cluster on + * this endpoint. + * + * The cluster must not already be added to another endpoint. + */ +- (BOOL)addServerCluster:(MTRServerCluster *)serverCluster; + +@property (nonatomic, copy, readonly) NSNumber * endpointID; + +@property (nonatomic, copy, readonly) NSArray * deviceTypes; + +/** + * The list of entities that are allowed to access all clusters on this + * endpoint. If more fine-grained access control is desired, access grants + * should be defined on individual clusters. + * + * Defaults to empty list, which means no access granted. + */ +@property (nonatomic, copy, readonly) NSArray * accessGrants; + +/** + * 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. + */ +@property (nonatomic, copy, readonly) NSArray * serverClusters; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.mm new file mode 100644 index 00000000000000..ee35e4da0bc0db --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.mm @@ -0,0 +1,197 @@ +/** + * 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 "MTRDefines_Internal.h" +#import "MTRDeviceController_Internal.h" +#import "MTRLogging_Internal.h" +#import "MTRServerCluster_Internal.h" +#import "MTRServerEndpoint_Internal.h" +#import + +#include +#include +#include + +using namespace chip; + +MTR_DIRECT_MEMBERS +@implementation MTRServerEndpoint { + /** + * The access grants our API consumer can manipulate directly. Never + * touched on the Matter queue. + */ + NSMutableSet * _accessGrants; + NSMutableArray * _serverClusters; + MTRDeviceController * __weak _deviceController; +} + +- (nullable instancetype)initWithEndpointID:(NSNumber *)endpointID deviceTypes:(NSArray *)deviceTypes +{ + auto endpointIDValue = endpointID.unsignedLongLongValue; + if (!CanCastTo(endpointIDValue)) { + MTR_LOG_ERROR("MTRServerEndpoint provided too-large endpoint ID: 0x%llx", endpointIDValue); + return nil; + } + + auto id = static_cast(endpointIDValue); + if (!IsValidEndpointId(id)) { + MTR_LOG_ERROR("MTRServerEndpoint provided invalid endpoint ID: 0x%x", id); + return nil; + } + + if (id == kRootEndpointId) { + // We don't allow this; we use that endpoint for our own purposes in + // Matter.framework. + MTR_LOG_ERROR("MTRServerEndpoint provided invalid endpoint ID: 0x%x", id); + return nil; + } + + if (deviceTypes.count == 0) { + MTR_LOG_ERROR("MTRServerEndpoint needs a non-empty list of device types"); + return nil; + } + + return [self initInternalWithEndpointID:endpointID deviceTypes:deviceTypes accessGrants:[NSSet set] clusters:@[]]; +} + +- (instancetype)initInternalWithEndpointID:(NSNumber *)endpointID deviceTypes:(NSArray *)deviceTypes accessGrants:(NSSet *)accessGrants clusters:(NSArray *)clusters +{ + if (!(self = [super init])) { + return nil; + } + + _endpointID = [endpointID copy]; + _deviceTypes = [deviceTypes copy]; + _accessGrants = [[NSMutableSet alloc] init]; + _serverClusters = [[NSMutableArray alloc] init]; + _matterAccessGrants = [NSSet set]; + + for (MTRAccessGrant * grant in accessGrants) { + // Since our state is MTRServerEndpointStateInitializing, we know this + // will succeed. + [self addAccessGrant:[grant copy]]; + } + + for (MTRServerCluster * cluster in clusters) { + // Since our state is MTRServerEndpointStateInitializing and the initial + // cluster array was valid, we know this will succeed. + [self addServerCluster:[cluster copy]]; + } + + return self; +} + +- (void)updateMatterAccessGrants +{ + MTRDeviceController * deviceController = _deviceController; + if (deviceController == nil) { + // _matterAccessGrants will be updated when we get bound to a controller. + return; + } + + NSSet * grants = [_accessGrants copy]; + [deviceController asyncDispatchToMatterQueue:^{ + self->_matterAccessGrants = grants; + } + errorHandler:nil]; +} + +- (void)addAccessGrant:(MTRAccessGrant *)accessGrant +{ + [_accessGrants addObject:accessGrant]; + + [self updateMatterAccessGrants]; +} + +- (void)removeAccessGrant:(MTRAccessGrant *)accessGrant; +{ + [_accessGrants removeObject:accessGrant]; + + [self updateMatterAccessGrants]; +} + +- (BOOL)addServerCluster:(MTRServerCluster *)serverCluster +{ + MTRDeviceController * deviceController = _deviceController; + if (deviceController != nil) { + MTR_LOG_ERROR("Cannot add cluster on endpoint %llu which is already in use", _endpointID.unsignedLongLongValue); + return NO; + } + + if (serverCluster.parentEndpoint != kInvalidEndpointId) { + MTR_LOG_ERROR("Cannot add cluster to endpoint %llu; already added to endpoint %" PRIu32, _endpointID.unsignedLongLongValue, serverCluster.parentEndpoint); + return NO; + } + + for (MTRServerCluster * existingCluster in _serverClusters) { + if ([existingCluster.clusterID isEqual:serverCluster.clusterID]) { + MTR_LOG_ERROR("Cannot add second cluster with ID %llx on endpoint %llu", serverCluster.clusterID.unsignedLongLongValue, _endpointID.unsignedLongLongValue); + return NO; + } + } + + [_serverClusters addObject:serverCluster]; + serverCluster.parentEndpoint = static_cast(_endpointID.unsignedLongLongValue); + return YES; +} + +- (BOOL)associateWithController:(MTRDeviceController *)controller +{ + MTRDeviceController * existingController = _deviceController; + if (existingController != nil) { +#if MTR_PER_CONTROLLER_STORAGE_ENABLED + MTR_LOG_ERROR("Cannot associate MTRServerEndpoint with controller %@; already associated with controller %@", + controller.uniqueIdentifier, existingController.uniqueIdentifier); +#else + MTR_LOG_ERROR("Cannot associate MTRServerEndpoint with controller; already associated with a different controller"); +#endif + return NO; + } + + for (MTRServerCluster * cluster in _serverClusters) { + if (![cluster associateWithController:controller]) { + return NO; + } + } + + // Snapshot _matterAccessGrants now; after this point it will only be + // updated on the Matter queue. + _matterAccessGrants = [_accessGrants copy]; + _deviceController = controller; + + return YES; +} + +- (void)invalidate +{ + for (MTRServerCluster * cluster in _serverClusters) { + [cluster invalidate]; + } + + _deviceController = nil; +} + +- (NSArray *)accessGrants +{ + return [_accessGrants allObjects]; +} + +- (NSArray *)serverClusters +{ + return [_serverClusters copy]; +} + +@end diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint_Internal.h b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint_Internal.h new file mode 100644 index 00000000000000..97725c2b1afad5 --- /dev/null +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint_Internal.h @@ -0,0 +1,39 @@ +/** + * 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 +#import +#import + +@interface MTRServerEndpoint () + +/** + * Mark this endpoint as associated with a particular controller. + */ +- (BOOL)associateWithController:(MTRDeviceController *)controller; + +/** + * Mark this endpoint as being in a Defunct state. + */ +- (void)invalidate; + +/** + * The access grants the Matter stack can observe. Only modified while in + * Initializing state or on the Matter queue. + */ +@property (nonatomic, strong, readonly) NSSet * matterAccessGrants; + +@end 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/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/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index 526df9ba2f07c8..ae5942f5a4fdc3 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -8548,6 +8548,7 @@ # Targeting Spring 2024 Matter release - EnergyEVSEMode - DeviceEnergyManagementMode + - Messages attributes: DoorLock: # Aliro is not ready yet. @@ -8661,3 +8662,13 @@ - Setpoints - Presets - MatterScheduleConfiguration + RVCRunMode: + Feature: + # Not really part of the spec, need to think about whether to + # expose this. + - NoFeatures + RVCCleanMode: + Feature: + # Not really part of the spec, need to think about whether to + # expose this. + - NoFeatures diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm index 3685e445500fd0..41aa2e3d322825 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm @@ -2199,9 +2199,6 @@ static BOOL AttributeIsSpecifiedInRVCRunModeCluster(AttributeId aAttributeId) case Attributes::CurrentMode::Id: { return YES; } - case Attributes::OnMode::Id: { - return YES; - } case Attributes::GeneratedCommandList::Id: { return YES; } @@ -2235,9 +2232,6 @@ static BOOL AttributeIsSpecifiedInRVCCleanModeCluster(AttributeId aAttributeId) case Attributes::CurrentMode::Id: { return YES; } - case Attributes::OnMode::Id: { - return YES; - } case Attributes::GeneratedCommandList::Id: { return YES; } @@ -2930,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; @@ -2949,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; } @@ -6585,6 +6666,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); } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index 75ec47f5e9587e..4d4f21bc96dd3d 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -5999,21 +5999,6 @@ static id _Nullable DecodeAttributeValueForRVCRunModeCluster(AttributeId aAttrib value = [NSNumber numberWithUnsignedChar:cppValue]; return value; } - case Attributes::OnMode::Id: { - using TypeInfo = Attributes::OnMode::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 numberWithUnsignedChar:cppValue.Value()]; - } - return value; - } default: { break; } @@ -6092,21 +6077,6 @@ static id _Nullable DecodeAttributeValueForRVCCleanModeCluster(AttributeId aAttr value = [NSNumber numberWithUnsignedChar:cppValue]; return value; } - case Attributes::OnMode::Id: { - using TypeInfo = Attributes::OnMode::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 numberWithUnsignedChar:cppValue.Value()]; - } - return value; - } default: { break; } @@ -7661,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; @@ -7872,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; } @@ -18955,6 +19424,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); } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index c0c29601f3e00a..fb16dbe03a412c 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -5424,14 +5424,6 @@ MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); + (void)readAttributeCurrentModeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); -- (void)readAttributeOnModeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; -- (void)writeAttributeOnModeWithValue:(NSNumber * _Nullable)value completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; -- (void)writeAttributeOnModeWithValue:(NSNumber * _Nullable)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; -- (void)subscribeAttributeOnModeWithParams:(MTRSubscribeParams *)params - subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished - reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; -+ (void)readAttributeOnModeWithClusterStateCache:(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_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); - (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished @@ -5513,14 +5505,6 @@ MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); + (void)readAttributeCurrentModeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); -- (void)readAttributeOnModeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; -- (void)writeAttributeOnModeWithValue:(NSNumber * _Nullable)value completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; -- (void)writeAttributeOnModeWithValue:(NSNumber * _Nullable)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; -- (void)subscribeAttributeOnModeWithParams:(MTRSubscribeParams *)params - subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished - reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; -+ (void)readAttributeOnModeWithClusterStateCache:(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_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); - (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished @@ -6520,22 +6504,6 @@ MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) - (void)pauseWithParams:(MTRRVCOperationalStateClusterPauseParams * _Nullable)params completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); - (void)pauseWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); -/** - * Command Stop - * - * Upon receipt, the device SHALL stop its operation if it is at a position where it is safe to do so and/or permitted. - */ -- (void)stopWithParams:(MTRRVCOperationalStateClusterStopParams * _Nullable)params completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; -- (void)stopWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion - MTR_PROVISIONALLY_AVAILABLE; -/** - * Command Start - * - * Upon receipt, the device SHALL start its operation if it is safe to do so and the device is in an operational state from which it can be started. - */ -- (void)startWithParams:(MTRRVCOperationalStateClusterStartParams * _Nullable)params completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; -- (void)startWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion - MTR_PROVISIONALLY_AVAILABLE; /** * Command Resume * @@ -7258,6 +7226,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 * @@ -7296,6 +7439,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 @@ -17251,7 +17400,7 @@ typedef NS_ENUM(uint8_t, MTRRVCRunModeStatusCode) { } MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); typedef NS_OPTIONS(uint32_t, MTRRVCRunModeFeature) { - MTRRVCRunModeFeatureOnOff MTR_PROVISIONALLY_AVAILABLE = 0x1, + MTRRVCRunModeFeatureNoFeatures MTR_PROVISIONALLY_AVAILABLE = 0x0, } MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); typedef NS_ENUM(uint16_t, MTRRVCCleanModeModeTag) { @@ -17265,7 +17414,7 @@ typedef NS_ENUM(uint8_t, MTRRVCCleanModeStatusCode) { } MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); typedef NS_OPTIONS(uint32_t, MTRRVCCleanModeFeature) { - MTRRVCCleanModeFeatureOnOff MTR_PROVISIONALLY_AVAILABLE = 0x1, + MTRRVCCleanModeFeatureNoFeatures MTR_PROVISIONALLY_AVAILABLE = 0x0, } MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); typedef NS_OPTIONS(uint32_t, MTRTemperatureControlFeature) { @@ -17508,6 +17657,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, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index 0df20ec55b9d5a..9900b52d1c311f 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 @@ -41733,75 +41733,6 @@ + (void)readAttributeCurrentModeWithClusterStateCache:(MTRClusterStateCacheConta completion:completion]; } -- (void)readAttributeOnModeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion -{ - using TypeInfo = RvcRunMode::Attributes::OnMode::TypeInfo; - [self.device _readKnownAttributeWithEndpointID:self.endpointID - clusterID:@(TypeInfo::GetClusterId()) - attributeID:@(TypeInfo::GetAttributeId()) - params:nil - queue:self.callbackQueue - completion:completion]; -} - -- (void)writeAttributeOnModeWithValue:(NSNumber * _Nullable)value completion:(MTRStatusCompletion)completion -{ - [self writeAttributeOnModeWithValue:(NSNumber * _Nullable) value params:nil completion:completion]; -} -- (void)writeAttributeOnModeWithValue:(NSNumber * _Nullable)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion -{ - // Make a copy of params before we go async. - params = [params copy]; - value = [value copy]; - - auto * bridge = new MTRDefaultSuccessCallbackBridge(self.callbackQueue, ^(id _Nullable ignored, NSError * _Nullable error) { completion(error); }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DefaultSuccessCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { - chip::Optional timedWriteTimeout; - if (params != nil) { - if (params.timedWriteTimeout != nil){ - timedWriteTimeout.SetValue(params.timedWriteTimeout.unsignedShortValue); - } - } - - ListFreer listFreer; - using TypeInfo = RvcRunMode::Attributes::OnMode::TypeInfo; - TypeInfo::Type cppValue; - if (value == nil) { - cppValue.SetNull(); - } else { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = value.unsignedCharValue; - } - - chip::Controller::ClusterBase cppCluster(exchangeManager, session, self.endpointID.unsignedShortValue); - return cppCluster.WriteAttribute(cppValue, bridge, successCb, failureCb, timedWriteTimeout); }); - std::move(*bridge).DispatchAction(self.device); -} - -- (void)subscribeAttributeOnModeWithParams:(MTRSubscribeParams * _Nonnull)params - subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished - reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler -{ - using TypeInfo = RvcRunMode::Attributes::OnMode::TypeInfo; - [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID - clusterID:@(TypeInfo::GetClusterId()) - attributeID:@(TypeInfo::GetAttributeId()) - params:params - queue:self.callbackQueue - reportHandler:reportHandler - subscriptionEstablished:subscriptionEstablished]; -} - -+ (void)readAttributeOnModeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion -{ - using TypeInfo = RvcRunMode::Attributes::OnMode::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 = RvcRunMode::Attributes::GeneratedCommandList::TypeInfo; @@ -42119,75 +42050,6 @@ + (void)readAttributeCurrentModeWithClusterStateCache:(MTRClusterStateCacheConta completion:completion]; } -- (void)readAttributeOnModeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion -{ - using TypeInfo = RvcCleanMode::Attributes::OnMode::TypeInfo; - [self.device _readKnownAttributeWithEndpointID:self.endpointID - clusterID:@(TypeInfo::GetClusterId()) - attributeID:@(TypeInfo::GetAttributeId()) - params:nil - queue:self.callbackQueue - completion:completion]; -} - -- (void)writeAttributeOnModeWithValue:(NSNumber * _Nullable)value completion:(MTRStatusCompletion)completion -{ - [self writeAttributeOnModeWithValue:(NSNumber * _Nullable) value params:nil completion:completion]; -} -- (void)writeAttributeOnModeWithValue:(NSNumber * _Nullable)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion -{ - // Make a copy of params before we go async. - params = [params copy]; - value = [value copy]; - - auto * bridge = new MTRDefaultSuccessCallbackBridge(self.callbackQueue, ^(id _Nullable ignored, NSError * _Nullable error) { completion(error); }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DefaultSuccessCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { - chip::Optional timedWriteTimeout; - if (params != nil) { - if (params.timedWriteTimeout != nil){ - timedWriteTimeout.SetValue(params.timedWriteTimeout.unsignedShortValue); - } - } - - ListFreer listFreer; - using TypeInfo = RvcCleanMode::Attributes::OnMode::TypeInfo; - TypeInfo::Type cppValue; - if (value == nil) { - cppValue.SetNull(); - } else { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = value.unsignedCharValue; - } - - chip::Controller::ClusterBase cppCluster(exchangeManager, session, self.endpointID.unsignedShortValue); - return cppCluster.WriteAttribute(cppValue, bridge, successCb, failureCb, timedWriteTimeout); }); - std::move(*bridge).DispatchAction(self.device); -} - -- (void)subscribeAttributeOnModeWithParams:(MTRSubscribeParams * _Nonnull)params - subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished - reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler -{ - using TypeInfo = RvcCleanMode::Attributes::OnMode::TypeInfo; - [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID - clusterID:@(TypeInfo::GetClusterId()) - attributeID:@(TypeInfo::GetAttributeId()) - params:params - queue:self.callbackQueue - reportHandler:reportHandler - subscriptionEstablished:subscriptionEstablished]; -} - -+ (void)readAttributeOnModeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion -{ - using TypeInfo = RvcCleanMode::Attributes::OnMode::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 = RvcCleanMode::Attributes::GeneratedCommandList::TypeInfo; @@ -46536,62 +46398,6 @@ - (void)pauseWithParams:(MTRRVCOperationalStateClusterPauseParams * _Nullable)pa queue:self.callbackQueue completion:responseHandler]; } -- (void)stopWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion -{ - [self stopWithParams:nil completion:completion]; -} -- (void)stopWithParams:(MTRRVCOperationalStateClusterStopParams * _Nullable)params completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion -{ - if (params == nil) { - params = [[MTRRVCOperationalStateClusterStopParams - alloc] init]; - } - - auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { - completion(response, error); - }; - - auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; - - using RequestType = RvcOperationalState::Commands::Stop::Type; - [self.device _invokeKnownCommandWithEndpointID:self.endpointID - clusterID:@(RequestType::GetClusterId()) - commandID:@(RequestType::GetCommandId()) - commandPayload:params - timedInvokeTimeout:timedInvokeTimeoutMs - serverSideProcessingTimeout:params.serverSideProcessingTimeout - responseClass:MTRRVCOperationalStateClusterOperationalCommandResponseParams.class - queue:self.callbackQueue - completion:responseHandler]; -} -- (void)startWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion -{ - [self startWithParams:nil completion:completion]; -} -- (void)startWithParams:(MTRRVCOperationalStateClusterStartParams * _Nullable)params completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion -{ - if (params == nil) { - params = [[MTRRVCOperationalStateClusterStartParams - alloc] init]; - } - - auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { - completion(response, error); - }; - - auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; - - using RequestType = RvcOperationalState::Commands::Start::Type; - [self.device _invokeKnownCommandWithEndpointID:self.endpointID - clusterID:@(RequestType::GetClusterId()) - commandID:@(RequestType::GetCommandId()) - commandPayload:params - timedInvokeTimeout:timedInvokeTimeoutMs - serverSideProcessingTimeout:params.serverSideProcessingTimeout - responseClass:MTRRVCOperationalStateClusterOperationalCommandResponseParams.class - queue:self.callbackQueue - completion:responseHandler]; -} - (void)resumeWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion { [self resumeWithParams:nil completion:completion]; @@ -49919,6 +49725,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 @@ -50101,6 +50811,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; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index 0264d42d26f001..9518cb9ae6fcd5 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -149,6 +149,7 @@ 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, @@ -2352,7 +2353,6 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { // Cluster RVCRunMode attributes MTRAttributeIDTypeClusterRVCRunModeAttributeSupportedModesID MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) = 0x00000000, MTRAttributeIDTypeClusterRVCRunModeAttributeCurrentModeID MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) = 0x00000001, - MTRAttributeIDTypeClusterRVCRunModeAttributeOnModeID MTR_PROVISIONALLY_AVAILABLE = 0x00000003, MTRAttributeIDTypeClusterRVCRunModeAttributeGeneratedCommandListID MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, MTRAttributeIDTypeClusterRVCRunModeAttributeAcceptedCommandListID MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) = MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID, MTRAttributeIDTypeClusterRVCRunModeAttributeEventListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeEventListID, @@ -2363,7 +2363,6 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { // Cluster RVCCleanMode attributes MTRAttributeIDTypeClusterRVCCleanModeAttributeSupportedModesID MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) = 0x00000000, MTRAttributeIDTypeClusterRVCCleanModeAttributeCurrentModeID MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) = 0x00000001, - MTRAttributeIDTypeClusterRVCCleanModeAttributeOnModeID MTR_PROVISIONALLY_AVAILABLE = 0x00000003, MTRAttributeIDTypeClusterRVCCleanModeAttributeGeneratedCommandListID MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, MTRAttributeIDTypeClusterRVCCleanModeAttributeAcceptedCommandListID MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) = MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID, MTRAttributeIDTypeClusterRVCCleanModeAttributeEventListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeEventListID, @@ -2579,12 +2578,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, @@ -6198,8 +6225,6 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) { // Cluster RVCOperationalState commands MTRCommandIDTypeClusterRVCOperationalStateCommandPauseID MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) = 0x00000000, - MTRCommandIDTypeClusterRVCOperationalStateCommandStopID MTR_PROVISIONALLY_AVAILABLE = 0x00000001, - MTRCommandIDTypeClusterRVCOperationalStateCommandStartID MTR_PROVISIONALLY_AVAILABLE = 0x00000002, MTRCommandIDTypeClusterRVCOperationalStateCommandResumeID MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) = 0x00000003, MTRCommandIDTypeClusterRVCOperationalStateCommandOperationalCommandResponseID MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) = 0x00000004, MTRCommandIDTypeClusterRVCOperationalStateCommandGoHomeID MTR_PROVISIONALLY_AVAILABLE = 0x00000080, @@ -7160,6 +7185,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/MTRClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h index f9cfd98a478930..d093371fdfd94a 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h @@ -2558,10 +2558,6 @@ MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) - (NSDictionary * _Nullable)readAttributeCurrentModeWithParams:(MTRReadParams * _Nullable)params MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); -- (NSDictionary * _Nullable)readAttributeOnModeWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; -- (void)writeAttributeOnModeWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs MTR_PROVISIONALLY_AVAILABLE; -- (void)writeAttributeOnModeWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; - - (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); - (NSDictionary * _Nullable)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); @@ -2604,10 +2600,6 @@ MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) - (NSDictionary * _Nullable)readAttributeCurrentModeWithParams:(MTRReadParams * _Nullable)params MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); -- (NSDictionary * _Nullable)readAttributeOnModeWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; -- (void)writeAttributeOnModeWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs MTR_PROVISIONALLY_AVAILABLE; -- (void)writeAttributeOnModeWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; - - (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); - (NSDictionary * _Nullable)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); @@ -3104,12 +3096,6 @@ MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) - (void)pauseWithParams:(MTRRVCOperationalStateClusterPauseParams * _Nullable)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); - (void)pauseWithExpectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); -- (void)stopWithParams:(MTRRVCOperationalStateClusterStopParams * _Nullable)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; -- (void)stopWithExpectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion - MTR_PROVISIONALLY_AVAILABLE; -- (void)startWithParams:(MTRRVCOperationalStateClusterStartParams * _Nullable)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; -- (void)startWithExpectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion - MTR_PROVISIONALLY_AVAILABLE; - (void)resumeWithParams:(MTRRVCOperationalStateClusterResumeParams * _Nullable)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); - (void)resumeWithExpectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); @@ -3443,6 +3429,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. @@ -3460,6 +3520,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; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm index 855d65f15475ad..d81a35a1e50388 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -7116,22 +7116,6 @@ - (void)changeToModeWithParams:(MTRRVCRunModeClusterChangeToModeParams *)params return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeRVCRunModeID) attributeID:@(MTRAttributeIDTypeClusterRVCRunModeAttributeCurrentModeID) params:params]; } -- (NSDictionary * _Nullable)readAttributeOnModeWithParams:(MTRReadParams * _Nullable)params -{ - return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeRVCRunModeID) attributeID:@(MTRAttributeIDTypeClusterRVCRunModeAttributeOnModeID) params:params]; -} - -- (void)writeAttributeOnModeWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs -{ - [self writeAttributeOnModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; -} -- (void)writeAttributeOnModeWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params -{ - NSNumber * timedWriteTimeout = params.timedWriteTimeout; - - [self.device writeAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeRVCRunModeID) attributeID:@(MTRAttributeIDTypeClusterRVCRunModeAttributeOnModeID) value:dataValueDictionary expectedValueInterval:expectedValueIntervalMs timedWriteTimeout:timedWriteTimeout]; -} - - (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params { return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeRVCRunModeID) attributeID:@(MTRAttributeIDTypeClusterRVCRunModeAttributeGeneratedCommandListID) params:params]; @@ -7203,22 +7187,6 @@ - (void)changeToModeWithParams:(MTRRVCCleanModeClusterChangeToModeParams *)param return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeRVCCleanModeID) attributeID:@(MTRAttributeIDTypeClusterRVCCleanModeAttributeCurrentModeID) params:params]; } -- (NSDictionary * _Nullable)readAttributeOnModeWithParams:(MTRReadParams * _Nullable)params -{ - return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeRVCCleanModeID) attributeID:@(MTRAttributeIDTypeClusterRVCCleanModeAttributeOnModeID) params:params]; -} - -- (void)writeAttributeOnModeWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs -{ - [self writeAttributeOnModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; -} -- (void)writeAttributeOnModeWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params -{ - NSNumber * timedWriteTimeout = params.timedWriteTimeout; - - [self.device writeAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeRVCCleanModeID) attributeID:@(MTRAttributeIDTypeClusterRVCCleanModeAttributeOnModeID) value:dataValueDictionary expectedValueInterval:expectedValueIntervalMs timedWriteTimeout:timedWriteTimeout]; -} - - (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params { return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeRVCCleanModeID) attributeID:@(MTRAttributeIDTypeClusterRVCCleanModeAttributeGeneratedCommandListID) params:params]; @@ -8188,68 +8156,6 @@ - (void)pauseWithParams:(MTRRVCOperationalStateClusterPauseParams * _Nullable)pa completion:responseHandler]; } -- (void)stopWithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion -{ - [self stopWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion]; -} -- (void)stopWithParams:(MTRRVCOperationalStateClusterStopParams * _Nullable)params expectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion -{ - if (params == nil) { - params = [[MTRRVCOperationalStateClusterStopParams - alloc] init]; - } - - auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { - completion(response, error); - }; - - auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; - - using RequestType = RvcOperationalState::Commands::Stop::Type; - [self.device _invokeKnownCommandWithEndpointID:self.endpointID - clusterID:@(RequestType::GetClusterId()) - commandID:@(RequestType::GetCommandId()) - commandPayload:params - expectedValues:expectedValues - expectedValueInterval:expectedValueIntervalMs - timedInvokeTimeout:timedInvokeTimeoutMs - serverSideProcessingTimeout:params.serverSideProcessingTimeout - responseClass:MTRRVCOperationalStateClusterOperationalCommandResponseParams.class - queue:self.callbackQueue - completion:responseHandler]; -} - -- (void)startWithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion -{ - [self startWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion]; -} -- (void)startWithParams:(MTRRVCOperationalStateClusterStartParams * _Nullable)params expectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion -{ - if (params == nil) { - params = [[MTRRVCOperationalStateClusterStartParams - alloc] init]; - } - - auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { - completion(response, error); - }; - - auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; - - using RequestType = RvcOperationalState::Commands::Start::Type; - [self.device _invokeKnownCommandWithEndpointID:self.endpointID - clusterID:@(RequestType::GetClusterId()) - commandID:@(RequestType::GetCommandId()) - commandPayload:params - expectedValues:expectedValues - expectedValueInterval:expectedValueIntervalMs - timedInvokeTimeout:timedInvokeTimeoutMs - serverSideProcessingTimeout:params.serverSideProcessingTimeout - responseClass:MTRRVCOperationalStateClusterOperationalCommandResponseParams.class - queue:self.callbackQueue - completion:responseHandler]; -} - - (void)resumeWithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data, NSError * _Nullable error))completion { [self resumeWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion]; @@ -9163,6 +9069,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 @@ -9190,6 +9225,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]; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index 6dd11137d0f2d8..b2159626d29866 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -4621,62 +4621,6 @@ MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) @property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; @end -MTR_PROVISIONALLY_AVAILABLE -@interface MTRRVCOperationalStateClusterStopParams : NSObject -/** - * 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 MTRRVCOperationalStateClusterStartParams : NSObject -/** - * 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_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)) @interface MTRRVCOperationalStateClusterResumeParams : NSObject /** @@ -5514,7 +5458,19 @@ MTR_PROVISIONALLY_AVAILABLE MTR_PROVISIONALLY_AVAILABLE @interface MTRMessagesClusterPresentMessagesRequestParams : NSObject -@property (nonatomic, copy) NSArray * _Nonnull messages MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSData * _Nonnull messageID MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull priority MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull messageControl MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nullable startTime MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nullable duration MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSString * _Nonnull messageText MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSArray * _Nullable responses MTR_PROVISIONALLY_AVAILABLE; /** * Controls whether the command is a timed command (using Timed Invoke). * diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index 3358d9fa790561..0e172b2118b5fc 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 @@ -12554,152 +12554,6 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader } @end -@implementation MTRRVCOperationalStateClusterStopParams -- (instancetype)init -{ - if (self = [super init]) { - _timedInvokeTimeoutMs = nil; - _serverSideProcessingTimeout = nil; - } - return self; -} - -- (id)copyWithZone:(NSZone * _Nullable)zone; -{ - auto other = [[MTRRVCOperationalStateClusterStopParams alloc] init]; - - other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; - other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; - - return other; -} - -- (NSString *)description -{ - NSString * descriptionString = [NSString stringWithFormat:@"<%@: >", NSStringFromClass([self class])]; - return descriptionString; -} - -@end - -@implementation MTRRVCOperationalStateClusterStopParams (InternalMethods) - -- (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader -{ - chip::app::Clusters::RvcOperationalState::Commands::Stop::Type encodableStruct; - ListFreer listFreer; - - 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 MTRRVCOperationalStateClusterStartParams -- (instancetype)init -{ - if (self = [super init]) { - _timedInvokeTimeoutMs = nil; - _serverSideProcessingTimeout = nil; - } - return self; -} - -- (id)copyWithZone:(NSZone * _Nullable)zone; -{ - auto other = [[MTRRVCOperationalStateClusterStartParams alloc] init]; - - other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; - other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; - - return other; -} - -- (NSString *)description -{ - NSString * descriptionString = [NSString stringWithFormat:@"<%@: >", NSStringFromClass([self class])]; - return descriptionString; -} - -@end - -@implementation MTRRVCOperationalStateClusterStartParams (InternalMethods) - -- (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader -{ - chip::app::Clusters::RvcOperationalState::Commands::Start::Type encodableStruct; - ListFreer listFreer; - - 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 MTRRVCOperationalStateClusterResumeParams - (instancetype)init { @@ -15420,7 +15274,19 @@ - (instancetype)init { if (self = [super init]) { - _messages = [NSArray array]; + _messageID = [NSData data]; + + _priority = @(0); + + _messageControl = @(0); + + _startTime = nil; + + _duration = nil; + + _messageText = @""; + + _responses = nil; _timedInvokeTimeoutMs = nil; _serverSideProcessingTimeout = nil; } @@ -15431,7 +15297,13 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; { auto other = [[MTRMessagesClusterPresentMessagesRequestParams alloc] init]; - other.messages = self.messages; + other.messageID = self.messageID; + other.priority = self.priority; + other.messageControl = self.messageControl; + other.startTime = self.startTime; + other.duration = self.duration; + other.messageText = self.messageText; + other.responses = self.responses; other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; @@ -15440,7 +15312,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: messages:%@; >", NSStringFromClass([self class]), _messages]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: messageID:%@; priority:%@; messageControl:%@; startTime:%@; duration:%@; messageText:%@; responses:%@; >", NSStringFromClass([self class]), [_messageID base64EncodedStringWithOptions:0], _priority, _messageControl, _startTime, _duration, _messageText, _responses]; return descriptionString; } @@ -15453,73 +15325,64 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader chip::app::Clusters::Messages::Commands::PresentMessagesRequest::Type encodableStruct; ListFreer listFreer; { - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - if (self.messages.count != 0) { - auto * listHolder_0 = new ListHolder(self.messages.count); - if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { - return CHIP_ERROR_INVALID_ARGUMENT; - } - listFreer.add(listHolder_0); - for (size_t i_0 = 0; i_0 < self.messages.count; ++i_0) { - if (![self.messages[i_0] isKindOfClass:[MTRMessagesClusterMessageStruct class]]) { - // Wrong kind of value. + encodableStruct.messageID = AsByteSpan(self.messageID); + } + { + encodableStruct.priority = static_cast>(self.priority.unsignedCharValue); + } + { + encodableStruct.messageControl = static_cast>(self.messageControl.unsignedCharValue); + } + { + if (self.startTime == nil) { + encodableStruct.startTime.SetNull(); + } else { + auto & nonNullValue_0 = encodableStruct.startTime.SetNonNull(); + nonNullValue_0 = self.startTime.unsignedIntValue; + } + } + { + if (self.duration == nil) { + encodableStruct.duration.SetNull(); + } else { + auto & nonNullValue_0 = encodableStruct.duration.SetNonNull(); + nonNullValue_0 = self.duration.unsignedShortValue; + } + } + { + encodableStruct.messageText = AsCharSpan(self.messageText); + } + { + if (self.responses != nil) { + auto & definedValue_0 = encodableStruct.responses.Emplace(); + { + using ListType_1 = std::remove_reference_t; + using ListMemberType_1 = ListMemberTypeGetter::Type; + if (self.responses.count != 0) { + auto * listHolder_1 = new ListHolder(self.responses.count); + if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) { return CHIP_ERROR_INVALID_ARGUMENT; } - auto element_0 = (MTRMessagesClusterMessageStruct *) self.messages[i_0]; - listHolder_0->mList[i_0].messageID = AsByteSpan(element_0.messageID); - listHolder_0->mList[i_0].priority = static_castmList[i_0].priority)>>(element_0.priority.unsignedCharValue); - listHolder_0->mList[i_0].messageControl = static_castmList[i_0].messageControl)>>(element_0.messageControl.unsignedCharValue); - if (element_0.startTime == nil) { - listHolder_0->mList[i_0].startTime.SetNull(); - } else { - auto & nonNullValue_2 = listHolder_0->mList[i_0].startTime.SetNonNull(); - nonNullValue_2 = element_0.startTime.unsignedIntValue; - } - if (element_0.duration == nil) { - listHolder_0->mList[i_0].duration.SetNull(); - } else { - auto & nonNullValue_2 = listHolder_0->mList[i_0].duration.SetNonNull(); - nonNullValue_2 = element_0.duration.unsignedShortValue; - } - listHolder_0->mList[i_0].messageText = AsCharSpan(element_0.messageText); - if (element_0.responses != nil) { - auto & definedValue_2 = listHolder_0->mList[i_0].responses.Emplace(); - { - using ListType_3 = std::remove_reference_t; - using ListMemberType_3 = ListMemberTypeGetter::Type; - if (element_0.responses.count != 0) { - auto * listHolder_3 = new ListHolder(element_0.responses.count); - if (listHolder_3 == nullptr || listHolder_3->mList == nullptr) { - return CHIP_ERROR_INVALID_ARGUMENT; - } - listFreer.add(listHolder_3); - for (size_t i_3 = 0; i_3 < element_0.responses.count; ++i_3) { - if (![element_0.responses[i_3] isKindOfClass:[MTRMessagesClusterMessageResponseOptionStruct class]]) { - // Wrong kind of value. - return CHIP_ERROR_INVALID_ARGUMENT; - } - auto element_3 = (MTRMessagesClusterMessageResponseOptionStruct *) element_0.responses[i_3]; - if (element_3.messageResponseID != nil) { - auto & definedValue_5 = listHolder_3->mList[i_3].messageResponseID.Emplace(); - definedValue_5 = element_3.messageResponseID.unsignedIntValue; - } - if (element_3.label != nil) { - auto & definedValue_5 = listHolder_3->mList[i_3].label.Emplace(); - definedValue_5 = AsCharSpan(element_3.label); - } - } - definedValue_2 = ListType_3(listHolder_3->mList, element_0.responses.count); - } else { - definedValue_2 = ListType_3(); - } + listFreer.add(listHolder_1); + for (size_t i_1 = 0; i_1 < self.responses.count; ++i_1) { + if (![self.responses[i_1] isKindOfClass:[MTRMessagesClusterMessageResponseOptionStruct class]]) { + // Wrong kind of value. + return CHIP_ERROR_INVALID_ARGUMENT; + } + auto element_1 = (MTRMessagesClusterMessageResponseOptionStruct *) self.responses[i_1]; + if (element_1.messageResponseID != nil) { + auto & definedValue_3 = listHolder_1->mList[i_1].messageResponseID.Emplace(); + definedValue_3 = element_1.messageResponseID.unsignedIntValue; + } + if (element_1.label != nil) { + auto & definedValue_3 = listHolder_1->mList[i_1].label.Emplace(); + definedValue_3 = AsCharSpan(element_1.label); } } + definedValue_0 = ListType_1(listHolder_1->mList, self.responses.count); + } else { + definedValue_0 = ListType_1(); } - encodableStruct.messages = ListType_0(listHolder_0->mList, self.messages.count); - } else { - encodableStruct.messages = ListType_0(); } } } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h index bfa3ba9db6d782..d72da7c651f191 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h @@ -844,18 +844,6 @@ NS_ASSUME_NONNULL_BEGIN @end -@interface MTRRVCOperationalStateClusterStopParams (InternalMethods) - -- (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error; - -@end - -@interface MTRRVCOperationalStateClusterStartParams (InternalMethods) - -- (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error; - -@end - @interface MTRRVCOperationalStateClusterResumeParams (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..c599d23347fe22 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; @@ -1296,6 +1305,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); } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm b/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm index c9a5be796fc548..991f6fb6170e48 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRDeviceTypeMetadata.mm @@ -92,6 +92,7 @@ { 0x00000305, DeviceTypeClass::Simple, "Matter Pressure Sensor" }, { 0x00000306, DeviceTypeClass::Simple, "Matter Flow Sensor" }, { 0x00000307, DeviceTypeClass::Simple, "Matter Humidity Sensor" }, + { 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..a6a7256e379c57 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; @@ -4632,6 +4719,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); } 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/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index 645fdc0acf7415..ffe7fa989cd50e 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -1575,6 +1575,38 @@ - (void)test017_TestMTRDeviceBasics // nonexistent attribute [self waitForExpectations:@[ expectedValueReportedExpectation, expectedValueRemovedExpectation ] timeout:5 enforceOrder:YES]; + // Test if previous value is reported on a write + uint16_t testOnTimeValue = 10; + XCTestExpectation * onTimeWriteSuccess = [self expectationWithDescription:@"OnTime write success"]; + XCTestExpectation * onTimePreviousValue = [self expectationWithDescription:@"OnTime previous value"]; + delegate.onAttributeDataReceived = ^(NSArray *> * data) { + for (NSDictionary * attributeReponseValue in data) { + MTRAttributePath * path = attributeReponseValue[MTRAttributePathKey]; + if (path.cluster.unsignedIntValue == MTRClusterIDTypeOnOffID && path.attribute.unsignedLongValue == MTRAttributeIDTypeClusterOnOffAttributeOnTimeID) { + NSDictionary * dataValue = attributeReponseValue[MTRDataKey]; + NSNumber * onTimeValue = dataValue[MTRValueKey]; + if (onTimeValue && (onTimeValue.unsignedIntValue == testOnTimeValue)) { + [onTimeWriteSuccess fulfill]; + } + + NSDictionary * previousDataValue = attributeReponseValue[MTRPreviousDataKey]; + NSNumber * previousOnTimeValue = previousDataValue[MTRValueKey]; + if (previousOnTimeValue) { + [onTimePreviousValue fulfill]; + } + } + } + }; + NSDictionary * writeOnTimeValue = @{ MTRTypeKey : MTRUnsignedIntegerValueType, MTRValueKey : @(testOnTimeValue) }; + [device writeAttributeWithEndpointID:@(1) + clusterID:@(MTRClusterIDTypeOnOffID) + attributeID:@(MTRAttributeIDTypeClusterOnOffAttributeOnTimeID) + value:writeOnTimeValue + expectedValueInterval:@(10000) + timedWriteTimeout:nil]; + + [self waitForExpectations:@[ onTimeWriteSuccess, onTimePreviousValue ] timeout:10]; + // Test if errors are properly received XCTestExpectation * attributeReportErrorExpectation = [self expectationWithDescription:@"Attribute read error"]; delegate.onAttributeDataReceived = ^(NSArray *> * data) { diff --git a/src/darwin/Framework/CHIPTests/MTRMetricsTests.m b/src/darwin/Framework/CHIPTests/MTRMetricsTests.m new file mode 100644 index 00000000000000..ed5de20b5c433b --- /dev/null +++ b/src/darwin/Framework/CHIPTests/MTRMetricsTests.m @@ -0,0 +1,131 @@ +/* + * + * 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. + */ + +// module headers +#import + +#import "MTRMetrics_Internal.h" + +// system dependencies +#import + +@interface MTRMetricsTests : XCTestCase +@end + +@implementation MTRMetricsTests + +- (void)setUp +{ + // Per-test setup, runs before each test. + [super setUp]; +} + +- (void)tearDown +{ + // Per-test teardown, runs after each test. + [super tearDown]; +} + +- (void)test000_SetUp +{ + // Nothing to do here; our setUp method handled this already. This test + // just exists to make the setup not look like it's happening inside other + // tests. +} + +- (void)test001_TestAllKeys +{ + MTRMetrics * metrics = [MTRMetrics new]; + [metrics setValue:@"metricsCounter1" forKey:@"com.matter.metrics.counter1"]; + [metrics setValue:@"metricsCounter2" forKey:@"com.matter.metrics.counter2"]; + [metrics setValue:@"metricsCounter3" forKey:@"com.matter.metrics.counter3"]; + [metrics setValue:@"metricsCounter4" forKey:@"com.matter.metrics.counter4"]; + + NSArray * keys = [metrics allKeys]; + XCTAssertTrue([keys count] == 4); + XCTAssertTrue([keys containsObject:@"com.matter.metrics.counter1"]); + XCTAssertTrue([keys containsObject:@"com.matter.metrics.counter2"]); + XCTAssertTrue([keys containsObject:@"com.matter.metrics.counter3"]); + XCTAssertTrue([keys containsObject:@"com.matter.metrics.counter4"]); + XCTAssertFalse([keys containsObject:@"com.matter.metrics.counter5"]); +} +- (void)test002_TestOneKey +{ + MTRMetrics * metrics = [MTRMetrics new]; + [metrics setValue:@"metricsCounter1" forKey:@"com.matter.metrics.counter1"]; + + NSArray * keys = [metrics allKeys]; + XCTAssertTrue([keys count] == 1); + XCTAssertTrue([keys containsObject:@"com.matter.metrics.counter1"]); +} + +- (void)test003_TestMultipleKeys +{ + MTRMetrics * metrics = [MTRMetrics new]; + [metrics setValue:@"metricsCounter1" forKey:@"com.matter.metrics.counter1"]; + [metrics setValue:@"metricsCounter2" forKey:@"com.matter.metrics.counter2"]; + [metrics setValue:[NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeInvalidState userInfo:nil] forKey:@"com.matter.metrics.counter3"]; + + NSArray * keys = [metrics allKeys]; + XCTAssertTrue([keys count] == 3); + XCTAssertTrue([keys containsObject:@"com.matter.metrics.counter1"]); + XCTAssertTrue([keys containsObject:@"com.matter.metrics.counter2"]); + XCTAssertTrue([keys containsObject:@"com.matter.metrics.counter3"]); + XCTAssertFalse([keys containsObject:@"com.matter.metrics.counter4"]); +} + +- (void)test004_TestValueForKey +{ + MTRMetrics * metrics = [MTRMetrics new]; + [metrics setValue:@"metricsCounter1" forKey:@"com.matter.metrics.counter1"]; + + XCTAssertEqualObjects([metrics valueForKey:@"com.matter.metrics.counter1"], @"metricsCounter1"); +} + +- (void)test005_TestMultipleValueForKeys +{ + MTRMetrics * metrics = [MTRMetrics new]; + [metrics setValue:@"metricsCounter1" forKey:@"com.matter.metrics.counter1"]; + [metrics setValue:@"metricsCounter2" forKey:@"com.matter.metrics.counter2"]; + [metrics setValue:[NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeInvalidState userInfo:nil] forKey:@"com.matter.metrics.counter3"]; + + XCTAssertEqualObjects([metrics valueForKey:@"com.matter.metrics.counter1"], @"metricsCounter1"); + XCTAssertEqualObjects([metrics valueForKey:@"com.matter.metrics.counter2"], @"metricsCounter2"); + XCTAssertEqualObjects([metrics valueForKey:@"com.matter.metrics.counter3"], [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeInvalidState userInfo:nil]); +} + +- (void)test006_TestValueRemoval +{ + MTRMetrics * metrics = [MTRMetrics new]; + [metrics setValue:@"metricsCounter1" forKey:@"com.matter.metrics.counter1"]; + [metrics setValue:@"metricsCounter2" forKey:@"com.matter.metrics.counter2"]; + + NSArray * keys = [metrics allKeys]; + XCTAssertTrue([keys count] == 2); + + [metrics setValue:nil forKey:@"com.matter.metrics.counter2"]; + keys = [metrics allKeys]; + XCTAssertTrue([keys count] == 1); + XCTAssertTrue([keys containsObject:@"com.matter.metrics.counter1"]); + XCTAssertFalse([keys containsObject:@"com.matter.metrics.counter2"]); + + [metrics setValue:nil forKey:@"com.matter.metrics.counter1"]; + keys = [metrics allKeys]; + XCTAssertTrue([keys count] == 0); +} + +@end diff --git a/src/darwin/Framework/CHIPTests/MTRServerEndpointTests.m b/src/darwin/Framework/CHIPTests/MTRServerEndpointTests.m new file mode 100644 index 00000000000000..57b47f8eb540b7 --- /dev/null +++ b/src/darwin/Framework/CHIPTests/MTRServerEndpointTests.m @@ -0,0 +1,492 @@ +/** + * 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 +#import + +@interface MTRServerEndpointTests : XCTestCase + +@end + +@implementation MTRServerEndpointTests + +- (void)testAccessGrant +{ + // Try to create an access grant with an invalid node ID + { + __auto_type * grant = [MTRAccessGrant accessGrantForNodeID:@(0) privilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNil(grant); + } + + // Try to create an access grant with a group-range node ID + { + __auto_type * grant = [MTRAccessGrant accessGrantForNodeID:@(0xFFFFFFFFFFFF0001) privilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNil(grant); + } + + // Try to create an access grant with a local node ID + { + __auto_type * grant = [MTRAccessGrant accessGrantForNodeID:@(0xFFFFFFFE00020002) privilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNil(grant); + } + + // Try to create an access grant with a CAT-range node ID + { + __auto_type * grant = [MTRAccessGrant accessGrantForNodeID:@(0xFFFFFFFD00020002) privilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNil(grant); + } + + // Try to create an access grant with an operational node ID + { + NSNumber * nodeID = @(2); + __auto_type * grant = [MTRAccessGrant accessGrantForNodeID:nodeID privilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNotNil(grant); + XCTAssertEqualObjects(grant.subjectID, nodeID); + XCTAssertEqual(grant.grantedPrivilege, MTRAccessControlEntryPrivilegeView); + XCTAssertEqual(grant.authenticationMode, MTRAccessControlEntryAuthModeCASE); + XCTAssertEqualObjects([grant description], @""); + } + + // Try different privileges + { + NSNumber * nodeID = @(2); + __auto_type * grant = [MTRAccessGrant accessGrantForNodeID:nodeID privilege:MTRAccessControlEntryPrivilegeAdminister]; + XCTAssertNotNil(grant); + XCTAssertEqualObjects(grant.subjectID, nodeID); + XCTAssertEqual(grant.grantedPrivilege, MTRAccessControlEntryPrivilegeAdminister); + XCTAssertEqual(grant.authenticationMode, MTRAccessControlEntryAuthModeCASE); + XCTAssertEqualObjects([grant description], @""); + } + + // Try a CAT + { + __auto_type * grant = [MTRAccessGrant accessGrantForCASEAuthenticatedTag:@(0x00020003) privilege:MTRAccessControlEntryPrivilegeManage]; + XCTAssertNotNil(grant); + XCTAssertEqualObjects(grant.subjectID, @(0xFFFFFFFD00020003)); + XCTAssertEqual(grant.grantedPrivilege, MTRAccessControlEntryPrivilegeManage); + XCTAssertEqual(grant.authenticationMode, MTRAccessControlEntryAuthModeCASE); + XCTAssertEqualObjects([grant description], @""); + } + + // Try some invalid CATs + { + __auto_type * grant = [MTRAccessGrant accessGrantForCASEAuthenticatedTag:@(0x100000000) privilege:MTRAccessControlEntryPrivilegeManage]; + XCTAssertNil(grant); + } + + { + __auto_type * grant = [MTRAccessGrant accessGrantForCASEAuthenticatedTag:@(0x00020000) privilege:MTRAccessControlEntryPrivilegeManage]; + XCTAssertNil(grant); + } + + // Try a group ID + { + __auto_type * grant = [MTRAccessGrant accessGrantForGroupID:@(0x0005) privilege:MTRAccessControlEntryPrivilegeOperate]; + XCTAssertNotNil(grant); + XCTAssertEqualObjects(grant.subjectID, @(0xFFFFFFFFFFFF0005)); + XCTAssertEqual(grant.grantedPrivilege, MTRAccessControlEntryPrivilegeOperate); + XCTAssertEqual(grant.authenticationMode, MTRAccessControlEntryAuthModeGroup); + XCTAssertEqualObjects([grant description], @""); + } + + // Try an invalid group ID + { + __auto_type * grant = [MTRAccessGrant accessGrantForGroupID:@(0) privilege:MTRAccessControlEntryPrivilegeOperate]; + XCTAssertNil(grant); + } + + // Try a wildcard subject. + { + __auto_type * grant = [MTRAccessGrant accessGrantForAllNodesWithPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNotNil(grant); + XCTAssertNil(grant.subjectID); + XCTAssertEqual(grant.grantedPrivilege, MTRAccessControlEntryPrivilegeView); + XCTAssertEqual(grant.authenticationMode, MTRAccessControlEntryAuthModeCASE); + XCTAssertEqualObjects([grant description], @""); + } +} + +- (void)testServerAttribute +{ + __auto_type * unsignedIntValue = @{ + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(5), + }; + + __auto_type * listOfStringsValue = @{ + MTRTypeKey : MTRArrayValueType, + MTRValueKey : @[ + @{ + MTRTypeKey : MTRUTF8StringValueType, + MTRValueKey : @"str1", + }, + @{ + MTRTypeKey : MTRUTF8StringValueType, + MTRValueKey : @"str2", + }, + ], + }; + + // Basic readonly attribute. + { + __auto_type * attr = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0) initialValue:unsignedIntValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNotNil(attr); + XCTAssertEqualObjects(attr.attributeID, @(0)); + XCTAssertEqualObjects(attr.value, unsignedIntValue); + XCTAssertEqual(attr.writable, NO); + } + + // list-typed readonly attribute. + { + __auto_type * attr = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(5) initialValue:listOfStringsValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNotNil(attr); + XCTAssertEqualObjects(attr.attributeID, @(5)); + XCTAssertEqualObjects(attr.value, listOfStringsValue); + XCTAssertEqual(attr.writable, NO); + } + + // Vendor-specific attribute. + { + NSNumber * vendorSpecificID = @(0xFFF10004); + __auto_type * attr = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:vendorSpecificID initialValue:unsignedIntValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNotNil(attr); + XCTAssertEqualObjects(attr.attributeID, vendorSpecificID); + XCTAssertEqualObjects(attr.value, unsignedIntValue); + XCTAssertEqual(attr.writable, NO); + } + + // Invalid attribute ID + { + NSNumber * invalidID = @(0x00005000); + __auto_type * attr = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:invalidID initialValue:unsignedIntValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNil(attr); + } + + // Invalid "global" attribute ID + { + NSNumber * invalidID = @(0x0000FFFF); + __auto_type * attr = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:invalidID initialValue:unsignedIntValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNil(attr); + } + + // Invalid vendor prefix on attribute ID + { + NSNumber * invalidID = @(0xFFFF0000); + __auto_type * attr = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:invalidID initialValue:unsignedIntValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertNil(attr); + } +} + +- (void)testDeviceType +{ + // Invalid device type ID + { + __auto_type * deviceType = [[MTRDeviceTypeRevision alloc] initWithDeviceTypeID:@(0xC000) revision:@(1)]; + XCTAssertNil(deviceType); + } + + // Another invalid device type ID + { + __auto_type * deviceType = [[MTRDeviceTypeRevision alloc] initWithDeviceTypeID:@(0xFFFF1234) revision:@(1)]; + XCTAssertNil(deviceType); + } + + // Another invalid device type ID + { + __auto_type * deviceType = [[MTRDeviceTypeRevision alloc] initWithDeviceTypeID:@(0x100000000) revision:@(1)]; + XCTAssertNil(deviceType); + } + + // Invalid device type revision + { + __auto_type * deviceType = [[MTRDeviceTypeRevision alloc] initWithDeviceTypeID:@(0x1234) revision:@(0)]; + XCTAssertNil(deviceType); + } + + // Another invalid device type revision + { + __auto_type * deviceType = [[MTRDeviceTypeRevision alloc] initWithDeviceTypeID:@(0x1234) revision:@(0x10000)]; + XCTAssertNil(deviceType); + } + + // Valid device type + { + NSNumber * deviceTypeID = @(0x1234); + NSNumber * deviceTypeRevision = @(1); + __auto_type * deviceType = [[MTRDeviceTypeRevision alloc] initWithDeviceTypeID:deviceTypeID revision:deviceTypeRevision]; + XCTAssertNotNil(deviceType); + XCTAssertEqualObjects(deviceType.deviceTypeID, deviceTypeID); + XCTAssertEqualObjects(deviceType.deviceTypeRevision, deviceTypeRevision); + } +} + +- (void)testClusterDescription +{ + // Standard cluster. + { + NSNumber * clusterID = @(6); + NSNumber * clusterRevision = @(1); + __auto_type * cluster = [[MTRServerCluster alloc] initWithClusterID:clusterID revision:clusterRevision]; + XCTAssertNotNil(cluster); + XCTAssertEqualObjects(cluster.clusterID, clusterID); + XCTAssertEqualObjects(cluster.clusterRevision, clusterRevision); + XCTAssertEqualObjects(cluster.accessGrants, @[]); + XCTAssertEqualObjects(cluster.attributes, @[]); + } + + // Vendor-specific cluster. + { + NSNumber * clusterID = @(0xFFF1FC01); + NSNumber * clusterRevision = @(1); + __auto_type * cluster = [[MTRServerCluster alloc] initWithClusterID:clusterID revision:clusterRevision]; + XCTAssertNotNil(cluster); + XCTAssertEqualObjects(cluster.clusterID, clusterID); + XCTAssertEqualObjects(cluster.clusterRevision, clusterRevision); + XCTAssertEqualObjects(cluster.accessGrants, @[]); + XCTAssertEqualObjects(cluster.attributes, @[]); + } + + // Invalid "standard" cluster. + { + NSNumber * clusterID = @(0x8000); + NSNumber * clusterRevision = @(1); + __auto_type * cluster = [[MTRServerCluster alloc] initWithClusterID:clusterID revision:clusterRevision]; + XCTAssertNil(cluster); + } + + // Invalid vendor-specific cluster. + { + NSNumber * clusterID = @(0xFFF10002); + NSNumber * clusterRevision = @(1); + __auto_type * cluster = [[MTRServerCluster alloc] initWithClusterID:clusterID revision:clusterRevision]; + XCTAssertNil(cluster); + } + + // Cluster ID out of range. + { + NSNumber * clusterID = @(0x100000000); + NSNumber * clusterRevision = @(1); + __auto_type * cluster = [[MTRServerCluster alloc] initWithClusterID:clusterID revision:clusterRevision]; + XCTAssertNil(cluster); + } + + // Revision too small. + { + NSNumber * clusterID = @(6); + NSNumber * clusterRevision = @(0); + __auto_type * cluster = [[MTRServerCluster alloc] initWithClusterID:clusterID revision:clusterRevision]; + XCTAssertNil(cluster); + } + + // Revision too big. + { + NSNumber * clusterID = @(6); + NSNumber * clusterRevision = @(0x10000); + __auto_type * cluster = [[MTRServerCluster alloc] initWithClusterID:clusterID revision:clusterRevision]; + XCTAssertNil(cluster); + } + + // Descriptor cluster wrong method. + { + NSNumber * clusterID = @(0x001D); + NSNumber * clusterRevision = @(0x10000); + __auto_type * cluster = [[MTRServerCluster alloc] initWithClusterID:clusterID revision:clusterRevision]; + XCTAssertNil(cluster); + } + + __auto_type * emptyListValue = @{ + MTRTypeKey : MTRArrayValueType, + MTRValueKey : @[], + }; + + __auto_type * unsignedIntValue = @{ + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(2), + }; + + // Descriptor cluster right method + { + NSNumber * clusterID = @(0x001D); + __auto_type * cluster = [MTRServerCluster newDescriptorCluster]; + XCTAssertNotNil(cluster); + XCTAssertEqualObjects(cluster.clusterID, clusterID); + // Don't hardcode the cluster revision here; we want it to be able to + // change without updating this test. + XCTAssertEqualObjects(cluster.accessGrants, @[]); + XCTAssertEqualObjects(cluster.attributes, @[]); + + // Adding descriptor's list attributes should fail. + __auto_type * deviceTypeListAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0) initialValue:emptyListValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertFalse([cluster addAttribute:deviceTypeListAttribute]); + + __auto_type * serverListAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(1) initialValue:emptyListValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertFalse([cluster addAttribute:serverListAttribute]); + + __auto_type * clientListAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(2) initialValue:emptyListValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertFalse([cluster addAttribute:clientListAttribute]); + + __auto_type * partsListAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(3) initialValue:emptyListValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertFalse([cluster addAttribute:partsListAttribute]); + + // Adding global attributes should fail. + __auto_type * attributeListAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0xFFFB) initialValue:emptyListValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertFalse([cluster addAttribute:attributeListAttribute]); + + __auto_type * acceptedCommandListAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0xFFF9) initialValue:emptyListValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertFalse([cluster addAttribute:acceptedCommandListAttribute]); + + __auto_type * generatedCommandListAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0xFFF8) initialValue:emptyListValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertFalse([cluster addAttribute:generatedCommandListAttribute]); + + __auto_type * clusterRevisionAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0xFFFD) initialValue:unsignedIntValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertFalse([cluster addAttribute:clusterRevisionAttribute]); + + // Adding random attributes should succeed. + __auto_type * randomListAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0xFFF10000) initialValue:emptyListValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertTrue([cluster addAttribute:randomListAttribute]); + } + + // Adding some attributes + { + NSNumber * clusterID = @(0xFFF1FC01); + NSNumber * clusterRevision = @(1); + __auto_type * cluster = [[MTRServerCluster alloc] initWithClusterID:clusterID revision:clusterRevision]; + XCTAssertNotNil(cluster); + XCTAssertEqualObjects(cluster.accessGrants, @[]); + XCTAssertEqualObjects(cluster.attributes, @[]); + + __auto_type * grants = @[ + [MTRAccessGrant accessGrantForAllNodesWithPrivilege:MTRAccessControlEntryPrivilegeManage], + [MTRAccessGrant accessGrantForNodeID:@(1) privilege:MTRAccessControlEntryPrivilegeView], + ]; + for (MTRAccessGrant * grant in grants) { + [cluster addAccessGrant:grant]; + } + XCTAssertEqualObjects(cluster.accessGrants, grants); + + __auto_type * signedIntValue = @{ + MTRTypeKey : MTRSignedIntegerValueType, + MTRValueKey : @(5), + }; + + __auto_type * attributes = @[ [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0) initialValue:signedIntValue requiredPrivilege:MTRAccessControlEntryPrivilegeView] ]; + XCTAssertNotNil(attributes); + for (MTRServerAttribute * attribute in attributes) { + XCTAssertTrue([cluster addAttribute:attribute]); + } + XCTAssertEqualObjects(cluster.attributes, attributes); + + __auto_type * otherCluster = [[MTRServerCluster alloc] initWithClusterID:clusterID revision:clusterRevision]; + + // Adding an already-added attribute should fail. + XCTAssertFalse([otherCluster addAttribute:attributes[0]]); + + MTRServerAttribute * otherAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0) initialValue:signedIntValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + + // Adding same-id attribute should fail. + XCTAssertFalse([cluster addAttribute:otherAttribute]); + + // Adding the same-id attribute to a different cluster should work. + XCTAssertTrue([otherCluster addAttribute:otherAttribute]); + + // Adding global attributes should fail. + __auto_type * attributeListAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0xFFFB) initialValue:emptyListValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertFalse([cluster addAttribute:attributeListAttribute]); + + __auto_type * acceptedCommandListAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0xFFF9) initialValue:emptyListValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertFalse([cluster addAttribute:acceptedCommandListAttribute]); + + __auto_type * generatedCommandListAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0xFFF8) initialValue:emptyListValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertFalse([cluster addAttribute:generatedCommandListAttribute]); + + __auto_type * clusterRevisionAttribute = [[MTRServerAttribute alloc] initReadonlyAttributeWithID:@(0xFFFD) initialValue:unsignedIntValue requiredPrivilege:MTRAccessControlEntryPrivilegeView]; + XCTAssertFalse([cluster addAttribute:clusterRevisionAttribute]); + } +} + +- (void)testEndpointDescription +{ + NSArray * deviceTypes; + { + deviceTypes = @[ [[MTRDeviceTypeRevision alloc] initWithDeviceTypeID:@(0xFFF11234) revision:@(2)] ]; + XCTAssertNotNil(deviceTypes); + } + + // Invalid endpoint ID. + { + NSNumber * endpointID = @(0); + __auto_type * endpoint = [[MTRServerEndpoint alloc] initWithEndpointID:endpointID deviceTypes:deviceTypes]; + XCTAssertNil(endpoint); + } + + // Too-large endpoint ID. + { + NSNumber * endpointID = @(0x10000); + __auto_type * endpoint = [[MTRServerEndpoint alloc] initWithEndpointID:endpointID deviceTypes:deviceTypes]; + XCTAssertNil(endpoint); + } + + // Invalid device type list. + { + NSNumber * endpointID = @(1); + __auto_type * endpoint = [[MTRServerEndpoint alloc] initWithEndpointID:endpointID deviceTypes:@[]]; + XCTAssertNil(endpoint); + } + + // Valid endpoint definition. + { + NSNumber * endpointID = @(1); + __auto_type * endpoint = [[MTRServerEndpoint alloc] initWithEndpointID:endpointID deviceTypes:deviceTypes]; + XCTAssertNotNil(endpoint); + + XCTAssertEqualObjects(endpoint.endpointID, endpointID); + XCTAssertEqualObjects(endpoint.deviceTypes, deviceTypes); + XCTAssertEqualObjects(endpoint.accessGrants, @[]); + XCTAssertEqualObjects(endpoint.serverClusters, @[]); + + __auto_type * grants = @[ + [MTRAccessGrant accessGrantForAllNodesWithPrivilege:MTRAccessControlEntryPrivilegeManage], + [MTRAccessGrant accessGrantForGroupID:@(1) privilege:MTRAccessControlEntryPrivilegeAdminister], + ]; + for (MTRAccessGrant * grant in grants) { + [endpoint addAccessGrant:grant]; + } + XCTAssertEqualObjects(endpoint.accessGrants, grants); + + __auto_type * clusters = @[ + [[MTRServerCluster alloc] initWithClusterID:@(6) revision:@(1)], + ]; + for (MTRServerCluster * cluster in clusters) { + XCTAssertTrue([endpoint addServerCluster:cluster]); + } + XCTAssertEqualObjects(endpoint.serverClusters, clusters); + + __auto_type * otherEndpoint = [[MTRServerEndpoint alloc] initWithEndpointID:endpointID deviceTypes:deviceTypes]; + + // Adding an already-added cluster should fail. + XCTAssertFalse([otherEndpoint addServerCluster:clusters[0]]); + + MTRServerCluster * otherCluster = [[MTRServerCluster alloc] initWithClusterID:@(6) revision:@(1)]; + + // Adding same-id cluster should fail. + XCTAssertFalse([endpoint addServerCluster:otherCluster]); + + // Adding the same-id cluster to a different endpoint should work. + XCTAssertTrue([otherEndpoint addServerCluster:otherCluster]); + } +} + +@end diff --git a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj index ea1b9b8bf338c4..52cd52b0b9599b 100644 --- a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj @@ -150,6 +150,9 @@ 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 */; }; + 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 */; }; 51565CAE2A79D42100469F18 /* MTRConversion.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51565CAD2A79D42100469F18 /* MTRConversion.mm */; }; 51565CB12A7AD77600469F18 /* MTRDeviceControllerDataStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 51565CAF2A7AD77600469F18 /* MTRDeviceControllerDataStore.h */; }; 51565CB22A7AD77600469F18 /* MTRDeviceControllerDataStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51565CB02A7AD77600469F18 /* MTRDeviceControllerDataStore.mm */; }; @@ -182,6 +185,17 @@ 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 */; }; + 51D0B12E2B6177FD006E3511 /* MTRAccessGrant.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D0B12C2B6177D9006E3511 /* MTRAccessGrant.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 51D0B12F2B617800006E3511 /* MTRAccessGrant.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D0B12B2B6177D9006E3511 /* MTRAccessGrant.mm */; }; + 51D0B1382B618CC6006E3511 /* MTRServerAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D0B1362B618CC6006E3511 /* MTRServerAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 51D0B1392B618CC6006E3511 /* MTRServerAttribute.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D0B1372B618CC6006E3511 /* MTRServerAttribute.mm */; }; + 51D0B13C2B61B2F2006E3511 /* MTRDeviceTypeRevision.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D0B13A2B61B2F2006E3511 /* MTRDeviceTypeRevision.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 51D0B13D2B61B2F2006E3511 /* MTRDeviceTypeRevision.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D0B13B2B61B2F2006E3511 /* MTRDeviceTypeRevision.mm */; }; + 51D0B1402B61B3A4006E3511 /* MTRServerCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D0B13E2B61B3A3006E3511 /* MTRServerCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 51D0B1412B61B3A4006E3511 /* MTRServerCluster.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D0B13F2B61B3A3006E3511 /* MTRServerCluster.mm */; }; 51D10D2E2808E2CA00E8CA3D /* MTRTestStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 51D10D2D2808E2CA00E8CA3D /* MTRTestStorage.m */; }; 51E0FC102ACBBF230001E197 /* MTRSwiftDeviceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E0FC0F2ACBBF230001E197 /* MTRSwiftDeviceTests.swift */; }; 51E24E73274E0DAC007CCF6E /* MTRErrorTestUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51E24E72274E0DAC007CCF6E /* MTRErrorTestUtils.mm */; }; @@ -228,6 +242,10 @@ 7596A85728788557004DAE0E /* MTRClusters.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A85428788557004DAE0E /* MTRClusters.h */; settings = {ATTRIBUTES = (Public, ); }; }; 75B765C12A1D71BC0014719B /* MTRAttributeSpecifiedCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 75B765C02A1D71BC0014719B /* MTRAttributeSpecifiedCheck.h */; }; 75B765C32A1D82D30014719B /* MTRAttributeSpecifiedCheck.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75B765C22A1D82D30014719B /* MTRAttributeSpecifiedCheck.mm */; }; + 8874C1322B69C7060084BEFD /* MTRMetricsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8874C1312B69C7060084BEFD /* MTRMetricsTests.m */; }; + 88E6C9462B6334ED001A1FE0 /* MTRMetrics.h in Headers */ = {isa = PBXBuildFile; fileRef = 88E6C9432B6334ED001A1FE0 /* MTRMetrics.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 88E6C9472B6334ED001A1FE0 /* MTRMetrics_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 88E6C9442B6334ED001A1FE0 /* MTRMetrics_Internal.h */; }; + 88E6C9482B6334ED001A1FE0 /* MTRMetrics.mm in Sources */ = {isa = PBXBuildFile; fileRef = 88E6C9452B6334ED001A1FE0 /* MTRMetrics.mm */; }; 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 */; }; @@ -305,10 +323,10 @@ B4E2621B2AA0D02000DBA5BC /* SleepCommand.mm in Sources */ = {isa = PBXBuildFile; fileRef = B4E262192AA0D01D00DBA5BC /* SleepCommand.mm */; }; B4E2621E2AA0D02D00DBA5BC /* WaitForCommissioneeCommand.mm in Sources */ = {isa = PBXBuildFile; fileRef = B4E2621C2AA0D02A00DBA5BC /* WaitForCommissioneeCommand.mm */; }; B4FCD56A2B5EDBD300832859 /* MTRDiagnosticLogsType.h in Headers */ = {isa = PBXBuildFile; fileRef = B4FCD5692B5EDBD300832859 /* MTRDiagnosticLogsType.h */; settings = {ATTRIBUTES = (Public, ); }; }; - B4FCD5732B611EB300832859 /* MTRDiagnosticLogsDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = B4C8E6B32B3453AD00FCD54D /* MTRDiagnosticLogsDownloader.h */; }; B4FCD5702B603A6300832859 /* Commands.h in Headers */ = {isa = PBXBuildFile; fileRef = B4FCD56D2B603A6300832859 /* Commands.h */; }; B4FCD5712B603A6300832859 /* DownloadLogCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = B4FCD56E2B603A6300832859 /* DownloadLogCommand.h */; }; B4FCD5722B603A6300832859 /* DownloadLogCommand.mm in Sources */ = {isa = PBXBuildFile; fileRef = B4FCD56F2B603A6300832859 /* DownloadLogCommand.mm */; }; + B4FCD5732B611EB300832859 /* MTRDiagnosticLogsDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = B4C8E6B32B3453AD00FCD54D /* MTRDiagnosticLogsDownloader.h */; }; BA09EB43247477BA00605257 /* libCHIP.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BA09EB3F2474762900605257 /* libCHIP.a */; }; D4772A46285AE98400383630 /* MTRClusterConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = D4772A45285AE98300383630 /* MTRClusterConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ @@ -515,6 +533,9 @@ 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 = ""; }; + 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 = ""; }; 51565CAD2A79D42100469F18 /* MTRConversion.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRConversion.mm; sourceTree = ""; }; 51565CAF2A7AD77600469F18 /* MTRDeviceControllerDataStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRDeviceControllerDataStore.h; sourceTree = ""; }; 51565CB02A7AD77600469F18 /* MTRDeviceControllerDataStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDeviceControllerDataStore.mm; sourceTree = ""; }; @@ -553,6 +574,17 @@ 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 = ""; }; + 51D0B12B2B6177D9006E3511 /* MTRAccessGrant.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRAccessGrant.mm; sourceTree = ""; }; + 51D0B12C2B6177D9006E3511 /* MTRAccessGrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRAccessGrant.h; sourceTree = ""; }; + 51D0B1362B618CC6006E3511 /* MTRServerAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRServerAttribute.h; sourceTree = ""; }; + 51D0B1372B618CC6006E3511 /* MTRServerAttribute.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRServerAttribute.mm; sourceTree = ""; }; + 51D0B13A2B61B2F2006E3511 /* MTRDeviceTypeRevision.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRDeviceTypeRevision.h; sourceTree = ""; }; + 51D0B13B2B61B2F2006E3511 /* MTRDeviceTypeRevision.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDeviceTypeRevision.mm; sourceTree = ""; }; + 51D0B13E2B61B3A3006E3511 /* MTRServerCluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRServerCluster.h; sourceTree = ""; }; + 51D0B13F2B61B3A3006E3511 /* MTRServerCluster.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRServerCluster.mm; sourceTree = ""; }; 51D10D2D2808E2CA00E8CA3D /* MTRTestStorage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRTestStorage.m; sourceTree = ""; }; 51E0FC0F2ACBBF230001E197 /* MTRSwiftDeviceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MTRSwiftDeviceTests.swift; sourceTree = ""; }; 51E24E72274E0DAC007CCF6E /* MTRErrorTestUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRErrorTestUtils.mm; sourceTree = ""; }; @@ -601,6 +633,10 @@ 75B765BF2A1D70F80014719B /* MTRAttributeSpecifiedCheck-src.zapt */ = {isa = PBXFileReference; lastKnownFileType = text; path = "MTRAttributeSpecifiedCheck-src.zapt"; sourceTree = ""; }; 75B765C02A1D71BC0014719B /* MTRAttributeSpecifiedCheck.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRAttributeSpecifiedCheck.h; sourceTree = ""; }; 75B765C22A1D82D30014719B /* MTRAttributeSpecifiedCheck.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRAttributeSpecifiedCheck.mm; sourceTree = ""; }; + 8874C1312B69C7060084BEFD /* MTRMetricsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRMetricsTests.m; sourceTree = ""; }; + 88E6C9432B6334ED001A1FE0 /* MTRMetrics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRMetrics.h; sourceTree = ""; }; + 88E6C9442B6334ED001A1FE0 /* MTRMetrics_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRMetrics_Internal.h; sourceTree = ""; }; + 88E6C9452B6334ED001A1FE0 /* MTRMetrics.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRMetrics.mm; sourceTree = ""; }; 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 = ""; }; @@ -1092,6 +1128,26 @@ path = TestHelpers; sourceTree = ""; }; + 51D0B1312B618C4F006E3511 /* ServerEndpoint */ = { + isa = PBXGroup; + children = ( + 51D0B12C2B6177D9006E3511 /* MTRAccessGrant.h */, + 51D0B12B2B6177D9006E3511 /* MTRAccessGrant.mm */, + 51D0B1362B618CC6006E3511 /* MTRServerAttribute.h */, + 51D0B1372B618CC6006E3511 /* MTRServerAttribute.mm */, + 514C79FF2B64223400DD6D7B /* MTRServerAttribute_Internal.h */, + 51D0B13A2B61B2F2006E3511 /* MTRDeviceTypeRevision.h */, + 51D0B13B2B61B2F2006E3511 /* MTRDeviceTypeRevision.mm */, + 51D0B1262B617246006E3511 /* MTRServerEndpoint.h */, + 51D0B1252B617246006E3511 /* MTRServerEndpoint.mm */, + 514C7A002B64223400DD6D7B /* MTRServerEndpoint_Internal.h */, + 51D0B13E2B61B3A3006E3511 /* MTRServerCluster.h */, + 51D0B13F2B61B3A3006E3511 /* MTRServerCluster.mm */, + 514C7A032B6436D500DD6D7B /* MTRServerCluster_Internal.h */, + ); + path = ServerEndpoint; + sourceTree = ""; + }; B20252832459E34F00F97062 = { isa = PBXGroup; children = ( @@ -1118,6 +1174,9 @@ B202528F2459E34F00F97062 /* CHIP */ = { isa = PBXGroup; children = ( + 88E6C9442B6334ED001A1FE0 /* MTRMetrics_Internal.h */, + 88E6C9432B6334ED001A1FE0 /* MTRMetrics.h */, + 88E6C9452B6334ED001A1FE0 /* MTRMetrics.mm */, B4FCD5692B5EDBD300832859 /* MTRDiagnosticLogsType.h */, B4C8E6B32B3453AD00FCD54D /* MTRDiagnosticLogsDownloader.h */, B4C8E6B42B3453AD00FCD54D /* MTRDiagnosticLogsDownloader.mm */, @@ -1130,6 +1189,7 @@ 1EC4CE5825CC26AB00D7304F /* zap-generated */, B20252912459E34F00F97062 /* Info.plist */, B2E0D7A8245B0B5C003C5B48 /* Matter.h */, + 51D0B1312B618C4F006E3511 /* ServerEndpoint */, 7596A84628762783004DAE0E /* MTRAsyncCallbackWorkQueue.h */, 7596A84728762783004DAE0E /* MTRAsyncCallbackWorkQueue.mm */, 3DA1A3522ABAB3B4004F0BB9 /* MTRAsyncWorkQueue.h */, @@ -1260,6 +1320,7 @@ B202529A2459E34F00F97062 /* CHIPTests */ = { isa = PBXGroup; children = ( + 8874C1312B69C7060084BEFD /* MTRMetricsTests.m */, 1EE0805C2A448756008A03C2 /* MTRCommissionableBrowserTests.m */, 51189FC72A33ACE900184508 /* TestHelpers */, 3DFCB3282966684500332B35 /* MTRCertificateInfoTests.m */, @@ -1285,6 +1346,7 @@ 51E0FC0F2ACBBF230001E197 /* MTRSwiftDeviceTests.swift */, 51E95DF72A78110900A434F0 /* MTRPerControllerStorageTests.m */, 518D3F842AA14006008E0007 /* MTRControllerAdvertisingTests.m */, + 51D0B1292B61766F006E3511 /* MTRServerEndpointTests.m */, B202529D2459E34F00F97062 /* Info.plist */, 5143851C2A65885400EDC8E6 /* MatterTests-Bridging-Header.h */, ); @@ -1428,6 +1490,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 51D0B1282B617246006E3511 /* MTRServerEndpoint.h in Headers */, 51565CB62A7B0D6600469F18 /* MTRDeviceControllerParameters.h in Headers */, 51565CB42A7AD78D00469F18 /* MTRDeviceControllerStorageDelegate.h in Headers */, 510A07492A685D3900A9241C /* Matter.apinotes in Headers */, @@ -1438,6 +1501,8 @@ 5136661628067D550025EDAE /* MTRDeviceControllerFactory.h in Headers */, 5178E6812AE098520069DF72 /* MTRCommandTimedCheck.h in Headers */, 7596A84B287636C1004DAE0E /* MTRDevice_Internal.h in Headers */, + 514C7A042B6436D500DD6D7B /* MTRServerCluster_Internal.h in Headers */, + 88E6C9472B6334ED001A1FE0 /* MTRMetrics_Internal.h in Headers */, 5A6FEC9927B5C88900F25F42 /* MTRDeviceOverXPC.h in Headers */, B4FCD5732B611EB300832859 /* MTRDiagnosticLogsDownloader.h in Headers */, 51B22C222740CB1D008D5055 /* MTRCommandPayloadsObjc.h in Headers */, @@ -1464,7 +1529,9 @@ 2C222AD0255C620600E446B9 /* MTRBaseDevice.h in Headers */, 7596A84F2877E6A9004DAE0E /* MTRCluster_Internal.h in Headers */, 991DC0842475F45400C13860 /* MTRDeviceController.h in Headers */, + 88E6C9462B6334ED001A1FE0 /* MTRMetrics.h in Headers */, AF1CB86E2874B03B00865A96 /* MTROTAProviderDelegate.h in Headers */, + 51D0B1402B61B3A4006E3511 /* MTRServerCluster.h in Headers */, 754F3DF427FBB94B00E60580 /* MTREventTLVValueDecoder_Internal.h in Headers */, 3CF134AF289D90FF0017A19E /* MTROperationalCertificateIssuer.h in Headers */, 5178E6822AE098520069DF72 /* MTRCommissionableBrowserResult_Internal.h in Headers */, @@ -1481,7 +1548,9 @@ 9956064426420367000C28DE /* MTRSetupPayload_Internal.h in Headers */, 27A53C1727FBC6920053F131 /* MTRAttestationTrustStoreBridge.h in Headers */, 5A830D6C27CFCF590053B85D /* MTRDeviceControllerOverXPC_Internal.h in Headers */, + 51D0B13C2B61B2F2006E3511 /* MTRDeviceTypeRevision.h in Headers */, 88EBF8D027FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.h in Headers */, + 514C7A012B64223400DD6D7B /* MTRServerAttribute_Internal.h in Headers */, 3DFCB32C29678C9500332B35 /* MTRConversion.h in Headers */, 5A60370827EA1FF60020DB79 /* MTRClusterStateCacheContainer+XPC.h in Headers */, 5ACDDD7E27CD3F3A00EFD68A /* MTRClusterStateCacheContainer_Internal.h in Headers */, @@ -1495,6 +1564,7 @@ 2C8C8FC1253E0C2100797F05 /* MTRStorage.h in Headers */, AF1CB8702874B04C00865A96 /* MTROTAProviderDelegateBridge.h in Headers */, B2E0D7B5245B0B5C003C5B48 /* MTRQRCodeSetupPayloadParser.h in Headers */, + 51D0B1382B618CC6006E3511 /* MTRServerAttribute.h in Headers */, 1EC4CE6425CC276600D7304F /* MTRBaseClusters.h in Headers */, 3D843712294977000070D20A /* MTRCallbackBridgeBase.h in Headers */, 3DECCB742934C21B00585AEC /* MTRDefines.h in Headers */, @@ -1506,11 +1576,13 @@ 1E4D654E29C208DD00BC3478 /* MTRCommissionableBrowserResult.h in Headers */, 998F286F26D55EC5001846C6 /* MTRP256KeypairBridge.h in Headers */, 2C222ADF255C811800E446B9 /* MTRBaseDevice_Internal.h in Headers */, + 514C7A022B64223400DD6D7B /* MTRServerEndpoint_Internal.h in Headers */, 511913FC28C100EF009235E9 /* MTRBaseSubscriptionCallback.h in Headers */, 51565CB12A7AD77600469F18 /* MTRDeviceControllerDataStore.h in Headers */, 3D843713294977000070D20A /* NSDataSpanConversion.h in Headers */, 991DC08B247704DC00C13860 /* MTRLogging_Internal.h in Headers */, 51FE723F2ACDEF3E00437032 /* MTRCommandPayloadExtensions_Internal.h in Headers */, + 51D0B12E2B6177FD006E3511 /* MTRAccessGrant.h in Headers */, 1E4D655029C208DD00BC3478 /* MTRCommissionableBrowserDelegate.h in Headers */, 7596A84828762783004DAE0E /* MTRAsyncCallbackWorkQueue.h in Headers */, 5A7947E527C0129F00434CF2 /* MTRDeviceController+XPC.h in Headers */, @@ -1760,7 +1832,9 @@ 51029DF6293AA6100087AFB0 /* MTROperationalCertificateIssuer.mm in Sources */, 27A53C1827FBC6920053F131 /* MTRAttestationTrustStoreBridge.mm in Sources */, 998F287126D56940001846C6 /* MTRP256KeypairBridge.mm in Sources */, + 51D0B1412B61B3A4006E3511 /* MTRServerCluster.mm 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 */, @@ -1777,8 +1851,11 @@ B2E0D7B7245B0B5C003C5B48 /* MTRQRCodeSetupPayloadParser.mm in Sources */, 514304202914CED9004DC7FE /* generic-callback-stubs.cpp in Sources */, 1EDCE546289049A100E41EC9 /* MTROTAHeader.mm in Sources */, + 51D0B13D2B61B2F2006E3511 /* MTRDeviceTypeRevision.mm in Sources */, 1EC4CE5D25CC26E900D7304F /* MTRBaseClusters.mm in Sources */, 51565CB22A7AD77600469F18 /* MTRDeviceControllerDataStore.mm in Sources */, + 51D0B12F2B617800006E3511 /* MTRAccessGrant.mm in Sources */, + 88E6C9482B6334ED001A1FE0 /* MTRMetrics.mm in Sources */, 1ED276E226C5812A00547A89 /* MTRCluster.mm in Sources */, B2E0D7B3245B0B5C003C5B48 /* MTRError.mm in Sources */, 51E51FC1282AD37A00FC978D /* MTRDeviceControllerStartupParams.mm in Sources */, @@ -1809,6 +1886,7 @@ 514654492A72F9DF00904E61 /* MTRDemuxingStorage.mm in Sources */, 1E4D655229C30A8700BC3478 /* MTRCommissionableBrowser.mm in Sources */, 3DA1A3562ABAB3B4004F0BB9 /* MTRAsyncWorkQueue.mm in Sources */, + 51D0B1272B617246006E3511 /* MTRServerEndpoint.mm in Sources */, 3DECCB722934AFE200585AEC /* MTRLogging.mm in Sources */, 7596A84528762729004DAE0E /* MTRDevice.mm in Sources */, ); @@ -1821,12 +1899,14 @@ 51742B4E29CB6B88009974FE /* MTRPairingTests.m in Sources */, 51669AF02913204400F4AA36 /* MTRBackwardsCompatTests.m in Sources */, 51D10D2E2808E2CA00E8CA3D /* MTRTestStorage.m in Sources */, + 51D0B12A2B61766F006E3511 /* MTRServerEndpointTests.m in Sources */, 7596A8512878709F004DAE0E /* MTRAsyncCallbackQueueTests.m in Sources */, 997DED1A26955D0200975E97 /* MTRThreadOperationalDatasetTests.mm in Sources */, 518D3F852AA14006008E0007 /* MTRControllerAdvertisingTests.m in Sources */, 51C8E3F82825CDB600D47D00 /* MTRTestKeys.m in Sources */, 51C984622A61CE2A00B0AD9A /* MTRFabricInfoChecker.m in Sources */, 99C65E10267282F1003402F6 /* MTRControllerTests.m in Sources */, + 8874C1322B69C7060084BEFD /* MTRMetricsTests.m in Sources */, 1E5801C328941C050033A199 /* MTRTestOTAProvider.m in Sources */, 5A6FEC9D27B5E48900F25F42 /* MTRXPCProtocolTests.m in Sources */, 1EE0805E2A44875E008A03C2 /* MTRCommissionableBrowserTests.m in Sources */, diff --git a/src/include/platform/CHIPDeviceConfig.h b/src/include/platform/CHIPDeviceConfig.h index b203c997db8ff8..6ee7d9c9634999 100644 --- a/src/include/platform/CHIPDeviceConfig.h +++ b/src/include/platform/CHIPDeviceConfig.h @@ -953,6 +953,17 @@ static_assert(CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN < CHIP_DEVICE_ #ifndef CHIP_DEVICE_CONFIG_THREAD_BORDER_ROUTER #define CHIP_DEVICE_CONFIG_THREAD_BORDER_ROUTER 0 #endif + +/** + * CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK + * + * Indicate if the matter device thread stack is implemented using the ot-br-posix dbus API + * Rather than the standard openthread stack api + * + */ +#ifndef CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK +#define CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK 0 +#endif /** * CHIP_DEVICE_CONFIG_THREAD_TASK_NAME * diff --git a/src/include/platform/ConnectivityManager.h b/src/include/platform/ConnectivityManager.h index e874773886e51b..ed881f78cc2c3c 100644 --- a/src/include/platform/ConnectivityManager.h +++ b/src/include/platform/ConnectivityManager.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include @@ -202,7 +202,6 @@ class ConnectivityManager bool IsThreadProvisioned(); void ErasePersistentInfo(); void ResetThreadNetworkDiagnosticsCounts(); - CHIP_ERROR WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); CHIP_ERROR SetPollingInterval(System::Clock::Milliseconds32 pollingInterval); @@ -477,25 +476,6 @@ inline void ConnectivityManager::ResetThreadNetworkDiagnosticsCounts() static_cast(this)->_ResetThreadNetworkDiagnosticsCounts(); } -/* - * @brief Get runtime value from the thread network based on the given attribute ID. - * The info is encoded via the AttributeValueEncoder. - * - * @param attributeId Id of the attribute for the requested info. - * @param aEncoder Encoder to encode the attribute value. - * - * @return CHIP_NO_ERROR = Succes. - * CHIP_ERROR_NOT_IMPLEMENTED = Runtime value for this attribute to yet available to send as reply - * Use standard read. - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE = Is not a Runtime readable attribute. Use standard read - * All other errors should be treated as a read error and reported as such. - */ -inline CHIP_ERROR ConnectivityManager::WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, - app::AttributeValueEncoder & encoder) -{ - return static_cast(this)->_WriteThreadNetworkDiagnosticAttributeToTlv(attributeId, encoder); -} - inline Ble::BleLayer * ConnectivityManager::GetBleLayer() { return static_cast(this)->_GetBleLayer(); diff --git a/src/include/platform/ThreadStackManager.h b/src/include/platform/ThreadStackManager.h index b6c9a7e38dd7d5..86d895ec1cfe52 100644 --- a/src/include/platform/ThreadStackManager.h +++ b/src/include/platform/ThreadStackManager.h @@ -132,7 +132,6 @@ class ThreadStackManager #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT void ResetThreadNetworkDiagnosticsCounts(void); - CHIP_ERROR WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); private: // ===== Members for internal use by the following friends. @@ -425,24 +424,5 @@ inline void ThreadStackManager::ResetThreadNetworkDiagnosticsCounts() static_cast(this)->_ResetThreadNetworkDiagnosticsCounts(); } -/* - * @brief Get runtime value from the thread network based on the given attribute ID. - * The info is encoded via the AttributeValueEncoder. - * - * @param attributeId Id of the attribute for the requested info. - * @param aEncoder Encoder to encode the attribute value. - * - * @return CHIP_NO_ERROR = Succes. - * CHIP_ERROR_NOT_IMPLEMENTED = Runtime value for this attribute to yet available to send as reply - * Use standard read. - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE = Is not a Runtime readable attribute. Use standard read - * All other errors should be treated as a read error and reported as such. - */ -inline CHIP_ERROR ThreadStackManager::WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, - app::AttributeValueEncoder & encoder) -{ - return static_cast(this)->_WriteThreadNetworkDiagnosticAttributeToTlv(attributeId, encoder); -} - } // namespace DeviceLayer } // namespace chip diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h b/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h index e7af04965182fa..c84f2160a1457b 100755 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h @@ -54,8 +54,6 @@ class GenericConnectivityManagerImpl_NoThread bool _IsThreadProvisioned(void); void _ErasePersistentInfo(void); void _ResetThreadNetworkDiagnosticsCounts(void); - CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); - ImplClass * Impl() { return static_cast(this); } }; @@ -116,100 +114,6 @@ template inline void GenericConnectivityManagerImpl_NoThread::_ResetThreadNetworkDiagnosticsCounts() {} -template -inline CHIP_ERROR GenericConnectivityManagerImpl_NoThread::_WriteThreadNetworkDiagnosticAttributeToTlv( - AttributeId attributeId, app::AttributeValueEncoder & encoder) -{ - // If we get here the Thread Network Diagnostic cluster is enabled on the device but doesn't run thread. - // Encode Null or default values for all attributes of the cluster. - CHIP_ERROR err = CHIP_NO_ERROR; - switch (attributeId) - { - // Encode EmptyList - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RouteTable::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::NeighborTable::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::ActiveNetworkFaultsList::Id: - err = encoder.EncodeEmptyList(); - break; - // Encode Null - case app::Clusters::ThreadNetworkDiagnostics::Attributes::Channel::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RoutingRole::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::NetworkName::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::PanId::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::ExtendedPanId::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::MeshLocalPrefix::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::PartitionId::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::Weighting::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::DataVersion::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::StableDataVersion::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::LeaderRouterId::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::ActiveTimestamp::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::PendingTimestamp::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::Delay::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::ChannelPage0Mask::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::SecurityPolicy::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::Id: - err = encoder.EncodeNull(); - break; - // Encode UINT64_T 0 - case app::Clusters::ThreadNetworkDiagnostics::Attributes::OverrunCount::Id: - err = encoder.Encode(static_cast(0)); - break; - // Encode UINT16_T 0 - case app::Clusters::ThreadNetworkDiagnostics::Attributes::DetachedRoleCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::ChildRoleCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RouterRoleCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::LeaderRoleCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::AttachAttemptCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::PartitionIdChangeCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::BetterPartitionAttachAttemptCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::ParentChangeCount::Id: - err = encoder.Encode(static_cast(0)); - break; - // Encode UINT32_T 0 - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxTotalCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxUnicastCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxBroadcastCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxAckedCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxAckRequestedCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxNoAckRequestedCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxDataCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxDataPollCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxBeaconCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxBeaconRequestCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxOtherCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxRetryCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxDirectMaxRetryExpiryCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxIndirectMaxRetryExpiryCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxErrCcaCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxErrAbortCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::TxErrBusyChannelCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxTotalCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxUnicastCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxBroadcastCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDataCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDataPollCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxBeaconCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxBeaconRequestCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxOtherCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxAddressFilteredCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDestAddrFilteredCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDuplicatedCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrNoFrameCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrUnknownNeighborCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrInvalidSrcAddrCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrSecCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrFcsCount::Id: - case app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - default: - err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; - break; - } - - return err; -} } // namespace Internal } // namespace DeviceLayer } // namespace chip diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h index a1d24c2e1c80d4..456d843c488224 100755 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h @@ -70,7 +70,6 @@ class GenericConnectivityManagerImpl_Thread bool _IsThreadProvisioned(); void _ErasePersistentInfo(); void _ResetThreadNetworkDiagnosticsCounts(); - CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); // ===== Members for use by the implementation subclass. @@ -154,14 +153,6 @@ inline void GenericConnectivityManagerImpl_Thread::_ResetThreadNetwor ThreadStackMgrImpl().ResetThreadNetworkDiagnosticsCounts(); } -template -inline CHIP_ERROR -GenericConnectivityManagerImpl_Thread::_WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, - app::AttributeValueEncoder & encoder) -{ - return ThreadStackMgrImpl().WriteThreadNetworkDiagnosticAttributeToTlv(attributeId, encoder); -} - } // namespace Internal } // namespace DeviceLayer } // namespace chip diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index 8d6c07f40e3412..09a6e569d5b1e0 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") @@ -100,10 +99,10 @@ static_library("inet") { public_deps = [ ":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) { diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index 88e3e37e8c3736..27611376c10069 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -101,6 +101,29 @@ 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", + "Global.h", + "InPlace.h", + "Optional.h", + "ReferenceCounted.h", + "Unchecked.h", + ] + + public_deps = [ + ":chip_config_header", + "${chip_root}/src/lib/support:memory", + "${chip_root}/src/lib/support:verifymacros", ] } @@ -108,15 +131,12 @@ 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", "ClusterEnums.h", "DataModelTypes.h", "GroupId.h", @@ -125,17 +145,26 @@ static_library("core") { "OTAImageHeader.h", "PasscodeId.h", "PeerId.h", + "ScopedNodeId.h", "TLV.h", + "TLVBackingStore.h", "TLVCircularBuffer.cpp", "TLVCircularBuffer.h", + "TLVCommon.h", + "TLVData.h", "TLVDebug.cpp", + "TLVDebug.h", "TLVReader.cpp", + "TLVReader.h", "TLVTags.cpp", "TLVTags.h", "TLVTypes.h", "TLVUpdater.cpp", + "TLVUpdater.h", "TLVUtilities.cpp", + "TLVUtilities.h", "TLVWriter.cpp", + "TLVWriter.h", ] cflags = [ "-Wconversion" ] @@ -143,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/core/InPlace.h b/src/lib/core/InPlace.h index 14ce5773101412..60c691ae27e3a0 100644 --- a/src/lib/core/InPlace.h +++ b/src/lib/core/InPlace.h @@ -14,13 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * @file - * This file defines the chip::Optional class to handle values which may - * or may not be present. - * - */ #pragma once namespace chip { diff --git a/src/lib/core/Optional.h b/src/lib/core/Optional.h index 7278484a6e6be9..3d509f544c97cd 100644 --- a/src/lib/core/Optional.h +++ b/src/lib/core/Optional.h @@ -25,9 +25,10 @@ #include #include +#include -#include #include +#include namespace chip { diff --git a/src/lib/core/TLVWriter.cpp b/src/lib/core/TLVWriter.cpp index b20cc70adde8f0..825b8c7b671406 100644 --- a/src/lib/core/TLVWriter.cpp +++ b/src/lib/core/TLVWriter.cpp @@ -101,6 +101,7 @@ CHIP_ERROR TLVWriter::Init(TLVBackingStore & backingStore, uint32_t maxLen /* = if (err != CHIP_NO_ERROR) return err; + VerifyOrReturnError(mBufStart != nullptr, CHIP_ERROR_INTERNAL); mWritePoint = mBufStart; mInitializationCookie = kExpectedInitializationCookie; return CHIP_NO_ERROR; @@ -363,11 +364,7 @@ CHIP_ERROR TLVWriter::VPutStringF(Tag tag, const char * fmt, va_list ap) size_t dataLen; CHIP_ERROR err = CHIP_NO_ERROR; TLVFieldSize lenFieldSize; -#if CONFIG_HAVE_VSNPRINTF_EX - size_t skipLen; - size_t writtenBytes; -#elif CONFIG_HAVE_VCBPRINTF -#else +#if !CONFIG_HAVE_VCBPRINTF char * tmpBuf; #endif va_copy(aq, ap); @@ -396,47 +393,14 @@ CHIP_ERROR TLVWriter::VPutStringF(Tag tag, const char * fmt, va_list ap) VerifyOrExit((mLenWritten + dataLen) <= mMaxLen, err = CHIP_ERROR_BUFFER_TOO_SMALL); // write data -#if CONFIG_HAVE_VSNPRINTF_EX - - skipLen = 0; - - do - { - va_copy(aq, ap); - - vsnprintf_ex(reinterpret_cast(mWritePoint), mRemainingLen, skipLen, fmt, aq); - - va_end(aq); - - writtenBytes = (mRemainingLen >= (dataLen - skipLen)) ? dataLen - skipLen : mRemainingLen; - skipLen += writtenBytes; - mWritePoint += writtenBytes; - mRemainingLen -= writtenBytes; - mLenWritten += writtenBytes; - if (skipLen < dataLen) - { - VerifyOrExit(mBackingStore != NULL, err = CHIP_ERROR_NO_MEMORY); - - err = mBackingStore->FinalizeBuffer(*this, mBufHandle, mBufStart, mWritePoint - mBufStart); - SuccessOrExit(err); - - err = mBackingStore->GetNewBuffer(*this, mBufHandle, mBufStart, mRemainingLen); - SuccessOrExit(err); - - mWritePoint = mBufStart; - } - - } while (skipLen < dataLen); - -#elif CONFIG_HAVE_VCBPRINTF +#if CONFIG_HAVE_VCBPRINTF va_copy(aq, ap); vcbprintf(TLVWriterPutcharCB, this, dataLen, fmt, aq); va_end(aq); - -#else // CONFIG_HAVE_VSNPRINTF_EX +#else // CONFIG_HAVE_VCBPRINTF tmpBuf = static_cast(chip::Platform::MemoryAlloc(dataLen + 1)); VerifyOrExit(tmpBuf != nullptr, err = CHIP_ERROR_NO_MEMORY); @@ -450,7 +414,7 @@ CHIP_ERROR TLVWriter::VPutStringF(Tag tag, const char * fmt, va_list ap) err = WriteData(reinterpret_cast(tmpBuf), static_cast(dataLen)); chip::Platform::MemoryFree(tmpBuf); -#endif // CONFIG_HAVE_VSNPRINTF_EX +#endif // CONFIG_HAVE_VCBPRINTF exit: @@ -694,19 +658,13 @@ CHIP_ERROR TLVWriter::WriteElementHead(TLVElementType elemType, Tag tag, uint64_ ABORT_ON_UNINITIALIZED_IF_ENABLED(); VerifyOrReturnError(IsInitialized(), CHIP_ERROR_INCORRECT_STATE); - uint8_t * p; - uint8_t stagingBuf[17]; // 17 = 1 control byte + 8 tag bytes + 8 length/value bytes - if (IsContainerOpen()) return CHIP_ERROR_TLV_CONTAINER_OPEN; + uint8_t stagingBuf[17]; // 17 = 1 control byte + 8 tag bytes + 8 length/value bytes + uint8_t * p = stagingBuf; uint32_t tagNum = TagNumFromTag(tag); - if ((mRemainingLen >= sizeof(stagingBuf)) && (mMaxLen >= sizeof(stagingBuf))) - p = mWritePoint; - else - p = stagingBuf; - if (IsSpecialTag(tag)) { if (tagNum <= Tag::kContextTagMaxNum) @@ -799,15 +757,9 @@ CHIP_ERROR TLVWriter::WriteElementHead(TLVElementType elemType, Tag tag, uint64_ break; } - if ((mRemainingLen >= sizeof(stagingBuf)) && (mMaxLen >= sizeof(stagingBuf))) - { - uint32_t len = static_cast(p - mWritePoint); - mWritePoint = p; - mRemainingLen -= len; - mLenWritten += len; - return CHIP_NO_ERROR; - } - return WriteData(stagingBuf, static_cast(p - stagingBuf)); + uint32_t bytesStaged = static_cast(p - stagingBuf); + VerifyOrDie(bytesStaged <= sizeof(stagingBuf)); + return WriteData(stagingBuf, bytesStaged); } CHIP_ERROR TLVWriter::WriteElementWithData(TLVType type, Tag tag, const uint8_t * data, uint32_t dataLen) @@ -855,6 +807,7 @@ CHIP_ERROR TLVWriter::WriteData(const uint8_t * p, uint32_t len) ReturnErrorOnFailure(mBackingStore->FinalizeBuffer(*this, mBufStart, static_cast(mWritePoint - mBufStart))); ReturnErrorOnFailure(mBackingStore->GetNewBuffer(*this, mBufStart, mRemainingLen)); + VerifyOrReturnError(mRemainingLen > 0, CHIP_ERROR_NO_MEMORY); mWritePoint = mBufStart; diff --git a/src/lib/core/Unchecked.h b/src/lib/core/Unchecked.h index d7fab990268168..29283f5f130dba 100644 --- a/src/lib/core/Unchecked.h +++ b/src/lib/core/Unchecked.h @@ -14,13 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * @file - * This file defines the chip::Optional class to handle values which may - * or may not be present. - * - */ #pragma once namespace chip { diff --git a/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp b/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp index a77abebab68a58..b3b1f8ea8876a6 100644 --- a/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp +++ b/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp @@ -23,7 +23,7 @@ #include "MinimalMdnsServer.h" #include "ServiceNaming.h" -#include +#include #include #include #include diff --git a/src/lib/dnssd/BUILD.gn b/src/lib/dnssd/BUILD.gn index cb8fb449908bca..295be7d51a191d 100644 --- a/src/lib/dnssd/BUILD.gn +++ b/src/lib/dnssd/BUILD.gn @@ -23,7 +23,7 @@ source_set("platform_header") { static_library("dnssd") { public_deps = [ ":platform_header", - "${chip_root}/src/app/icd:icd_config", + "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/crypto", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", diff --git a/src/lib/dnssd/Discovery_ImplPlatform.cpp b/src/lib/dnssd/Discovery_ImplPlatform.cpp index 240bb979991038..8b1bbbfb7b82e5 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.cpp +++ b/src/lib/dnssd/Discovery_ImplPlatform.cpp @@ -19,7 +19,7 @@ #include -#include +#include #include #include #include diff --git a/src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp b/src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp index 560b013dfea133..8f3e39c026eb6d 100644 --- a/src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp +++ b/src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include +#include #include #include diff --git a/src/lib/shell/MainLoopDefault.cpp b/src/lib/shell/MainLoopDefault.cpp index fba29a7238f161..c83fc96e4a1413 100644 --- a/src/lib/shell/MainLoopDefault.cpp +++ b/src/lib/shell/MainLoopDefault.cpp @@ -69,6 +69,7 @@ size_t ReadLine(char * buffer, size_t max) done = true; } break; + case 0x08: case 0x7F: // Do not accept backspace character (i.e. don't increment line_sz) and remove 1 additional character if it exists. if (line_sz >= 1u) diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index 9f71492a5b3877..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") @@ -149,7 +148,10 @@ source_set("verifymacros") { source_set("span") { sources = [ "Span.h" ] - public_deps = [ ":verifymacros" ] + public_deps = [ + ":verifymacros", + "${chip_root}/src/lib/core:types", + ] } source_set("chip_version_header") { @@ -158,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" @@ -177,6 +190,8 @@ static_library("support") { "CHIPArgParser.cpp", "CHIPCounter.h", "CHIPMemString.h", + "CommonIterator.h", + "CommonPersistentData.h", "DLLUtil.h", "DefaultStorageKeyAllocator.h", "Defer.h", @@ -184,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", @@ -250,14 +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 @@ -332,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/IntrusiveList.h b/src/lib/support/IntrusiveList.h index 8bd0afb0daf71d..961113e8d1ee6b 100644 --- a/src/lib/support/IntrusiveList.h +++ b/src/lib/support/IntrusiveList.h @@ -439,6 +439,14 @@ class IntrusiveList : public IntrusiveListBase void Remove(T * value) { IntrusiveListBase::Remove(Hook::ToNode(value)); } void Replace(T * original, T * replacement) { IntrusiveListBase::Replace(Hook::ToNode(original), Hook::ToNode(replacement)); } bool Contains(const T * value) const { return IntrusiveListBase::Contains(Hook::ToNode(value)); } + + void Clear() + { + while (begin() != end()) + { + Remove(&(*begin())); + } + } }; } // namespace chip diff --git a/src/lib/support/JniReferences.cpp b/src/lib/support/JniReferences.cpp index a3f0b0353aab98..76c3f77e8bbecf 100644 --- a/src/lib/support/JniReferences.cpp +++ b/src/lib/support/JniReferences.cpp @@ -254,9 +254,8 @@ CHIP_ERROR JniReferences::CreateOptional(jobject objectToWrap, jobject & outOpti { JNIEnv * env = GetEnvForCurrentThread(); jclass optionalCls; - chip::JniReferences::GetInstance().GetClassRef(env, "java/util/Optional", optionalCls); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "java/util/Optional", optionalCls); VerifyOrReturnError(optionalCls != nullptr, CHIP_JNI_ERROR_TYPE_NOT_FOUND); - chip::JniClass jniClass(optionalCls); jmethodID ofMethod = env->GetStaticMethodID(optionalCls, "ofNullable", "(Ljava/lang/Object;)Ljava/util/Optional;"); env->ExceptionClear(); @@ -280,9 +279,8 @@ CHIP_ERROR JniReferences::GetOptionalValue(jobject optionalObj, jobject & option { JNIEnv * env = GetEnvForCurrentThread(); jclass optionalCls; - chip::JniReferences::GetInstance().GetClassRef(env, "java/util/Optional", optionalCls); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "java/util/Optional", optionalCls); VerifyOrReturnError(optionalCls != nullptr, CHIP_JNI_ERROR_TYPE_NOT_FOUND); - chip::JniClass jniClass(optionalCls); jmethodID isPresentMethod = env->GetMethodID(optionalCls, "isPresent", "()Z"); VerifyOrReturnError(isPresentMethod != nullptr, CHIP_JNI_ERROR_METHOD_NOT_FOUND); @@ -304,8 +302,7 @@ jint JniReferences::IntegerToPrimitive(jobject boxedInteger) { JNIEnv * env = GetEnvForCurrentThread(); jclass boxedTypeCls; - chip::JniReferences::GetInstance().GetClassRef(env, "java/lang/Integer", boxedTypeCls); - chip::JniClass jniClass(boxedTypeCls); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "java/lang/Integer", boxedTypeCls); jmethodID valueMethod = env->GetMethodID(boxedTypeCls, "intValue", "()I"); return env->CallIntMethod(boxedInteger, valueMethod); @@ -315,8 +312,7 @@ jlong JniReferences::LongToPrimitive(jobject boxedLong) { JNIEnv * env = GetEnvForCurrentThread(); jclass boxedTypeCls; - chip::JniReferences::GetInstance().GetClassRef(env, "java/lang/Long", boxedTypeCls); - chip::JniClass jniClass(boxedTypeCls); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "java/lang/Long", boxedTypeCls); jmethodID valueMethod = env->GetMethodID(boxedTypeCls, "longValue", "()J"); return env->CallLongMethod(boxedLong, valueMethod); @@ -326,8 +322,7 @@ jboolean JniReferences::BooleanToPrimitive(jobject boxedBoolean) { JNIEnv * env = GetEnvForCurrentThread(); jclass boxedTypeCls; - chip::JniReferences::GetInstance().GetClassRef(env, "java/lang/Boolean", boxedTypeCls); - chip::JniClass jniClass(boxedTypeCls); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "java/lang/Boolean", boxedTypeCls); jmethodID valueMethod = env->GetMethodID(boxedTypeCls, "booleanValue", "()Z"); return env->CallBooleanMethod(boxedBoolean, valueMethod); @@ -337,8 +332,7 @@ jfloat JniReferences::FloatToPrimitive(jobject boxedFloat) { JNIEnv * env = GetEnvForCurrentThread(); jclass boxedTypeCls; - chip::JniReferences::GetInstance().GetClassRef(env, "java/lang/Float", boxedTypeCls); - chip::JniClass jniClass(boxedTypeCls); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "java/lang/Float", boxedTypeCls); jmethodID valueMethod = env->GetMethodID(boxedTypeCls, "floatValue", "()F"); return env->CallFloatMethod(boxedFloat, valueMethod); @@ -348,8 +342,7 @@ jdouble JniReferences::DoubleToPrimitive(jobject boxedDouble) { JNIEnv * env = GetEnvForCurrentThread(); jclass boxedTypeCls; - chip::JniReferences::GetInstance().GetClassRef(env, "java/lang/Double", boxedTypeCls); - chip::JniClass jniClass(boxedTypeCls); + chip::JniReferences::GetInstance().GetLocalClassRef(env, "java/lang/Double", boxedTypeCls); jmethodID valueMethod = env->GetMethodID(boxedTypeCls, "doubleValue", "()D"); return env->CallDoubleMethod(boxedDouble, valueMethod); diff --git a/src/lib/support/JniTypeWrappers.h b/src/lib/support/JniTypeWrappers.h index 0b4999b644a435..f2f040e93d8e9e 100644 --- a/src/lib/support/JniTypeWrappers.h +++ b/src/lib/support/JniTypeWrappers.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2021-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. @@ -167,19 +167,6 @@ class ByteArray jbyteArray mArray = nullptr; }; -/// Manages an pre-existing global reference to a jclass. -class JniClass -{ -public: - explicit JniClass(jclass mClassRef) : mClassRef(mClassRef) {} - ~JniClass() { chip::JniReferences::GetInstance().GetEnvForCurrentThread()->DeleteGlobalRef(mClassRef); } - - jclass classRef() { return mClassRef; } - -private: - jclass mClassRef; -}; - // Manages an pre-existing global reference to a jobject. class JniGlobalRefWrapper { @@ -196,17 +183,18 @@ class JniGlobalRefWrapper jobject mGlobalRef = nullptr; }; -class JniLocalReferenceManager +class JniLocalReferenceScope { public: - JniLocalReferenceManager(JNIEnv * env) : mEnv(env) + explicit JniLocalReferenceScope(JNIEnv * env) : mEnv(env) { if (mEnv->PushLocalFrame(JNI_LOCAL_REF_COUNT) == 0) { mlocalFramePushed = true; } } - ~JniLocalReferenceManager() + + ~JniLocalReferenceScope() { if (mlocalFramePushed) { @@ -215,8 +203,12 @@ class JniLocalReferenceManager } } + // Delete copy constructor and copy assignment operator + JniLocalReferenceScope(const JniLocalReferenceScope &) = delete; + JniLocalReferenceScope & operator=(const JniLocalReferenceScope &) = delete; + private: - JNIEnv * mEnv = nullptr; + JNIEnv * const mEnv; bool mlocalFramePushed = false; }; 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/lib/support/tests/TestIntrusiveList.cpp b/src/lib/support/tests/TestIntrusiveList.cpp index afe7a1c07f548a..0d1779b00ac987 100644 --- a/src/lib/support/tests/TestIntrusiveList.cpp +++ b/src/lib/support/tests/TestIntrusiveList.cpp @@ -131,6 +131,35 @@ void TestContains(nlTestSuite * inSuite, void * inContext) list.Remove(&b); } +void TestClear(nlTestSuite * inSuite, void * inContext) +{ + ListNode a, b, c; + IntrusiveList list; + + NL_TEST_ASSERT(inSuite, !list.Contains(&a)); + NL_TEST_ASSERT(inSuite, !list.Contains(&b)); + NL_TEST_ASSERT(inSuite, !list.Contains(&c)); + + list.PushBack(&a); + list.PushFront(&c); + + NL_TEST_ASSERT(inSuite, list.Contains(&a)); + NL_TEST_ASSERT(inSuite, !list.Contains(&b)); + NL_TEST_ASSERT(inSuite, list.Contains(&c)); + + list.PushBack(&b); + + NL_TEST_ASSERT(inSuite, list.Contains(&a)); + NL_TEST_ASSERT(inSuite, list.Contains(&b)); + NL_TEST_ASSERT(inSuite, list.Contains(&c)); + + list.Clear(); + + NL_TEST_ASSERT(inSuite, !list.Contains(&a)); + NL_TEST_ASSERT(inSuite, !list.Contains(&b)); + NL_TEST_ASSERT(inSuite, !list.Contains(&c)); +} + void TestReplaceNode(nlTestSuite * inSuite, void * inContext) { ListNode a, b; @@ -242,6 +271,7 @@ static const nlTest sTests[] = { NL_TEST_DEF_FN(TestReplaceNode), // NL_TEST_DEF_FN(TestMoveList), // NL_TEST_DEF_FN(TestAutoUnlink), // + NL_TEST_DEF_FN(TestClear), // NL_TEST_SENTINEL(), // }; diff --git a/src/messaging/BUILD.gn b/src/messaging/BUILD.gn index 4c8ba1b9cb243c..7d402e78ee2306 100644 --- a/src/messaging/BUILD.gn +++ b/src/messaging/BUILD.gn @@ -67,7 +67,7 @@ static_library("messaging") { public_deps = [ ":messaging_mrp_config", - "${chip_root}/src/app/icd:icd_config", + "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/crypto", "${chip_root}/src/inet", "${chip_root}/src/lib/core", @@ -80,8 +80,8 @@ static_library("messaging") { if (chip_enable_icd_server) { public_deps += [ - "${chip_root}/src/app/icd:configuration-data", - "${chip_root}/src/app/icd:notifier", + "${chip_root}/src/app/icd/server:configuration-data", + "${chip_root}/src/app/icd/server:notifier", ] } } diff --git a/src/messaging/ExchangeContext.cpp b/src/messaging/ExchangeContext.cpp index af3b87c5337703..15522ebcb76d77 100644 --- a/src/messaging/ExchangeContext.cpp +++ b/src/messaging/ExchangeContext.cpp @@ -32,9 +32,9 @@ #include #include -#include +#include #if CHIP_CONFIG_ENABLE_ICD_SERVER -#include // nogncheck +#include // nogncheck #endif #include #include diff --git a/src/messaging/ReliableMessageMgr.cpp b/src/messaging/ReliableMessageMgr.cpp index d4e2457d178098..2db80c5ffd337e 100644 --- a/src/messaging/ReliableMessageMgr.cpp +++ b/src/messaging/ReliableMessageMgr.cpp @@ -37,8 +37,8 @@ #include #if CHIP_CONFIG_ENABLE_ICD_SERVER -#include // nogncheck -#include // nogncheck +#include // nogncheck +#include // nogncheck #endif using namespace chip::System::Clock::Literals; diff --git a/src/messaging/ReliableMessageProtocolConfig.cpp b/src/messaging/ReliableMessageProtocolConfig.cpp index 46d4b4b675b405..67e199779c3bcd 100644 --- a/src/messaging/ReliableMessageProtocolConfig.cpp +++ b/src/messaging/ReliableMessageProtocolConfig.cpp @@ -30,7 +30,7 @@ #include #if CHIP_CONFIG_ENABLE_ICD_SERVER -#include // nogncheck +#include // nogncheck #endif namespace chip { diff --git a/src/messaging/tests/BUILD.gn b/src/messaging/tests/BUILD.gn index db09de5034e253..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,11 +77,10 @@ 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", ] if (chip_enable_icd_server) { - public_deps += [ "${chip_root}/src/app/icd:configuration-data" ] + public_deps += [ "${chip_root}/src/app/icd/server:configuration-data" ] } } diff --git a/src/messaging/tests/TestAbortExchangesForFabric.cpp b/src/messaging/tests/TestAbortExchangesForFabric.cpp index 4c2d682441ab82..455462bb14e2e4 100644 --- a/src/messaging/tests/TestAbortExchangesForFabric.cpp +++ b/src/messaging/tests/TestAbortExchangesForFabric.cpp @@ -33,7 +33,7 @@ #include #if CHIP_CONFIG_ENABLE_ICD_SERVER -#include // nogncheck +#include // nogncheck #endif namespace { diff --git a/src/messaging/tests/TestReliableMessageProtocol.cpp b/src/messaging/tests/TestReliableMessageProtocol.cpp index db5dc144b0c2ae..cfdd00bff624f5 100644 --- a/src/messaging/tests/TestReliableMessageProtocol.cpp +++ b/src/messaging/tests/TestReliableMessageProtocol.cpp @@ -46,7 +46,7 @@ #include #if CHIP_CONFIG_ENABLE_ICD_SERVER -#include // nogncheck +#include // nogncheck #endif namespace { diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index c81a268849fa1e..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") @@ -111,11 +110,20 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { chip_enable_wifi && chip_device_platform != "darwin" chip_stack_lock_tracking_log = chip_stack_lock_tracking != "none" chip_stack_lock_tracking_fatal = chip_stack_lock_tracking == "fatal" + + # This is used to identify which platforms implement their ThreadStackManager + # with the otbr posix dbus api. + chip_device_uses_otbr_posix_dbus = + chip_enable_openthread && + (chip_device_platform == "linux" || chip_device_platform == "tizen" || + chip_device_platform == "webos") + defines = [ "CHIP_DEVICE_CONFIG_ENABLE_WPA=${chip_device_config_enable_wpa}", "CHIP_ENABLE_OPENTHREAD=${chip_enable_openthread}", "CHIP_DEVICE_CONFIG_THREAD_FTD=${chip_device_config_thread_ftd}", "CHIP_DEVICE_CONFIG_THREAD_BORDER_ROUTER=${chip_openthread_border_router}", + "CHIP_DEVICE_CONFIG_USES_OTBR_POSIX_DBUS_STACK=${chip_device_uses_otbr_posix_dbus}", "CHIP_STACK_LOCK_TRACKING_ENABLED=${chip_stack_lock_tracking_log}", "CHIP_STACK_LOCK_TRACKING_ERROR_FATAL=${chip_stack_lock_tracking_fatal}", "CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING=${chip_enable_additional_data_advertising}", @@ -507,7 +515,7 @@ if (chip_device_platform != "none") { ":platform_base", "${chip_root}/src/app:app_config", "${chip_root}/src/app/common:cluster-objects", - "${chip_root}/src/app/icd:icd_config", + "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/credentials:build_time_header", "${chip_root}/src/crypto", "${chip_root}/src/lib/support", diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index e1ce775d071901..c532c975e22319 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -576,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, mDeviceName)); + SuccessOrExit(err = mEndpoint.Init(mAdapterId, mIsCentral, nullptr)); mFlags.Set(Flags::kBluezBLELayerInitialized); } @@ -600,7 +600,7 @@ void BLEManagerImpl::DriveBLEState() // Configure advertising data if it hasn't been done yet. if (!mFlags.Has(Flags::kAdvertisingConfigured)) { - SuccessOrExit(err = mBLEAdvertisement.Init(mEndpoint, mpBLEAdvUUID)); + SuccessOrExit(err = mBLEAdvertisement.Init(mEndpoint, mpBLEAdvUUID, mDeviceName)); mFlags.Set(Flags::kAdvertisingConfigured); } diff --git a/src/platform/Linux/DnssdImpl.cpp b/src/platform/Linux/DnssdImpl.cpp index 5f46dd24d8728f..2a1873072fbb9e 100644 --- a/src/platform/Linux/DnssdImpl.cpp +++ b/src/platform/Linux/DnssdImpl.cpp @@ -893,7 +893,7 @@ void MdnsAvahi::HandleResolve(AvahiServiceResolver * resolver, AvahiIfIndex inte avahi_service_resolver_free(resolver); context->mResolver = avahi_service_resolver_new( context->mInstance->mClient, context->mInterface, context->mTransport, context->mName, context->mFullType.c_str(), - nullptr, context->mAddressType, static_cast(0), HandleResolve, context); + nullptr, context->mAddressType, static_cast(0), HandleResolve, userdata); if (context->mResolver == nullptr) { ChipLogError(DeviceLayer, "Avahi resolve failed on retry"); diff --git a/src/platform/Linux/ThreadStackManagerImpl.cpp b/src/platform/Linux/ThreadStackManagerImpl.cpp index 1eb5958bef17af..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; @@ -715,174 +711,6 @@ void ThreadStackManagerImpl::_OnNetworkScanFinished(GAsyncResult * res) void ThreadStackManagerImpl::_ResetThreadNetworkDiagnosticsCounts() {} -CHIP_ERROR ThreadStackManagerImpl::_WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, - app::AttributeValueEncoder & encoder) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - switch (attributeId) - { - case ThreadNetworkDiagnostics::Attributes::NeighborTable::Id: - case ThreadNetworkDiagnostics::Attributes::RouteTable::Id: - case ThreadNetworkDiagnostics::Attributes::ActiveNetworkFaultsList::Id: - err = encoder.EncodeEmptyList(); - break; - case ThreadNetworkDiagnostics::Attributes::Channel::Id: - case ThreadNetworkDiagnostics::Attributes::RoutingRole::Id: - case ThreadNetworkDiagnostics::Attributes::NetworkName::Id: - case ThreadNetworkDiagnostics::Attributes::PanId::Id: - case ThreadNetworkDiagnostics::Attributes::ExtendedPanId::Id: - case ThreadNetworkDiagnostics::Attributes::MeshLocalPrefix::Id: - case ThreadNetworkDiagnostics::Attributes::PartitionId::Id: - case ThreadNetworkDiagnostics::Attributes::Weighting::Id: - case ThreadNetworkDiagnostics::Attributes::DataVersion::Id: - case ThreadNetworkDiagnostics::Attributes::StableDataVersion::Id: - case ThreadNetworkDiagnostics::Attributes::LeaderRouterId::Id: - case ThreadNetworkDiagnostics::Attributes::ActiveTimestamp::Id: - case ThreadNetworkDiagnostics::Attributes::PendingTimestamp::Id: - case ThreadNetworkDiagnostics::Attributes::Delay::Id: - case ThreadNetworkDiagnostics::Attributes::ChannelPage0Mask::Id: - case ThreadNetworkDiagnostics::Attributes::SecurityPolicy::Id: - case ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::Id: - err = encoder.EncodeNull(); - break; - case ThreadNetworkDiagnostics::Attributes::OverrunCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::DetachedRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::ChildRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RouterRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::LeaderRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::AttachAttemptCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::PartitionIdChangeCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::BetterPartitionAttachAttemptCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::ParentChangeCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxTotalCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxUnicastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxBroadcastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxAckRequestedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxAckedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxNoAckRequestedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxDataCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxDataPollCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxBeaconCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxBeaconRequestCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxRetryCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxDirectMaxRetryExpiryCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxIndirectMaxRetryExpiryCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxErrCcaCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxErrAbortCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxErrBusyChannelCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxTotalCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxUnicastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxBroadcastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDataCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDataPollCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxBeaconCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxBeaconRequestCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxAddressFilteredCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDestAddrFilteredCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDuplicatedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrNoFrameCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrUnknownNeighborCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrInvalidSrcAddrCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrSecCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrFcsCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - default: - err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; - break; - } - - return err; -} - CHIP_ERROR ThreadStackManagerImpl::_AttachToThreadNetwork(const Thread::OperationalDataset & dataset, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback) diff --git a/src/platform/Linux/ThreadStackManagerImpl.h b/src/platform/Linux/ThreadStackManagerImpl.h index 5e077cba3bd1fe..977c6b94d0027f 100755 --- a/src/platform/Linux/ThreadStackManagerImpl.h +++ b/src/platform/Linux/ThreadStackManagerImpl.h @@ -115,8 +115,6 @@ class ThreadStackManagerImpl : public ThreadStackManager void _ResetThreadNetworkDiagnosticsCounts(); - CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); - CHIP_ERROR _StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback); ~ThreadStackManagerImpl() = default; diff --git a/src/platform/Linux/bluez/BluezAdvertisement.cpp b/src/platform/Linux/bluez/BluezAdvertisement.cpp index cc4bed5f485241..db74da8bec1ec4 100644 --- a/src/platform/Linux/bluez/BluezAdvertisement.cpp +++ b/src/platform/Linux/bluez/BluezAdvertisement.cpp @@ -44,8 +44,6 @@ BluezLEAdvertisement1 * BluezAdvertisement::CreateLEAdvertisement() BluezObjectSkeleton * object; GVariant * serviceUUID; GVariantBuilder serviceUUIDsBuilder; - const char * localNamePtr; - char localName[32]; ChipLogDetail(DeviceLayer, "Create BLE adv object at %s", mpAdvPath); object = bluez_object_skeleton_new(mpAdvPath); @@ -55,13 +53,6 @@ BluezLEAdvertisement1 * BluezAdvertisement::CreateLEAdvertisement() g_variant_builder_init(&serviceUUIDsBuilder, G_VARIANT_TYPE("as")); g_variant_builder_add(&serviceUUIDsBuilder, "s", mpAdvUUID); - localNamePtr = mpAdapterName; - if (localNamePtr == nullptr) - { - g_snprintf(localName, sizeof(localName), "%s%04x", CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, getpid() & 0xffff); - localNamePtr = localName; - } - serviceUUID = g_variant_builder_end(&serviceUUIDsBuilder); bluez_leadvertisement1_set_type_(adv, "peripheral"); @@ -77,7 +68,7 @@ BluezLEAdvertisement1 * BluezAdvertisement::CreateLEAdvertisement() bluez_leadvertisement1_set_discoverable_timeout(adv, 0 /* infinite */); // empty includes - bluez_leadvertisement1_set_local_name(adv, localNamePtr); + bluez_leadvertisement1_set_local_name(adv, mAdvName); bluez_leadvertisement1_set_appearance(adv, 0xffff /* no appearance */); // empty duration // empty timeout @@ -116,7 +107,7 @@ CHIP_ERROR BluezAdvertisement::InitImpl() return CHIP_NO_ERROR; } -CHIP_ERROR BluezAdvertisement::Init(const BluezEndpoint & aEndpoint, const char * aAdvUUID) +CHIP_ERROR BluezAdvertisement::Init(const BluezEndpoint & aEndpoint, const char * aAdvUUID, const char * aAdvName) { GAutoPtr rootPath; CHIP_ERROR err; @@ -124,14 +115,23 @@ CHIP_ERROR BluezAdvertisement::Init(const BluezEndpoint & aEndpoint, const char VerifyOrExit(mpAdv == nullptr, err = CHIP_ERROR_INCORRECT_STATE; ChipLogError(DeviceLayer, "FAIL: BLE advertisement already initialized in %s", __func__)); - mpRoot = reinterpret_cast(g_object_ref(aEndpoint.GetGattApplicationObjectManager())); - mpAdapter = reinterpret_cast(g_object_ref(aEndpoint.GetAdapter())); - mpAdapterName = g_strdup(aEndpoint.GetAdapterName()); + mpRoot = reinterpret_cast(g_object_ref(aEndpoint.GetGattApplicationObjectManager())); + 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()); mpAdvUUID = g_strdup(aAdvUUID); + if (aAdvName != nullptr) + { + g_snprintf(mAdvName, sizeof(mAdvName), "%s", aAdvName); + } + else + { + // Advertising name corresponding to the PID, for debug purposes. + g_snprintf(mAdvName, sizeof(mAdvName), "%s%04x", CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, getpid() & 0xffff); + } + err = PlatformMgrImpl().GLibMatterContextInvokeSync( +[](BluezAdvertisement * self) { return self->InitImpl(); }, this); VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INCORRECT_STATE, @@ -229,8 +229,6 @@ void BluezAdvertisement::Shutdown() g_free(mpAdvPath); mpAdvPath = nullptr; - g_free(mpAdapterName); - mpAdapterName = nullptr; g_free(mpAdvUUID); mpAdvUUID = nullptr; diff --git a/src/platform/Linux/bluez/BluezAdvertisement.h b/src/platform/Linux/bluez/BluezAdvertisement.h index a82a024fcea1fe..11fe51c8e7cdb9 100644 --- a/src/platform/Linux/bluez/BluezAdvertisement.h +++ b/src/platform/Linux/bluez/BluezAdvertisement.h @@ -49,7 +49,7 @@ class BluezAdvertisement BluezAdvertisement() = default; ~BluezAdvertisement() { Shutdown(); } - CHIP_ERROR Init(const BluezEndpoint & aEndpoint, const char * aAdvUUID); + CHIP_ERROR Init(const BluezEndpoint & aEndpoint, const char * aAdvUUID, const char * aAdvName); CHIP_ERROR SetupServiceData(ServiceDataFlags aFlags); CHIP_ERROR SetIntervals(AdvertisingIntervals aAdvIntervals); void Shutdown(); @@ -86,9 +86,9 @@ class BluezAdvertisement bool mIsInitialized = false; bool mIsAdvertising = false; - char * mpAdvPath = nullptr; - char * mpAdapterName = nullptr; - char * mpAdvUUID = nullptr; + 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 4c315f11a7d581..24614eba63d24f 100644 --- a/src/platform/Linux/bluez/BluezEndpoint.cpp +++ b/src/platform/Linux/bluez/BluezEndpoint.cpp @@ -617,12 +617,6 @@ CHIP_ERROR BluezEndpoint::StartupEndpointBindings() VerifyOrReturnError(conn != nullptr, CHIP_ERROR_INTERNAL, ChipLogError(DeviceLayer, "FAIL: get bus sync in %s, error: %s", __func__, err->message)); - if (mpAdapterName != nullptr) - mpOwningName = g_strdup_printf("%s", mpAdapterName); - else - mpOwningName = g_strdup_printf("C-%04x", getpid() & 0xffff); - ChipLogDetail(DeviceLayer, "TRACE: Bus acquired for name %s", mpOwningName); - SetupGattServer(conn.get()); mpObjMgr = g_dbus_object_manager_client_new_sync( @@ -662,7 +656,7 @@ CHIP_ERROR BluezEndpoint::RegisterGattApplication() return err; } -CHIP_ERROR BluezEndpoint::Init(uint32_t aAdapterId, bool aIsCentral, const char * apBleAddr, const char * apBleName) +CHIP_ERROR BluezEndpoint::Init(uint32_t aAdapterId, bool aIsCentral, const char * apBleAddr) { CHIP_ERROR err; @@ -672,11 +666,7 @@ CHIP_ERROR BluezEndpoint::Init(uint32_t aAdapterId, bool aIsCentral, const char if (apBleAddr != nullptr) mpAdapterAddr = g_strdup(apBleAddr); - if (!aIsCentral) - { - mpAdapterName = g_strdup(apBleName); - } - else + if (aIsCentral) { mpConnectCancellable = g_cancellable_new(); } @@ -723,8 +713,6 @@ void BluezEndpoint::Shutdown() }, this); - g_free(mpOwningName); - g_free(mpAdapterName); g_free(mpAdapterAddr); g_free(mpRootPath); g_free(mpServicePath); diff --git a/src/platform/Linux/bluez/BluezEndpoint.h b/src/platform/Linux/bluez/BluezEndpoint.h index 24b7ad140cde65..397b5a1597168b 100644 --- a/src/platform/Linux/bluez/BluezEndpoint.h +++ b/src/platform/Linux/bluez/BluezEndpoint.h @@ -69,11 +69,10 @@ class BluezEndpoint BluezEndpoint() = default; ~BluezEndpoint() = default; - CHIP_ERROR Init(uint32_t aAdapterId, bool aIsCentral, const char * apBleAddr, const char * apBleName); + CHIP_ERROR Init(uint32_t aAdapterId, bool aIsCentral, const char * apBleAddr); void Shutdown(); BluezAdapter1 * GetAdapter() const { return mpAdapter; } - const char * GetAdapterName() const { return mpAdapterName; } CHIP_ERROR RegisterGattApplication(); GDBusObjectManagerServer * GetGattApplicationObjectManager() const { return mpRoot; } @@ -127,12 +126,8 @@ class BluezEndpoint bool mIsCentral = false; bool mIsInitialized = false; - // Bus owning name - char * mpOwningName = nullptr; - // Adapter properties uint32_t mAdapterId = 0; - char * mpAdapterName = nullptr; char * mpAdapterAddr = nullptr; // Paths for objects published by this service diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h index ccc3f65e3f6cad..161c2b202a8310 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h @@ -37,7 +37,6 @@ #include #endif -#include #include #include #include @@ -111,7 +110,6 @@ class GenericThreadStackManagerImpl_OpenThread CHIP_ERROR _GetPrimary802154MACAddress(uint8_t * buf); CHIP_ERROR _GetExternalIPv6Address(chip::Inet::IPAddress & addr); void _ResetThreadNetworkDiagnosticsCounts(void); - CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); CHIP_ERROR _GetPollPeriod(uint32_t & buf); void _OnWoBLEAdvertisingStart(void); void _OnWoBLEAdvertisingStop(void); diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp index c1fd8635d33eb0..acc0c78d0c8eb7 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp @@ -45,7 +45,6 @@ #include #endif -#include #include #include #include @@ -59,11 +58,6 @@ #include #include -#include -#include -#include -#include - #include extern "C" void otSysProcessDrivers(otInstance * aInstance); @@ -1036,652 +1030,6 @@ void GenericThreadStackManagerImpl_OpenThread::_ResetThreadNetworkDia // Based on the spec, only OverrunCount should be resetted. mOverrunCount = 0; } -/* - * @brief Get runtime value from the thread network based on the given attribute ID. - * The info is encoded via the AttributeValueEncoder. - * - * @param attributeId Id of the attribute for the requested info. - * @param aEncoder Encoder to encode the attribute value. - * - * @return CHIP_NO_ERROR = Succes. - * CHIP_ERROR_NOT_IMPLEMENTED = Runtime value for this attribute to yet available to send as reply - * Use standard read. - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE = Is not a Runtime readable attribute. Use standard read - * All other errors should be treated as a read error and reported as such. - */ -template -CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_WriteThreadNetworkDiagnosticAttributeToTlv( - AttributeId attributeId, app::AttributeValueEncoder & encoder) -{ - CHIP_ERROR err; - - namespace ThreadNetworkDiagnostics = app::Clusters::ThreadNetworkDiagnostics; - - if (!otDatasetIsCommissioned(mOTInst)) - { - // For the following nullable attributes of the cluster, encodeNull since - // thread instance cannot provide the related data when it is not currently configured. - // - // Note that RoutingRole is nullable but not listed here as thread provides - // valid data even when disabled or detached - switch (attributeId) - { - case ThreadNetworkDiagnostics::Attributes::Channel::Id: - case ThreadNetworkDiagnostics::Attributes::NetworkName::Id: - case ThreadNetworkDiagnostics::Attributes::PanId::Id: - case ThreadNetworkDiagnostics::Attributes::ExtendedPanId::Id: - case ThreadNetworkDiagnostics::Attributes::MeshLocalPrefix::Id: - case ThreadNetworkDiagnostics::Attributes::PartitionId::Id: - case ThreadNetworkDiagnostics::Attributes::Weighting::Id: - case ThreadNetworkDiagnostics::Attributes::DataVersion::Id: - case ThreadNetworkDiagnostics::Attributes::StableDataVersion::Id: - case ThreadNetworkDiagnostics::Attributes::LeaderRouterId::Id: - case ThreadNetworkDiagnostics::Attributes::ActiveTimestamp::Id: - case ThreadNetworkDiagnostics::Attributes::PendingTimestamp::Id: - case ThreadNetworkDiagnostics::Attributes::Delay::Id: - case ThreadNetworkDiagnostics::Attributes::SecurityPolicy::Id: - case ThreadNetworkDiagnostics::Attributes::ChannelPage0Mask::Id: - case ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::Id: - return encoder.EncodeNull(); - } - } - - switch (attributeId) - { - case ThreadNetworkDiagnostics::Attributes::Channel::Id: { - uint16_t channel = otLinkGetChannel(mOTInst); - err = encoder.Encode(channel); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RoutingRole::Id: { - using ThreadNetworkDiagnostics::RoutingRoleEnum; - RoutingRoleEnum routingRole; - otDeviceRole otRole = otThreadGetDeviceRole(mOTInst); - - if (otRole == OT_DEVICE_ROLE_DISABLED) - { - routingRole = RoutingRoleEnum::kUnspecified; - } - else if (otRole == OT_DEVICE_ROLE_DETACHED) - { - routingRole = RoutingRoleEnum::kUnassigned; - } - else if (otRole == OT_DEVICE_ROLE_ROUTER) - { - routingRole = RoutingRoleEnum::kRouter; - } - else if (otRole == OT_DEVICE_ROLE_LEADER) - { - routingRole = RoutingRoleEnum::kLeader; - } - else if (otRole == OT_DEVICE_ROLE_CHILD) - { - otLinkModeConfig linkMode = otThreadGetLinkMode(mOTInst); - - if (linkMode.mRxOnWhenIdle) - { - routingRole = RoutingRoleEnum::kEndDevice; -#if CHIP_DEVICE_CONFIG_THREAD_FTD - if (otThreadIsRouterEligible(mOTInst)) - { - routingRole = RoutingRoleEnum::kReed; - } -#endif - } - else - { - routingRole = RoutingRoleEnum::kSleepyEndDevice; - } - } - - err = encoder.Encode(routingRole); - } - break; - - case ThreadNetworkDiagnostics::Attributes::NetworkName::Id: { - const char * networkName = otThreadGetNetworkName(mOTInst); - err = encoder.Encode(CharSpan::fromCharString(networkName)); - } - break; - - case ThreadNetworkDiagnostics::Attributes::PanId::Id: { - uint16_t panId = otLinkGetPanId(mOTInst); - err = encoder.Encode(panId); - } - break; - - case ThreadNetworkDiagnostics::Attributes::ExtendedPanId::Id: { - const otExtendedPanId * pExtendedPanid = otThreadGetExtendedPanId(mOTInst); - err = encoder.Encode(Encoding::BigEndian::Get64(pExtendedPanid->m8)); - } - break; - - case ThreadNetworkDiagnostics::Attributes::MeshLocalPrefix::Id: { - uint8_t meshLocaPrefix[OT_MESH_LOCAL_PREFIX_SIZE + 1] = { 0 }; // + 1 to encode prefix Len in the octstr - - const otMeshLocalPrefix * pMeshLocalPrefix = otThreadGetMeshLocalPrefix(mOTInst); - meshLocaPrefix[0] = OT_IP6_PREFIX_BITSIZE; - - memcpy(&meshLocaPrefix[1], pMeshLocalPrefix->m8, OT_MESH_LOCAL_PREFIX_SIZE); - err = encoder.Encode(ByteSpan(meshLocaPrefix)); - } - break; - - case ThreadNetworkDiagnostics::Attributes::OverrunCount::Id: { - uint64_t overrunCount = mOverrunCount; - err = encoder.Encode(overrunCount); - } - break; - - case ThreadNetworkDiagnostics::Attributes::NeighborTable::Id: { - err = encoder.EncodeList([this](const auto & aEncoder) -> CHIP_ERROR { - constexpr uint16_t kFrameErrorRate100Percent = 0xffff; - constexpr uint16_t kMessageErrorRate100Percent = 0xffff; - - otNeighborInfo neighInfo; - otNeighborInfoIterator iterator = OT_NEIGHBOR_INFO_ITERATOR_INIT; - - while (otThreadGetNextNeighborInfo(mOTInst, &iterator, &neighInfo) == OT_ERROR_NONE) - { - ThreadNetworkDiagnostics::Structs::NeighborTableStruct::Type neighborTable; - app::DataModel::Nullable averageRssi; - app::DataModel::Nullable lastRssi; - - if (neighInfo.mAverageRssi == OT_RADIO_RSSI_INVALID) - { - averageRssi.SetNull(); - } - else - { - // Thread average calculation already restrict mAverageRssi to be between -128 and 0 - averageRssi.SetNonNull(neighInfo.mAverageRssi); - } - - if (neighInfo.mLastRssi == OT_RADIO_RSSI_INVALID) - { - lastRssi.SetNull(); - } - else - { - lastRssi.SetNonNull(min(static_cast(0), neighInfo.mLastRssi)); - } - - neighborTable.averageRssi = averageRssi; - neighborTable.lastRssi = lastRssi; - neighborTable.extAddress = Encoding::BigEndian::Get64(neighInfo.mExtAddress.m8); - neighborTable.age = neighInfo.mAge; - neighborTable.rloc16 = neighInfo.mRloc16; - neighborTable.linkFrameCounter = neighInfo.mLinkFrameCounter; - neighborTable.mleFrameCounter = neighInfo.mMleFrameCounter; - neighborTable.lqi = neighInfo.mLinkQualityIn; - neighborTable.frameErrorRate = - static_cast((static_cast(neighInfo.mFrameErrorRate) * 100) / kFrameErrorRate100Percent); - neighborTable.messageErrorRate = - static_cast((static_cast(neighInfo.mMessageErrorRate) * 100) / kMessageErrorRate100Percent); - neighborTable.rxOnWhenIdle = neighInfo.mRxOnWhenIdle; - neighborTable.fullThreadDevice = neighInfo.mFullThreadDevice; - neighborTable.fullNetworkData = neighInfo.mFullNetworkData; - neighborTable.isChild = neighInfo.mIsChild; - - ReturnErrorOnFailure(aEncoder.Encode(neighborTable)); - } - - return CHIP_NO_ERROR; - }); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RouteTable::Id: { - err = encoder.EncodeList([this](const auto & aEncoder) -> CHIP_ERROR { - otRouterInfo routerInfo; - -#if CHIP_DEVICE_CONFIG_THREAD_FTD - uint8_t maxRouterId = otThreadGetMaxRouterId(mOTInst); - CHIP_ERROR chipErr = CHIP_ERROR_INCORRECT_STATE; - - for (uint8_t i = 0; i <= maxRouterId; i++) - { - if (otThreadGetRouterInfo(mOTInst, i, &routerInfo) == OT_ERROR_NONE) - { - ThreadNetworkDiagnostics::Structs::RouteTableStruct::Type routeTable; - - routeTable.extAddress = Encoding::BigEndian::Get64(routerInfo.mExtAddress.m8); - routeTable.rloc16 = routerInfo.mRloc16; - routeTable.routerId = routerInfo.mRouterId; - routeTable.nextHop = routerInfo.mNextHop; - routeTable.pathCost = routerInfo.mPathCost; - routeTable.LQIIn = routerInfo.mLinkQualityIn; - routeTable.LQIOut = routerInfo.mLinkQualityOut; - routeTable.age = routerInfo.mAge; - routeTable.allocated = routerInfo.mAllocated; - routeTable.linkEstablished = routerInfo.mLinkEstablished; - - ReturnErrorOnFailure(aEncoder.Encode(routeTable)); - chipErr = CHIP_NO_ERROR; - } - } - - return chipErr; - -#else // OPENTHREAD_MTD - otError otErr = otThreadGetParentInfo(mOTInst, &routerInfo); - ReturnErrorOnFailure(MapOpenThreadError(otErr)); - - ThreadNetworkDiagnostics::Structs::RouteTableStruct::Type routeTable; - - routeTable.extAddress = Encoding::BigEndian::Get64(routerInfo.mExtAddress.m8); - routeTable.rloc16 = routerInfo.mRloc16; - routeTable.routerId = routerInfo.mRouterId; - routeTable.nextHop = routerInfo.mNextHop; - routeTable.pathCost = routerInfo.mPathCost; - routeTable.LQIIn = routerInfo.mLinkQualityIn; - routeTable.LQIOut = routerInfo.mLinkQualityOut; - routeTable.age = routerInfo.mAge; - routeTable.allocated = routerInfo.mAllocated; - routeTable.linkEstablished = routerInfo.mLinkEstablished; - - ReturnErrorOnFailure(aEncoder.Encode(routeTable)); - return CHIP_NO_ERROR; -#endif - }); - } - break; - - case ThreadNetworkDiagnostics::Attributes::PartitionId::Id: { - uint32_t partitionId = otThreadGetPartitionId(mOTInst); - err = encoder.Encode(partitionId); - } - break; - - case ThreadNetworkDiagnostics::Attributes::Weighting::Id: { - uint8_t weight = otThreadGetLeaderWeight(mOTInst); - err = encoder.Encode(weight); - } - break; - - case ThreadNetworkDiagnostics::Attributes::DataVersion::Id: { - uint8_t dataVersion = otNetDataGetVersion(mOTInst); - err = encoder.Encode(dataVersion); - } - break; - - case ThreadNetworkDiagnostics::Attributes::StableDataVersion::Id: { - uint8_t stableVersion = otNetDataGetStableVersion(mOTInst); - err = encoder.Encode(stableVersion); - } - break; - - case ThreadNetworkDiagnostics::Attributes::LeaderRouterId::Id: { - uint8_t leaderRouterId = otThreadGetLeaderRouterId(mOTInst); - err = encoder.Encode(leaderRouterId); - } - break; - - case ThreadNetworkDiagnostics::Attributes::DetachedRoleCount::Id: { - uint16_t detachedRole = otThreadGetMleCounters(mOTInst)->mDetachedRole; - err = encoder.Encode(detachedRole); - } - break; - - case ThreadNetworkDiagnostics::Attributes::ChildRoleCount::Id: { - uint16_t childRole = otThreadGetMleCounters(mOTInst)->mChildRole; - err = encoder.Encode(childRole); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RouterRoleCount::Id: { - uint16_t routerRole = otThreadGetMleCounters(mOTInst)->mRouterRole; - err = encoder.Encode(routerRole); - } - break; - - case ThreadNetworkDiagnostics::Attributes::LeaderRoleCount::Id: { - uint16_t leaderRole = otThreadGetMleCounters(mOTInst)->mLeaderRole; - err = encoder.Encode(leaderRole); - } - break; - - case ThreadNetworkDiagnostics::Attributes::AttachAttemptCount::Id: { - uint16_t attachAttempts = otThreadGetMleCounters(mOTInst)->mAttachAttempts; - err = encoder.Encode(attachAttempts); - } - break; - - case ThreadNetworkDiagnostics::Attributes::PartitionIdChangeCount::Id: { - uint16_t partitionIdChanges = otThreadGetMleCounters(mOTInst)->mPartitionIdChanges; - err = encoder.Encode(partitionIdChanges); - } - break; - - case ThreadNetworkDiagnostics::Attributes::BetterPartitionAttachAttemptCount::Id: { - uint16_t betterPartitionAttachAttempts = otThreadGetMleCounters(mOTInst)->mBetterPartitionAttachAttempts; - err = encoder.Encode(betterPartitionAttachAttempts); - } - break; - - case ThreadNetworkDiagnostics::Attributes::ParentChangeCount::Id: { - uint16_t parentChanges = otThreadGetMleCounters(mOTInst)->mParentChanges; - err = encoder.Encode(parentChanges); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxTotalCount::Id: { - uint32_t txTotal = otLinkGetCounters(mOTInst)->mTxTotal; - err = encoder.Encode(txTotal); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxUnicastCount::Id: { - uint32_t txUnicast = otLinkGetCounters(mOTInst)->mTxUnicast; - err = encoder.Encode(txUnicast); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxBroadcastCount::Id: { - uint32_t txBroadcast = otLinkGetCounters(mOTInst)->mTxBroadcast; - err = encoder.Encode(txBroadcast); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxAckRequestedCount::Id: { - uint32_t txAckRequested = otLinkGetCounters(mOTInst)->mTxAckRequested; - err = encoder.Encode(txAckRequested); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxAckedCount::Id: { - uint32_t txAcked = otLinkGetCounters(mOTInst)->mTxAcked; - err = encoder.Encode(txAcked); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxNoAckRequestedCount::Id: { - uint32_t txNoAckRequested = otLinkGetCounters(mOTInst)->mTxNoAckRequested; - err = encoder.Encode(txNoAckRequested); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxDataCount::Id: { - uint32_t txData = otLinkGetCounters(mOTInst)->mTxData; - err = encoder.Encode(txData); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxDataPollCount::Id: { - uint32_t txDataPoll = otLinkGetCounters(mOTInst)->mTxDataPoll; - err = encoder.Encode(txDataPoll); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxBeaconCount::Id: { - uint32_t txBeacon = otLinkGetCounters(mOTInst)->mTxBeacon; - err = encoder.Encode(txBeacon); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxBeaconRequestCount::Id: { - uint32_t txBeaconRequest = otLinkGetCounters(mOTInst)->mTxBeaconRequest; - err = encoder.Encode(txBeaconRequest); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxOtherCount::Id: { - uint32_t txOther = otLinkGetCounters(mOTInst)->mTxOther; - err = encoder.Encode(txOther); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxRetryCount::Id: { - uint32_t txRetry = otLinkGetCounters(mOTInst)->mTxRetry; - err = encoder.Encode(txRetry); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxDirectMaxRetryExpiryCount::Id: { - uint32_t txDirectMaxRetryExpiry = otLinkGetCounters(mOTInst)->mTxDirectMaxRetryExpiry; - err = encoder.Encode(txDirectMaxRetryExpiry); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxIndirectMaxRetryExpiryCount::Id: { - uint32_t txIndirectMaxRetryExpiry = otLinkGetCounters(mOTInst)->mTxIndirectMaxRetryExpiry; - err = encoder.Encode(txIndirectMaxRetryExpiry); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxErrCcaCount::Id: { - uint32_t txErrCca = otLinkGetCounters(mOTInst)->mTxErrCca; - err = encoder.Encode(txErrCca); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxErrAbortCount::Id: { - uint32_t TxErrAbort = otLinkGetCounters(mOTInst)->mTxErrAbort; - err = encoder.Encode(TxErrAbort); - } - break; - - case ThreadNetworkDiagnostics::Attributes::TxErrBusyChannelCount::Id: { - uint32_t TxErrBusyChannel = otLinkGetCounters(mOTInst)->mTxErrBusyChannel; - err = encoder.Encode(TxErrBusyChannel); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxTotalCount::Id: { - uint32_t rxTotal = otLinkGetCounters(mOTInst)->mRxTotal; - err = encoder.Encode(rxTotal); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxUnicastCount::Id: { - uint32_t rxUnicast = otLinkGetCounters(mOTInst)->mRxUnicast; - err = encoder.Encode(rxUnicast); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxBroadcastCount::Id: { - uint32_t rxBroadcast = otLinkGetCounters(mOTInst)->mRxBroadcast; - err = encoder.Encode(rxBroadcast); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxDataCount::Id: { - uint32_t rxData = otLinkGetCounters(mOTInst)->mRxData; - err = encoder.Encode(rxData); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxDataPollCount::Id: { - uint32_t rxDataPoll = otLinkGetCounters(mOTInst)->mRxDataPoll; - err = encoder.Encode(rxDataPoll); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxBeaconCount::Id: { - uint32_t rxBeacon = otLinkGetCounters(mOTInst)->mRxBeacon; - err = encoder.Encode(rxBeacon); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxBeaconRequestCount::Id: { - uint32_t rxBeaconRequest = otLinkGetCounters(mOTInst)->mRxBeaconRequest; - err = encoder.Encode(rxBeaconRequest); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxOtherCount::Id: { - uint32_t rxOther = otLinkGetCounters(mOTInst)->mRxOther; - err = encoder.Encode(rxOther); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxAddressFilteredCount::Id: { - uint32_t rxAddressFiltered = otLinkGetCounters(mOTInst)->mRxAddressFiltered; - err = encoder.Encode(rxAddressFiltered); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxDestAddrFilteredCount::Id: { - uint32_t rxDestAddrFiltered = otLinkGetCounters(mOTInst)->mRxDestAddrFiltered; - err = encoder.Encode(rxDestAddrFiltered); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxDuplicatedCount::Id: { - uint32_t rxDuplicated = otLinkGetCounters(mOTInst)->mRxDuplicated; - err = encoder.Encode(rxDuplicated); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxErrNoFrameCount::Id: { - uint32_t rxErrNoFrame = otLinkGetCounters(mOTInst)->mRxErrNoFrame; - err = encoder.Encode(rxErrNoFrame); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxErrUnknownNeighborCount::Id: { - uint32_t rxErrUnknownNeighbor = otLinkGetCounters(mOTInst)->mRxErrUnknownNeighbor; - err = encoder.Encode(rxErrUnknownNeighbor); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxErrInvalidSrcAddrCount::Id: { - uint32_t rxErrInvalidSrcAddr = otLinkGetCounters(mOTInst)->mRxErrInvalidSrcAddr; - err = encoder.Encode(rxErrInvalidSrcAddr); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxErrSecCount::Id: { - uint32_t rxErrSec = otLinkGetCounters(mOTInst)->mRxErrSec; - err = encoder.Encode(rxErrSec); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxErrFcsCount::Id: { - uint32_t rxErrFcs = otLinkGetCounters(mOTInst)->mRxErrFcs; - err = encoder.Encode(rxErrFcs); - } - break; - - case ThreadNetworkDiagnostics::Attributes::RxErrOtherCount::Id: { - uint32_t rxErrOther = otLinkGetCounters(mOTInst)->mRxErrOther; - err = encoder.Encode(rxErrOther); - } - break; - - case ThreadNetworkDiagnostics::Attributes::ActiveTimestamp::Id: { - otOperationalDataset activeDataset; - otError otErr = otDatasetGetActive(mOTInst, &activeDataset); - VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr)); - uint64_t activeTimestamp = (activeDataset.mActiveTimestamp.mSeconds << 16) | (activeDataset.mActiveTimestamp.mTicks << 1) | - activeDataset.mActiveTimestamp.mAuthoritative; - err = encoder.Encode(activeTimestamp); - } - break; - - case ThreadNetworkDiagnostics::Attributes::PendingTimestamp::Id: { - otOperationalDataset activeDataset; - otError otErr = otDatasetGetActive(mOTInst, &activeDataset); - VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr)); - uint64_t pendingTimestamp = (activeDataset.mPendingTimestamp.mSeconds << 16) | - (activeDataset.mPendingTimestamp.mTicks << 1) | activeDataset.mPendingTimestamp.mAuthoritative; - err = encoder.Encode(pendingTimestamp); - } - break; - - case ThreadNetworkDiagnostics::Attributes::Delay::Id: { - otOperationalDataset activeDataset; - otError otErr = otDatasetGetActive(mOTInst, &activeDataset); - VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr)); - uint32_t delay = activeDataset.mDelay; - err = encoder.Encode(delay); - } - break; - - case ThreadNetworkDiagnostics::Attributes::SecurityPolicy::Id: { - otOperationalDataset activeDataset; - otError otErr = otDatasetGetActive(mOTInst, &activeDataset); - VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr)); - - ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type securityPolicy; - static_assert(sizeof(securityPolicy) == sizeof(activeDataset.mSecurityPolicy), - "securityPolicy Struct do not match otSecurityPolicy"); - uint16_t policyAsInts[2]; - static_assert(sizeof(policyAsInts) == sizeof(activeDataset.mSecurityPolicy), - "We're missing some members of otSecurityPolicy?"); - memcpy(&policyAsInts, &activeDataset.mSecurityPolicy, sizeof(policyAsInts)); - securityPolicy.rotationTime = policyAsInts[0]; - securityPolicy.flags = policyAsInts[1]; - err = encoder.Encode(securityPolicy); - } - break; - - case ThreadNetworkDiagnostics::Attributes::ChannelPage0Mask::Id: { - otOperationalDataset activeDataset; - otError otErr = otDatasetGetActive(mOTInst, &activeDataset); - VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr)); - - // In the resultant Octet string, the most significant bit of the left-most byte indicates channel 0 - // We have to bitswap the entire uint32_t before converting to octet string - uint32_t bitSwappedChannelMask = 0; - for (int i = 0, j = 31; i < 32; i++, j--) - { - bitSwappedChannelMask |= ((activeDataset.mChannelMask >> j) & 1) << i; - } - - uint8_t buffer[sizeof(uint32_t)] = { 0 }; - Encoding::BigEndian::Put32(buffer, bitSwappedChannelMask); - err = encoder.Encode(ByteSpan(buffer)); - } - break; - - case ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::Id: { - otOperationalDataset activeDataset; - otError otErr = otDatasetGetActive(mOTInst, &activeDataset); - VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr)); - ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type OpDatasetComponents; - - OpDatasetComponents.activeTimestampPresent = activeDataset.mComponents.mIsActiveTimestampPresent; - OpDatasetComponents.pendingTimestampPresent = activeDataset.mComponents.mIsPendingTimestampPresent; - OpDatasetComponents.masterKeyPresent = activeDataset.mComponents.mIsNetworkKeyPresent; - OpDatasetComponents.networkNamePresent = activeDataset.mComponents.mIsNetworkNamePresent; - OpDatasetComponents.extendedPanIdPresent = activeDataset.mComponents.mIsExtendedPanIdPresent; - OpDatasetComponents.meshLocalPrefixPresent = activeDataset.mComponents.mIsMeshLocalPrefixPresent; - OpDatasetComponents.delayPresent = activeDataset.mComponents.mIsDelayPresent; - OpDatasetComponents.panIdPresent = activeDataset.mComponents.mIsPanIdPresent; - OpDatasetComponents.channelPresent = activeDataset.mComponents.mIsChannelPresent; - OpDatasetComponents.pskcPresent = activeDataset.mComponents.mIsPskcPresent; - OpDatasetComponents.securityPolicyPresent = activeDataset.mComponents.mIsSecurityPolicyPresent; - OpDatasetComponents.channelMaskPresent = activeDataset.mComponents.mIsChannelMaskPresent; - - err = encoder.Encode(OpDatasetComponents); - } - break; - - case ThreadNetworkDiagnostics::Attributes::ActiveNetworkFaultsList::Id: { - err = encoder.EncodeList([](const auto & aEncoder) -> CHIP_ERROR { - // TODO activeNetworkFaultsList isn't tracked. Encode the list of 4 entries at 0 none the less - ThreadNetworkDiagnostics::NetworkFaultEnum activeNetworkFaultsList[4] = { ThreadNetworkDiagnostics::NetworkFaultEnum( - 0) }; - for (auto fault : activeNetworkFaultsList) - { - ReturnErrorOnFailure(aEncoder.Encode(fault)); - } - - return CHIP_NO_ERROR; - }); - } - break; - - default: { - err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; - } - break; - } - - return err; -} template CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_GetPollPeriod(uint32_t & buf) diff --git a/src/platform/Tizen/ThreadStackManagerImpl.cpp b/src/platform/Tizen/ThreadStackManagerImpl.cpp index a5169d462c0209..47a4548507e332 100644 --- a/src/platform/Tizen/ThreadStackManagerImpl.cpp +++ b/src/platform/Tizen/ThreadStackManagerImpl.cpp @@ -535,13 +535,6 @@ CHIP_ERROR ThreadStackManagerImpl::_StartThreadScan(NetworkCommissioning::Thread void ThreadStackManagerImpl::_ResetThreadNetworkDiagnosticsCounts() {} -CHIP_ERROR ThreadStackManagerImpl::_WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, - app::AttributeValueEncoder & encoder) -{ - ChipLogError(DeviceLayer, "Not implemented"); - return CHIP_ERROR_NOT_IMPLEMENTED; -} - CHIP_ERROR ThreadStackManagerImpl::_AttachToThreadNetwork(const Thread::OperationalDataset & dataset, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback) diff --git a/src/platform/Tizen/ThreadStackManagerImpl.h b/src/platform/Tizen/ThreadStackManagerImpl.h index efa2c84e93252a..05b300f574114b 100644 --- a/src/platform/Tizen/ThreadStackManagerImpl.h +++ b/src/platform/Tizen/ThreadStackManagerImpl.h @@ -102,8 +102,6 @@ class ThreadStackManagerImpl : public ThreadStackManager void _ResetThreadNetworkDiagnosticsCounts(); - CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); - CHIP_ERROR _StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback); ~ThreadStackManagerImpl() = default; diff --git a/src/platform/android/DiagnosticDataProviderImpl.cpp b/src/platform/android/DiagnosticDataProviderImpl.cpp index 3b0784a7a079b8..9be5c59a2fbe16 100644 --- a/src/platform/android/DiagnosticDataProviderImpl.cpp +++ b/src/platform/android/DiagnosticDataProviderImpl.cpp @@ -97,9 +97,11 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** chip::DeviceLayer::StackUnlock unlock; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnError(env != nullptr, CHIP_JNI_ERROR_NULL_OBJECT, + ChipLogError(DeviceLayer, "Could not get JNIEnv for current thread")); + JniLocalReferenceScope scope(env); VerifyOrExit(mDiagnosticDataProviderManagerObject != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetNifMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != nullptr, err = CHIP_JNI_ERROR_NO_ENV); { ChipLogProgress(DeviceLayer, "Received GetNetworkInterfaces"); jobjectArray nifList = (jobjectArray) env->CallObjectMethod(mDiagnosticDataProviderManagerObject, mGetNifMethod); diff --git a/src/platform/bouffalolab/common/CHIPDevicePlatformEvent.h b/src/platform/bouffalolab/common/CHIPDevicePlatformEvent.h index a7ee3ec529f146..c41a791fec4099 100644 --- a/src/platform/bouffalolab/common/CHIPDevicePlatformEvent.h +++ b/src/platform/bouffalolab/common/CHIPDevicePlatformEvent.h @@ -18,6 +18,7 @@ #pragma once #include +#include #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE #include diff --git a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp index 1a01acfdb69385..69935bb024559d 100644 --- a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp +++ b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp @@ -28,15 +28,4 @@ bool DefaultTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enable return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); } -CHIP_ERROR DefaultTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) -{ - if (eventTrigger == kQueryTrigger) - { - ChipLogProgress(DeviceLayer, "DefaultTestEventTriggerDelegate: event triggered"); - return CHIP_NO_ERROR; - } - - return CHIP_ERROR_INVALID_ARGUMENT; -} - } // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h index cf71fb37d96470..0bfd4c5b0fa725 100644 --- a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h +++ b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h @@ -25,12 +25,9 @@ namespace chip { class DefaultTestEventTriggerDelegate : public TestEventTriggerDelegate { public: - static constexpr uint64_t kQueryTrigger = 1234; - explicit DefaultTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {} bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; - CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; private: ByteSpan mEnableKey; diff --git a/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.cpp b/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.cpp index 1a01acfdb69385..69935bb024559d 100644 --- a/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.cpp +++ b/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.cpp @@ -28,15 +28,4 @@ bool DefaultTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enable return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); } -CHIP_ERROR DefaultTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) -{ - if (eventTrigger == kQueryTrigger) - { - ChipLogProgress(DeviceLayer, "DefaultTestEventTriggerDelegate: event triggered"); - return CHIP_NO_ERROR; - } - - return CHIP_ERROR_INVALID_ARGUMENT; -} - } // namespace chip diff --git a/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.h b/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.h index cf71fb37d96470..0bfd4c5b0fa725 100644 --- a/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.h +++ b/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.h @@ -25,12 +25,9 @@ namespace chip { class DefaultTestEventTriggerDelegate : public TestEventTriggerDelegate { public: - static constexpr uint64_t kQueryTrigger = 1234; - explicit DefaultTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {} bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; - CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; private: ByteSpan mEnableKey; diff --git a/src/platform/webos/ThreadStackManagerImpl.cpp b/src/platform/webos/ThreadStackManagerImpl.cpp index 6acb542d78a3c1..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; @@ -647,174 +643,6 @@ void ThreadStackManagerImpl::_OnNetworkScanFinished(GAsyncResult * res) void ThreadStackManagerImpl::_ResetThreadNetworkDiagnosticsCounts() {} -CHIP_ERROR ThreadStackManagerImpl::_WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, - app::AttributeValueEncoder & encoder) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - switch (attributeId) - { - case ThreadNetworkDiagnostics::Attributes::NeighborTable::Id: - case ThreadNetworkDiagnostics::Attributes::RouteTable::Id: - case ThreadNetworkDiagnostics::Attributes::ActiveNetworkFaultsList::Id: - err = encoder.EncodeEmptyList(); - break; - case ThreadNetworkDiagnostics::Attributes::Channel::Id: - case ThreadNetworkDiagnostics::Attributes::RoutingRole::Id: - case ThreadNetworkDiagnostics::Attributes::NetworkName::Id: - case ThreadNetworkDiagnostics::Attributes::PanId::Id: - case ThreadNetworkDiagnostics::Attributes::ExtendedPanId::Id: - case ThreadNetworkDiagnostics::Attributes::MeshLocalPrefix::Id: - case ThreadNetworkDiagnostics::Attributes::PartitionId::Id: - case ThreadNetworkDiagnostics::Attributes::Weighting::Id: - case ThreadNetworkDiagnostics::Attributes::DataVersion::Id: - case ThreadNetworkDiagnostics::Attributes::StableDataVersion::Id: - case ThreadNetworkDiagnostics::Attributes::LeaderRouterId::Id: - case ThreadNetworkDiagnostics::Attributes::ActiveTimestamp::Id: - case ThreadNetworkDiagnostics::Attributes::PendingTimestamp::Id: - case ThreadNetworkDiagnostics::Attributes::Delay::Id: - case ThreadNetworkDiagnostics::Attributes::ChannelPage0Mask::Id: - case ThreadNetworkDiagnostics::Attributes::SecurityPolicy::Id: - case ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::Id: - err = encoder.EncodeNull(); - break; - case ThreadNetworkDiagnostics::Attributes::OverrunCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::DetachedRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::ChildRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RouterRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::LeaderRoleCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::AttachAttemptCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::PartitionIdChangeCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::BetterPartitionAttachAttemptCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::ParentChangeCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxTotalCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxUnicastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxBroadcastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxAckRequestedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxAckedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxNoAckRequestedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxDataCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxDataPollCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxBeaconCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxBeaconRequestCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxRetryCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxDirectMaxRetryExpiryCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxIndirectMaxRetryExpiryCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxErrCcaCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxErrAbortCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::TxErrBusyChannelCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxTotalCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxUnicastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxBroadcastCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDataCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDataPollCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxBeaconCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxBeaconRequestCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxAddressFilteredCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDestAddrFilteredCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxDuplicatedCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrNoFrameCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrUnknownNeighborCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrInvalidSrcAddrCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrSecCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrFcsCount::Id: - err = encoder.Encode(static_cast(0)); - break; - case ThreadNetworkDiagnostics::Attributes::RxErrOtherCount::Id: - err = encoder.Encode(static_cast(0)); - break; - default: - err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; - break; - } - - return err; -} - CHIP_ERROR ThreadStackManagerImpl::_AttachToThreadNetwork(const Thread::OperationalDataset & dataset, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback) diff --git a/src/platform/webos/ThreadStackManagerImpl.h b/src/platform/webos/ThreadStackManagerImpl.h index 330e601f75a7fd..876c339cceb6ae 100644 --- a/src/platform/webos/ThreadStackManagerImpl.h +++ b/src/platform/webos/ThreadStackManagerImpl.h @@ -104,8 +104,6 @@ class ThreadStackManagerImpl : public ThreadStackManager void _ResetThreadNetworkDiagnosticsCounts(); - CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); - CHIP_ERROR _StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback); ~ThreadStackManagerImpl() = default; diff --git a/src/protocols/bdx/BdxTransferSession.h b/src/protocols/bdx/BdxTransferSession.h index f5ef397ca7d9e8..ccd241e7fe508c 100644 --- a/src/protocols/bdx/BdxTransferSession.h +++ b/src/protocols/bdx/BdxTransferSession.h @@ -9,6 +9,7 @@ #include #include +#include #include #include 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..f596345474301e 100644 --- a/src/protocols/secure_channel/BUILD.gn +++ b/src/protocols/secure_channel/BUILD.gn @@ -12,6 +12,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", ] @@ -55,6 +56,7 @@ static_library("secure_channel") { "${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/tests/BUILD.gn b/src/protocols/secure_channel/tests/BUILD.gn index de3984a74dc2aa..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") @@ -24,24 +23,24 @@ chip_test_suite_using_nltest("tests") { sources = [ "CheckIn_Message_test_vectors.h" ] public_deps = [ - "${chip_root}/src/app/icd:icd_config", + "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/credentials/tests:cert_test_vectors", "${chip_root}/src/crypto/tests:tests.lib", "${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", ] cflags = [ "-Wconversion" ] if (chip_enable_icd_server) { - public_deps += [ "${chip_root}/src/app/icd:configuration-data" ] + public_deps += [ "${chip_root}/src/app/icd/server:configuration-data" ] } } diff --git a/src/protocols/secure_channel/tests/TestPASESession.cpp b/src/protocols/secure_channel/tests/TestPASESession.cpp index 01e987d425446b..f94ebb0921a533 100644 --- a/src/protocols/secure_channel/tests/TestPASESession.cpp +++ b/src/protocols/secure_channel/tests/TestPASESession.cpp @@ -36,7 +36,7 @@ #include #if CHIP_CONFIG_ENABLE_ICD_SERVER -#include // nogncheck +#include // nogncheck #endif // This test suite pushes multiple PASESession objects onto the stack for the 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_BOOLCFG_4_2.py b/src/python_testing/TC_BOOLCFG_4_2.py index 06f5ecad6adbad..c0a74a9c46538a 100644 --- a/src/python_testing/TC_BOOLCFG_4_2.py +++ b/src/python_testing/TC_BOOLCFG_4_2.py @@ -65,10 +65,11 @@ async def test_TC_BOOLCFG_4_2(self): asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " - "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:, " + "e.g. --hex-arg PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f") endpoint = self.user_params.get("endpoint", 1) - enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'] self.step(1) attributes = Clusters.BooleanStateConfiguration.Attributes diff --git a/src/python_testing/TC_BOOLCFG_4_3.py b/src/python_testing/TC_BOOLCFG_4_3.py index 40a44a004a67e5..90106efc2b8ab4 100644 --- a/src/python_testing/TC_BOOLCFG_4_3.py +++ b/src/python_testing/TC_BOOLCFG_4_3.py @@ -77,10 +77,11 @@ async def test_TC_BOOLCFG_4_3(self): asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " - "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:, " + "e.g. --hex-arg PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f") endpoint = self.user_params.get("endpoint", 1) - enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'] self.step(1) attributes = Clusters.BooleanStateConfiguration.Attributes diff --git a/src/python_testing/TC_BOOLCFG_4_4.py b/src/python_testing/TC_BOOLCFG_4_4.py index 12c350baedbc40..b60ef12fd16f5f 100644 --- a/src/python_testing/TC_BOOLCFG_4_4.py +++ b/src/python_testing/TC_BOOLCFG_4_4.py @@ -69,10 +69,11 @@ async def test_TC_BOOLCFG_4_4(self): asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " - "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:, " + "e.g. --hex-arg PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f") endpoint = self.user_params.get("endpoint", 1) - enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'] self.step(1) attributes = Clusters.BooleanStateConfiguration.Attributes diff --git a/src/python_testing/TC_BOOLCFG_5_1.py b/src/python_testing/TC_BOOLCFG_5_1.py index 3d3d1b681752c9..90868fd8e6316c 100644 --- a/src/python_testing/TC_BOOLCFG_5_1.py +++ b/src/python_testing/TC_BOOLCFG_5_1.py @@ -64,10 +64,11 @@ async def test_TC_BOOLCFG_5_1(self): asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " - "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:, " + "e.g. --hex-arg PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f") endpoint = self.user_params.get("endpoint", 1) - enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'] self.step(1) attributes = Clusters.BooleanStateConfiguration.Attributes diff --git a/src/python_testing/TC_BOOLCFG_5_2.py b/src/python_testing/TC_BOOLCFG_5_2.py index 65dd00f7d690e2..6e2657698a9d5c 100644 --- a/src/python_testing/TC_BOOLCFG_5_2.py +++ b/src/python_testing/TC_BOOLCFG_5_2.py @@ -63,10 +63,11 @@ async def test_TC_BOOLCFG_5_2(self): asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " - "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:, " + "e.g. --hex-arg PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f") endpoint = self.user_params.get("endpoint", 1) - enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'] self.step(1) attributes = Clusters.BooleanStateConfiguration.Attributes diff --git a/src/python_testing/TC_IDM_1_4.py b/src/python_testing/TC_IDM_1_4.py index a0bcf0c3ade5ca..04dfdf12c7bf0a 100644 --- a/src/python_testing/TC_IDM_1_4.py +++ b/src/python_testing/TC_IDM_1_4.py @@ -22,7 +22,7 @@ from chip import ChipUtility from chip.exceptions import ChipStackError from chip.interaction_model import InteractionModelError, Status -from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches from mobly import asserts @@ -35,6 +35,18 @@ def must_use_timed_invoke(cls) -> bool: class TC_IDM_1_4(MatterBaseTest): + def steps_TC_IDM_1_4(self) -> list[TestStep]: + steps = [TestStep(1, "Get remote node's MaxPathsPerInvoke", is_commissioning=True), + TestStep(2, "Sending `MaxPathsPerInvoke + 1` InvokeRequest if it fits into single MTU"), + TestStep(3, "Sending two InvokeRequests with identical paths"), + TestStep(4, "Sending two InvokeRequests with unique paths, but identical CommandRefs"), + TestStep(5, "Verify DUT responds to InvokeRequestMessage containing two valid paths"), + TestStep(6, "Verify DUT responds to InvokeRequestMessage containing one valid paths, and one InvokeRequest to unsupported endpoint"), + TestStep(7, "Verify DUT responds to InvokeRequestMessage containing two valid paths. One of which requires timed invoke, and TimedRequest in InvokeResponseMessage set to true, but never sending preceding Timed Invoke Action"), + TestStep(8, "Verify DUT responds to InvokeRequestMessage containing two valid paths. One of which requires timed invoke, and TimedRequest in InvokeResponseMessage set to true"), + TestStep(9, "Verify DUT capable of responding to request with multiple InvokeResponseMessages")] + return steps + @async_test_body async def test_TC_IDM_1_4(self): dev_ctrl = self.default_controller @@ -42,14 +54,14 @@ async def test_TC_IDM_1_4(self): self.print_step(0, "Commissioning - already done") - self.print_step(1, "Get remote node's MaxPathsPerInvoke") + self.step(1) session_parameters = dev_ctrl.GetRemoteSessionParameters(dut_node_id) max_paths_per_invoke = session_parameters.maxPathsPerInvoke - asserts.assert_greater_equal(max_paths_per_invoke, 1, "Unexpected error returned from unsupported endpoint") - asserts.assert_less_equal(max_paths_per_invoke, 65535, "Unexpected error returned from unsupported endpoint") + asserts.assert_greater_equal(max_paths_per_invoke, 1, "Max Paths per Invoke less than spec min") + asserts.assert_less_equal(max_paths_per_invoke, 65535, "Max Paths per Invoke greater than spec max") - self.print_step(2, "Sending `MaxPathsPerInvoke + 1` InvokeRequest if it fits into single MTU") + self.step(2) # In practice, it was noticed that we could only fit 57 commands before we hit the MTU limit as a result we # conservatively try putting up to 100 commands into an Invoke request. We are expecting one of 2 things to # happen if max_paths_per_invoke + 1 is greater than what cap_for_batch_commands is set to: @@ -59,7 +71,7 @@ async def test_TC_IDM_1_4(self): # 2. Client (TH) able to send command. While unexpected we will hit two different test failure depending on # what the server does. # a. Server successfully handle command and send InvokeResponse with results of all individual commands - # being failure. In this case, test fails on unexpected successes like this + # being failure. In this case, test already will fail on unexpected successes. # b. Server fails to handle command that is between cap_for_batch_commands and max_paths_per_invoke + 1. # In this case, test fails as device should have actually succeeded and been caught in 2.a. cap_for_batch_commands = 100 @@ -80,34 +92,31 @@ async def test_TC_IDM_1_4(self): "Step 2 is always expected to try sending at least 2 command, something wrong with test logic") try: await dev_ctrl.TestOnlySendBatchCommands(dut_node_id, list_of_commands_to_send, remoteMaxPathsPerInvoke=number_of_commands_to_send) - # If you get the assert below it is likely because cap_for_batch_commands is actually too low. - # This might happen after TCP is enabled and DUT supports TCP. + # This might happen after TCP is enabled and DUT supports TCP. See comment above `cap_for_batch_commands` + # for more information. + asserts.assert_not_equal(number_of_commands_to_send, cap_for_batch_commands, + "Test needs to be updated! Soft cap `cap_for_batch_commands` used in test is no longer correct") asserts.fail( f"Unexpected success return from sending too many commands, we sent {number_of_commands_to_send}, test capped at {cap_for_batch_commands}") except InteractionModelError as e: - # This check is for 2.a., mentioned above introduction of variable cap_for_batch_commands. + # This check is for 2.b, mentioned above. If this assert occurs, test likely needs updating. Although DUT + # is still going to fail since it seemingly is failing to process a smaller number then it is reporting + # that it is capable of processing. asserts.assert_equal(number_of_commands_to_send, max_paths_per_invoke + 1, "Test didn't send as many command as max_paths_per_invoke + 1, likely due to MTU cap_for_batch_commands, but we still got an error from server. This should have been a success from server") asserts.assert_equal(e.status, Status.InvalidAction, "DUT sent back an unexpected error, we were expecting InvalidAction") - self.print_step(2, "DUT successfully failed to process `MaxPathsPerInvoke + 1` InvokeRequests") + logging.info("DUT successfully failed to process `MaxPathsPerInvoke + 1` InvokeRequests") except ChipStackError as e: chip_error_no_memory = 0x0b asserts.assert_equal(e.err, chip_error_no_memory, "Unexpected error while trying to send InvokeRequest") # TODO it is possible we want to confirm DUT can handle up to MTU max. But that is not in test plan as of right now. # Additionally CommandSender is not currently set up to enable caller to fill up to MTU. This might be coming soon, # just that it is not supported today. - self.print_step(2, "DUTs reported MaxPathsPerInvoke + 1 is larger than what fits into MTU. Test step is skipped") + logging.info("DUTs reported MaxPathsPerInvoke + 1 is larger than what fits into MTU. Test step is skipped") if max_paths_per_invoke == 1: - # TODO(#31139) After issue is resolved use that API properly to mark tests steps as skipped - self.print_step(3, "Skipping test step as max_paths_per_invoke == 1") - self.print_step(4, "Skipping test step as max_paths_per_invoke == 1") - self.print_step(5, "Skipping test step as max_paths_per_invoke == 1") - self.print_step(6, "Skipping test step as max_paths_per_invoke == 1") - self.print_step(7, "Skipping test step as max_paths_per_invoke == 1") - self.print_step(8, "Skipping test step as max_paths_per_invoke == 1") - self.print_step(9, "Skipping test step as max_paths_per_invoke == 1") + self.skip_all_remaining_steps(3) else: await self.steps_3_to_9(False) @@ -115,7 +124,7 @@ async def steps_3_to_9(self, dummy_value): dev_ctrl = self.default_controller dut_node_id = self.dut_node_id - self.print_step(3, "Sending sending two InvokeRequests with idential paths") + self.step(3) command = Clusters.BasicInformation.Commands.MfgSpecificPing() endpoint = 0 invoke_request_1 = Clusters.Command.InvokeRequestInfo(endpoint, command) @@ -127,7 +136,7 @@ async def steps_3_to_9(self, dummy_value): "DUT sent back an unexpected error, we were expecting InvalidAction") logging.info("DUT successfully failed to process two InvokeRequests that contains non-unique paths") - self.print_step(4, "Sending two InvokeRequests with unique paths, but identical CommandRefs") + self.step(4) endpoint = 0 command = Clusters.OperationalCredentials.Commands.CertificateChainRequest( Clusters.OperationalCredentials.Enums.CertificateChainTypeEnum.kDACCertificate) @@ -144,7 +153,7 @@ async def steps_3_to_9(self, dummy_value): "DUT sent back an unexpected error, we were expecting InvalidAction") logging.info("DUT successfully failed to process two InvokeRequests that contains non-unique CommandRef") - self.print_step(5, "Verify DUT is able to responsed to InvokeRequestMessage that contains two valid paths") + self.step(5) endpoint = 0 command = Clusters.OperationalCredentials.Commands.CertificateChainRequest( Clusters.OperationalCredentials.Enums.CertificateChainTypeEnum.kDACCertificate) @@ -164,8 +173,7 @@ async def steps_3_to_9(self, dummy_value): except InteractionModelError: asserts.fail("DUT failed to successfully responded to a InvokeRequest action with two valid commands") - self.print_step( - 6, "Verify DUT is able to responsed to InvokeRequestMessage that contains one paths InvokeRequest, and one InvokeRequest to unsupported endpoint") + self.step(6) # First finding non-existent endpoint wildcard_descriptor = await dev_ctrl.ReadAttribute(dut_node_id, [(Clusters.Descriptor)]) endpoints = list(wildcard_descriptor.keys()) @@ -195,7 +203,7 @@ async def steps_3_to_9(self, dummy_value): except InteractionModelError: asserts.fail("DUT failed to successfully responded to a InvokeRequest action with two valid commands") - self.print_step(7, "Verify DUT is able to responsed to InvokeRequestMessage that contains two valid paths. One of which requires timed invoke, and TimedRequest in InvokeResponseMessage set to true, but never sent preceding Timed Invoke Action") + self.step(7) endpoint = 0 command = Clusters.GroupKeyManagement.Commands.KeySetRead(0) invoke_request_1 = Clusters.Command.InvokeRequestInfo(endpoint, command) @@ -214,7 +222,7 @@ async def steps_3_to_9(self, dummy_value): asserts.assert_equal(e.status, Status.TimedRequestMismatch, "Unexpected error response from Invoke with TimedRequest flag and no TimedInvoke") - self.print_step(8, "Verify DUT is able to responsed to InvokeRequestMessage that contains two valid paths. One of which requires timed invoke, and TimedRequest in InvokeResponseMessage set to true") + self.step(8) endpoint = 0 command = Clusters.GroupKeyManagement.Commands.KeySetRead(0) invoke_request_1 = Clusters.Command.InvokeRequestInfo(endpoint, command) @@ -235,12 +243,12 @@ async def steps_3_to_9(self, dummy_value): window_not_open_cluster_error = 4 asserts.assert_equal(result[1].clusterStatus, window_not_open_cluster_error, "Timed command, RevokeCommissioning, failed with incorrect cluster code") - self.print_step( - 8, "DUT successfully responded to a InvokeRequest action with two valid commands. One of which required timed invoke, and TimedRequest in InvokeResponseMessage was set to true") + logging.info("DUT successfully responded to a InvokeRequest action with two valid commands. One of which required timed invoke, and TimedRequest in InvokeResponseMessage was set to true") except InteractionModelError: asserts.fail("DUT failed with non-path specific error when path specific error was expected") - self.print_step(9, "Skipping test until https://github.com/project-chip/connectedhomeip/issues/31434 resolved") + # Skipping test until https://github.com/project-chip/connectedhomeip/issues/31434 resolved + self.skip_step(9) if __name__ == "__main__": diff --git a/src/python_testing/TC_RVCOPSTATE_2_1.py b/src/python_testing/TC_RVCOPSTATE_2_1.py index 8ca7a00ab2c134..a74a27616b7b09 100644 --- a/src/python_testing/TC_RVCOPSTATE_2_1.py +++ b/src/python_testing/TC_RVCOPSTATE_2_1.py @@ -22,12 +22,11 @@ from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main from mobly import asserts -# This test requires several additional command line arguments -# run with -# --int-arg PIXIT_ENDPOINT: - class TC_RVCOPSTATE_2_1(MatterBaseTest): + def __init__(self, *args): + super().__init__(*args) + self.endpoint = None async def read_mod_attribute_expect_success(self, endpoint, attribute): cluster = Clusters.Objects.RvcOperationalState @@ -54,12 +53,8 @@ def TC_RVCOPSTATE_2_1(self) -> list[str]: @async_test_body async def test_TC_RVCOPSTATE_2_1(self): - - asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, - "PIXIT_ENDPOINT must be included on the command line in " - "the --int-arg flag as PIXIT_ENDPOINT:") - - self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] + self.endpoint = self.matter_test_config.endpoint + asserts.assert_false(self.endpoint is None, "--endpoint must be included on the command line in.") attributes = Clusters.RvcOperationalState.Attributes @@ -108,8 +103,7 @@ async def test_TC_RVCOPSTATE_2_1(self): defined_states = [state.value for state in Clusters.OperationalState.Enums.OperationalStateEnum if state is not Clusters.OperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] - defined_states.extend(state.value for state in Clusters.RvcOperationalState.Enums.OperationalStateEnum - if state is not Clusters.RvcOperationalState.Enums.OperationalStateEnum.kUnknownEnumValue) + defined_states.extend(state.value for state in Clusters.RvcOperationalState.Enums.OperationalStateEnum) for state in operational_state_list: in_range = (0x80 <= state.operationalStateID <= 0xBF) @@ -172,8 +166,7 @@ async def test_TC_RVCOPSTATE_2_1(self): # Defined Errors defined_errors = [error.value for error in Clusters.OperationalState.Enums.ErrorStateEnum if error is not Clusters.OperationalState.Enums.ErrorStateEnum.kUnknownEnumValue] - defined_errors.extend(error.value for error in Clusters.RvcOperationalState.Enums.ErrorStateEnum - if error is not Clusters.RvcOperationalState.Enums.ErrorStateEnum.kUnknownEnumValue) + defined_errors.extend(error.value for error in Clusters.RvcOperationalState.Enums.ErrorStateEnum) in_range = (0x80 <= operational_error.errorStateID <= 0xBF) asserts.assert_true(operational_error.errorStateID in defined_errors diff --git a/src/python_testing/TC_RVCOPSTATE_2_3.py b/src/python_testing/TC_RVCOPSTATE_2_3.py index 8303905482b3f9..da3f1522d74976 100644 --- a/src/python_testing/TC_RVCOPSTATE_2_3.py +++ b/src/python_testing/TC_RVCOPSTATE_2_3.py @@ -23,10 +23,6 @@ from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches from mobly import asserts -# This test requires several additional command line arguments -# run with -# --int-arg PIXIT_ENDPOINT: - # Takes an OpState or RvcOpState state enum and returns a string representation def state_enum_to_text(state_enum): @@ -82,20 +78,20 @@ def pics_TC_RVCOPSTATE_2_3(self) -> list[str]: class TC_RVCOPSTATE_2_3(MatterBaseTest): def __init__(self, *args): - super().__init__(args) - self.endpoint = 0 + super().__init__(*args) + self.endpoint = None async def read_mod_attribute_expect_success(self, endpoint, attribute): cluster = Clusters.Objects.RvcOperationalState return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) - async def send_pause_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands.Pause: + async def send_pause_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands.OperationalCommandResponse: ret = await self.send_single_cmd(cmd=Clusters.Objects.RvcOperationalState.Commands.Pause(), endpoint=self.endpoint) asserts.assert_true(type_matches(ret, Clusters.Objects.RvcOperationalState.Commands.OperationalCommandResponse), "Unexpected return type for Pause") return ret - async def send_resume_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands.Resume: + async def send_resume_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands.OperationalCommandResponse: ret = await self.send_single_cmd(cmd=Clusters.Objects.RvcOperationalState.Commands.Resume(), endpoint=self.endpoint) asserts.assert_true(type_matches(ret, Clusters.Objects.RvcOperationalState.Commands.OperationalCommandResponse), "Unexpected return type for Resume") @@ -108,23 +104,23 @@ async def read_operational_state_with_check(self, step_number, expected_state): endpoint=self.endpoint, attribute=Clusters.RvcOperationalState.Attributes.OperationalState) logging.info("OperationalState: %s" % operational_state) asserts.assert_equal(operational_state, expected_state, - "OperationalState(%s) should be %s" % operational_state, state_enum_to_text(expected_state)) + "OperationalState(%s) should be %s" % (operational_state, state_enum_to_text(expected_state))) # Sends the Pause command and checks that the returned error matches the expected_error async def send_pause_cmd_with_check(self, step_number, expected_error): self.print_step(step_number, "Send Pause command") - ret = self.send_pause_cmd() + ret = await self.send_pause_cmd() asserts.assert_equal(ret.commandResponseState.errorStateID, expected_error, - "errorStateID(%s) should be %s" % ret.commandResponseState.errorStateID, - error_enum_to_text(expected_error)) + "errorStateID(%s) should be %s" % (ret.commandResponseState.errorStateID, + error_enum_to_text(expected_error))) # Sends the Resume command and checks that the returned error matches the expected_error async def send_resume_cmd_with_check(self, step_number, expected_error): self.print_step(step_number, "Send Pause command") - ret = self.send_resume_cmd() + ret = await self.send_resume_cmd() asserts.assert_equal(ret.commandResponseState.errorStateID, expected_error, - "errorStateID(%s) should be %s" % ret.commandResponseState.errorStateID, - error_enum_to_text(expected_error)) + "errorStateID(%s) should be %s" % (ret.commandResponseState.errorStateID, + error_enum_to_text(expected_error))) # Prints the instruction and waits for a user input to continue def print_instruction(self, step_number, instruction): @@ -134,18 +130,15 @@ def print_instruction(self, step_number, instruction): @async_test_body async def test_TC_RVCOPSTATE_2_3(self): - asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, - "PIXIT_ENDPOINT must be included on the command line in " - "the --int-arg flag as PIXIT_ENDPOINT:") - - self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] + self.endpoint = self.matter_test_config.endpoint + asserts.assert_false(self.endpoint is None, "--endpoint must be included on the command line in.") asserts.assert_true(self.check_pics("RVCOPSTATE.S.A0003"), "RVCOPSTATE.S.A0003 must be supported") asserts.assert_true(self.check_pics("RVCOPSTATE.S.A0004"), "RVCOPSTATE.S.A0004 must be supported") asserts.assert_true(self.check_pics("RVCOPSTATE.S.C00.Rsp"), "RVCOPSTATE.S.C00.Rsp must be supported") asserts.assert_true(self.check_pics("RVCOPSTATE.S.C03.Rsp"), "RVCOPSTATE.S.C03.Rsp must be supported") # This command SHALL be supported by an implementation if any of the other commands are supported (6.5) - asserts.assert_true(self.check_pics("RVCOPSTATE.S.C04.Rsp"), "RVCOPSTATE.S.C04.Rsp must be supported") + asserts.assert_true(self.check_pics("RVCOPSTATE.S.C04.Tx"), "RVCOPSTATE.S.C04.Tx must be supported") attributes = Clusters.RvcOperationalState.Attributes op_states = Clusters.OperationalState.Enums.OperationalStateEnum @@ -208,7 +201,7 @@ async def test_TC_RVCOPSTATE_2_3(self): attribute=attributes.OperationalState) logging.info("OperationalState: %s" % operational_state) asserts.assert_equal(operational_state, old_opstate_dut, - "OperationalState(%s) should be the state before pause (%s)" % operational_state, old_opstate_dut) + "OperationalState(%s) should be the state before pause (%s)" % (operational_state, old_opstate_dut)) await self.send_resume_cmd_with_check(13, op_errors.kNoError) diff --git a/src/python_testing/TC_RVCOPSTATE_2_4.py b/src/python_testing/TC_RVCOPSTATE_2_4.py index 41de4cbbdaa4ef..ddcb134ed96d77 100644 --- a/src/python_testing/TC_RVCOPSTATE_2_4.py +++ b/src/python_testing/TC_RVCOPSTATE_2_4.py @@ -21,10 +21,6 @@ from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches from mobly import asserts -# This test requires several additional command line arguments -# run with -# --int-arg PIXIT_ENDPOINT: - # Takes an OpState or RvcOpState state enum and returns a string representation def state_enum_to_text(state_enum): @@ -79,14 +75,14 @@ def pics_TC_RVCOPSTATE_2_4(self) -> list[str]: class TC_RVCOPSTATE_2_4(MatterBaseTest): def __init__(self, *args): - super().__init__(args) - self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] + super().__init__(*args) + self.endpoint = None async def read_mod_attribute_expect_success(self, endpoint, attribute): cluster = Clusters.Objects.RvcOperationalState return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) - async def send_go_home_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands.GoHome: + async def send_go_home_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands.OperationalCommandResponse: ret = await self.send_single_cmd(cmd=Clusters.Objects.RvcOperationalState.Commands.GoHome(), endpoint=self.endpoint) asserts.assert_true(type_matches(ret, Clusters.Objects.RvcOperationalState.Commands.OperationalCommandResponse), "Unexpected return type for GoHome") @@ -95,10 +91,10 @@ async def send_go_home_cmd(self) -> Clusters.Objects.RvcOperationalState.Command # Sends the GoHome command and checks that the returned error matches the expected_error async def send_go_home_cmd_with_check(self, step_number, expected_error): self.print_step(step_number, "Send GoHome command") - ret = self.send_go_home_cmd() + ret = await self.send_go_home_cmd() asserts.assert_equal(ret.commandResponseState.errorStateID, expected_error, - "errorStateID(%s) should be %s" % ret.commandResponseState.errorStateID, - error_enum_to_text(expected_error)) + "errorStateID(%s) should be %s" % (ret.commandResponseState.errorStateID, + error_enum_to_text(expected_error))) # Prints the step number, reads the operational state attribute and checks if it matches with expected_state async def read_operational_state_with_check(self, step_number, expected_state): @@ -107,7 +103,7 @@ async def read_operational_state_with_check(self, step_number, expected_state): endpoint=self.endpoint, attribute=Clusters.RvcOperationalState.Attributes.OperationalState) logging.info("OperationalState: %s" % operational_state) asserts.assert_equal(operational_state, expected_state, - "OperationalState(%s) should be %s" % operational_state, state_enum_to_text(expected_state)) + "OperationalState(%s) should be %s" % (operational_state, state_enum_to_text(expected_state))) # Prints the instruction and waits for a user input to continue def print_instruction(self, step_number, instruction): @@ -116,13 +112,11 @@ def print_instruction(self, step_number, instruction): @async_test_body async def test_TC_RVCOPSTATE_2_4(self): - - asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, - "PIXIT_ENDPOINT must be included on the command line in " - "the --int-arg flag as PIXIT_ENDPOINT:") + self.endpoint = self.matter_test_config.endpoint + asserts.assert_false(self.endpoint is None, "--endpoint must be included on the command line in.") asserts.assert_true(self.check_pics("RVCOPSTATE.S.A0004"), "RVCOPSTATE.S.A0004 must be supported") - asserts.assert_true(self.check_pics("RVCOPSTATE.S.C04.Rsp"), "RVCOPSTATE.S.C04.Rsp must be supported") + asserts.assert_true(self.check_pics("RVCOPSTATE.S.C04.Tx"), "RVCOPSTATE.S.C04.Tx must be supported") asserts.assert_true(self.check_pics("RVCOPSTATE.S.C128.Rsp"), "RVCOPSTATE.S.C128.Rsp must be supported") op_states = Clusters.OperationalState.Enums.OperationalStateEnum diff --git a/src/python_testing/TC_pics_checker.py b/src/python_testing/TC_pics_checker.py index d7f076b471173d..6d49142f8f40b2 100644 --- a/src/python_testing/TC_pics_checker.py +++ b/src/python_testing/TC_pics_checker.py @@ -20,7 +20,7 @@ from basic_composition_support import BasicCompositionTests from global_attribute_ids import GlobalAttributeIds from matter_testing_support import (AttributePathLocation, ClusterPathLocation, CommandPathLocation, FeaturePathLocation, - MatterBaseTest, async_test_body, default_matter_test_main) + MatterBaseTest, TestStep, async_test_body, default_matter_test_main) from mobly import asserts from spec_parsing_support import build_xml_clusters @@ -101,27 +101,48 @@ def _add_pics_for_lists(self, cluster_id: int, attribute_id_of_element_list: Glo self._check_and_record_errors(location, required, pics) - def test_TC_pics_checker(self): + def steps_TC_IDM_10_4(self): + return [TestStep(1, "TH performs a wildcard read of all attributes on the endpoint under test"), + TestStep(2, "For every standard cluster: If the cluster is present on the endpoint, ensure the server-side PICS code for the cluster is present in the PICS file (e.g. OO.S for On/Off cluster).If the cluster is not present on the endpoint, ensure the cluster server PICS code is not present in the PICS file."), + TestStep(3, "For every standard cluster, for every attribute in the cluster:If the cluster is present on the endpoint and the attribute ID is present in the AttributeList global attribute within the cluster, ensure the server-side PICS code for the attribute is present in the PICS file (e.g. OO.S.A000 for On/Off cluster’s OnOff attribute).Otherwise, ensure the attribute PICS code is NOT present in the PICS file."), + TestStep(4, "For every cluster present in the spec, for every client → server command in the cluster: If the cluster is present on the endpoint and the command id is present in the accepted commands list, ensure the PICS code for the accepted command is present in the PICS file. Otherwise, ensure the accepted command PICS code is not present in the PICS file."), + TestStep(5, "For every cluster present in the spec, for every server → client command in the cluster: If the cluster is present on the endpoint and the command id is present in the generated commands list, ensure the PICS code for the generated command is present in the PICS file. Otherwise, ensure the generated command PICS code is not present in the PICS file."), + TestStep(6, "For every cluster present in the spec, for every feature in the cluster: If the cluster is present on the endpoint and the feature is marked in the feature map, ensure the PICS code for the feature is present in the PICS file. Otherwise, ensure the feature PICS code is not present in the PICS file.")] + + def test_TC_IDM_10_4(self): + # wildcard read is done in setup_class + self.step(1) self.endpoint_id = self.matter_test_config.endpoint self.endpoint = self.endpoints_tlv[self.endpoint_id] self.success = True - for cluster_id, cluster in Clusters.ClusterObjects.ALL_CLUSTERS.items(): - # Data model XML is used to get the PICS code for this cluster. If we don't know the PICS - # code, we can't evaluate the PICS list. Clusters that are present on the device but are - # not present in the spec are checked in the IDM tests. - if cluster_id not in self.xml_clusters or self.xml_clusters[cluster_id].pics is None: - continue + # Data model XML is used to get the PICS code for this cluster. If we don't know the PICS + # code, we can't evaluate the PICS list. Clusters that are present on the device but are + # not present in the spec are checked in the IDM tests. + checkable_clusters = {cluster_id: cluster for cluster_id, cluster in Clusters.ClusterObjects.ALL_CLUSTERS.items( + ) if cluster_id in self.xml_clusters and self.xml_clusters[cluster_id].pics is not None} + self.step(2) + for cluster_id, cluster in checkable_clusters.items(): # Ensure the PICS.S code is correctly marked pics_cluster = f'{self.xml_clusters[cluster_id].pics}.S' location = ClusterPathLocation(endpoint_id=self.endpoint_id, cluster_id=cluster_id) self._check_and_record_errors(location, cluster_id in self.endpoint, pics_cluster) + self.step(3) + for cluster_id, cluster in checkable_clusters.items(): self._add_pics_for_lists(cluster_id, GlobalAttributeIds.ATTRIBUTE_LIST_ID) + + self.step(4) + for cluster_id, cluster in checkable_clusters.items(): self._add_pics_for_lists(cluster_id, GlobalAttributeIds.ACCEPTED_COMMAND_LIST_ID) + + self.step(5) + for cluster_id, cluster in checkable_clusters.items(): self._add_pics_for_lists(cluster_id, GlobalAttributeIds.GENERATED_COMMAND_LIST_ID) + self.step(6) + for cluster_id, cluster in checkable_clusters.items(): try: cluster_features = cluster.Bitmaps.Feature except AttributeError: diff --git a/src/python_testing/matter_testing_support.py b/src/python_testing/matter_testing_support.py index 77e79d980483ac..9d3c3e2a1fa302 100644 --- a/src/python_testing/matter_testing_support.py +++ b/src/python_testing/matter_testing_support.py @@ -888,7 +888,6 @@ def mark_current_step_skipped(self): steps = self.get_test_steps(self.current_test_info.name) if self.current_step_index == 0: asserts.fail("Script error: mark_current_step_skipped cannot be called before step()") - print(self.current_step_index-1) num = steps[self.current_step_index-1].test_plan_number except KeyError: num = self.current_step_index @@ -906,6 +905,17 @@ def skip_step(self, step): self.step(step) self.mark_current_step_skipped() + def skip_all_remaining_steps(self, starting_step): + ''' Skips all remaining test steps starting with provided starting step + + starting_step must be provided, and is not derived intentionally. By providing argument + test is more deliberately identifying where test skips are starting from, making + it easier to validate against the test plan for correctness. + ''' + last_step = len(self.get_test_steps(self.current_test_info.name)) + 1 + for index in range(starting_step, last_step): + self.skip_step(index) + def step(self, step: typing.Union[int, str]): test_name = self.current_test_info.name steps = self.get_test_steps(test_name) diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 73acdf1bc24d42..5953dc6a0ffdd0 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -118,7 +118,6 @@ buildconfig_header("system_buildconfig") { "HAVE_NETINET_ICMP6_H=true", "HAVE_ICMP6_FILTER=true", "CONFIG_HAVE_VCBPRINTF=false", - "CONFIG_HAVE_VSNPRINTF_EX=false", "HAVE_SYS_SOCKET_H=${chip_system_config_use_sockets}", ] diff --git a/src/test_driver/efr32/README.md b/src/test_driver/efr32/README.md index 97cbebf9e74889..0f4ea0b33176d4 100644 --- a/src/test_driver/efr32/README.md +++ b/src/test_driver/efr32/README.md @@ -28,8 +28,9 @@ test runner. (For Mac OS X, `commander` is located inside `Commander.app/Contents/MacOS/`.) -- Download and install a suitable ARM gcc tool chain: - [GNU Arm Embedded Toolchain 9-2019-q4-major](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) +- Download and install a suitable ARM gcc tool chain (For most Host, the + bootstrap already installs the toolchain): + [GNU Arm Embedded Toolchain 12.2 Rel1](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) - Install some additional tools(likely already present for CHIP developers): diff --git a/src/tools/device-graph/README.md b/src/tools/device-graph/README.md new file mode 100644 index 00000000000000..db8c10f96b1c7f --- /dev/null +++ b/src/tools/device-graph/README.md @@ -0,0 +1,82 @@ +--- +orphan: true +--- + +# Setup + +This tool uses the python environment used by the python_testing efforts, which +can be built using the below command. Notice that graphviz is required as an +extra package in order for the tool to generate the graph file. + +``` +scripts/build_python.sh -m platform -i out/python_env --extra_packages graphviz +``` + +Once the python environment is build it can be activated using this command: + +``` +source out/python_env/bin/activate +``` + +# How to run + +When the python environment is activated the tool can be started as a regular +python script. The tool does rely on the "framework" used for python testing, +which means it is possible to do the commissioning of the DUT as well. + +By adding the appropriate parameters to the script execution, it will +automatically perform a commissioning before running the tool itself. + +This is an example of running the test including commissioning a Thread based +example app device + +``` +python3 '/Users/renejosefsen/Developer/GitData/connectedhomeip/src/tools/device-graph/matter-device-graph.py' --commissioning-method ble-thread --discriminator 3840 --passcode 20202021 --thread-dataset-hex 0e08000000000001000035060004001fffe00708fdbeb88eb19ecbe60410ec73aeaadc21448df01599e6eaf216eb0c0402a0f7f8000300001901025b3502085b35dead5b35beef030435623335051000112233445566778899aabbccddeeff +``` + +In case the setup code and discriminator is not available, the QR code can also +be used: + +``` +python3 '/Users/renejosefsen/Developer/GitData/connectedhomeip/src/tools/device-graph/matter-device-graph.py' --commissioning-method ble-thread --qr-code MT:K2AA04EG15LL6I0LF00 --thread-dataset-hex 0e08000000000001000035060004001fffe00708fd6df9cc6d0db45b0410e12c1d624d8b4daf6adbfe5b2cd7787b0c0402a0f7f8000300001901025b3502085b35dead5b35beef030435623335051000112233445566778899aabbccddeeff +``` + +In case the device uses a development PAA, the following parameter should be +added. + +``` +--paa-trust-store-path credentials/development/paa-root-certs +``` + +In case the device uses a production PAA, the following parameter should be +added. + +``` +--paa-trust-store-path credentials/production/paa-root-certs +``` + +Once a commissioning is completed for the device, is is possible to rerun the +tool again for an already commissioned devices, this is an example of how to do +so: + +``` +python3 '/Users/renejosefsen/Developer/GitData/connectedhomeip/src/tools/device-graph/matter-device-graph.py' +``` + +The tool currently outputs the dot file in this folder and the output file is +named "matter-device-graph.dot". + +# How to view graph + +In order to view the graph, any tool that renders dot/graphviz files can be +used. + +It is possible to open dot files and get them rendered in vscode using this +extension: +[vscode-graphviz](https://marketplace.visualstudio.com/items?itemName=joaompinto.vscode-graphviz) + +# Example of output + +This is an example of the graph outputted from a device: + +![matter device graph example](./matter-device-graph-example.png) diff --git a/src/tools/device-graph/matter-device-graph-example.png b/src/tools/device-graph/matter-device-graph-example.png new file mode 100644 index 00000000000000..f6ae192adffa07 Binary files /dev/null and b/src/tools/device-graph/matter-device-graph-example.png differ diff --git a/src/tools/device-graph/matter-device-graph.py b/src/tools/device-graph/matter-device-graph.py new file mode 100644 index 00000000000000..16a2e6dbb0cd5b --- /dev/null +++ b/src/tools/device-graph/matter-device-graph.py @@ -0,0 +1,208 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import os +import pprint +import sys + +import chip.clusters as Clusters +import graphviz +from rich.console import Console + +# Add the path to python_testing folder, in order to be able to import from matter_testing_support +sys.path.append(os.path.abspath(sys.path[0] + "/../../python_testing")) +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main # noqa: E402 + +console = None +maxClusterNameLength = 30 + + +# Given there is currently no tranlation from DeviceTypeID to the device type name, +# this dict is created for now. When some more general is available, it should be updated to use this. +deviceTypeDict = { + 22: "Root Node", + 17: "Power Source", + 18: "OTA Requestor", + 20: "OTA Provider", + 14: "Aggregator", + 19: "Bridged Node", + 256: "On/Off Light", + 257: "Dimmable Light", + 268: "Color Temperature Light", + 269: "Extended Color Light", + 266: "On/Off Plug-in Unit", + 267: "Dimmable Plug-In Unit", + 771: "Pump", + 259: "On/Off Light Switch", + 260: "Dimmer Switch", + 261: "Color Dimmer Switch", + 2112: "Control Bridge", + 772: "Pump Controller", + 15: "Generic Switch", + 21: "Contact Sensor", + 262: "Light Sensor", + 263: "Occupancy Sensor", + 770: "Temperature Sensor", + 773: "Pressure Sensor", + 774: "Flow Sensor", + 775: "Humidity Sensor", + 2128: "On/Off Sensor", + 10: "Door Lock", + 11: "Door Lock Controller", + 514: "Window Covering", + 515: "Window Covering Controller", + 768: "Heating/Cooling Unit", + 769: "Thermostat", + 43: "Fan", + 35: "Casting Video Player", + 34: "Speaker", + 36: "Content App", + 40: "Basic Video Player", + 41: "Casting Video Client", + 42: "Video Remote Control", + 39: "Mode Select", + 45: "Air Purifier", + 44: "Air Quality Sensor", + 112: "Refrigerator", + 113: "Temperature Controlled Cabinet", + 114: "Room Air Conditioner", + 115: "Laundry Washer", + 116: "Robotic Vacuum Cleaner", + 117: "Dishwasher", + 118: "Smoke CO Alarm" +} + + +def AddServerOrClientNode(graphSection, endpoint, clusterName, color, nodeRef): + + if (len(clusterName) > maxClusterNameLength): + clusterNameAdjustedLength = clusterName[:maxClusterNameLength] + '...' + else: + clusterNameAdjustedLength = clusterName + + graphSection.node(f"ep{endpoint}_{clusterName}", label=f"{clusterNameAdjustedLength}", style="filled,rounded", + color=color, shape="box", fixedsize="true", width="3", height="0.5") + graphSection.edge(nodeRef, f"ep{endpoint}_{clusterName}", style="invis") + + +def CreateEndpointGraph(graph, graphSection, endpoint, wildcardResponse): + + numberOfRowsInEndpoint = 2 + + partsListFromWildcardRead = wildcardResponse[endpoint][Clusters.Objects.Descriptor][Clusters.Objects.Descriptor.Attributes.PartsList] + + listOfDeviceTypes = [] + for deviceTypeStruct in wildcardResponse[endpoint][Clusters.Objects.Descriptor][Clusters.Objects.Descriptor.Attributes.DeviceTypeList]: + try: + listOfDeviceTypes.append(deviceTypeDict[deviceTypeStruct.deviceType]) + except KeyError: + listOfDeviceTypes.append(deviceTypeStruct.deviceType) + + # console.print(f"Endpoint: {endpoint}") + # console.print(f"DeviceTypeList: {listOfDeviceTypes}") + # console.print(f"PartsList: {partsListFromWildcardRead}") + + endpointLabel = f"Endpoint: {endpoint}\lDeviceTypeList: {listOfDeviceTypes}\lPartsList: {partsListFromWildcardRead}\l" # noqa: W605 + + nextNodeRef = "" + nodeRef = f"ep{endpoint}" + clusterColumnCount = 0 + + graphSection.node(f"ep{endpoint}", label=endpointLabel, style="filled,rounded", + color="dodgerblue", shape="box", fixedsize="true", width="4", height="1") + + for clusterId in wildcardResponse[endpoint][Clusters.Objects.Descriptor][Clusters.Objects.Descriptor.Attributes.ServerList]: + clusterColumnCount += 1 + + try: + clusterName = Clusters.ClusterObjects.ALL_CLUSTERS[clusterId].__name__ + except KeyError: + clusterName = f"Custom server\l0x{clusterId:08X}" # noqa: W605 + + AddServerOrClientNode(graphSection, endpoint, clusterName, "olivedrab", nodeRef) + + if clusterColumnCount == 2: + nextNodeRef = f"ep{endpoint}_{clusterName}" + elif clusterColumnCount == 3: + nodeRef = nextNodeRef + clusterColumnCount = 0 + numberOfRowsInEndpoint += 1 + + for clusterId in wildcardResponse[endpoint][Clusters.Objects.Descriptor][Clusters.Objects.Descriptor.Attributes.ClientList]: + clusterColumnCount += 1 + + try: + clusterName = Clusters.ClusterObjects.ALL_CLUSTERS[clusterId].__name__ + except KeyError: + clusterName = f"Custom client\l0x{clusterId:08X}" # noqa: W605 + + AddServerOrClientNode(graphSection, endpoint, clusterName, "orange", nodeRef) + + if clusterColumnCount == 2: + nextNodeRef = f"ep{endpoint}_{clusterName}" + elif clusterColumnCount == 3: + nodeRef = nextNodeRef + clusterColumnCount = 0 + numberOfRowsInEndpoint += 1 + + if endpoint != 0: + # Create link to endpoints in the parts list + for part in partsListFromWildcardRead: + graph.edge(f"ep{endpoint}", f"ep{part}", ltail=f"cluster_{endpoint}", minlen=f"{numberOfRowsInEndpoint}") + + +class TC_MatterDeviceGraph(MatterBaseTest): + @async_test_body + async def test_matter_device_graph(self): + + # Create console to print + global console + console = Console() + + # Run descriptor validation test + dev_ctrl = self.default_controller + + # Perform wildcard read to get all attributes from device + console.print("[blue]Capturing data from device") + wildcardResponse = await dev_ctrl.ReadAttribute(self.dut_node_id, [('*')]) + # console.print(wildcardResponse) + + # Creating graph object + deviceGraph = graphviz.Digraph() + deviceGraph.attr(style="rounded", splines="line", compound="true") + + console.print("[blue]Generating graph") + # Loop through each endpoint in the response from the wildcard read + for endpoint in wildcardResponse: + + if endpoint == 0: + with deviceGraph.subgraph(name='cluster_rootnode') as rootNodeSection: + CreateEndpointGraph(deviceGraph, rootNodeSection, endpoint, wildcardResponse) + else: + with deviceGraph.subgraph(name='cluster_endpoints') as endpointsSection: + with endpointsSection.subgraph(name=f'cluster_{endpoint}') as endpointSection: + CreateEndpointGraph(deviceGraph, endpointSection, endpoint, wildcardResponse) + + deviceGraph.save(f'{sys.path[0]}/matter-device-graph.dot') + + deviceDataFile = open(f'{sys.path[0]}/matter-device-data.txt', 'w') + deviceDataFile.write(pprint.pformat((wildcardResponse))) + deviceDataFile.close() + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/transport/BUILD.gn b/src/transport/BUILD.gn index 33a8f05f8c64df..5d1a9c9d3becc0 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") @@ -68,7 +67,6 @@ 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) { 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..057065a3d1a1bc 100644 --- a/src/transport/tests/BUILD.gn +++ b/src/transport/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") @@ -55,11 +54,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 6228c2e1ec7ef2..96839b445e32e4 160000 --- a/third_party/imgui/repo +++ b/third_party/imgui/repo @@ -1 +1 @@ -Subproject commit 6228c2e1ec7ef21ca1809579c055ed34540dedb0 +Subproject commit 96839b445e32e46d87a44fd43a9cdd60c806f7e1 diff --git a/third_party/mbedtls/repo b/third_party/mbedtls/repo index c7e208d2fa8b1e..1b9cea30b1d59a 160000 --- a/third_party/mbedtls/repo +++ b/third_party/mbedtls/repo @@ -1 +1 @@ -Subproject commit c7e208d2fa8b1e66edd53121a618577d7c54cc96 +Subproject commit 1b9cea30b1d59a42df7d0f98aed97462985d42d5 diff --git a/third_party/nanopb/repo b/third_party/nanopb/repo index 423c03b626a861..f8724ee54b3733 160000 --- a/third_party/nanopb/repo +++ b/third_party/nanopb/repo @@ -1 +1 @@ -Subproject commit 423c03b626a861a7b3a08a2d411e23aefd58827b +Subproject commit f8724ee54b3733aebfc25ac0ed5e8b142569c59e diff --git a/third_party/openthread/repo b/third_party/openthread/repo index f1e74a036b5bd2..bf587dd09005ab 160000 --- a/third_party/openthread/repo +++ b/third_party/openthread/repo @@ -1 +1 @@ -Subproject commit f1e74a036b5bd2e9dd6565161ab806cc854dc0b4 +Subproject commit bf587dd09005abc49a5595f8691afb9512fac9c1 diff --git a/third_party/ot-br-posix/repo b/third_party/ot-br-posix/repo index 02421b0ea6422a..13d583e361c703 160000 --- a/third_party/ot-br-posix/repo +++ b/third_party/ot-br-posix/repo @@ -1 +1 @@ -Subproject commit 02421b0ea6422a71150f786168a470d5d87a6d81 +Subproject commit 13d583e361c7038b967b601d5e5f6739b0bcf736 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..957132452b900c 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 @@ -9918,17 +9918,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 +9937,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 +9947,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 { 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..c37d28b28bc936 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 @@ -1936,13 +1936,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 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..7cf3765f7ba28c 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 */ @@ -3124,6 +3129,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 // 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..727ddd76e02024 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 static_cast(3); + } +} +static auto __attribute__((unused)) EnsureKnownEnumValue(detail::DegradationDirectionEnum val) +{ + using EnumType = detail::DegradationDirectionEnum; + switch (val) + { + case EnumType::kUp: + case EnumType::kDown: + return val; + default: + return static_cast(2); + } +} +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 static_cast(4); + } +} +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 static_cast(5); + } +} +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 static_cast(3); + } +} +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 static_cast(15); + } +} +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 static_cast(8); + } +} +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 static_cast(4); + } +} +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 static_cast(5); + } +} + static auto __attribute__((unused)) EnsureKnownEnumValue(Identify::EffectIdentifierEnum val) { using EnumType = Identify::EffectIdentifierEnum; @@ -1216,35 +1356,6 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Timer::TimerStatusEnum } } -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); - } -} - static auto __attribute__((unused)) EnsureKnownEnumValue(OvenMode::ModeTag val) { using EnumType = OvenMode::ModeTag; @@ -1410,264 +1521,141 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(MicrowaveOvenMode::Mode } } -static auto __attribute__((unused)) EnsureKnownEnumValue(OperationalState::ErrorStateEnum val) +static auto __attribute__((unused)) EnsureKnownEnumValue(ValveConfigurationAndControl::StatusCodeEnum val) { - using EnumType = OperationalState::ErrorStateEnum; + using EnumType = ValveConfigurationAndControl::StatusCodeEnum; switch (val) { - case EnumType::kNoError: - case EnumType::kUnableToStartOrResume: - case EnumType::kUnableToCompleteOperation: - case EnumType::kCommandInvalidInState: + case EnumType::kFailureDueToFault: return val; default: - return static_cast(4); + return static_cast(0); } } -static auto __attribute__((unused)) EnsureKnownEnumValue(OperationalState::OperationalStateEnum val) +static auto __attribute__((unused)) EnsureKnownEnumValue(ValveConfigurationAndControl::ValveStateEnum val) { - using EnumType = OperationalState::OperationalStateEnum; + using EnumType = ValveConfigurationAndControl::ValveStateEnum; switch (val) { - case EnumType::kStopped: - case EnumType::kRunning: - case EnumType::kPaused: - case EnumType::kError: + case EnumType::kClosed: + case EnumType::kOpen: + case EnumType::kTransitioning: return val; default: - return static_cast(4); + return static_cast(3); } } -static auto __attribute__((unused)) EnsureKnownEnumValue(HepaFilterMonitoring::ChangeIndicationEnum val) +static auto __attribute__((unused)) EnsureKnownEnumValue(ElectricalPowerMeasurement::PowerModeEnum val) { - using EnumType = HepaFilterMonitoring::ChangeIndicationEnum; + using EnumType = ElectricalPowerMeasurement::PowerModeEnum; switch (val) { - case EnumType::kOk: - case EnumType::kWarning: - case EnumType::kCritical: + case EnumType::kUnknown: + case EnumType::kDc: + case EnumType::kAc: return val; default: return static_cast(3); } } -static auto __attribute__((unused)) EnsureKnownEnumValue(HepaFilterMonitoring::DegradationDirectionEnum val) + +static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadControl::CriticalityLevelEnum val) { - using EnumType = HepaFilterMonitoring::DegradationDirectionEnum; + using EnumType = DemandResponseLoadControl::CriticalityLevelEnum; switch (val) { - case EnumType::kUp: - case EnumType::kDown: + case EnumType::kUnknown: + case EnumType::kGreen: + case EnumType::kLevel1: + case EnumType::kLevel2: + case EnumType::kLevel3: + case EnumType::kLevel4: + case EnumType::kLevel5: + case EnumType::kEmergency: + case EnumType::kPlannedOutage: + case EnumType::kServiceDisconnect: return val; default: - return static_cast(2); + return static_cast(10); } } -static auto __attribute__((unused)) EnsureKnownEnumValue(HepaFilterMonitoring::ProductIdentifierTypeEnum val) +static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadControl::HeatingSourceEnum val) { - using EnumType = HepaFilterMonitoring::ProductIdentifierTypeEnum; + using EnumType = DemandResponseLoadControl::HeatingSourceEnum; switch (val) { - case EnumType::kUpc: - case EnumType::kGtin8: - case EnumType::kEan: - case EnumType::kGtin14: - case EnumType::kOem: + case EnumType::kAny: + case EnumType::kElectric: + case EnumType::kNonElectric: return val; default: - return static_cast(5); + return static_cast(3); } } - -static auto __attribute__((unused)) EnsureKnownEnumValue(ActivatedCarbonFilterMonitoring::ChangeIndicationEnum val) +static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadControl::LoadControlEventChangeSourceEnum val) { - using EnumType = ActivatedCarbonFilterMonitoring::ChangeIndicationEnum; + using EnumType = DemandResponseLoadControl::LoadControlEventChangeSourceEnum; switch (val) { - case EnumType::kOk: - case EnumType::kWarning: - case EnumType::kCritical: + case EnumType::kAutomatic: + case EnumType::kUserAction: return val; default: - return static_cast(3); + return static_cast(2); } } -static auto __attribute__((unused)) EnsureKnownEnumValue(ActivatedCarbonFilterMonitoring::DegradationDirectionEnum val) +static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadControl::LoadControlEventStatusEnum val) { - using EnumType = ActivatedCarbonFilterMonitoring::DegradationDirectionEnum; + using EnumType = DemandResponseLoadControl::LoadControlEventStatusEnum; switch (val) { - case EnumType::kUp: - case EnumType::kDown: + case EnumType::kUnknown: + case EnumType::kReceived: + case EnumType::kInProgress: + case EnumType::kCompleted: + case EnumType::kOptedOut: + case EnumType::kOptedIn: + case EnumType::kCanceled: + case EnumType::kSuperseded: + case EnumType::kPartialOptedOut: + case EnumType::kPartialOptedIn: + case EnumType::kNoParticipation: + case EnumType::kUnavailable: + case EnumType::kFailed: return val; default: - return static_cast(2); + return static_cast(13); } } -static auto __attribute__((unused)) EnsureKnownEnumValue(ActivatedCarbonFilterMonitoring::ProductIdentifierTypeEnum val) + +static auto __attribute__((unused)) EnsureKnownEnumValue(Messages::FutureMessagePreferenceEnum val) { - using EnumType = ActivatedCarbonFilterMonitoring::ProductIdentifierTypeEnum; + using EnumType = Messages::FutureMessagePreferenceEnum; switch (val) { - case EnumType::kUpc: - case EnumType::kGtin8: - case EnumType::kEan: - case EnumType::kGtin14: - case EnumType::kOem: + case EnumType::kAllowed: + case EnumType::kIncreased: + case EnumType::kReduced: + case EnumType::kDisallowed: + case EnumType::kBanned: return val; default: return static_cast(5); } } - -static auto __attribute__((unused)) EnsureKnownEnumValue(ValveConfigurationAndControl::StatusCodeEnum val) +static auto __attribute__((unused)) EnsureKnownEnumValue(Messages::MessagePriorityEnum val) { - using EnumType = ValveConfigurationAndControl::StatusCodeEnum; + using EnumType = Messages::MessagePriorityEnum; switch (val) { - case EnumType::kFailureDueToFault: + case EnumType::kLow: + case EnumType::kMedium: + case EnumType::kHigh: + case EnumType::kCritical: return val; default: - return static_cast(0); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(ValveConfigurationAndControl::ValveStateEnum val) -{ - using EnumType = ValveConfigurationAndControl::ValveStateEnum; - switch (val) - { - case EnumType::kClosed: - case EnumType::kOpen: - case EnumType::kTransitioning: - return val; - default: - return static_cast(3); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(ElectricalEnergyMeasurement::MeasurementTypeEnum val) -{ - using EnumType = ElectricalEnergyMeasurement::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 static_cast(15); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadControl::CriticalityLevelEnum val) -{ - using EnumType = DemandResponseLoadControl::CriticalityLevelEnum; - switch (val) - { - case EnumType::kUnknown: - case EnumType::kGreen: - case EnumType::kLevel1: - case EnumType::kLevel2: - case EnumType::kLevel3: - case EnumType::kLevel4: - case EnumType::kLevel5: - case EnumType::kEmergency: - case EnumType::kPlannedOutage: - case EnumType::kServiceDisconnect: - return val; - default: - return static_cast(10); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadControl::HeatingSourceEnum val) -{ - using EnumType = DemandResponseLoadControl::HeatingSourceEnum; - switch (val) - { - case EnumType::kAny: - case EnumType::kElectric: - case EnumType::kNonElectric: - return val; - default: - return static_cast(3); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadControl::LoadControlEventChangeSourceEnum val) -{ - using EnumType = DemandResponseLoadControl::LoadControlEventChangeSourceEnum; - switch (val) - { - case EnumType::kAutomatic: - case EnumType::kUserAction: - return val; - default: - return static_cast(2); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadControl::LoadControlEventStatusEnum val) -{ - using EnumType = DemandResponseLoadControl::LoadControlEventStatusEnum; - switch (val) - { - case EnumType::kUnknown: - case EnumType::kReceived: - case EnumType::kInProgress: - case EnumType::kCompleted: - case EnumType::kOptedOut: - case EnumType::kOptedIn: - case EnumType::kCanceled: - case EnumType::kSuperseded: - case EnumType::kPartialOptedOut: - case EnumType::kPartialOptedIn: - case EnumType::kNoParticipation: - case EnumType::kUnavailable: - case EnumType::kFailed: - return val; - default: - return static_cast(13); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(Messages::FutureMessagePreferenceEnum val) -{ - using EnumType = Messages::FutureMessagePreferenceEnum; - switch (val) - { - case EnumType::kAllowed: - case EnumType::kIncreased: - case EnumType::kReduced: - case EnumType::kDisallowed: - case EnumType::kBanned: - return val; - default: - return static_cast(5); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(Messages::MessagePriorityEnum val) -{ - using EnumType = Messages::MessagePriorityEnum; - switch (val) - { - case EnumType::kLow: - case EnumType::kMedium: - case EnumType::kHigh: - case EnumType::kCritical: - return val; - default: - return static_cast(4); + return static_cast(4); } } @@ -2719,478 +2707,6 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(OccupancySensing::Occup } } -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); - } -} - static auto __attribute__((unused)) EnsureKnownEnumValue(Channel::ChannelTypeEnum val) { using EnumType = Channel::ChannelTypeEnum; 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 17d692d6930bc8..0d543de50b2744 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 @@ -1516,33 +1662,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 { @@ -1703,7 +1825,7 @@ enum class StatusCode : uint8_t // Bitmap for Feature enum class Feature : uint32_t { - kOnOff = 0x1, + kNoFeatures = 0x0, }; } // namespace RvcRunMode @@ -1736,7 +1858,7 @@ enum class StatusCode : uint8_t // Bitmap for Feature enum class Feature : uint32_t { - kOnOff = 0x1, + kNoFeatures = 0x0, }; } // namespace RvcCleanMode @@ -1958,33 +2080,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 +2136,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 +2153,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 +2238,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 { @@ -4058,51 +4093,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 +4113,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 +4133,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 +4153,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 +4173,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 +4193,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 +4213,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 +4233,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 +4253,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 +4273,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 8b0a7d22694475..d8717b571de30c 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 { @@ -10748,8 +10875,6 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre return DataModel::Decode(reader, supportedModes); case Attributes::CurrentMode::TypeInfo::GetAttributeId(): return DataModel::Decode(reader, currentMode); - case Attributes::OnMode::TypeInfo::GetAttributeId(): - return DataModel::Decode(reader, onMode); case Attributes::GeneratedCommandList::TypeInfo::GetAttributeId(): return DataModel::Decode(reader, generatedCommandList); case Attributes::AcceptedCommandList::TypeInfo::GetAttributeId(): @@ -10859,8 +10984,6 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre return DataModel::Decode(reader, supportedModes); case Attributes::CurrentMode::TypeInfo::GetAttributeId(): return DataModel::Decode(reader, currentMode); - case Attributes::OnMode::TypeInfo::GetAttributeId(): - return DataModel::Decode(reader, onMode); case Attributes::GeneratedCommandList::TypeInfo::GetAttributeId(): return DataModel::Decode(reader, generatedCommandList); case Attributes::AcceptedCommandList::TypeInfo::GetAttributeId(): @@ -12168,46 +12291,6 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } } } // namespace Pause. -namespace Stop { -CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const -{ - DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; - 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); - } - } -} -} // namespace Stop. -namespace Start { -CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const -{ - DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; - 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); - } - } -} -} // namespace Start. namespace Resume { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { @@ -13862,21 +13945,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(); } @@ -13894,37 +13971,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 { @@ -13934,18 +14073,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) @@ -13962,25 +14163,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 { @@ -13990,7 +14230,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 @@ -14066,6 +14306,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(): @@ -14963,7 +15205,13 @@ namespace PresentMessagesRequest { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; - encoder.Encode(to_underlying(Fields::kMessages), messages); + encoder.Encode(to_underlying(Fields::kMessageID), messageID); + encoder.Encode(to_underlying(Fields::kPriority), priority); + encoder.Encode(to_underlying(Fields::kMessageControl), messageControl); + encoder.Encode(to_underlying(Fields::kStartTime), startTime); + encoder.Encode(to_underlying(Fields::kDuration), duration); + encoder.Encode(to_underlying(Fields::kMessageText), messageText); + encoder.Encode(to_underlying(Fields::kResponses), responses); return encoder.Finalize(); } @@ -14981,9 +15229,33 @@ 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::kMessages)) + if (__context_tag == to_underlying(Fields::kMessageID)) { - err = DataModel::Decode(reader, messages); + err = DataModel::Decode(reader, messageID); + } + else if (__context_tag == to_underlying(Fields::kPriority)) + { + err = DataModel::Decode(reader, priority); + } + else if (__context_tag == to_underlying(Fields::kMessageControl)) + { + err = DataModel::Decode(reader, messageControl); + } + else if (__context_tag == to_underlying(Fields::kStartTime)) + { + err = DataModel::Decode(reader, startTime); + } + else if (__context_tag == to_underlying(Fields::kDuration)) + { + err = DataModel::Decode(reader, duration); + } + else if (__context_tag == to_underlying(Fields::kMessageText)) + { + err = DataModel::Decode(reader, messageText); + } + else if (__context_tag == to_underlying(Fields::kResponses)) + { + err = DataModel::Decode(reader, responses); } else { 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 0a56f821cb37f8..03b4650b243e5f 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 { @@ -15199,18 +15274,6 @@ struct TypeInfo static constexpr bool MustUseTimedWrite() { return false; } }; } // namespace CurrentMode -namespace OnMode { -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::RvcRunMode::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::OnMode::Id; } - static constexpr bool MustUseTimedWrite() { return false; } -}; -} // namespace OnMode namespace GeneratedCommandList { struct TypeInfo : public Clusters::Globals::Attributes::GeneratedCommandList::TypeInfo { @@ -15258,7 +15321,6 @@ struct TypeInfo Attributes::SupportedModes::TypeInfo::DecodableType supportedModes; Attributes::CurrentMode::TypeInfo::DecodableType currentMode = static_cast(0); - Attributes::OnMode::TypeInfo::DecodableType onMode; Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; Attributes::EventList::TypeInfo::DecodableType eventList; @@ -15388,18 +15450,6 @@ struct TypeInfo static constexpr bool MustUseTimedWrite() { return false; } }; } // namespace CurrentMode -namespace OnMode { -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::RvcCleanMode::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::OnMode::Id; } - static constexpr bool MustUseTimedWrite() { return false; } -}; -} // namespace OnMode namespace GeneratedCommandList { struct TypeInfo : public Clusters::Globals::Attributes::GeneratedCommandList::TypeInfo { @@ -15447,7 +15497,6 @@ struct TypeInfo Attributes::SupportedModes::TypeInfo::DecodableType supportedModes; Attributes::CurrentMode::TypeInfo::DecodableType currentMode = static_cast(0); - Attributes::OnMode::TypeInfo::DecodableType onMode; Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; Attributes::EventList::TypeInfo::DecodableType eventList; @@ -17687,16 +17736,6 @@ struct Type; struct DecodableType; } // namespace Pause -namespace Stop { -struct Type; -struct DecodableType; -} // namespace Stop - -namespace Start { -struct Type; -struct DecodableType; -} // namespace Start - namespace Resume { struct Type; struct DecodableType; @@ -17743,62 +17782,6 @@ struct DecodableType CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace Pause -namespace Stop { -enum class Fields : uint8_t -{ -}; - -struct Type -{ -public: - // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand - static constexpr CommandId GetCommandId() { return Commands::Stop::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::RvcOperationalState::Id; } - - CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; - - using ResponseType = Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType; - - static constexpr bool MustUseTimedInvoke() { return false; } -}; - -struct DecodableType -{ -public: - static constexpr CommandId GetCommandId() { return Commands::Stop::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::RvcOperationalState::Id; } - - CHIP_ERROR Decode(TLV::TLVReader & reader); -}; -}; // namespace Stop -namespace Start { -enum class Fields : uint8_t -{ -}; - -struct Type -{ -public: - // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand - static constexpr CommandId GetCommandId() { return Commands::Start::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::RvcOperationalState::Id; } - - CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; - - using ResponseType = Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType; - - static constexpr bool MustUseTimedInvoke() { return false; } -}; - -struct DecodableType -{ -public: - static constexpr CommandId GetCommandId() { return Commands::Start::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::RvcOperationalState::Id; } - - CHIP_ERROR Decode(TLV::TLVReader & reader); -}; -}; // namespace Start namespace Resume { enum class Fields : uint8_t { @@ -20041,32 +20024,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); @@ -20077,46 +20050,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 { @@ -20223,6 +20583,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 { @@ -20273,6 +20648,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; @@ -21097,7 +21473,13 @@ namespace Commands { namespace PresentMessagesRequest { enum class Fields : uint8_t { - kMessages = 0, + kMessageID = 0, + kPriority = 1, + kMessageControl = 2, + kStartTime = 3, + kDuration = 4, + kMessageText = 5, + kResponses = 6, }; struct Type @@ -21107,7 +21489,13 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::PresentMessagesRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::Messages::Id; } - DataModel::List messages; + chip::ByteSpan messageID; + MessagePriorityEnum priority = static_cast(0); + chip::BitMask messageControl = static_cast>(0); + DataModel::Nullable startTime; + DataModel::Nullable duration; + chip::CharSpan messageText; + Optional> responses; CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -21122,7 +21510,13 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::PresentMessagesRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::Messages::Id; } - DataModel::DecodableList messages; + chip::ByteSpan messageID; + MessagePriorityEnum priority = static_cast(0); + chip::BitMask messageControl = static_cast>(0); + DataModel::Nullable startTime; + DataModel::Nullable duration; + chip::CharSpan messageText; + Optional> responses; CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace PresentMessagesRequest 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 f42ceca8f55b74..868602695023c6 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 @@ -2774,10 +2774,6 @@ namespace CurrentMode { static constexpr AttributeId Id = 0x00000001; } // namespace CurrentMode -namespace OnMode { -static constexpr AttributeId Id = 0x00000003; -} // namespace OnMode - namespace GeneratedCommandList { static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; } // namespace GeneratedCommandList @@ -2816,10 +2812,6 @@ namespace CurrentMode { static constexpr AttributeId Id = 0x00000001; } // namespace CurrentMode -namespace OnMode { -static constexpr AttributeId Id = 0x00000003; -} // namespace OnMode - namespace GeneratedCommandList { static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; } // namespace GeneratedCommandList @@ -3649,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 { @@ -3672,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 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..6f956f1b36a40b 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 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 3f944364a87260..6093139e72464d 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 @@ -792,14 +792,6 @@ namespace Pause { static constexpr CommandId Id = 0x00000000; } // namespace Pause -namespace Stop { -static constexpr CommandId Id = 0x00000001; -} // namespace Stop - -namespace Start { -static constexpr CommandId Id = 0x00000002; -} // namespace Start - namespace Resume { static constexpr CommandId Id = 0x00000003; } // namespace Resume 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..e15b9701610a05 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 \ @@ -851,6 +858,7 @@ 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 \ diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index ac81a48f41d711..16600c53bf5817 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -100,6 +100,7 @@ | ActivatedCarbonFilterMonitoring | 0x0072 | | BooleanStateConfiguration | 0x0080 | | ValveConfigurationAndControl | 0x0081 | +| ElectricalPowerMeasurement | 0x0090 | | ElectricalEnergyMeasurement | 0x0091 | | DemandResponseLoadControl | 0x0096 | | Messages | 0x0097 | @@ -4926,7 +4927,6 @@ class RefrigeratorAndTemperatureControlledCabinetModeChangeToMode : public Clust | Attributes: | | | * SupportedModes | 0x0000 | | * CurrentMode | 0x0001 | -| * OnMode | 0x0003 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -4983,7 +4983,6 @@ class RvcRunModeChangeToMode : public ClusterCommand | Attributes: | | | * SupportedModes | 0x0000 | | * CurrentMode | 0x0001 | -| * OnMode | 0x0003 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -5666,8 +5665,6 @@ class OperationalStateResume : public ClusterCommand |------------------------------------------------------------------------------| | Commands: | | | * Pause | 0x00 | -| * Stop | 0x01 | -| * Start | 0x02 | | * Resume | 0x03 | | * GoHome | 0x80 | |------------------------------------------------------------------------------| @@ -5726,78 +5723,6 @@ class RvcOperationalStatePause : public ClusterCommand chip::app::Clusters::RvcOperationalState::Commands::Pause::Type mRequest; }; -/* - * Command Stop - */ -class RvcOperationalStateStop : public ClusterCommand -{ -public: - RvcOperationalStateStop(CredentialIssuerCommands * credsIssuerConfig) : ClusterCommand("stop", credsIssuerConfig) - { - ClusterCommand::AddArguments(); - } - - CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override - { - constexpr chip::ClusterId clusterId = chip::app::Clusters::RvcOperationalState::Id; - constexpr chip::CommandId commandId = chip::app::Clusters::RvcOperationalState::Commands::Stop::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::RvcOperationalState::Id; - constexpr chip::CommandId commandId = chip::app::Clusters::RvcOperationalState::Commands::Stop::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::RvcOperationalState::Commands::Stop::Type mRequest; -}; - -/* - * Command Start - */ -class RvcOperationalStateStart : public ClusterCommand -{ -public: - RvcOperationalStateStart(CredentialIssuerCommands * credsIssuerConfig) : ClusterCommand("start", credsIssuerConfig) - { - ClusterCommand::AddArguments(); - } - - CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override - { - constexpr chip::ClusterId clusterId = chip::app::Clusters::RvcOperationalState::Id; - constexpr chip::CommandId commandId = chip::app::Clusters::RvcOperationalState::Commands::Start::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::RvcOperationalState::Id; - constexpr chip::CommandId commandId = chip::app::Clusters::RvcOperationalState::Commands::Start::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::RvcOperationalState::Commands::Start::Type mRequest; -}; - /* * Command Resume */ @@ -6540,6 +6465,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 | |------------------------------------------------------------------------------| @@ -6551,6 +6512,7 @@ class ValveConfigurationAndControlClose : public ClusterCommand | * CumulativeEnergyExported | 0x0002 | | * PeriodicEnergyImported | 0x0003 | | * PeriodicEnergyExported | 0x0004 | +| * CumulativeEnergyReset | 0x0005 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -6827,9 +6789,15 @@ class MessagesPresentMessagesRequest : public ClusterCommand { public: MessagesPresentMessagesRequest(CredentialIssuerCommands * credsIssuerConfig) : - ClusterCommand("present-messages-request", credsIssuerConfig), mComplex_Messages(&mRequest.messages) + ClusterCommand("present-messages-request", credsIssuerConfig), mComplex_Responses(&mRequest.responses) { - AddArgument("Messages", &mComplex_Messages); + AddArgument("MessageID", &mRequest.messageID); + AddArgument("Priority", 0, UINT8_MAX, &mRequest.priority); + AddArgument("MessageControl", 0, UINT8_MAX, &mRequest.messageControl); + AddArgument("StartTime", 0, UINT32_MAX, &mRequest.startTime); + AddArgument("Duration", 0, UINT16_MAX, &mRequest.duration); + AddArgument("MessageText", &mRequest.messageText); + AddArgument("Responses", &mComplex_Responses, "", Argument::kOptional); ClusterCommand::AddArguments(); } @@ -6856,8 +6824,9 @@ class MessagesPresentMessagesRequest : public ClusterCommand private: chip::app::Clusters::Messages::Commands::PresentMessagesRequest::Type mRequest; - TypedComplexArgument> - mComplex_Messages; + TypedComplexArgument< + chip::Optional>> + mComplex_Responses; }; /* @@ -18769,7 +18738,6 @@ void registerClusterRvcRunMode(Commands & commands, CredentialIssuerCommands * c make_unique(Id, credsIssuerConfig), // make_unique(Id, "supported-modes", Attributes::SupportedModes::Id, credsIssuerConfig), // make_unique(Id, "current-mode", Attributes::CurrentMode::Id, credsIssuerConfig), // - make_unique(Id, "on-mode", Attributes::OnMode::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), // @@ -18782,8 +18750,6 @@ void registerClusterRvcRunMode(Commands & commands, CredentialIssuerCommands * c Id, "supported-modes", Attributes::SupportedModes::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>(Id, "current-mode", 0, UINT8_MAX, Attributes::CurrentMode::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>>(Id, "on-mode", 0, UINT8_MAX, Attributes::OnMode::Id, - WriteCommandType::kWrite, credsIssuerConfig), // make_unique>>( Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // @@ -18800,7 +18766,6 @@ void registerClusterRvcRunMode(Commands & commands, CredentialIssuerCommands * c make_unique(Id, credsIssuerConfig), // make_unique(Id, "supported-modes", Attributes::SupportedModes::Id, credsIssuerConfig), // make_unique(Id, "current-mode", Attributes::CurrentMode::Id, credsIssuerConfig), // - make_unique(Id, "on-mode", Attributes::OnMode::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), // @@ -18834,7 +18799,6 @@ void registerClusterRvcCleanMode(Commands & commands, CredentialIssuerCommands * make_unique(Id, credsIssuerConfig), // make_unique(Id, "supported-modes", Attributes::SupportedModes::Id, credsIssuerConfig), // make_unique(Id, "current-mode", Attributes::CurrentMode::Id, credsIssuerConfig), // - make_unique(Id, "on-mode", Attributes::OnMode::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), // @@ -18847,8 +18811,6 @@ void registerClusterRvcCleanMode(Commands & commands, CredentialIssuerCommands * Id, "supported-modes", Attributes::SupportedModes::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>(Id, "current-mode", 0, UINT8_MAX, Attributes::CurrentMode::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>>(Id, "on-mode", 0, UINT8_MAX, Attributes::OnMode::Id, - WriteCommandType::kWrite, credsIssuerConfig), // make_unique>>( Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // @@ -18865,7 +18827,6 @@ void registerClusterRvcCleanMode(Commands & commands, CredentialIssuerCommands * make_unique(Id, credsIssuerConfig), // make_unique(Id, "supported-modes", Attributes::SupportedModes::Id, credsIssuerConfig), // make_unique(Id, "current-mode", Attributes::CurrentMode::Id, credsIssuerConfig), // - make_unique(Id, "on-mode", Attributes::OnMode::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), // @@ -19604,8 +19565,6 @@ void registerClusterRvcOperationalState(Commands & commands, CredentialIssuerCom // make_unique(Id, credsIssuerConfig), // make_unique(credsIssuerConfig), // - make_unique(credsIssuerConfig), // - make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // // @@ -20118,6 +20077,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; @@ -20140,6 +20245,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), // @@ -20166,6 +20272,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), // @@ -20188,13 +20298,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 // @@ -26594,6 +26705,7 @@ 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); 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 ed55791683b074..c0734b7387be0f 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); - 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); + 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 'Measured'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ImportedResetTimestamp'"); return err; } } { - CHIP_ERROR err = LogValue("MinMeasuredValue", indent + 1, value.minMeasuredValue); + 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 'MinMeasuredValue'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExportedResetTimestamp'"); return err; } } { - CHIP_ERROR err = LogValue("MaxMeasuredValue", indent + 1, value.maxMeasuredValue); + 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 'MaxMeasuredValue'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ImportedResetSystime'"); return err; } } { - CHIP_ERROR err = LogValue("AccuracyRanges", indent + 1, value.accuracyRanges); + 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 '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) { @@ -11175,11 +11356,6 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("CurrentMode", 1, value); } - case RvcRunMode::Attributes::OnMode::Id: { - chip::app::DataModel::Nullable value; - ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("OnMode", 1, value); - } case RvcRunMode::Attributes::GeneratedCommandList::Id: { chip::app::DataModel::DecodableList value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); @@ -11226,11 +11402,6 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("CurrentMode", 1, value); } - case RvcCleanMode::Attributes::OnMode::Id: { - chip::app::DataModel::Nullable value; - ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("OnMode", 1, value); - } case RvcCleanMode::Attributes::GeneratedCommandList::Id: { chip::app::DataModel::DecodableList value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); @@ -12255,6 +12426,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) { @@ -12291,6 +12601,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)); @@ -18750,6 +19067,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..f201e84ad8a572 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::ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::DecodableType & value); + 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::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 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 b68a2b4974cb32..b8761b9f618318 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -102,6 +102,7 @@ | ActivatedCarbonFilterMonitoring | 0x0072 | | BooleanStateConfiguration | 0x0080 | | ValveConfigurationAndControl | 0x0081 | +| ElectricalPowerMeasurement | 0x0090 | | ElectricalEnergyMeasurement | 0x0091 | | DemandResponseLoadControl | 0x0096 | | Messages | 0x0097 | @@ -57077,7 +57078,6 @@ class SubscribeAttributeLaundryWasherControlsClusterRevision : public SubscribeA | Attributes: | | | * SupportedModes | 0x0000 | | * CurrentMode | 0x0001 | -| * OnMode | 0x0003 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -57305,136 +57305,6 @@ class SubscribeAttributeRvcRunModeCurrentMode : public SubscribeAttribute { } }; -#if MTR_ENABLE_PROVISIONAL - -/* - * Attribute OnMode - */ -class ReadRvcRunModeOnMode : public ReadAttribute { -public: - ReadRvcRunModeOnMode() - : ReadAttribute("on-mode") - { - } - - ~ReadRvcRunModeOnMode() - { - } - - CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override - { - constexpr chip::ClusterId clusterId = chip::app::Clusters::RvcRunMode::Id; - constexpr chip::AttributeId attributeId = chip::app::Clusters::RvcRunMode::Attributes::OnMode::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 = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; - [cluster readAttributeOnModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { - NSLog(@"RVCRunMode.OnMode response %@", [value description]); - if (error == nil) { - RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); - } else { - LogNSError("RVCRunMode OnMode read Error", error); - RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); - } - SetCommandExitStatus(error); - }]; - return CHIP_NO_ERROR; - } -}; - -class WriteRvcRunModeOnMode : public WriteAttribute { -public: - WriteRvcRunModeOnMode() - : WriteAttribute("on-mode") - { - AddArgument("attr-name", "on-mode"); - AddArgument("attr-value", 0, UINT8_MAX, &mValue); - WriteAttribute::AddArguments(); - } - - ~WriteRvcRunModeOnMode() - { - } - - CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override - { - constexpr chip::ClusterId clusterId = chip::app::Clusters::RvcRunMode::Id; - constexpr chip::AttributeId attributeId = chip::app::Clusters::RvcRunMode::Attributes::OnMode::Id; - - ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") WriteAttribute (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 = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; - __auto_type * params = [[MTRWriteParams alloc] init]; - params.timedWriteTimeout = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; - params.dataVersion = mDataVersion.HasValue() ? [NSNumber numberWithUnsignedInt:mDataVersion.Value()] : nil; - NSNumber * _Nullable value = nil; - if (!mValue.IsNull()) { - value = [NSNumber numberWithUnsignedChar:mValue.Value()]; - } - - [cluster writeAttributeOnModeWithValue:value params:params completion:^(NSError * _Nullable error) { - if (error != nil) { - LogNSError("RVCRunMode OnMode write Error", error); - RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); - } - SetCommandExitStatus(error); - }]; - return CHIP_NO_ERROR; - } - -private: - chip::app::DataModel::Nullable mValue; -}; - -class SubscribeAttributeRvcRunModeOnMode : public SubscribeAttribute { -public: - SubscribeAttributeRvcRunModeOnMode() - : SubscribeAttribute("on-mode") - { - } - - ~SubscribeAttributeRvcRunModeOnMode() - { - } - - CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override - { - constexpr chip::ClusterId clusterId = chip::app::Clusters::RvcRunMode::Id; - constexpr chip::CommandId attributeId = chip::app::Clusters::RvcRunMode::Attributes::OnMode::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 = [[MTRBaseClusterRVCRunMode 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 subscribeAttributeOnModeWithParams:params - subscriptionEstablished:^() { mSubscriptionEstablished = YES; } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { - NSLog(@"RVCRunMode.OnMode 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 - /* * Attribute GeneratedCommandList */ @@ -57940,7 +57810,6 @@ class SubscribeAttributeRvcRunModeClusterRevision : public SubscribeAttribute { | Attributes: | | | * SupportedModes | 0x0000 | | * CurrentMode | 0x0001 | -| * OnMode | 0x0003 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -58168,136 +58037,6 @@ class SubscribeAttributeRvcCleanModeCurrentMode : public SubscribeAttribute { } }; -#if MTR_ENABLE_PROVISIONAL - -/* - * Attribute OnMode - */ -class ReadRvcCleanModeOnMode : public ReadAttribute { -public: - ReadRvcCleanModeOnMode() - : ReadAttribute("on-mode") - { - } - - ~ReadRvcCleanModeOnMode() - { - } - - CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override - { - constexpr chip::ClusterId clusterId = chip::app::Clusters::RvcCleanMode::Id; - constexpr chip::AttributeId attributeId = chip::app::Clusters::RvcCleanMode::Attributes::OnMode::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 = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; - [cluster readAttributeOnModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { - NSLog(@"RVCCleanMode.OnMode response %@", [value description]); - if (error == nil) { - RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); - } else { - LogNSError("RVCCleanMode OnMode read Error", error); - RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); - } - SetCommandExitStatus(error); - }]; - return CHIP_NO_ERROR; - } -}; - -class WriteRvcCleanModeOnMode : public WriteAttribute { -public: - WriteRvcCleanModeOnMode() - : WriteAttribute("on-mode") - { - AddArgument("attr-name", "on-mode"); - AddArgument("attr-value", 0, UINT8_MAX, &mValue); - WriteAttribute::AddArguments(); - } - - ~WriteRvcCleanModeOnMode() - { - } - - CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override - { - constexpr chip::ClusterId clusterId = chip::app::Clusters::RvcCleanMode::Id; - constexpr chip::AttributeId attributeId = chip::app::Clusters::RvcCleanMode::Attributes::OnMode::Id; - - ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") WriteAttribute (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 = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; - __auto_type * params = [[MTRWriteParams alloc] init]; - params.timedWriteTimeout = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; - params.dataVersion = mDataVersion.HasValue() ? [NSNumber numberWithUnsignedInt:mDataVersion.Value()] : nil; - NSNumber * _Nullable value = nil; - if (!mValue.IsNull()) { - value = [NSNumber numberWithUnsignedChar:mValue.Value()]; - } - - [cluster writeAttributeOnModeWithValue:value params:params completion:^(NSError * _Nullable error) { - if (error != nil) { - LogNSError("RVCCleanMode OnMode write Error", error); - RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); - } - SetCommandExitStatus(error); - }]; - return CHIP_NO_ERROR; - } - -private: - chip::app::DataModel::Nullable mValue; -}; - -class SubscribeAttributeRvcCleanModeOnMode : public SubscribeAttribute { -public: - SubscribeAttributeRvcCleanModeOnMode() - : SubscribeAttribute("on-mode") - { - } - - ~SubscribeAttributeRvcCleanModeOnMode() - { - } - - CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override - { - constexpr chip::ClusterId clusterId = chip::app::Clusters::RvcCleanMode::Id; - constexpr chip::CommandId attributeId = chip::app::Clusters::RvcCleanMode::Attributes::OnMode::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 = [[MTRBaseClusterRVCCleanMode 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 subscribeAttributeOnModeWithParams:params - subscriptionEstablished:^() { mSubscriptionEstablished = YES; } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { - NSLog(@"RVCCleanMode.OnMode 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 - /* * Attribute GeneratedCommandList */ @@ -68433,8 +68172,6 @@ class SubscribeAttributeOperationalStateClusterRevision : public SubscribeAttrib |------------------------------------------------------------------------------| | Commands: | | | * Pause | 0x00 | -| * Stop | 0x01 | -| * Start | 0x02 | | * Resume | 0x03 | | * GoHome | 0x80 | |------------------------------------------------------------------------------| @@ -68507,110 +68244,6 @@ class RvcOperationalStatePause : public ClusterCommand { private: }; -#if MTR_ENABLE_PROVISIONAL -/* - * Command Stop - */ -class RvcOperationalStateStop : public ClusterCommand { -public: - RvcOperationalStateStop() - : ClusterCommand("stop") - { - ClusterCommand::AddArguments(); - } - - CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override - { - constexpr chip::ClusterId clusterId = chip::app::Clusters::RvcOperationalState::Id; - constexpr chip::CommandId commandId = chip::app::Clusters::RvcOperationalState::Commands::Stop::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 = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; - __auto_type * params = [[MTRRVCOperationalStateClusterStopParams alloc] init]; - params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; - uint16_t repeatCount = mRepeatCount.ValueOr(1); - uint16_t __block responsesNeeded = repeatCount; - while (repeatCount--) { - [cluster stopWithParams:params completion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable error) { - NSLog(@"Values: %@", values); - if (error == nil) { - constexpr chip::CommandId responseId = chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::Id; - RemoteDataModelLogger::LogCommandAsJSON(@(endpointId), @(clusterId), @(responseId), values); - } - responsesNeeded--; - if (error != nil) { - mError = error; - LogNSError("Error", error); - constexpr chip::CommandId responseId = chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::Id; - RemoteDataModelLogger::LogCommandErrorAsJSON(@(endpointId), @(clusterId), @(responseId), error); - } - if (responsesNeeded == 0) { - SetCommandExitStatus(mError); - } - }]; - } - return CHIP_NO_ERROR; - } - -private: -}; - -#endif // MTR_ENABLE_PROVISIONAL -#if MTR_ENABLE_PROVISIONAL -/* - * Command Start - */ -class RvcOperationalStateStart : public ClusterCommand { -public: - RvcOperationalStateStart() - : ClusterCommand("start") - { - ClusterCommand::AddArguments(); - } - - CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override - { - constexpr chip::ClusterId clusterId = chip::app::Clusters::RvcOperationalState::Id; - constexpr chip::CommandId commandId = chip::app::Clusters::RvcOperationalState::Commands::Start::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 = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; - __auto_type * params = [[MTRRVCOperationalStateClusterStartParams alloc] init]; - params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; - uint16_t repeatCount = mRepeatCount.ValueOr(1); - uint16_t __block responsesNeeded = repeatCount; - while (repeatCount--) { - [cluster startWithParams:params completion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable error) { - NSLog(@"Values: %@", values); - if (error == nil) { - constexpr chip::CommandId responseId = chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::Id; - RemoteDataModelLogger::LogCommandAsJSON(@(endpointId), @(clusterId), @(responseId), values); - } - responsesNeeded--; - if (error != nil) { - mError = error; - LogNSError("Error", error); - constexpr chip::CommandId responseId = chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::Id; - RemoteDataModelLogger::LogCommandErrorAsJSON(@(endpointId), @(clusterId), @(responseId), error); - } - if (responsesNeeded == 0) { - SetCommandExitStatus(mError); - } - }]; - } - return CHIP_NO_ERROR; - } - -private: -}; - -#endif // MTR_ENABLE_PROVISIONAL /* * Command Resume */ @@ -76394,6 +76027,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 @@ -76408,6 +78204,7 @@ class SubscribeAttributeValveConfigurationAndControlClusterRevision : public Sub | * CumulativeEnergyExported | 0x0002 | | * PeriodicEnergyImported | 0x0003 | | * PeriodicEnergyExported | 0x0004 | +| * CumulativeEnergyReset | 0x0005 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -76847,6 +78644,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 */ @@ -79073,10 +80955,28 @@ class MessagesPresentMessagesRequest : public ClusterCommand { public: MessagesPresentMessagesRequest() : ClusterCommand("present-messages-request") - , mComplex_Messages(&mRequest.messages) + , mComplex_Responses(&mRequest.responses) { #if MTR_ENABLE_PROVISIONAL - AddArgument("Messages", &mComplex_Messages); + AddArgument("MessageID", &mRequest.messageID); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("Priority", 0, UINT8_MAX, &mRequest.priority); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("MessageControl", 0, UINT8_MAX, &mRequest.messageControl); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("StartTime", 0, UINT32_MAX, &mRequest.startTime); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("Duration", 0, UINT16_MAX, &mRequest.duration); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("MessageText", &mRequest.messageText); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("Responses", &mComplex_Responses); #endif // MTR_ENABLE_PROVISIONAL ClusterCommand::AddArguments(); } @@ -79093,51 +80993,54 @@ class MessagesPresentMessagesRequest : public ClusterCommand { __auto_type * params = [[MTRMessagesClusterPresentMessagesRequestParams alloc] init]; params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; #if MTR_ENABLE_PROVISIONAL - { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; - for (auto & entry_0 : mRequest.messages) { - MTRMessagesClusterMessageStruct * newElement_0; - newElement_0 = [MTRMessagesClusterMessageStruct new]; - newElement_0.messageID = [NSData dataWithBytes:entry_0.messageID.data() length:entry_0.messageID.size()]; - newElement_0.priority = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.priority)]; - newElement_0.messageControl = [NSNumber numberWithUnsignedChar:entry_0.messageControl.Raw()]; - if (entry_0.startTime.IsNull()) { - newElement_0.startTime = nil; - } else { - newElement_0.startTime = [NSNumber numberWithUnsignedInt:entry_0.startTime.Value()]; - } - if (entry_0.duration.IsNull()) { - newElement_0.duration = nil; - } else { - newElement_0.duration = [NSNumber numberWithUnsignedShort:entry_0.duration.Value()]; - } - newElement_0.messageText = [[NSString alloc] initWithBytes:entry_0.messageText.data() length:entry_0.messageText.size() encoding:NSUTF8StringEncoding]; - if (entry_0.responses.HasValue()) { - { // Scope for our temporary variables - auto * array_3 = [NSMutableArray new]; - for (auto & entry_3 : entry_0.responses.Value()) { - MTRMessagesClusterMessageResponseOptionStruct * newElement_3; - newElement_3 = [MTRMessagesClusterMessageResponseOptionStruct new]; - if (entry_3.messageResponseID.HasValue()) { - newElement_3.messageResponseID = [NSNumber numberWithUnsignedInt:entry_3.messageResponseID.Value()]; - } else { - newElement_3.messageResponseID = nil; - } - if (entry_3.label.HasValue()) { - newElement_3.label = [[NSString alloc] initWithBytes:entry_3.label.Value().data() length:entry_3.label.Value().size() encoding:NSUTF8StringEncoding]; - } else { - newElement_3.label = nil; - } - [array_3 addObject:newElement_3]; - } - newElement_0.responses = array_3; + params.messageID = [NSData dataWithBytes:mRequest.messageID.data() length:mRequest.messageID.size()]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.priority = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.priority)]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.messageControl = [NSNumber numberWithUnsignedChar:mRequest.messageControl.Raw()]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + if (mRequest.startTime.IsNull()) { + params.startTime = nil; + } else { + params.startTime = [NSNumber numberWithUnsignedInt:mRequest.startTime.Value()]; + } +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + if (mRequest.duration.IsNull()) { + params.duration = nil; + } else { + params.duration = [NSNumber numberWithUnsignedShort:mRequest.duration.Value()]; + } +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.messageText = [[NSString alloc] initWithBytes:mRequest.messageText.data() length:mRequest.messageText.size() encoding:NSUTF8StringEncoding]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + if (mRequest.responses.HasValue()) { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + for (auto & entry_1 : mRequest.responses.Value()) { + MTRMessagesClusterMessageResponseOptionStruct * newElement_1; + newElement_1 = [MTRMessagesClusterMessageResponseOptionStruct new]; + if (entry_1.messageResponseID.HasValue()) { + newElement_1.messageResponseID = [NSNumber numberWithUnsignedInt:entry_1.messageResponseID.Value()]; + } else { + newElement_1.messageResponseID = nil; } - } else { - newElement_0.responses = nil; + if (entry_1.label.HasValue()) { + newElement_1.label = [[NSString alloc] initWithBytes:entry_1.label.Value().data() length:entry_1.label.Value().size() encoding:NSUTF8StringEncoding]; + } else { + newElement_1.label = nil; + } + [array_1 addObject:newElement_1]; } - [array_0 addObject:newElement_0]; + params.responses = array_1; } - params.messages = array_0; + } else { + params.responses = nil; } #endif // MTR_ENABLE_PROVISIONAL uint16_t repeatCount = mRepeatCount.ValueOr(1); @@ -79161,7 +81064,7 @@ class MessagesPresentMessagesRequest : public ClusterCommand { private: chip::app::Clusters::Messages::Commands::PresentMessagesRequest::Type mRequest; - TypedComplexArgument> mComplex_Messages; + TypedComplexArgument>> mComplex_Responses; }; #endif // MTR_ENABLE_PROVISIONAL @@ -182704,11 +184607,6 @@ void registerClusterRvcRunMode(Commands & commands) make_unique(), // make_unique(), // make_unique(), // -#if MTR_ENABLE_PROVISIONAL - make_unique(), // - make_unique(), // - make_unique(), // -#endif // MTR_ENABLE_PROVISIONAL make_unique(), // make_unique(), // make_unique(), // @@ -182743,11 +184641,6 @@ void registerClusterRvcCleanMode(Commands & commands) make_unique(), // make_unique(), // make_unique(), // -#if MTR_ENABLE_PROVISIONAL - make_unique(), // - make_unique(), // - make_unique(), // -#endif // MTR_ENABLE_PROVISIONAL make_unique(), // make_unique(), // make_unique(), // @@ -183348,12 +185241,6 @@ void registerClusterRvcOperationalState(Commands & commands) commands_list clusterCommands = { make_unique(Id), // make_unique(), // -#if MTR_ENABLE_PROVISIONAL - make_unique(), // -#endif // MTR_ENABLE_PROVISIONAL -#if MTR_ENABLE_PROVISIONAL - make_unique(), // -#endif // MTR_ENABLE_PROVISIONAL make_unique(), // #if MTR_ENABLE_PROVISIONAL make_unique(), // @@ -183785,6 +185672,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 @@ -183817,6 +185823,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(), // @@ -187900,6 +189910,7 @@ void registerClusters(Commands & commands) registerClusterActivatedCarbonFilterMonitoring(commands); registerClusterBooleanStateConfiguration(commands); registerClusterValveConfigurationAndControl(commands); + registerClusterElectricalPowerMeasurement(commands); registerClusterElectricalEnergyMeasurement(commands); registerClusterDemandResponseLoadControl(commands); registerClusterMessages(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 index c1b428dd930133..c801864f724f3b 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -157387,44 +157387,48 @@ class TestAccessControlConstraints : public TestCommandBridge { err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Constraint error: PASE reserved for future (TC-ACL-2.4 step 29)\n"); - err = TestConstraintErrorPaseReservedForFutureTcAcl24Step29_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: Invalid combination administer + group (TC-ACL-2.4 step 31)\n"); - err = TestConstraintErrorInvalidCombinationAdministerGroupTcAcl24Step31_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 auth mode (TC-ACL-2.4 step 33)\n"); - err = TestConstraintErrorInvalidAuthModeTcAcl24Step33_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 subject (TC-ACL-2.4 step 34)\n"); - err = TestConstraintErrorInvalidSubjectTcAcl24Step34_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 target (TC-ACL-2.4 step 38)\n"); - err = TestConstraintErrorInvalidTargetTcAcl24Step38_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: target has both endpoint and device type (TC-ACL-2.4 step 42)\n"); - err = TestConstraintErrorTargetHasBothEndpointAndDeviceTypeTcAcl24Step42_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: Invalid privilege value step 32)\n"); - err = TestConstraintErrorInvalidPrivilegeValueStep32_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 subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35)\n"); - err = TestConstraintErrorInvalidSubject0xFFFFFfffFfffFfffTcAcl24Step35_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_FFFD_0000_0000 (TC-ACL-2.4 step 36)\n"); - err = TestConstraintErrorInvalidSubject0xFFFFFffd00000000TcAcl24Step36_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_FFFF_FFFF_0000 (TC-ACL-2.4 step 37)\n"); - err = TestConstraintErrorInvalidSubject0xFFFFFfffFfff0000TcAcl24Step37_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; } @@ -157441,7 +157445,7 @@ class TestAccessControlConstraints : public TestCommandBridge { 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)); + 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)); @@ -157470,6 +157474,9 @@ class TestAccessControlConstraints : public TestCommandBridge { 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. @@ -157480,7 +157487,7 @@ class TestAccessControlConstraints : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; + const uint16_t mTestCount = 12; chip::Optional mNodeId; chip::Optional mCluster; @@ -157494,8 +157501,21 @@ class TestAccessControlConstraints : public TestCommandBridge { value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; return WaitForCommissionee("alpha", value); } + NSNumber * _Nonnull commissionerNodeIdAlpha; - CHIP_ERROR TestConstraintErrorPaseReservedForFutureTcAcl24Step29_1() + 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"); @@ -157513,12 +157533,12 @@ class TestAccessControlConstraints : public TestCommandBridge { { NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; + [commissionerNodeIdAlpha copy]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = @@ -157531,7 +157551,7 @@ class TestAccessControlConstraints : public TestCommandBridge { } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; aclArgument = temp_0; } @@ -157549,7 +157569,7 @@ class TestAccessControlConstraints : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestConstraintErrorInvalidCombinationAdministerGroupTcAcl24Step31_2() + CHIP_ERROR TestConstraintErrorInvalidCombinationAdministerGroupTcAcl24Step31_3() { MTRBaseDevice * device = GetDevice("alpha"); @@ -157567,12 +157587,12 @@ class TestAccessControlConstraints : public TestCommandBridge { { NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; + [commissionerNodeIdAlpha copy]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = @@ -157585,7 +157605,7 @@ class TestAccessControlConstraints : public TestCommandBridge { } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; aclArgument = temp_0; } @@ -157603,7 +157623,7 @@ class TestAccessControlConstraints : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestConstraintErrorInvalidAuthModeTcAcl24Step33_3() + CHIP_ERROR TestConstraintErrorInvalidAuthModeTcAcl24Step33_4() { MTRBaseDevice * device = GetDevice("alpha"); @@ -157621,12 +157641,12 @@ class TestAccessControlConstraints : public TestCommandBridge { { NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; + [commissionerNodeIdAlpha copy]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = @@ -157639,7 +157659,7 @@ class TestAccessControlConstraints : public TestCommandBridge { } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; aclArgument = temp_0; } @@ -157657,7 +157677,7 @@ class TestAccessControlConstraints : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestConstraintErrorInvalidSubjectTcAcl24Step34_4() + CHIP_ERROR TestConstraintErrorInvalidSubjectTcAcl24Step34_5() { MTRBaseDevice * device = GetDevice("alpha"); @@ -157675,12 +157695,12 @@ class TestAccessControlConstraints : public TestCommandBridge { { NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; + [commissionerNodeIdAlpha copy]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = @@ -157695,7 +157715,7 @@ class TestAccessControlConstraints : public TestCommandBridge { } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; aclArgument = temp_0; } @@ -157713,7 +157733,7 @@ class TestAccessControlConstraints : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestConstraintErrorInvalidTargetTcAcl24Step38_5() + CHIP_ERROR TestConstraintErrorInvalidTargetTcAcl24Step38_6() { MTRBaseDevice * device = GetDevice("alpha"); @@ -157731,12 +157751,12 @@ class TestAccessControlConstraints : public TestCommandBridge { { NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; + [commissionerNodeIdAlpha copy]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = @@ -157754,7 +157774,7 @@ class TestAccessControlConstraints : public TestCommandBridge { ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; aclArgument = temp_0; } @@ -157772,7 +157792,7 @@ class TestAccessControlConstraints : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestConstraintErrorTargetHasBothEndpointAndDeviceTypeTcAcl24Step42_6() + CHIP_ERROR TestConstraintErrorTargetHasBothEndpointAndDeviceTypeTcAcl24Step42_7() { MTRBaseDevice * device = GetDevice("alpha"); @@ -157790,12 +157810,12 @@ class TestAccessControlConstraints : public TestCommandBridge { { NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; + [commissionerNodeIdAlpha copy]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = @@ -157815,7 +157835,7 @@ class TestAccessControlConstraints : public TestCommandBridge { ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; aclArgument = temp_0; } @@ -157833,7 +157853,7 @@ class TestAccessControlConstraints : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestConstraintErrorInvalidPrivilegeValueStep32_7() + CHIP_ERROR TestConstraintErrorInvalidPrivilegeValueStep32_8() { MTRBaseDevice * device = GetDevice("alpha"); @@ -157851,12 +157871,12 @@ class TestAccessControlConstraints : public TestCommandBridge { { NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; + [commissionerNodeIdAlpha copy]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = @@ -157866,7 +157886,7 @@ class TestAccessControlConstraints : public TestCommandBridge { ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; aclArgument = temp_0; } @@ -157884,7 +157904,7 @@ class TestAccessControlConstraints : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFfffFfffFfffTcAcl24Step35_8() + CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFfffFfffFfffTcAcl24Step35_9() { MTRBaseDevice * device = GetDevice("alpha"); @@ -157902,12 +157922,12 @@ class TestAccessControlConstraints : public TestCommandBridge { { NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; + [commissionerNodeIdAlpha copy]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = @@ -157922,7 +157942,7 @@ class TestAccessControlConstraints : public TestCommandBridge { } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; aclArgument = temp_0; } @@ -157940,7 +157960,7 @@ class TestAccessControlConstraints : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFffd00000000TcAcl24Step36_9() + CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFffd00000000TcAcl24Step36_10() { MTRBaseDevice * device = GetDevice("alpha"); @@ -157958,12 +157978,12 @@ class TestAccessControlConstraints : public TestCommandBridge { { NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; + [commissionerNodeIdAlpha copy]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = @@ -157978,7 +157998,7 @@ class TestAccessControlConstraints : public TestCommandBridge { } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; aclArgument = temp_0; } @@ -157996,7 +158016,7 @@ class TestAccessControlConstraints : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFfffFfff0000TcAcl24Step37_10() + CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFfffFfff0000TcAcl24Step37_11() { MTRBaseDevice * device = GetDevice("alpha"); @@ -158014,12 +158034,12 @@ class TestAccessControlConstraints : public TestCommandBridge { { NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; + [commissionerNodeIdAlpha copy]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = @@ -158034,7 +158054,7 @@ class TestAccessControlConstraints : public TestCommandBridge { } ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; + [NSNumber numberWithUnsignedChar:0U]; aclArgument = temp_0; } @@ -162366,37 +162386,29 @@ class TestRVCOperationalState : public TestCommandBridge { err = TestReadCurrentOperationalState_6(); break; case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Start Command\n"); - err = TestStartCommand_7(); + ChipLogProgress(chipTool, " ***** Test Step 7 : Read current Operational State\n"); + err = TestReadCurrentOperationalState_7(); break; case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_8(); + ChipLogProgress(chipTool, " ***** Test Step 8 : Pause Command\n"); + err = TestPauseCommand_8(); break; case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Pause Command\n"); - err = TestPauseCommand_9(); + ChipLogProgress(chipTool, " ***** Test Step 9 : Read current Operational State\n"); + err = TestReadCurrentOperationalState_9(); break; case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_10(); + ChipLogProgress(chipTool, " ***** Test Step 10 : Resume Command\n"); + err = TestResumeCommand_10(); break; case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Resume Command\n"); - err = TestResumeCommand_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; - 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) { @@ -162430,7 +162442,7 @@ class TestRVCOperationalState : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 8: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -162447,12 +162459,6 @@ class TestRVCOperationalState : public TestCommandBridge { 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_UNSUPPORTED_COMMAND)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; } // Go on to the next test. @@ -162463,7 +162469,7 @@ class TestRVCOperationalState : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; + const uint16_t mTestCount = 13; chip::Optional mNodeId; chip::Optional mCluster; @@ -162647,29 +162653,7 @@ class TestRVCOperationalState : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestStartCommand_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster startWithCompletion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Start Command: Error: %@", err); - } else { - NSLog(@"Start Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_8() + CHIP_ERROR TestReadCurrentOperationalState_7() { MTRBaseDevice * device = GetDevice("alpha"); @@ -162696,7 +162680,7 @@ class TestRVCOperationalState : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestPauseCommand_9() + CHIP_ERROR TestPauseCommand_8() { MTRBaseDevice * device = GetDevice("alpha"); @@ -162724,7 +162708,7 @@ class TestRVCOperationalState : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestReadCurrentOperationalState_10() + CHIP_ERROR TestReadCurrentOperationalState_9() { MTRBaseDevice * device = GetDevice("alpha"); @@ -162751,7 +162735,7 @@ class TestRVCOperationalState : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestResumeCommand_11() + CHIP_ERROR TestResumeCommand_10() { MTRBaseDevice * device = GetDevice("alpha"); @@ -162779,7 +162763,7 @@ class TestRVCOperationalState : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestReadCurrentOperationalState_12() + CHIP_ERROR TestReadCurrentOperationalState_11() { MTRBaseDevice * device = GetDevice("alpha"); @@ -162806,29 +162790,7 @@ class TestRVCOperationalState : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestStopCommand_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopWithCompletion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Stop Command: Error: %@", err); - } else { - NSLog(@"Stop Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_14() + CHIP_ERROR TestReadCurrentOperationalState_12() { MTRBaseDevice * device = GetDevice("alpha"); 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 {