diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 94ad9314b9a56c..4d5be76434e8f8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -14,7 +14,7 @@ "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], - "initializeCommand": ".devcontainer/build.sh --tag matter-dev-environment:local --version 22", + "initializeCommand": "bash .devcontainer/build.sh --tag matter-dev-environment:local --version 22", "image": "matter-dev-environment:local", "remoteUser": "vscode", "customizations": { diff --git a/.github/workflows/darwin-tests.yaml b/.github/workflows/darwin-tests.yaml index 05943be5b0e155..e6e14ec4929a11 100644 --- a/.github/workflows/darwin-tests.yaml +++ b/.github/workflows/darwin-tests.yaml @@ -100,6 +100,7 @@ jobs: --target darwin-x64-bridge-${BUILD_VARIANT} \ --target darwin-x64-lit-icd-${BUILD_VARIANT} \ --target darwin-x64-microwave-oven-${BUILD_VARIANT} \ + --target darwin-x64-rvc-${BUILD_VARIANT} \ build \ --copy-artifacts-to objdir-clone \ " @@ -120,6 +121,7 @@ jobs: --tv-app ./out/darwin-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \ --bridge-app ./out/darwin-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \ --microwave-oven-app ./out/darwin-x64-microwave-oven-${BUILD_VARIANT}/chip-microwave-oven-app \ + --rvc-app ./out/darwin-x64-rvc-${BUILD_VARIANT}/chip-rvc-app \ " - name: Run OTA Test run: | diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 189f63837c841e..d811fe05fa888f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -93,35 +93,25 @@ jobs: --known-failure app/AttributeAccessInterface.h \ --known-failure app/AttributeAccessToken.h \ --known-failure app/att-storage.h \ - --known-failure app/BufferedReadCallback.h \ --known-failure app/CommandHandler.h \ --known-failure app/CommandHandlerInterface.h \ - --known-failure app/CommandPathParams.h \ - --known-failure app/CommandPathRegistry.h \ - --known-failure app/CommandResponseSender.h \ --known-failure app/CommandSender.h \ --known-failure app/CommandSenderLegacyCallback.h \ --known-failure app/CompatEnumNames.h \ - --known-failure app/ConcreteAttributePath.h \ - --known-failure app/ConcreteCommandPath.h \ --known-failure app/data-model/ListLargeSystemExtensions.h \ --known-failure app/EventHeader.h \ --known-failure app/EventLoggingDelegate.h \ --known-failure app/EventLogging.h \ --known-failure app/EventLoggingTypes.h \ - --known-failure app/EventManagement.h \ --known-failure app/InteractionModelHelper.h \ - --known-failure app/ObjectList.h \ --known-failure app/ReadClient.h \ --known-failure app/ReadHandler.h \ --known-failure app/ReadPrepareParams.h \ --known-failure app/reporting/tests/MockReportScheduler.cpp \ --known-failure app/reporting/tests/MockReportScheduler.h \ - --known-failure app/server/AppDelegate.h \ --known-failure app/TestEventTriggerDelegate.h \ --known-failure app/util/af.h \ --known-failure app/util/af-types.h \ - --known-failure app/util/attribute-metadata.h \ --known-failure app/util/attribute-storage.cpp \ --known-failure app/util/attribute-storage.h \ --known-failure app/util/attribute-storage-null-handling.h \ @@ -141,11 +131,7 @@ jobs: --known-failure app/util/im-client-callbacks.h \ --known-failure app/util/MatterCallbacks.h \ --known-failure app/util/message.cpp \ - --known-failure app/util/mock/Constants.h \ - --known-failure app/util/mock/Functions.h \ - --known-failure app/util/mock/MockNodeConfig.h \ --known-failure app/util/odd-sized-integers.h \ - --known-failure app/util/types_stub.h \ --known-failure app/util/util.cpp \ --known-failure app/util/util.h \ --known-failure app/WriteClient.h \ diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index f083cd70bccd7c..83d921c2fa4188 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -213,6 +213,7 @@ jobs: --target linux-x64-bridge-${BUILD_VARIANT} \ --target linux-x64-lit-icd-${BUILD_VARIANT} \ --target linux-x64-microwave-oven-${BUILD_VARIANT} \ + --target linux-x64-rvc-${BUILD_VARIANT} \ build \ --copy-artifacts-to objdir-clone \ " @@ -234,6 +235,7 @@ jobs: --bridge-app ./out/linux-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \ --lit-icd-app ./out/linux-x64-lit-icd-${BUILD_VARIANT}/lit-icd-app \ --microwave-oven-app ./out/linux-x64-microwave-oven-${BUILD_VARIANT}/chip-microwave-oven-app \ + --rvc-app ./out/linux-x64-rvc-${BUILD_VARIANT}/chip-rvc-app \ " - name: Run purposeful failure tests using the python parser sending commands to chip-tool @@ -274,6 +276,7 @@ jobs: --bridge-app ./out/linux-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \ --lit-icd-app ./out/linux-x64-lit-icd-${BUILD_VARIANT}/lit-icd-app \ --microwave-oven-app ./out/linux-x64-microwave-oven-${BUILD_VARIANT}/chip-microwave-oven-app \ + --rvc-app ./out/linux-x64-rvc-${BUILD_VARIANT}/chip-rvc-app \ " - name: Run Tests using chip-repl (including slow) if: github.event_name == 'push' @@ -292,6 +295,7 @@ jobs: --bridge-app ./out/linux-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \ --lit-icd-app ./out/linux-x64-lit-icd-${BUILD_VARIANT}/lit-icd-app \ --microwave-oven-app ./out/linux-x64-microwave-oven-${BUILD_VARIANT}/chip-microwave-oven-app \ + --rvc-app ./out/linux-x64-rvc-${BUILD_VARIANT}/chip-rvc-app \ " - name: Uploading core files uses: actions/upload-artifact@v4 @@ -359,6 +363,7 @@ jobs: --target darwin-x64-bridge-${BUILD_VARIANT} \ --target darwin-x64-lit-icd-${BUILD_VARIANT} \ --target darwin-x64-microwave-oven-${BUILD_VARIANT} \ + --target darwin-x64-rvc-${BUILD_VARIANT} \ build \ --copy-artifacts-to objdir-clone \ " @@ -381,6 +386,7 @@ jobs: --bridge-app ./out/darwin-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \ --lit-icd-app ./out/darwin-x64-lit-icd-${BUILD_VARIANT}/lit-icd-app \ --microwave-oven-app ./out/darwin-x64-microwave-oven-${BUILD_VARIANT}/chip-microwave-oven-app \ + --rvc-app ./out/darwin-x64-rvc-${BUILD_VARIANT}/chip-rvc-app \ " - name: Run purposeful failure tests using the python parser sending commands to chip-tool @@ -460,6 +466,7 @@ jobs: --target linux-x64-lit-icd-ipv6only-no-ble-no-wifi-tsan-clang-test \ --target linux-x64-energy-management-ipv6only-no-ble-no-wifi-tsan-clang-test \ --target linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test \ + --target linux-x64-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test \ --target linux-x64-python-bindings \ build \ --copy-artifacts-to objdir-clone \ @@ -504,8 +511,6 @@ 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_IDM_4_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_PWRTL_2_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_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_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 --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_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_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"' @@ -543,6 +548,15 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOCTRL_2_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"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOCTRL_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-microwave-oven-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-microwave-oven-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_MWOM_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-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCRUNM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --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-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCRUNM_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto --int-arg PIXIT.RVCRUNM.MODE_CHANGE_OK:0 PIXIT.RVCRUNM.MODE_CHANGE_FAIL:2"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCRUNM_2_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto --int-arg PIXIT.RVCRUNM.MODE_A:1 PIXIT.RVCRUNM.MODE_B:2"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCCLEANM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --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-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCCLEANM_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto --int-arg PIXIT.RVCCLEANM.MODE_CHANGE_FAIL:1 PIXIT.RVCCLEANM.MODE_CHANGE_OK:2"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCCLEANM_2_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --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-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCOPSTATE_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --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-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCOPSTATE_2_3.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --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-rvc-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-rvc-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_file json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCOPSTATE_2_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - name: Uploading core files uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} diff --git a/BUILD.gn b/BUILD.gn index 838ea743f348c8..a96f2a2e67265a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -363,6 +363,10 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { enable_linux_lit_icd_app_build = enable_default_builds && (host_os == "linux" || host_os == "mac") + # Build the Linux RVC app example. + enable_linux_rvc_app_build = + enable_default_builds && (host_os == "linux" || host_os == "mac") + # Build the cc13x2x7_26x2x7 lock app example. enable_cc13x2x7_26x2x7_lock_app_build = enable_ti_simplelink_builds @@ -744,6 +748,14 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { extra_build_deps += [ ":genio_shell_app" ] } + if (enable_linux_rvc_app_build) { + group("linux_rvc_app") { + deps = [ "${chip_root}/examples/rvc-app/linux(${standalone_toolchain})" ] + } + + extra_build_deps += [ ":linux_rvc_app" ] + } + group("default") { deps = extra_build_deps + builds } 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 62dc0d7d84c3fa..5a7b510b05b0c8 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 @@ -4455,6 +4455,40 @@ provisional cluster EnergyEvse = 153 { timed command ClearTargets(): DefaultSuccess = 7; } +/** This cluster provides an interface to specify preferences for how devices should consume energy. */ +provisional cluster EnergyPreference = 155 { + revision 1; + + enum EnergyPriorityEnum : enum8 { + kComfort = 0; + kSpeed = 1; + kEfficiency = 2; + kWaterConsumption = 3; + } + + bitmap Feature : bitmap32 { + kEnergyBalance = 0x1; + kLowPowerModeSensitivity = 0x2; + } + + struct BalanceStruct { + percent step = 0; + optional char_string<64> label = 1; + } + + readonly attribute optional BalanceStruct energyBalances[] = 0; + attribute optional int8u currentEnergyBalance = 1; + readonly attribute optional EnergyPriorityEnum energyPriorities[] = 2; + readonly attribute optional BalanceStruct lowPowerModeSensitivities[] = 3; + attribute optional int8u currentLowPowerModeSensitivity = 4; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + /** The Power Topology Cluster provides a mechanism for expressing how power is flowing between endpoints. */ provisional cluster PowerTopology = 156 { revision 1; @@ -8361,6 +8395,20 @@ endpoint 1 { handle command ClearTargets; } + server cluster EnergyPreference { + callback attribute energyBalances; + ram attribute currentEnergyBalance; + callback attribute energyPriorities; + callback attribute lowPowerModeSensitivities; + ram attribute currentLowPowerModeSensitivity; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 3; + ram attribute clusterRevision default = 1; + } + server cluster PowerTopology { callback attribute availableEndpoints; callback attribute activeEndpoints; 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 0a2a3faf1b37e8..21bcfee37b5e0d 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 @@ -14692,6 +14692,192 @@ } ] }, + { + "name": "Energy Preference", + "code": 155, + "mfgCode": null, + "define": "ENERGY_PREFERENCE_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "EnergyBalances", + "code": 0, + "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": "CurrentEnergyBalance", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EnergyPriorities", + "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": "LowPowerModeSensitivities", + "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": "CurrentLowPowerModeSensitivity", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, { "name": "Window Covering", "code": 258, diff --git a/examples/all-clusters-app/all-clusters-common/src/energy-preference-delegate.cpp b/examples/all-clusters-app/all-clusters-common/src/energy-preference-delegate.cpp new file mode 100644 index 00000000000000..cd9b47dd7979e6 --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/src/energy-preference-delegate.cpp @@ -0,0 +1,137 @@ +/* + * + * 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 + +using namespace chip; +using namespace chip::app::Clusters::EnergyPreference; +using namespace chip::app::Clusters::EnergyPreference::Structs; + +static BalanceStruct::Type gsEnergyBalances[] = { + { .step = 0, .label = Optional("Efficient"_span) }, + { .step = 50, .label = Optional() }, + { .step = 100, .label = Optional("Comfort"_span) }, +}; + +static BalanceStruct::Type gsPowerBalances[] = { + { .step = 0, .label = Optional("1 Minute"_span) }, + { .step = 12, .label = Optional("5 Minutes"_span) }, + { .step = 24, .label = Optional("10 Minutes"_span) }, + { .step = 36, .label = Optional("15 Minutes"_span) }, + { .step = 48, .label = Optional("20 Minutes"_span) }, + { .step = 60, .label = Optional("25 Minutes"_span) }, + { .step = 70, .label = Optional("30 Minutes"_span) }, + { .step = 80, .label = Optional("60 Minutes"_span) }, + { .step = 90, .label = Optional("120 Minutes"_span) }, + { .step = 100, .label = Optional("Never"_span) }, +}; + +// assumes it'll be the only delegate for it's lifetime. +struct EPrefDelegate : public Delegate +{ + EPrefDelegate(); + virtual ~EPrefDelegate(); + + CHIP_ERROR GetEnergyBalanceAtIndex(chip::EndpointId aEndpoint, size_t aIndex, chip::Percent & aOutStep, + chip::Optional & aOutLabel) override; + CHIP_ERROR GetEnergyPriorityAtIndex(chip::EndpointId aEndpoint, size_t aIndex, EnergyPriorityEnum & priority) override; + CHIP_ERROR GetLowPowerModeSensitivityAtIndex(chip::EndpointId aEndpoint, size_t aIndex, chip::Percent & aOutStep, + chip::Optional & aOutLabel) override; + + size_t GetNumEnergyBalances(chip::EndpointId aEndpoint) override; + size_t GetNumLowPowerModeSensitivities(chip::EndpointId aEndpoint) override; +}; + +EPrefDelegate::EPrefDelegate() : Delegate() +{ + VerifyOrDie(GetDelegate() == nullptr); + SetDelegate(this); +} + +EPrefDelegate::~EPrefDelegate() +{ + VerifyOrDie(GetDelegate() == this); + SetDelegate(nullptr); +} + +size_t EPrefDelegate::GetNumEnergyBalances(chip::EndpointId aEndpoint) +{ + return (ArraySize(gsEnergyBalances)); +} + +size_t EPrefDelegate::GetNumLowPowerModeSensitivities(chip::EndpointId aEndpoint) +{ + return (ArraySize(gsEnergyBalances)); +} + +CHIP_ERROR +EPrefDelegate::GetEnergyBalanceAtIndex(chip::EndpointId aEndpoint, size_t aIndex, chip::Percent & aOutStep, + chip::Optional & aOutLabel) +{ + if (aIndex < GetNumEnergyBalances(aEndpoint)) + { + aOutStep = gsEnergyBalances[aIndex].step; + if (gsEnergyBalances[aIndex].label.HasValue()) + { + chip::CopyCharSpanToMutableCharSpan(gsEnergyBalances[aIndex].label.Value(), aOutLabel.Value()); + } + else + { + aOutLabel.ClearValue(); + } + return CHIP_NO_ERROR; + } + return CHIP_ERROR_NOT_FOUND; +} + +CHIP_ERROR +EPrefDelegate::GetEnergyPriorityAtIndex(chip::EndpointId aEndpoint, size_t aIndex, EnergyPriorityEnum & priority) +{ + static EnergyPriorityEnum priorities[] = { EnergyPriorityEnum::kEfficiency, EnergyPriorityEnum::kComfort }; + + if (aIndex < ArraySize(priorities)) + { + priority = priorities[aIndex]; + return CHIP_NO_ERROR; + } + + return CHIP_ERROR_NOT_FOUND; +} + +CHIP_ERROR +EPrefDelegate::GetLowPowerModeSensitivityAtIndex(chip::EndpointId aEndpoint, size_t aIndex, chip::Percent & aOutStep, + chip::Optional & aOutLabel) +{ + if (aIndex < GetNumLowPowerModeSensitivities(aEndpoint)) + { + aOutStep = gsPowerBalances[aIndex].step; + if (gsPowerBalances[aIndex].label.HasValue()) + { + chip::CopyCharSpanToMutableCharSpan(gsPowerBalances[aIndex].label.Value(), aOutLabel.Value()); + } + else + { + aOutLabel.ClearValue(); + } + return CHIP_NO_ERROR; + } + + return CHIP_ERROR_NOT_FOUND; +} + +static EPrefDelegate gsDelegate; diff --git a/examples/all-clusters-app/ameba/chip_main.cmake b/examples/all-clusters-app/ameba/chip_main.cmake index 0d8b99c117716e..c4572063508ac0 100755 --- a/examples/all-clusters-app/ameba/chip_main.cmake +++ b/examples/all-clusters-app/ameba/chip_main.cmake @@ -158,6 +158,7 @@ list( ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp + ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/energy-preference-delegate.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/oven-modes.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 238f0e899c340d..63851b1deeb611 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -96,8 +96,11 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-synchronization-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/valve-configuration-and-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/dishwasher-alarm-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server" + "${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/examples/all-clusters-app/all-clusters-common/src" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/energy-preference-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 998f98a19cd3de..3d52ef748de90d 100644 --- a/examples/all-clusters-app/linux/BUILD.gn +++ b/examples/all-clusters-app/linux/BUILD.gn @@ -40,6 +40,7 @@ source_set("chip-all-clusters-common") { "${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/energy-preference-delegate.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", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp", diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterDetailFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterDetailFragment.kt index 50c33bd35c60ba..eb14eee23770bd 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterDetailFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterDetailFragment.kt @@ -199,10 +199,19 @@ class ClusterDetailFragment : Fragment() { private fun castStringToType(data: String, type: Class<*>, underlyingType: Class<*>): Any? { return when (type) { - Int::class.java -> data.toInt() - Boolean::class.java -> data.toBoolean() + Int::class.java, + java.lang.Integer::class.java -> data.toInt() + Boolean::class.java, + java.lang.Boolean::class.java -> data.toBoolean() ByteArray::class.java -> data.encodeToByteArray() - Long::class.java -> data.toLong() + Long::class.java, + java.lang.Long::class.java -> data.toLong() + Short::class.java, + java.lang.Short::class.java -> data.toShort() + Double::class.java, + java.lang.Double::class.java -> data.toDouble() + Float::class.java, + java.lang.Float::class.java -> data.toFloat() Optional::class.java -> if (data.isEmpty()) Optional.empty() else Optional.of(castStringToType(data, underlyingType, underlyingType)!!) diff --git a/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/MatterServant.java b/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/MatterServant.java index 79b02f01386769..540798aae913b7 100644 --- a/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/MatterServant.java +++ b/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/MatterServant.java @@ -41,6 +41,7 @@ import com.matter.tv.server.tvapp.LowPowerManagerStub; import com.matter.tv.server.tvapp.MediaInputManagerStub; import com.matter.tv.server.tvapp.MediaPlaybackManagerStub; +import com.matter.tv.server.tvapp.MessagesManagerStub; import com.matter.tv.server.tvapp.OnOffManagerStub; import com.matter.tv.server.tvapp.TvApp; import com.matter.tv.server.tvapp.WakeOnLanManagerStub; @@ -96,6 +97,8 @@ public void init(@NonNull Context context) { app.setMediaPlaybackManager(endpoint, new MediaPlaybackManagerStub(endpoint)); } else if (clusterId == Clusters.ClusterId_Channel) { app.setChannelManager(endpoint, new ChannelManagerStub(endpoint)); + } else if (clusterId == Clusters.ClusterId_Messaging) { + app.setMessagesManager(endpoint, new MessagesManagerStub(endpoint)); } else if (clusterId == Clusters.ClusterId_OnOff) { mOnOffEndpoint = endpoint; app.setOnOffManager(endpoint, new OnOffManagerStub(endpoint)); diff --git a/examples/tv-app/android/BUILD.gn b/examples/tv-app/android/BUILD.gn index 63de5a515b0754..47157a271edfe8 100644 --- a/examples/tv-app/android/BUILD.gn +++ b/examples/tv-app/android/BUILD.gn @@ -69,6 +69,8 @@ shared_library("jni") { "java/MediaInputManager.h", "java/MediaPlaybackManager.cpp", "java/MediaPlaybackManager.h", + "java/MessagesManager.cpp", + "java/MessagesManager.h", "java/MyUserPrompter-JNI.cpp", "java/MyUserPrompter-JNI.h", "java/MyUserPrompterResolver-JNI.cpp", @@ -143,6 +145,10 @@ android_library("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/Message.java", + "java/src/com/matter/tv/server/tvapp/MessageResponseOption.java", + "java/src/com/matter/tv/server/tvapp/MessagesManager.java", + "java/src/com/matter/tv/server/tvapp/MessagesManagerStub.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/ChannelManager.cpp b/examples/tv-app/android/java/ChannelManager.cpp index 3c0efcab9f8cdc..c7067132e46e9d 100644 --- a/examples/tv-app/android/java/ChannelManager.cpp +++ b/examples/tv-app/android/java/ChannelManager.cpp @@ -57,6 +57,7 @@ void ChannelManager::NewManager(jint endpoint, jobject manager) CHIP_ERROR ChannelManager::HandleGetChannelList(AttributeValueEncoder & aEncoder) { + DeviceLayer::StackUnlock unlock; 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")); @@ -66,6 +67,8 @@ CHIP_ERROR ChannelManager::HandleGetChannelList(AttributeValueEncoder & aEncoder VerifyOrExit(mChannelManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetChannelListMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + env->ExceptionClear(); + return aEncoder.EncodeList([this, env](const auto & encoder) -> CHIP_ERROR { jobjectArray channelInfoList = (jobjectArray) env->CallObjectMethod(mChannelManagerObject.ObjectRef(), mGetChannelListMethod); @@ -134,6 +137,7 @@ CHIP_ERROR ChannelManager::HandleGetChannelList(AttributeValueEncoder & aEncoder CHIP_ERROR ChannelManager::HandleGetLineup(AttributeValueEncoder & aEncoder) { + DeviceLayer::StackUnlock unlock; chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type lineupInfo; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); @@ -144,6 +148,8 @@ CHIP_ERROR ChannelManager::HandleGetLineup(AttributeValueEncoder & aEncoder) VerifyOrExit(mChannelManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetLineupMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + env->ExceptionClear(); + { jobject channelLineupObject = env->CallObjectMethod(mChannelManagerObject.ObjectRef(), mGetLineupMethod); if (channelLineupObject != nullptr) @@ -197,6 +203,7 @@ CHIP_ERROR ChannelManager::HandleGetLineup(AttributeValueEncoder & aEncoder) CHIP_ERROR ChannelManager::HandleGetCurrentChannel(AttributeValueEncoder & aEncoder) { + DeviceLayer::StackUnlock unlock; chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type channelInfo; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); @@ -207,6 +214,8 @@ CHIP_ERROR ChannelManager::HandleGetCurrentChannel(AttributeValueEncoder & aEnco VerifyOrExit(mChannelManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetCurrentChannelMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + env->ExceptionClear(); + { jobject channelInfoObject = env->CallObjectMethod(mChannelManagerObject.ObjectRef(), mGetCurrentChannelMethod); if (channelInfoObject != nullptr) @@ -273,6 +282,7 @@ CHIP_ERROR ChannelManager::HandleGetCurrentChannel(AttributeValueEncoder & aEnco void ChannelManager::HandleChangeChannel(CommandResponseHelper & helper, const CharSpan & match) { + DeviceLayer::StackUnlock unlock; std::string name(match.data(), match.size()); JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); @@ -282,9 +292,10 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelperExceptionClear(); + { UtfString jniname(env, name.c_str()); - env->ExceptionClear(); jobject channelObject = env->CallObjectMethod(mChannelManagerObject.ObjectRef(), mChangeChannelMethod, jniname.jniValue()); if (env->ExceptionCheck()) { @@ -319,6 +330,7 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper> & externalIdList, const chip::Optional & data) { + DeviceLayer::StackUnlock unlock; ProgramGuideResponseType response; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); @@ -394,6 +408,8 @@ void ChannelManager::HandleGetProgramGuide( VerifyOrExit(mChannelManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetProgramGuideMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + env->ExceptionClear(); + { // NOTE: this example app does not pass the Data, PageToken, ChannelsArray or ExternalIdList through to the Java layer UtfString jData(env, ""); @@ -591,6 +607,7 @@ bool ChannelManager::HandleRecordProgram(const chip::CharSpan & programIdentifie const DataModel::DecodableList & externalIdList, const chip::ByteSpan & data) { + DeviceLayer::StackUnlock unlock; jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); @@ -628,6 +645,7 @@ bool ChannelManager::HandleCancelRecordProgram(const chip::CharSpan & programIde const DataModel::DecodableList & externalIdList, const chip::ByteSpan & data) { + DeviceLayer::StackUnlock unlock; jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); diff --git a/examples/tv-app/android/java/ContentAppAttributeDelegate.cpp b/examples/tv-app/android/java/ContentAppAttributeDelegate.cpp index 84e7d9933ad022..00b4ca7a225b2c 100644 --- a/examples/tv-app/android/java/ContentAppAttributeDelegate.cpp +++ b/examples/tv-app/android/java/ContentAppAttributeDelegate.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include namespace chip { @@ -43,6 +44,7 @@ std::string ContentAppAttributeDelegate::Read(const chip::app::ConcreteReadAttri return ""; } + DeviceLayer::StackUnlock unlock; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); ChipLogProgress(Zcl, "ContentAppAttributeDelegate::Read being called for endpoint %d cluster %d attribute %d", aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId); diff --git a/examples/tv-app/android/java/ContentAppCommandDelegate.cpp b/examples/tv-app/android/java/ContentAppCommandDelegate.cpp index 3963140d1b5e65..2e5dcbe0f3b5e1 100644 --- a/examples/tv-app/android/java/ContentAppCommandDelegate.cpp +++ b/examples/tv-app/android/java/ContentAppCommandDelegate.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include namespace chip { @@ -50,6 +51,7 @@ void ContentAppCommandDelegate::InvokeCommand(CommandHandlerInterface::HandlerCo { if (handlerContext.mRequestPath.mEndpointId >= FIXED_ENDPOINT_COUNT) { + DeviceLayer::StackUnlock unlock; TLV::TLVReader readerForJson; readerForJson.Init(handlerContext.mPayload); diff --git a/examples/tv-app/android/java/ContentLauncherManager.cpp b/examples/tv-app/android/java/ContentLauncherManager.cpp index caa14b04f9e938..f68e1131fa6fb8 100644 --- a/examples/tv-app/android/java/ContentLauncherManager.cpp +++ b/examples/tv-app/android/java/ContentLauncherManager.cpp @@ -51,6 +51,7 @@ void ContentLauncherManager::HandleLaunchContent(CommandResponseHelper playbackPreferences, bool useCurrentContext) { + DeviceLayer::StackUnlock unlock; Commands::LauncherResponse::Type response; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); @@ -61,6 +62,7 @@ void ContentLauncherManager::HandleLaunchContent(CommandResponseHelperExceptionClear(); { UtfString jData(env, data); @@ -106,6 +108,7 @@ void ContentLauncherManager::HandleLaunchUrl(CommandResponseHelperExceptionClear(); + { UtfString jContentUrl(env, contentUrl); UtfString jDisplayString(env, displayString); @@ -160,6 +165,7 @@ void ContentLauncherManager::HandleLaunchUrl(CommandResponseHelper acceptedHeadersList; @@ -170,6 +176,8 @@ CHIP_ERROR ContentLauncherManager::HandleGetAcceptHeaderList(AttributeValueEncod VerifyOrExit(mContentLauncherManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetAcceptHeaderMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + env->ExceptionClear(); + return aEncoder.EncodeList([this, env](const auto & encoder) -> CHIP_ERROR { jobjectArray acceptedHeadersArray = (jobjectArray) env->CallObjectMethod(mContentLauncherManagerObject.ObjectRef(), mGetAcceptHeaderMethod); @@ -203,6 +211,7 @@ CHIP_ERROR ContentLauncherManager::HandleGetAcceptHeaderList(AttributeValueEncod uint32_t ContentLauncherManager::HandleGetSupportedStreamingProtocols() { + DeviceLayer::StackUnlock unlock; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); uint32_t supportedStreamingProtocols = 0; @@ -213,6 +222,8 @@ uint32_t ContentLauncherManager::HandleGetSupportedStreamingProtocols() VerifyOrExit(mContentLauncherManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetSupportedStreamingProtocolsMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + env->ExceptionClear(); + { jlong jSupportedStreamingProtocols = env->CallLongMethod(mContentLauncherManagerObject.ObjectRef(), mGetSupportedStreamingProtocolsMethod); diff --git a/examples/tv-app/android/java/KeypadInputManager.cpp b/examples/tv-app/android/java/KeypadInputManager.cpp index a43a56cb860978..2382397fc351d9 100644 --- a/examples/tv-app/android/java/KeypadInputManager.cpp +++ b/examples/tv-app/android/java/KeypadInputManager.cpp @@ -44,6 +44,7 @@ void KeypadInputManager::NewManager(jint endpoint, jobject manager) void KeypadInputManager::HandleSendKey(CommandResponseHelper & helper, const CECKeyCodeEnum & keyCode) { + DeviceLayer::StackUnlock unlock; Commands::SendKeyResponse::Type response; jint ret = -1; diff --git a/examples/tv-app/android/java/LevelManager.cpp b/examples/tv-app/android/java/LevelManager.cpp index b79f150c7ae20e..f9be7578e830ab 100644 --- a/examples/tv-app/android/java/LevelManager.cpp +++ b/examples/tv-app/android/java/LevelManager.cpp @@ -112,6 +112,7 @@ CHIP_ERROR LevelManager::InitializeWithObjects(jobject managerObject) void LevelManager::HandleLevelChanged(uint8_t value) { + DeviceLayer::StackUnlock unlock; ChipLogProgress(Zcl, "LevelManager::HandleLevelChanged"); JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); diff --git a/examples/tv-app/android/java/LowPowerManager.cpp b/examples/tv-app/android/java/LowPowerManager.cpp index 12e234964d4c5e..5c6906fcd1d659 100644 --- a/examples/tv-app/android/java/LowPowerManager.cpp +++ b/examples/tv-app/android/java/LowPowerManager.cpp @@ -64,6 +64,7 @@ void LowPowerManager::InitializeWithObjects(jobject managerObject) bool LowPowerManager::HandleSleep() { + DeviceLayer::StackUnlock unlock; jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); JniLocalReferenceScope scope(env); diff --git a/examples/tv-app/android/java/MediaInputManager.cpp b/examples/tv-app/android/java/MediaInputManager.cpp index bbc575b6eab378..0f1c922243c2be 100644 --- a/examples/tv-app/android/java/MediaInputManager.cpp +++ b/examples/tv-app/android/java/MediaInputManager.cpp @@ -51,6 +51,7 @@ void MediaInputManager::NewManager(jint endpoint, jobject manager) CHIP_ERROR MediaInputManager::HandleGetInputList(chip::app::AttributeValueEncoder & aEncoder) { + DeviceLayer::StackUnlock unlock; 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")); @@ -60,6 +61,8 @@ CHIP_ERROR MediaInputManager::HandleGetInputList(chip::app::AttributeValueEncode VerifyOrExit(mMediaInputManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetInputListMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + env->ExceptionClear(); + return aEncoder.EncodeList([this, env](const auto & encoder) -> CHIP_ERROR { jobjectArray inputArray = (jobjectArray) env->CallObjectMethod(mMediaInputManagerObject.ObjectRef(), mGetInputListMethod); if (env->ExceptionCheck()) @@ -121,6 +124,7 @@ CHIP_ERROR MediaInputManager::HandleGetInputList(chip::app::AttributeValueEncode uint8_t MediaInputManager::HandleGetCurrentInput() { + DeviceLayer::StackUnlock unlock; CHIP_ERROR err = CHIP_NO_ERROR; jint index = -1; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); @@ -130,7 +134,8 @@ uint8_t MediaInputManager::HandleGetCurrentInput() ChipLogProgress(Zcl, "Received MediaInputManager::HandleGetCurrentInput"); VerifyOrExit(mMediaInputManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetCurrentInputMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV); + + env->ExceptionClear(); { index = env->CallIntMethod(mMediaInputManagerObject.ObjectRef(), mGetCurrentInputMethod); @@ -154,6 +159,7 @@ uint8_t MediaInputManager::HandleGetCurrentInput() bool MediaInputManager::HandleSelectInput(const uint8_t index) { + DeviceLayer::StackUnlock unlock; jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); @@ -179,6 +185,7 @@ bool MediaInputManager::HandleSelectInput(const uint8_t index) bool MediaInputManager::HandleShowInputStatus() { + DeviceLayer::StackUnlock unlock; jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); @@ -204,6 +211,7 @@ bool MediaInputManager::HandleShowInputStatus() bool MediaInputManager::HandleHideInputStatus() { + DeviceLayer::StackUnlock unlock; jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturnValue(env != nullptr, false, ChipLogError(Zcl, "Could not get JNIEnv for current thread")); @@ -229,6 +237,7 @@ bool MediaInputManager::HandleHideInputStatus() bool MediaInputManager::HandleRenameInput(const uint8_t index, const chip::CharSpan & name) { + DeviceLayer::StackUnlock unlock; std::string inputname(name.data(), name.size()); jboolean ret = JNI_FALSE; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); @@ -239,9 +248,10 @@ bool MediaInputManager::HandleRenameInput(const uint8_t index, const chip::CharS VerifyOrExit(mMediaInputManagerObject.HasValidObjectRef(), ChipLogError(Zcl, "mMediaInputManagerObject is not valid")); VerifyOrExit(mRenameInputMethod != nullptr, ChipLogError(Zcl, "mHideInputStatusMethod null")); + env->ExceptionClear(); + { UtfString jniInputname(env, inputname.data()); - env->ExceptionClear(); ret = env->CallBooleanMethod(mMediaInputManagerObject.ObjectRef(), mRenameInputMethod, static_cast(index), jniInputname.jniValue()); if (env->ExceptionCheck()) diff --git a/examples/tv-app/android/java/MediaPlaybackManager.cpp b/examples/tv-app/android/java/MediaPlaybackManager.cpp index 62abeb12ec30eb..667ab2ec41b382 100644 --- a/examples/tv-app/android/java/MediaPlaybackManager.cpp +++ b/examples/tv-app/android/java/MediaPlaybackManager.cpp @@ -97,6 +97,7 @@ CHIP_ERROR MediaPlaybackManager::HandleGetActiveAudioTrack(AttributeValueEncoder CHIP_ERROR MediaPlaybackManager::HandleGetActiveTrack(bool audio, AttributeValueEncoder & aEncoder) { + DeviceLayer::StackUnlock unlock; Structs::TrackStruct::Type response; Structs::TrackAttributesStruct::Type trackAttributes; response.trackAttributes = Nullable(trackAttributes); @@ -170,6 +171,7 @@ CHIP_ERROR MediaPlaybackManager::HandleGetAvailableAudioTracks(AttributeValueEnc CHIP_ERROR MediaPlaybackManager::HandleGetAvailableTracks(bool audio, AttributeValueEncoder & aEncoder) { + DeviceLayer::StackUnlock unlock; 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")); @@ -179,6 +181,8 @@ CHIP_ERROR MediaPlaybackManager::HandleGetAvailableTracks(bool audio, AttributeV VerifyOrExit(mMediaPlaybackManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetAvailableTracksMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + env->ExceptionClear(); + return aEncoder.EncodeList([this, env, audio](const auto & encoder) -> CHIP_ERROR { jobjectArray trackList = (jobjectArray) env->CallObjectMethod(mMediaPlaybackManagerObject.ObjectRef(), mGetAvailableTracksMethod, static_cast(audio)); @@ -317,6 +321,7 @@ bool MediaPlaybackManager::HandleActivateAudioTrack(const chip::CharSpan & track bool MediaPlaybackManager::HandleActivateTrack(bool audio, const chip::CharSpan & trackId) { + DeviceLayer::StackUnlock unlock; std::string id(trackId.data(), trackId.size()); jint ret = -1; @@ -328,9 +333,11 @@ bool MediaPlaybackManager::HandleActivateTrack(bool audio, const chip::CharSpan ChipLogProgress(Zcl, "MediaPlaybackManager::HandleActivateAudioTrack"); VerifyOrExit(mMediaPlaybackManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mActivateTrackMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + + env->ExceptionClear(); + { UtfString jniid(env, id.c_str()); - env->ExceptionClear(); ret = env->CallIntMethod(mMediaPlaybackManagerObject.ObjectRef(), mActivateTrackMethod, static_cast(audio), jniid.jniValue()); if (env->ExceptionCheck()) @@ -351,6 +358,7 @@ bool MediaPlaybackManager::HandleActivateTextTrack(const chip::CharSpan & trackI bool MediaPlaybackManager::HandleDeactivateTextTrack() { + DeviceLayer::StackUnlock unlock; jint ret = -1; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); @@ -439,6 +447,7 @@ void MediaPlaybackManager::InitializeWithObjects(jobject managerObject) uint64_t MediaPlaybackManager::HandleMediaRequestGetAttribute(MediaPlaybackRequestAttribute attribute) { + DeviceLayer::StackUnlock unlock; uint64_t ret = std::numeric_limits::max(); jlong jAttributeValue = -1; CHIP_ERROR err = CHIP_NO_ERROR; @@ -450,6 +459,8 @@ uint64_t MediaPlaybackManager::HandleMediaRequestGetAttribute(MediaPlaybackReque VerifyOrExit(mMediaPlaybackManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetAttributeMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + env->ExceptionClear(); + jAttributeValue = env->CallLongMethod(mMediaPlaybackManagerObject.ObjectRef(), mGetAttributeMethod, static_cast(attribute)); if (env->ExceptionCheck()) @@ -480,6 +491,7 @@ uint64_t MediaPlaybackManager::HandleMediaRequestGetAttribute(MediaPlaybackReque long MediaPlaybackManager::HandleMediaRequestGetLongAttribute(MediaPlaybackRequestAttribute attribute) { + DeviceLayer::StackUnlock unlock; long ret = 0; jlong jAttributeValue = -1; CHIP_ERROR err = CHIP_NO_ERROR; @@ -491,6 +503,8 @@ long MediaPlaybackManager::HandleMediaRequestGetLongAttribute(MediaPlaybackReque VerifyOrExit(mMediaPlaybackManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mGetAttributeMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + env->ExceptionClear(); + jAttributeValue = env->CallLongMethod(mMediaPlaybackManagerObject.ObjectRef(), mGetAttributeMethod, static_cast(attribute)); if (env->ExceptionCheck()) @@ -516,6 +530,7 @@ Commands::PlaybackResponse::Type MediaPlaybackManager::HandleMediaRequest(MediaP uint64_t deltaPositionMilliseconds) { + DeviceLayer::StackUnlock unlock; Commands::PlaybackResponse::Type response; jint ret = -1; @@ -553,6 +568,7 @@ Commands::PlaybackResponse::Type MediaPlaybackManager::HandleMediaRequest(MediaP CHIP_ERROR MediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncoder & aEncoder) { + DeviceLayer::StackUnlock unlock; Structs::PlaybackPositionStruct::Type response; response.updatedAt = 0; response.position = Nullable(0); diff --git a/examples/tv-app/android/java/MessagesManager.cpp b/examples/tv-app/android/java/MessagesManager.cpp new file mode 100644 index 00000000000000..9203d7b54510f5 --- /dev/null +++ b/examples/tv-app/android/java/MessagesManager.cpp @@ -0,0 +1,454 @@ +/** + * + * Copyright (c) 2024 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "MessagesManager.h" +#include "TvApp-JNI.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters::Messages; +using namespace chip::Uint8; +using MessageResponseOption = chip::app::Clusters::Messages::Structs::MessageResponseOptionStruct::Type; + +/** @brief Messages Cluster Init + * + * This function is called when a specific cluster is initialized. It gives the + * application an opportunity to take care of cluster initialization procedures. + * It is called exactly once for each endpoint where cluster is present. + * + */ +void emberAfMessagesClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "------------TV Android App: Messages::PostClusterInit"); + TvAppJNIMgr().PostClusterInit(chip::app::Clusters::Messages::Id, endpoint); +} + +void MessagesManager::NewManager(jint endpoint, jobject manager) +{ + ChipLogProgress(Zcl, "-----TV Android App: Messages::SetDefaultDelegate"); + MessagesManager * mgr = new MessagesManager(); + VerifyOrReturn(mgr != nullptr, ChipLogError(Zcl, "Failed to create MessagesManager")); + mgr->InitializeWithObjects(manager); + chip::app::Clusters::Messages::SetDefaultDelegate(static_cast(endpoint), mgr); +} + +void MessagesManager::InitializeWithObjects(jobject managerObject) +{ + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Failed to GetEnvForCurrentThread for MessagesManager")); + + VerifyOrReturn(mMessagesManagerObject.Init(managerObject) == CHIP_NO_ERROR, + ChipLogError(Zcl, "Failed to init mMessagesManagerObject")); + + jclass managerClass = env->GetObjectClass(managerObject); + VerifyOrReturn(managerClass != nullptr, ChipLogError(Zcl, "Failed to get MessagesManager Java class")); + + mGetMessagesMethod = env->GetMethodID(managerClass, "getMessages", "()[Lcom/matter/tv/server/tvapp/Message;"); + if (mGetMessagesMethod == nullptr) + { + ChipLogError(Zcl, "Failed to access MessagesManager 'getMessages' method"); + env->ExceptionClear(); + } + + mPresentMessagesMethod = + env->GetMethodID(managerClass, "presentMessages", "(Ljava/lang/String;IIJILjava/lang/String;Ljava/util/HashMap;)Z"); + if (mPresentMessagesMethod == nullptr) + { + ChipLogError(Zcl, "Failed to access MessagesManager 'presentMessages' method"); + env->ExceptionClear(); + } + + mCancelMessagesMethod = env->GetMethodID(managerClass, "cancelMessage", "(Ljava/lang/String;)Z"); + if (mCancelMessagesMethod == nullptr) + { + ChipLogError(Zcl, "Failed to access MessagesManager 'cancelMessage' method"); + env->ExceptionClear(); + } +} + +uint32_t MessagesManager::GetFeatureMap(chip::EndpointId endpoint) +{ + if (endpoint >= MATTER_DM_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT) + { + return kEndpointFeatureMap; + } + + BitMask FeatureMap; + FeatureMap.Set(Feature::kReceivedConfirmation); + FeatureMap.Set(Feature::kConfirmationResponse); + FeatureMap.Set(Feature::kConfirmationReply); + FeatureMap.Set(Feature::kProtectedMessages); + + uint32_t featureMap = FeatureMap.Raw(); + // forcing to all features since this implementation supports all + // Attributes::FeatureMap::Get(endpoint, &featureMap); + return featureMap; +} + +CHIP_ERROR MessagesManager::HandleGetMessages(AttributeValueEncoder & aEncoder) +{ + DeviceLayer::StackUnlock unlock; + 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); + + env->ExceptionClear(); + + ChipLogProgress(Zcl, "Received MessagesManager::HandleGetMessages"); + VerifyOrExit(mMessagesManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mGetMessagesMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + + return aEncoder.EncodeList([this, env](const auto & encoder) -> CHIP_ERROR { + jobjectArray messagesList = + static_cast(env->CallObjectMethod(mMessagesManagerObject.ObjectRef(), mGetMessagesMethod)); + if (env->ExceptionCheck()) + { + ChipLogError(Zcl, "Java exception in MessagesManager::HandleGetMessages"); + env->ExceptionDescribe(); + env->ExceptionClear(); + return CHIP_ERROR_INCORRECT_STATE; + } + + jint length = env->GetArrayLength(messagesList); + + for (jint i = 0; i < length; i++) + { + std::vector options; + std::vector optionLabels; + uint8_t buf[kMessageIdLength]; + + chip::app::Clusters::Messages::Structs::MessageStruct::Type message; + jobject messageObject = env->GetObjectArrayElement(messagesList, i); + jclass messageClass = env->GetObjectClass(messageObject); + + jfieldID getMessageIdField = env->GetFieldID(messageClass, "messageId", "Ljava/lang/String;"); + jstring jmessageId = static_cast(env->GetObjectField(messageObject, getMessageIdField)); + JniUtfString messageId(env, jmessageId); + if (jmessageId != nullptr) + { + VerifyOrReturnValue(chip::Encoding::HexToBytes(messageId.charSpan().data(), messageId.charSpan().size(), buf, + sizeof(buf)) == sizeof(buf), + CHIP_ERROR_INVALID_ARGUMENT, ChipLogError(Zcl, "HexToBytes failed")); + message.messageID = ByteSpan(buf, sizeof(buf)); + } + + jfieldID getMessageTextField = env->GetFieldID(messageClass, "messageText", "Ljava/lang/String;"); + jstring jmessageText = static_cast(env->GetObjectField(messageObject, getMessageTextField)); + JniUtfString messageText(env, jmessageText); + if (jmessageText != nullptr) + { + message.messageText = messageText.charSpan(); + } + + jfieldID messageControlField = env->GetFieldID(messageClass, "messageControl", "I"); + jint jmessageControl = env->GetIntField(messageObject, messageControlField); + message.messageControl = static_cast>(static_cast(jmessageControl)); + + jfieldID priorityField = env->GetFieldID(messageClass, "priority", "I"); + jint jpriority = env->GetIntField(messageObject, priorityField); + if (jpriority >= 0) + { + message.priority = MessagePriorityEnum(static_cast(jpriority)); + } + + jfieldID startTimeField = env->GetFieldID(messageClass, "startTime", "J"); + jlong jstartTime = env->GetLongField(messageObject, startTimeField); + if (jstartTime >= 0) + { + message.startTime = DataModel::Nullable(static_cast(jstartTime)); + } + + jfieldID durationField = env->GetFieldID(messageClass, "duration", "I"); + jint jduration = env->GetIntField(messageObject, durationField); + if (jduration >= 0) + { + message.duration = DataModel::Nullable(static_cast(jduration)); + } + + jfieldID getResponseOptionsField = + env->GetFieldID(messageClass, "responseOptions", "[Lcom/matter/tv/server/tvapp/MessageResponseOption;"); + + jobjectArray responsesArray = static_cast(env->GetObjectField(messageObject, getResponseOptionsField)); + jint size = env->GetArrayLength(responsesArray); + if (size > 0) + { + for (jint j = 0; j < size; j++) + { + MessageResponseOption option; + + jobject responseOptionObject = env->GetObjectArrayElement(responsesArray, j); + jclass responseOptionClass = env->GetObjectClass(responseOptionObject); + + jfieldID idField = env->GetFieldID(responseOptionClass, "id", "J"); + jlong jid = env->GetLongField(responseOptionObject, idField); + option.messageResponseID = Optional(static_cast(jid)); + + jfieldID getLabelField = env->GetFieldID(responseOptionClass, "label", "Ljava/lang/String;"); + jstring jlabelText = static_cast(env->GetObjectField(responseOptionObject, getLabelField)); + VerifyOrReturnValue(jlabelText != nullptr, CHIP_ERROR_INVALID_ARGUMENT, ChipLogError(Zcl, "jlabelText null")); + JniUtfString * label = new JniUtfString(env, jlabelText); + VerifyOrReturnValue(label != nullptr, CHIP_ERROR_NO_MEMORY, ChipLogError(Zcl, "label null")); + + optionLabels.push_back(label); + + option.label = Optional(label->charSpan()); + + options.push_back(option); + } + + message.responses = Optional>( + DataModel::List(options.data(), options.size())); + } + ReturnErrorOnFailure(encoder.Encode(message)); + for (JniUtfString * optionLabel : optionLabels) + { + delete optionLabel; + } + } + + return CHIP_NO_ERROR; + }); + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "MessagesManager::HandleGetMessages status error: %s", err.AsString()); + } + return err; +} + +CHIP_ERROR MessagesManager::HandleGetActiveMessageIds(AttributeValueEncoder & aEncoder) +{ + DeviceLayer::StackUnlock unlock; + 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 MessagesManager::HandleGetActiveMessageIds"); + VerifyOrExit(mMessagesManagerObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mGetMessagesMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + + env->ExceptionClear(); + + return aEncoder.EncodeList([this, env](const auto & encoder) -> CHIP_ERROR { + jobjectArray messagesList = + static_cast(env->CallObjectMethod(mMessagesManagerObject.ObjectRef(), mGetMessagesMethod)); + if (env->ExceptionCheck()) + { + ChipLogError(Zcl, "Java exception in MessagesManager::HandleGetActiveMessageIds"); + env->ExceptionDescribe(); + env->ExceptionClear(); + return CHIP_ERROR_INCORRECT_STATE; + } + + jint length = env->GetArrayLength(messagesList); + + for (jint i = 0; i < length; i++) + { + jobject messageObject = env->GetObjectArrayElement(messagesList, i); + jclass messageClass = env->GetObjectClass(messageObject); + + jfieldID getMessageIdField = env->GetFieldID(messageClass, "messageId", "Ljava/lang/String;"); + jstring jmessageId = static_cast(env->GetObjectField(messageObject, getMessageIdField)); + JniUtfString messageId(env, jmessageId); + if (jmessageId != nullptr) + { + uint8_t buf[kMessageIdLength]; + VerifyOrReturnValue(chip::Encoding::HexToBytes(messageId.charSpan().data(), messageId.charSpan().size(), buf, + sizeof(buf)) == sizeof(buf), + CHIP_ERROR_INVALID_ARGUMENT, ChipLogError(Zcl, "HexToBytes failed")); + + ReturnErrorOnFailure(encoder.Encode(ByteSpan(buf, sizeof(buf)))); + } + } + + return CHIP_NO_ERROR; + }); + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "MessagesManager::HandleGetMessages status error: %s", err.AsString()); + } + + return err; +} + +CHIP_ERROR MessagesManager::HandlePresentMessagesRequest( + const ByteSpan & messageId, const MessagePriorityEnum & priority, const BitMask & messageControl, + const DataModel::Nullable & startTime, const DataModel::Nullable & duration, const CharSpan & messageText, + const Optional> & responses) +{ + DeviceLayer::StackUnlock unlock; + 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 MessagesManager::HandlePresentMessagesRequest"); + VerifyOrReturnError(mMessagesManagerObject.HasValidObjectRef(), CHIP_ERROR_INCORRECT_STATE, + ChipLogError(Zcl, "Invalid mMessagesManagerObject")); + VerifyOrReturnError(mPresentMessagesMethod != nullptr, CHIP_ERROR_INCORRECT_STATE, + ChipLogError(Zcl, "mPresentMessagesMethod null")); + + env->ExceptionClear(); + { + char hex_buf[(kMessageIdLength * 2) + 1]; + VerifyOrReturnError( + CHIP_NO_ERROR == + chip::Encoding::BytesToUppercaseHexString(messageId.data(), messageId.size(), hex_buf, sizeof(hex_buf)), + CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "BytesToUppercaseHexString failed")); + + jstring jid = env->NewStringUTF(hex_buf); + if (jid == nullptr) + { + return CHIP_ERROR_INTERNAL; + } + + std::string smessageText(messageText.data(), messageText.size()); + jstring jmessageText = env->NewStringUTF(smessageText.c_str()); + if (jmessageText == nullptr) + { + return CHIP_ERROR_INTERNAL; + } + + jint jcontrol = static_cast(messageControl.Raw()); + jint jduration = -1; + if (!duration.IsNull()) + { + jduration = static_cast(duration.Value()); + } + jlong jstartTime = -1; + if (!startTime.IsNull()) + { + jstartTime = static_cast(startTime.Value()); + } + + jint jpriority = static_cast(priority); + + jclass hashMapClass = env->FindClass("java/util/HashMap"); + VerifyOrReturnError(hashMapClass != nullptr, CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "Could not find class HashMap")); + jmethodID hashMapCtor = env->GetMethodID(hashMapClass, "", "()V"); + VerifyOrReturnError(hashMapCtor != nullptr, CHIP_ERROR_INCORRECT_STATE, + ChipLogError(Zcl, "Could not find HashMap constructor")); + jobject joptions = env->NewObject(hashMapClass, hashMapCtor); + VerifyOrReturnError(joptions != nullptr, CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "Could not create HashMap")); + + if (responses.HasValue()) + { + jmethodID hashMapPut = + env->GetMethodID(hashMapClass, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + VerifyOrReturnError(hashMapPut != nullptr, CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "Could not find HashMap put")); + + jclass longClass = env->FindClass("java/lang/Long"); + VerifyOrReturnError(longClass != nullptr, CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "Could not find class Long")); + jmethodID longCtor = env->GetMethodID(longClass, "", "(J)V"); + VerifyOrReturnError(longCtor != nullptr, CHIP_ERROR_INCORRECT_STATE, + ChipLogError(Zcl, "Could not find Long constructor")); + + auto iter = responses.Value().begin(); + while (iter.Next()) + { + auto & response = iter.GetValue(); + + std::string label(response.label.Value().data(), response.label.Value().size()); + jstring jlabel = env->NewStringUTF(label.c_str()); + if (jlabel == nullptr) + { + return CHIP_ERROR_INTERNAL; + } + + jobject jlong = env->NewObject(longClass, longCtor, response.messageResponseID.Value()); + VerifyOrReturnError(jlong != nullptr, CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "Could not create Long")); + + // add to HashMap + env->CallObjectMethod(joptions, hashMapPut, jlong, jlabel); + if (env->ExceptionCheck()) + { + ChipLogError(DeviceLayer, "Java exception in MessagesManager::HandlePresentMessagesRequest"); + env->ExceptionDescribe(); + env->ExceptionClear(); + return CHIP_ERROR_INTERNAL; + } + } + } + + env->CallBooleanMethod(mMessagesManagerObject.ObjectRef(), mPresentMessagesMethod, jid, jpriority, jcontrol, jstartTime, + jduration, jmessageText, joptions); + if (env->ExceptionCheck()) + { + ChipLogError(DeviceLayer, "Java exception in MessagesManager::HandlePresentMessagesRequest"); + env->ExceptionDescribe(); + env->ExceptionClear(); + return CHIP_ERROR_INTERNAL; + } + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR MessagesManager::HandleCancelMessagesRequest(const DataModel::DecodableList & messageIds) +{ + DeviceLayer::StackUnlock unlock; + 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 MessagesManager::HandleCancelMessagesRequest"); + VerifyOrReturnError(mMessagesManagerObject.HasValidObjectRef(), CHIP_ERROR_INCORRECT_STATE, + ChipLogError(Zcl, "Invalid mMessagesManagerObject")); + VerifyOrReturnError(mCancelMessagesMethod != nullptr, CHIP_ERROR_INCORRECT_STATE, + ChipLogError(Zcl, "mCancelMessagesMethod null")); + + env->ExceptionClear(); + + auto iter = messageIds.begin(); + while (iter.Next()) + { + auto & id = iter.GetValue(); + + char hex_buf[(kMessageIdLength * 2) + 1]; + VerifyOrReturnError(CHIP_NO_ERROR == + chip::Encoding::BytesToUppercaseHexString(id.data(), id.size(), hex_buf, sizeof(hex_buf)), + CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "BytesToUppercaseHexString failed")); + + jstring jid = env->NewStringUTF(hex_buf); + if (jid == nullptr) + { + return CHIP_ERROR_INTERNAL; + } + + env->CallBooleanMethod(mMessagesManagerObject.ObjectRef(), mCancelMessagesMethod, jid); + if (env->ExceptionCheck()) + { + ChipLogError(DeviceLayer, "Java exception in MessagesManager::HandleCancelMessagesRequest"); + env->ExceptionDescribe(); + env->ExceptionClear(); + return CHIP_ERROR_INTERNAL; + } + } + return CHIP_NO_ERROR; +} diff --git a/examples/tv-app/android/java/MessagesManager.h b/examples/tv-app/android/java/MessagesManager.h new file mode 100644 index 00000000000000..563192a542bdf6 --- /dev/null +++ b/examples/tv-app/android/java/MessagesManager.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. + */ + +#pragma once + +#include + +#include +#include + +#include +#include + +class MessagesManager : public chip::app::Clusters::Messages::Delegate +{ +public: + static void NewManager(jint endpoint, jobject manager); + void InitializeWithObjects(jobject managerObject); + + // Commands + CHIP_ERROR HandlePresentMessagesRequest( + const chip::ByteSpan & messageId, const chip::app::Clusters::Messages::MessagePriorityEnum & priority, + const chip::BitMask & messageControl, + const chip::app::DataModel::Nullable & startTime, const chip::app::DataModel::Nullable & duration, + const chip::CharSpan & messageText, + const chip::Optional< + chip::app::DataModel::DecodableList> & + responses) override; + CHIP_ERROR HandleCancelMessagesRequest(const chip::app::DataModel::DecodableList & messageIds) override; + + // Attributes + CHIP_ERROR HandleGetMessages(chip::app::AttributeValueEncoder & aEncoder) override; + CHIP_ERROR HandleGetActiveMessageIds(chip::app::AttributeValueEncoder & aEncoder) override; + + // Global Attributes + uint32_t GetFeatureMap(chip::EndpointId endpoint) override; + // uint16_t GetClusterRevision(chip::EndpointId endpoint) override; + +private: + chip::JniGlobalReference mMessagesManagerObject; + jmethodID mGetMessagesMethod = nullptr; + + jmethodID mPresentMessagesMethod = nullptr; + jmethodID mCancelMessagesMethod = nullptr; + + // TODO: set this based upon meta data from app + static constexpr uint32_t kEndpointFeatureMap = 15; + // static constexpr uint16_t kClusterRevision = 1; +}; diff --git a/examples/tv-app/android/java/MyUserPrompter-JNI.cpp b/examples/tv-app/android/java/MyUserPrompter-JNI.cpp index d2c83b28a1ce8f..82b06e210d7853 100644 --- a/examples/tv-app/android/java/MyUserPrompter-JNI.cpp +++ b/examples/tv-app/android/java/MyUserPrompter-JNI.cpp @@ -78,6 +78,7 @@ JNIMyUserPrompter::JNIMyUserPrompter(jobject provider) */ void JNIMyUserPrompter::PromptForCommissionOKPermission(uint16_t vendorId, uint16_t productId, const char * commissioneeName) { + DeviceLayer::StackUnlock unlock; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); std::string stringCommissioneeName(commissioneeName); @@ -119,6 +120,7 @@ void JNIMyUserPrompter::PromptForCommissionOKPermission(uint16_t vendorId, uint1 void JNIMyUserPrompter::PromptForCommissionPasscode(uint16_t vendorId, uint16_t productId, const char * commissioneeName, uint16_t pairingHint, const char * pairingInstruction) { + DeviceLayer::StackUnlock unlock; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); std::string stringCommissioneeName(commissioneeName); @@ -198,6 +200,7 @@ void JNIMyUserPrompter::PromptCommissioningStarted(uint16_t vendorId, uint16_t p */ void JNIMyUserPrompter::PromptCommissioningSucceeded(uint16_t vendorId, uint16_t productId, const char * commissioneeName) { + DeviceLayer::StackUnlock unlock; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); std::string stringCommissioneeName(commissioneeName); @@ -234,6 +237,7 @@ void JNIMyUserPrompter::PromptCommissioningSucceeded(uint16_t vendorId, uint16_t */ void JNIMyUserPrompter::PromptCommissioningFailed(const char * commissioneeName, CHIP_ERROR error) { + DeviceLayer::StackUnlock unlock; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); std::string stringCommissioneeName(commissioneeName); diff --git a/examples/tv-app/android/java/OnOffManager.cpp b/examples/tv-app/android/java/OnOffManager.cpp index 9a330754aa4a16..db694748e8a11b 100644 --- a/examples/tv-app/android/java/OnOffManager.cpp +++ b/examples/tv-app/android/java/OnOffManager.cpp @@ -113,6 +113,7 @@ CHIP_ERROR OnOffManager::InitializeWithObjects(jobject managerObject) void OnOffManager::HandleOnOffChanged(bool value) { + DeviceLayer::StackUnlock unlock; ChipLogProgress(Zcl, "OnOffManager::HandleOnOffChanged"); JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); diff --git a/examples/tv-app/android/java/TVApp-JNI.cpp b/examples/tv-app/android/java/TVApp-JNI.cpp index 6bbc35ed297415..72279c49dca9d7 100644 --- a/examples/tv-app/android/java/TVApp-JNI.cpp +++ b/examples/tv-app/android/java/TVApp-JNI.cpp @@ -27,6 +27,7 @@ #include "LowPowerManager.h" #include "MediaInputManager.h" #include "MediaPlaybackManager.h" +#include "MessagesManager.h" #include "MyUserPrompter-JNI.h" #include "OnOffManager.h" #include "WakeOnLanManager.h" @@ -137,6 +138,11 @@ JNI_METHOD(void, setMediaPlaybackManager)(JNIEnv *, jobject, jint endpoint, jobj MediaPlaybackManager::NewManager(endpoint, manager); } +JNI_METHOD(void, setMessagesManager)(JNIEnv *, jobject, jint endpoint, jobject manager) +{ + MessagesManager::NewManager(endpoint, manager); +} + JNI_METHOD(void, setChannelManager)(JNIEnv *, jobject, jint endpoint, jobject manager) { ChannelManager::NewManager(endpoint, manager); diff --git a/examples/tv-app/android/java/WakeOnLanManager.cpp b/examples/tv-app/android/java/WakeOnLanManager.cpp index 5a3093aca53332..a50ddca72bbb3e 100644 --- a/examples/tv-app/android/java/WakeOnLanManager.cpp +++ b/examples/tv-app/android/java/WakeOnLanManager.cpp @@ -51,6 +51,7 @@ void WakeOnLanManager::NewManager(jint endpoint, jobject manager) CHIP_ERROR WakeOnLanManager::HandleGetMacAddress(chip::app::AttributeValueEncoder & aEncoder) { + DeviceLayer::StackUnlock unlock; jobject javaMac; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/Clusters.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/Clusters.java index d699ca68ea6365..5928c1b10181c7 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/Clusters.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/Clusters.java @@ -129,7 +129,7 @@ public class Clusters { public static final long ClusterId_ApplicationBasic = 0x0000050D; public static final long ClusterId_AccountLogin = 0x0000050E; public static final long ClusterId_TestCluster = 0xFFF1FC05; - public static final long ClusterId_Messaging = 0x00000703; + public static final long ClusterId_Messaging = 0x00000097; public static final long ClusterId_ApplianceIdentification = 0x00000B00; public static final long ClusterId_MeterIdentification = 0x00000B01; public static final long ClusterId_ApplianceEventsAndAlert = 0x00000B02; diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/Message.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/Message.java new file mode 100644 index 00000000000000..c194ffb44f9ee1 --- /dev/null +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/Message.java @@ -0,0 +1,46 @@ +/* + * 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 Message { + + public String messageId; + public int priority; + public int messageControl; + public long startTime; + public int duration; + public String messageText; + public MessageResponseOption responseOptions[]; + + public Message( + String messageId, + int priority, + int messageControl, + long startTime, + int duration, + String messageText, + MessageResponseOption responseOptions[]) { + this.messageId = messageId; + this.priority = priority; + this.messageControl = messageControl; + this.startTime = startTime; + this.duration = duration; + this.messageText = messageText; + this.responseOptions = responseOptions; + } +} diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessageResponseOption.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessageResponseOption.java new file mode 100644 index 00000000000000..5d8e77d1e91389 --- /dev/null +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessageResponseOption.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 MessageResponseOption { + public long id = -1; + public String label = "na"; + + public MessageResponseOption(long id, String label) { + this.id = id; + this.label = label; + } +} diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManager.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManager.java new file mode 100644 index 00000000000000..0a5680866714c6 --- /dev/null +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManager.java @@ -0,0 +1,36 @@ +/* + * 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.HashMap; + +public interface MessagesManager { + + Message[] getMessages(); + + boolean presentMessages( + String messageId, + int priority, + int messageControl, + long startTime, + int duration, + String messageText, + HashMap responseOptions); + + boolean cancelMessage(String messageId); +} diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManagerStub.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManagerStub.java new file mode 100644 index 00000000000000..63fef69d35c936 --- /dev/null +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManagerStub.java @@ -0,0 +1,82 @@ +/* + * 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 android.util.Log; +import java.util.HashMap; +import java.util.Map; + +public class MessagesManagerStub implements MessagesManager { + private static final String TAG = MessagesManagerStub.class.getSimpleName(); + + private int endpoint = -1; + + private Map messages = new HashMap(); + + public MessagesManagerStub(int endpoint) { + this.endpoint = endpoint; + Log.d(TAG, "MessagesManagerStub: at " + this.endpoint); + + HashMap responseOptions = new HashMap(); + responseOptions.put(new Long(1), "Yes"); + responseOptions.put(new Long(2), "No"); + presentMessages( + "31323334353637383930313233343536", 1, 1, 30, 60, "TestMessage", responseOptions); + Log.d(TAG, "MessagesManagerStub: added dummy message"); + } + + @Override + public Message[] getMessages() { + Log.d(TAG, "getMessages: at " + this.endpoint); + return messages.values().toArray(new Message[0]); + } + + @Override + public boolean presentMessages( + String messageId, + int priority, + int messageControl, + long startTime, + int duration, + String messageText, + HashMap responseOptions) { + Log.d( + TAG, "presentMessages: at " + this.endpoint + " id:" + messageId + " text:" + messageText); + MessageResponseOption[] options = new MessageResponseOption[responseOptions.size()]; + int i = 0; + + for (Map.Entry set : responseOptions.entrySet()) { + Log.d(TAG, "presentMessages option: key:" + set.getKey() + " value:" + set.getValue()); + options[i] = new MessageResponseOption(set.getKey().longValue(), set.getValue()); + i++; + } + + messages.put( + messageId, + new Message( + messageId, priority, messageControl, startTime, duration, messageText, options)); + return true; + } + + @Override + public boolean cancelMessage(String messageId) { + Log.d(TAG, "cancelMessage: at " + this.endpoint + " messageId:" + messageId); + messages.remove(messageId); + return true; // per spec, succeed unless error + } +} diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/TvApp.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/TvApp.java index d8bb564370afa4..eaf207e45f3618 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/TvApp.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/TvApp.java @@ -57,6 +57,8 @@ private void postClusterInit(long clusterId, int endpoint) { public native void setMediaPlaybackManager(int endpoint, MediaPlaybackManager manager); + public native void setMessagesManager(int endpoint, MessagesManager manager); + public native void setChannelManager(int endpoint, ChannelManager manager); public native void setOnOffManager(int endpoint, OnOffManager manager); diff --git a/integrations/cloudbuild/build-all.yaml b/integrations/cloudbuild/build-all.yaml index 6590630957d902..cdefbcf1ddbe15 100644 --- a/integrations/cloudbuild/build-all.yaml +++ b/integrations/cloudbuild/build-all.yaml @@ -6,7 +6,7 @@ steps: - "--init" - "--recursive" id: Submodules - - name: "ghcr.io/project-chip/chip-build-vscode:35" + - name: "ghcr.io/project-chip/chip-build-vscode:36" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -21,7 +21,7 @@ steps: path: /pwenv timeout: 900s - - name: "ghcr.io/project-chip/chip-build-vscode:35" + - name: "ghcr.io/project-chip/chip-build-vscode:36" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -85,7 +85,7 @@ steps: --target k32w-shell build --create-archives /workspace/artifacts/ - - name: "ghcr.io/project-chip/chip-build-vscode:35" + - name: "ghcr.io/project-chip/chip-build-vscode:36" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/smoke-test.yaml b/integrations/cloudbuild/smoke-test.yaml index f05bbd0e369d2d..87e22dbbea99d0 100644 --- a/integrations/cloudbuild/smoke-test.yaml +++ b/integrations/cloudbuild/smoke-test.yaml @@ -1,5 +1,5 @@ steps: - - name: "ghcr.io/project-chip/chip-build-vscode:35" + - name: "ghcr.io/project-chip/chip-build-vscode:36" entrypoint: "bash" args: - "-c" @@ -7,7 +7,7 @@ steps: git config --global --add safe.directory "*" git submodule update --init --recursive id: Submodules - - name: "ghcr.io/project-chip/chip-build-vscode:35" + - name: "ghcr.io/project-chip/chip-build-vscode:36" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -22,7 +22,7 @@ steps: path: /pwenv timeout: 900s - - name: "ghcr.io/project-chip/chip-build-vscode:35" + - name: "ghcr.io/project-chip/chip-build-vscode:36" id: ESP32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -43,7 +43,7 @@ steps: volumes: - name: pwenv path: /pwenv - - name: "ghcr.io/project-chip/chip-build-vscode:35" + - name: "ghcr.io/project-chip/chip-build-vscode:36" id: NRFConnect env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -64,7 +64,7 @@ steps: - name: pwenv path: /pwenv - - name: "ghcr.io/project-chip/chip-build-vscode:35" + - name: "ghcr.io/project-chip/chip-build-vscode:36" id: EFR32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -86,7 +86,7 @@ steps: - name: pwenv path: /pwenv - - name: "ghcr.io/project-chip/chip-build-vscode:35" + - name: "ghcr.io/project-chip/chip-build-vscode:36" id: Linux env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -139,7 +139,7 @@ steps: - name: pwenv path: /pwenv - - name: "ghcr.io/project-chip/chip-build-vscode:35" + - name: "ghcr.io/project-chip/chip-build-vscode:36" id: Android env: - PW_ENVIRONMENT_ROOT=/pwenv diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile index 33662e66d3a9ba..dff19ccd0137ef 100644 --- a/integrations/docker/images/chip-cert-bins/Dockerfile +++ b/integrations/docker/images/chip-cert-bins/Dockerfile @@ -194,6 +194,7 @@ RUN case ${TARGETPLATFORM} in \ --target linux-x64-lit-icd-ipv6only \ --target linux-x64-energy-management-ipv6only \ --target linux-x64-microwave-oven-ipv6only \ + --target linux-x64-rvc-ipv6only \ build \ && mv out/linux-x64-chip-tool-ipv6only-platform-mdns/chip-tool out/chip-tool \ && mv out/linux-x64-shell-ipv6only-platform-mdns/chip-shell out/chip-shell \ @@ -213,6 +214,7 @@ RUN case ${TARGETPLATFORM} in \ && mv out/linux-x64-lit-icd-ipv6only/lit-icd-app out/lit-icd-app \ && mv out/linux-x64-energy-management-ipv6only/chip-energy-management-app out/chip-energy-management-app \ && mv out/linux-x64-microwave-oven-ipv6only/chip-microwave-oven-app out/chip-microwave-oven-app \ + && mv out/linux-x64-rvc-ipv6only/chip-rvc-app out/chip-rvc-app \ ;; \ "linux/arm64")\ set -x \ @@ -255,6 +257,7 @@ RUN case ${TARGETPLATFORM} in \ && mv out/linux-arm64-lit-icd-ipv6only/lit-icd-app out/lit-icd-app \ && mv out/linux-arm64-energy-management-ipv6only/chip-energy-management-app out/chip-energy-management-app \ && mv out/linux-arm64-microwave-oven-ipv6only/chip-microwave-oven-app out/chip-microwave-oven-app \ + && mv out/linux-arm64-rvc-ipv6only/chip-rvc-app out/chip-rvc-app \ ;; \ *) ;; \ esac @@ -287,6 +290,7 @@ COPY --from=chip-build-cert-bins /root/connectedhomeip/out/chip-app1 chip-app1 COPY --from=chip-build-cert-bins /root/connectedhomeip/out/lit-icd-app lit-icd-app COPY --from=chip-build-cert-bins /root/connectedhomeip/out/chip-energy-management-app chip-energy-management-app COPY --from=chip-build-cert-bins /root/connectedhomeip/out/chip-microwave-oven-app chip-microwave-oven-app +COPY --from=chip-build-cert-bins /root/connectedhomeip/out/chip-rvc-app chip-rvc-app # Stage 3.1: Setup the Matter Python environment COPY --from=chip-build-cert-bins /root/connectedhomeip/out/python_lib python_lib diff --git a/scripts/build/builders/host.py b/scripts/build/builders/host.py index a6ad8f343e0b16..fcb609c70e941f 100644 --- a/scripts/build/builders/host.py +++ b/scripts/build/builders/host.py @@ -234,8 +234,8 @@ def OutputNames(self): yield 'refrigerator-app' yield 'refrigerator-app.map' elif self == HostApp.RVC: - yield 'rvc-app' - yield 'rvc-app.map' + yield 'chip-rvc-app' + yield 'chip-rvc-app.map' elif self == HostApp.AIR_PURIFIER: yield 'air-purifier-app' yield 'air-purifier-app.map' diff --git a/scripts/build/gn_gen_cirque.sh b/scripts/build/gn_gen_cirque.sh index a0713f571189ab..d6f6bd86905a0e 100755 --- a/scripts/build/gn_gen_cirque.sh +++ b/scripts/build/gn_gen_cirque.sh @@ -36,7 +36,7 @@ echo "Setup build environment" source "./scripts/activate.sh" echo "Build: GN configure" -gn --root="$CHIP_ROOT" gen --check --fail-on-unused-args out/debug --args='target_os="all"'"chip_build_tests=false chip_enable_wifi=false chip_im_force_fabric_quota_check=true enable_default_builds=false enable_host_gcc_build=true enable_standalone_chip_tool_build=true enable_linux_all_clusters_app_build=true enable_linux_lighting_app_build=true enable_microwave_oven_app_build=true enable_linux_lit_icd_app_build=true" +gn --root="$CHIP_ROOT" gen --check --fail-on-unused-args out/debug --args='target_os="all"'"chip_build_tests=false chip_enable_wifi=false chip_im_force_fabric_quota_check=true enable_default_builds=false enable_host_gcc_build=true enable_standalone_chip_tool_build=true enable_linux_all_clusters_app_build=true enable_linux_lighting_app_build=true enable_linux_lit_icd_app_build=true" echo "Build: Ninja build" time ninja -C out/debug all check diff --git a/scripts/py_matter_yamltests/BUILD.gn b/scripts/py_matter_yamltests/BUILD.gn index b886fb04132c37..f8fa027672b868 100644 --- a/scripts/py_matter_yamltests/BUILD.gn +++ b/scripts/py_matter_yamltests/BUILD.gn @@ -55,6 +55,7 @@ pw_python_package("matter_yamltests") { "test_pics_checker.py", "test_parser_builder.py", "test_pseudo_clusters.py", + "test_yaml_parser.py", "test_yaml_loader.py", ] diff --git a/scripts/py_matter_yamltests/matter_yamltests/errors.py b/scripts/py_matter_yamltests/matter_yamltests/errors.py index daa886573569c1..1f26ea4f8354bc 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/errors.py +++ b/scripts/py_matter_yamltests/matter_yamltests/errors.py @@ -222,3 +222,45 @@ def __init__(self, content): self.tag_key_with_error(content, 'attribute') response = content.get('response') self.tag_key_with_error(response, 'saveAs') + + +class TestStepEnumError(TestStepError): + """ + Raise when an enum value or an enum name is not found in the definitions. + + Parameters: + - enum_name_or_value (str|int): The name (str) or value (int) of the enumeration in the step. + If a string is provided, it is considered the name of the enumeration; if an integer is provided, it is considered the value of the enumeration. + - enum_candidates (dict): A dictionary mapping enumeration names (as strings) to their corresponding values + (as integers). This dictionary represents all known values of the enumeration. + """ + + def __init__(self, enum_name_or_value, enum_candidates: dict): + if type(enum_name_or_value) is str: + message = f'Unknown enum name: "{enum_name_or_value}". The possible values are: "{enum_candidates}"' + + for enum_name in enum_candidates: + if enum_name.lower() == enum_name_or_value.lower(): + message = f'Unknown enum name: "{enum_name_or_value}". Did you mean "{enum_name}" ?' + break + + else: + message = f'Unknown enum value: "{enum_name_or_value}". The possible values are: "{enum_candidates}"' + + super().__init__(message) + + +class TestStepEnumSpecifierNotUnknownError(TestStepError): + """Raise when an enum value declared as unknown is in fact a known enum value from the definitions.""" + + def __init__(self, specified_value, enum_name): + message = f'The value "{specified_value}" is not unknown. It is the value of "{enum_name}"' + super().__init__(message) + + +class TestStepEnumSpecifierWrongError(TestStepError): + """Raise when an enum value is specified for a given enum name but it does not match the enum value from the definitions.""" + + def __init__(self, specified_value, enum_name, enum_value): + message = f'The value "{specified_value}" is not the value of "{enum_name}({enum_value})"' + super().__init__(message) diff --git a/scripts/py_matter_yamltests/matter_yamltests/parser.py b/scripts/py_matter_yamltests/matter_yamltests/parser.py index 16f98bcf96d800..cb0a89c6418756 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/parser.py +++ b/scripts/py_matter_yamltests/matter_yamltests/parser.py @@ -15,6 +15,7 @@ import copy import logging +import re from dataclasses import dataclass, field from enum import Enum, auto from typing import Optional @@ -22,7 +23,8 @@ from . import fixes from .constraints import get_constraints, is_typed_constraint from .definitions import SpecDefinitions -from .errors import TestStepError, TestStepKeyError, TestStepValueNameError +from .errors import (TestStepEnumError, TestStepEnumSpecifierNotUnknownError, TestStepEnumSpecifierWrongError, TestStepError, + TestStepKeyError, TestStepValueNameError) from .pics_checker import PICSChecker from .yaml_loader import YamlLoader @@ -38,6 +40,9 @@ 'SubscribeAll', ] +# If True, enum values should use a valid name instead of a raw value +STRICT_ENUM_VALUE_CHECK = False + class UnknownPathQualifierError(TestStepError): """Raise when an attribute/command/event name is not found in the definitions.""" @@ -169,6 +174,99 @@ def _value_or_config(data, key, config): return data[key] if key in data else config.get(key) +class EnumType: + def __init__(self, enum: Enum): + self.type = enum.name + self.base_type = enum.base_type + + self._codes = {} + self.entries_by_name = {} + self.entries_by_code = {} + self._compute_entries(enum) + + def translate(self, key: str, value) -> int: + if self._codes.get(key) is not None and self._codes.get(key) == value: + return self._codes.get(key) + + if type(value) is str: + code = self._get_code_by_name(value) + else: + code = self._get_code_by_value(value) + + if code is None: + raise TestStepEnumError(value, self.entries_by_name) + + self._codes[key] = code + return code + + def _get_code_by_name(self, value): + # For readability the name could sometimes be written as "enum_name(enum_code)" instead of "enum_name" + # In this case the enum_code should be checked to ensure that it is correct, unless enum_name is UnknownEnumValue + # in which case only invalid enum_code are allowed. + specified_name, specified_code = self._extract_name_and_code(value) + if specified_name not in self.entries_by_name: + return None + + enum_code = self.entries_by_name.get(specified_name) + if specified_code is None or specified_code == enum_code: + return enum_code + + if specified_name != f'{self.type}.UnknownEnumValue': + raise TestStepEnumSpecifierWrongError( + specified_code, specified_name, enum_code) + + enum_name = self.entries_by_code.get(specified_code) + if enum_name: + raise TestStepEnumSpecifierNotUnknownError(value, enum_name) + + return specified_code + + def _get_code_by_value(self, value): + enum_name = self.entries_by_code.get(value) + if not enum_name: + return None + + if STRICT_ENUM_VALUE_CHECK: + raise TestStepEnumError(value, self.entries_by_name) + + return value + + def _compute_entries(self, enum: Enum): + enum_codes = [] + for enum_entry in enum.entries: + name = f'{self.type}.{enum_entry.name}' + code = enum_entry.code + + self.entries_by_name[name] = code + self.entries_by_code[code] = name + enum_codes.append(code) + + # search for the first invalid entry if any + max_code = 0xFF + 1 + if self.base_type == 'enum16': + max_code = 0xFFFF + 1 + + for code in range(0, max_code): + if code not in enum_codes: + name = f'{self.type}.UnknownEnumValue' + self.entries_by_name[name] = code + self.entries_by_code[code] = name + break + + def _extract_name_and_code(self, enum_name: str): + match = re.match(r"([\w.]+)(?:\((\w+)\))?", enum_name) + if match: + name = match.group(1) + code = int(match.group(2)) if match.group(2) else None + return name, code + + return None, None + + @staticmethod + def is_valid_type(target_type: str): + return target_type == 'enum8' or target_type == 'enum16' + + class _TestStepWithPlaceholders: '''A single YAML test parsed, as is, from YAML. @@ -441,7 +539,11 @@ def _as_mapping(self, definitions, cluster_name, target_name): element = definitions.get_type_by_name(cluster_name, target_name) if hasattr(element, 'base_type'): - target_name = element.base_type.lower() + if EnumType.is_valid_type(element.base_type): + target_name = EnumType(element) + else: + target_name = element.base_type + elif hasattr(element, 'fields'): target_name = {f.name: self._as_mapping( definitions, cluster_name, f.data_type.name) for f in element.fields} @@ -480,7 +582,11 @@ def _update_with_definition(self, container: dict, mapping_type): if key == 'value': value[key] = self._update_value_with_definition( - item_value, mapping) + value, + key, + item_value, + mapping + ) elif key == 'saveAs' and type(item_value) is str and item_value not in self._parsing_config_variable_storage: self._parsing_config_variable_storage[item_value] = None elif key == 'saveDataVersionAs' and type(item_value) is str and item_value not in self._parsing_config_variable_storage: @@ -491,37 +597,80 @@ def _update_with_definition(self, container: dict, mapping_type): # the the value type for the target field. if is_typed_constraint(constraint): value[key][constraint] = self._update_value_with_definition( - constraint_value, mapping) + item_value, + constraint, + constraint_value, + mapping + ) else: # This key, value pair does not rely on cluster specifications. pass - def _update_value_with_definition(self, value, mapping_type): + def _update_value_with_definition(self, container: dict, key: str, value, mapping_type): + """ + Processes a given value based on a specified mapping type and returns the updated value. + This method does not modify the container in place; rather, it returns a new value that should be + used to update or process further as necessary. + + The 'container' and 'key' parameters are primarily used for error tagging. If an error occurs + during the value processing, these parameters allow for the error to be precisely located and + reported, facilitating easier debugging and error tracking. + + Parameters: + - container (dict): A dictionary that serves as a context for the operation. It is used for error + tagging if processing fails, by associating errors with specific locations within the data structure. + - key (str): The key related to the value being processed. It is used alongside 'container' to tag + errors, enabling precise identification of the error source. + - value: The value to be processed according to the mapping type. + - mapping_type: Dictates the processing or mapping logic to be applied to 'value'. + + Returns: + The processed value, which is the result of applying the specified mapping type to the original 'value'. + This method does not update the 'container'; any necessary updates based on the processed value must + be handled outside this method. + + Raises: + - TestStepError: If an error occurs during the processing of the value. The error includes details + from the 'container' and 'key' to facilitate error tracing and debugging. + """ + if not mapping_type: return value if type(value) is dict: rv = {} - for key in value: + for item_key in value: # FabricIndex is a special case where the framework requires it to be passed even # if it is not part of the requested arguments per spec and not part of the XML # definition. - if key == 'FabricIndex' or key == 'fabricIndex': - rv[key] = value[key] # int64u + if item_key == 'FabricIndex' or item_key == 'fabricIndex': + rv[item_key] = value[item_key] # int64u else: - if not mapping_type.get(key): - raise TestStepKeyError(value, key) - mapping = mapping_type[key] - rv[key] = self._update_value_with_definition( - value[key], mapping) + if not mapping_type.get(item_key): + raise TestStepKeyError(value, item_key) + mapping = mapping_type[item_key] + rv[item_key] = self._update_value_with_definition( + value, + item_key, + value[item_key], + mapping + ) return rv + if type(value) is list: - return [self._update_value_with_definition(entry, mapping_type) for entry in value] + return [self._update_value_with_definition(container, key, entry, mapping_type) for entry in value] + # TODO currently unsure if the check of `value not in config` is sufficant. For # example let's say value = 'foo + 1' and map type is 'int64u', we would arguably do # the wrong thing below. if value is not None and value not in self._parsing_config_variable_storage: - if mapping_type == 'int64u' or mapping_type == 'int64s' or mapping_type == 'bitmap64' or mapping_type == 'epoch_us': + if type(mapping_type) is EnumType: + try: + value = mapping_type.translate(key, value) + except (TestStepEnumError, TestStepEnumSpecifierNotUnknownError, TestStepEnumSpecifierWrongError) as e: + e.tag_key_with_error(container, key) + raise e + elif mapping_type == 'int64u' or mapping_type == 'int64s' or mapping_type == 'bitmap64' or mapping_type == 'epoch_us': value = fixes.try_apply_float_to_integer_fix(value) value = fixes.try_apply_yaml_cpp_longlong_limitation_fix(value) value = fixes.try_apply_yaml_unrepresentable_integer_for_javascript_fixes( diff --git a/scripts/py_matter_yamltests/test_yaml_parser.py b/scripts/py_matter_yamltests/test_yaml_parser.py index 055f949773f9d3..27472572a96d6b 100644 --- a/scripts/py_matter_yamltests/test_yaml_parser.py +++ b/scripts/py_matter_yamltests/test_yaml_parser.py @@ -20,14 +20,22 @@ # is arguably better then no checks at all. import io -import tempfile import unittest +from unittest.mock import mock_open, patch from matter_yamltests.definitions import ParseSource, SpecDefinitions +from matter_yamltests.errors import TestStepEnumError, TestStepEnumSpecifierNotUnknownError, TestStepEnumSpecifierWrongError from matter_yamltests.parser import TestParser, TestParserConfig simple_test_description = ''' + + + + + + + @@ -36,8 +44,11 @@ Test 0x1234 - + test_enum + + + ''' @@ -52,43 +63,145 @@ tests: - label: "Send Test Command" command: "test" +''' + +enum_values_yaml = ''' +name: Test Enum Values + +config: + nodeId: 0x12344321 + cluster: "Test" + endpoint: 1 + +tests: + - label: "Read attribute test_enum Value" + command: "readAttribute" + attribute: "test_enum" + response: + value: 0 + + - label: "Read attribute test_enum Value" + command: "readAttribute" + attribute: "test_enum" + response: + value: TestEnum.A + + - label: "Read attribute test_enum Value" + command: "readAttribute" + attribute: "test_enum" + response: + value: TestEnum.A(0) + + - label: "Read attribute test_enum Value" + command: "readAttribute" + attribute: "test_enum" + response: + value: TestEnum.UnknownEnumValue + + - label: "Read attribute test_enum Value" + command: "readAttribute" + attribute: "test_enum" + response: + value: TestEnum.UnknownEnumValue(255) + + - label: "Write attribute test_enum Value" + command: "writeAttribute" + attribute: "test_enum" + arguments: + value: 0 + + - label: "Write attribute test_enum Value" + command: "writeAttribute" + attribute: "test_enum" + arguments: + value: TestEnum.A + + - label: "Write attribute test_enum Value" + command: "writeAttribute" + attribute: "test_enum" + arguments: + value: TestEnum.A(0) + + - label: "Write attribute test_enum Value" + command: "writeAttribute" + attribute: "test_enum" + arguments: + value: TestEnum.UnknownEnumValue + + - label: "Write attribute test_enum Value" + command: "writeAttribute" + attribute: "test_enum" + arguments: + value: TestEnum.UnknownEnumValue(255) +''' + +enum_value_read_response_wrong_code_yaml = ''' +tests: + - label: "Read attribute test_enum Value" + cluster: "Test" + command: "readAttribute" + attribute: "test_enum" + response: + value: 123 +''' + +enum_value_read_response_wrong_name_yaml = ''' +tests: + - label: "Read attribute test_enum Value" + cluster: "Test" + command: "readAttribute" + attribute: "test_enum" + response: + value: ThisIsWrong +''' - - label: "Send Test Not Handled Command" - command: "testNotHandled" +enum_value_read_response_wrong_code_specified_yaml = ''' +tests: + - label: "Read attribute test_enum Value" + cluster: "Test" + command: "readAttribute" + attribute: "test_enum" response: - error: INVALID_COMMAND + value: TestEnum.A(123) +''' - - label: "Send Test Specific Command" - command: "testSpecific" +enum_value_read_response_not_unknown_code_specified_yaml = ''' +tests: + - label: "Read attribute test_enum Value" + cluster: "Test" + command: "readAttribute" + attribute: "test_enum" response: - values: - - name: "returnValue" - value: 7 + value: TestEnum.UnknownEnumValue(0) ''' +def mock_open_with_parameter_content(content): + file_object = mock_open(read_data=content).return_value + file_object.__iter__.return_value = content.splitlines(True) + return file_object + + +@patch('builtins.open', new=mock_open_with_parameter_content) class TestYamlParser(unittest.TestCase): def setUp(self): self._definitions = SpecDefinitions( [ParseSource(source=io.StringIO(simple_test_description), name='simple_test_description')]) - self._temp_file = tempfile.NamedTemporaryFile(suffix='.yaml') - with open(self._temp_file.name, 'w') as f: - f.writelines(simple_test_yaml) def test_able_to_iterate_over_all_parsed_tests(self): # self._yaml_parser.tests implements `__next__`, which does value substitution. We are # simply ensure there is no exceptions raise. parser_config = TestParserConfig(None, self._definitions) - yaml_parser = TestParser(self._temp_file.name, parser_config) + yaml_parser = TestParser(simple_test_yaml, parser_config) count = 0 for idx, test_step in enumerate(yaml_parser.tests): count += 1 pass - self.assertEqual(count, 3) + self.assertEqual(count, 1) def test_config(self): parser_config = TestParserConfig(None, self._definitions) - yaml_parser = TestParser(self._temp_file.name, parser_config) + yaml_parser = TestParser(simple_test_yaml, parser_config) for idx, test_step in enumerate(yaml_parser.tests): self.assertEqual(test_step.node_id, 0x12344321) self.assertEqual(test_step.cluster, 'Test') @@ -99,7 +212,7 @@ def test_config_override(self): 'cluster': 'TestOverride', 'endpoint': 4} parser_config = TestParserConfig( None, self._definitions, config_override) - yaml_parser = TestParser(self._temp_file.name, parser_config) + yaml_parser = TestParser(simple_test_yaml, parser_config) for idx, test_step in enumerate(yaml_parser.tests): self.assertEqual(test_step.node_id, 12345) self.assertEqual(test_step.cluster, 'TestOverride') @@ -109,8 +222,37 @@ def test_config_override_unknown_field(self): config_override = {'unknown_field': 1} parser_config = TestParserConfig( None, self._definitions, config_override) - self.assertRaises(KeyError, TestParser, - self._temp_file.name, parser_config) + + yaml_parser = TestParser(simple_test_yaml, parser_config) + self.assertIsInstance(yaml_parser, TestParser) + + def test_config_valid_enum_values(self): + parser_config = TestParserConfig(None, self._definitions) + yaml_parser = TestParser(enum_values_yaml, parser_config) + self.assertIsInstance(yaml_parser, TestParser) + + for idx, test_step in enumerate(yaml_parser.tests): + pass + + def test_config_read_response_wrong_code(self): + parser_config = TestParserConfig(None, self._definitions) + self.assertRaises(TestStepEnumError, TestParser, + enum_value_read_response_wrong_code_yaml, parser_config) + + def test_config_read_response_wrong_name(self): + parser_config = TestParserConfig(None, self._definitions) + self.assertRaises(TestStepEnumError, TestParser, + enum_value_read_response_wrong_name_yaml, parser_config) + + def test_config_read_response_wrong_code_specified(self): + parser_config = TestParserConfig(None, self._definitions) + self.assertRaises(TestStepEnumSpecifierWrongError, TestParser, + enum_value_read_response_wrong_code_specified_yaml, parser_config) + + def test_config_read_response_not_unknown_code_specified(self): + parser_config = TestParserConfig(None, self._definitions) + self.assertRaises(TestStepEnumSpecifierNotUnknownError, TestParser, + enum_value_read_response_not_unknown_code_specified_yaml, parser_config) def main(): diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py index 505a5e163cc5c4..ecfd98be618480 100644 --- a/scripts/tests/chiptest/__init__.py +++ b/scripts/tests/chiptest/__init__.py @@ -313,6 +313,8 @@ def target_for_name(name: str): return TestTarget.LIT_ICD if name.startswith("Test_TC_MWOCTRL_") or name.startswith("Test_TC_MWOM_"): return TestTarget.MWO + if name.startswith("Test_TC_RVCRUNM_") or name.startswith("Test_TC_RVCCLEANM_") or name.startswith("Test_TC_RVCOPSTATE_"): + return TestTarget.RVC return TestTarget.ALL_CLUSTERS diff --git a/scripts/tests/chiptest/linux.py b/scripts/tests/chiptest/linux.py index 1d679ee236a3fd..3dbd851be26b47 100644 --- a/scripts/tests/chiptest/linux.py +++ b/scripts/tests/chiptest/linux.py @@ -183,6 +183,7 @@ def PathsWithNetworkNamespaces(paths: ApplicationPaths) -> ApplicationPaths: tv_app='ip netns exec app'.split() + paths.tv_app, lit_icd_app='ip netns exec app'.split() + paths.lit_icd_app, microwave_oven_app='ip netns exec app'.split() + paths.microwave_oven_app, + rvc_app='ip netns exec app'.split() + paths.rvc_app, bridge_app='ip netns exec app'.split() + paths.bridge_app, chip_repl_yaml_tester_cmd='ip netns exec tool'.split() + paths.chip_repl_yaml_tester_cmd, chip_tool_with_python_cmd='ip netns exec tool'.split() + paths.chip_tool_with_python_cmd, diff --git a/scripts/tests/chiptest/test_definition.py b/scripts/tests/chiptest/test_definition.py index 95f7a631928ba4..12c59cfad0cc41 100644 --- a/scripts/tests/chiptest/test_definition.py +++ b/scripts/tests/chiptest/test_definition.py @@ -176,6 +176,7 @@ class TestTarget(Enum): BRIDGE = auto() LIT_ICD = auto() MWO = auto() + RVC = auto() @dataclass @@ -191,10 +192,11 @@ class ApplicationPaths: microwave_oven_app: typing.List[str] chip_repl_yaml_tester_cmd: typing.List[str] chip_tool_with_python_cmd: typing.List[str] + rvc_app: typing.List[str] def items(self): return [self.chip_tool, self.all_clusters_app, self.lock_app, self.ota_provider_app, self.ota_requestor_app, - self.tv_app, self.bridge_app, self.lit_icd_app, self.microwave_oven_app, self.chip_repl_yaml_tester_cmd, self.chip_tool_with_python_cmd] + self.tv_app, self.bridge_app, self.lit_icd_app, self.microwave_oven_app, self.chip_repl_yaml_tester_cmd, self.chip_tool_with_python_cmd, self.rvc_app] @dataclass @@ -305,6 +307,8 @@ def Run(self, runner, apps_register, paths: ApplicationPaths, pics_file: str, target_app = paths.lit_icd_app elif self.target == TestTarget.MWO: target_app = paths.microwave_oven_app + elif self.target == TestTarget.RVC: + target_app = paths.rvc_app else: raise Exception("Unknown test target - " "don't know which application to run") diff --git a/scripts/tests/run_test_suite.py b/scripts/tests/run_test_suite.py index 9dbe01d9dbcfa0..2df88cd6740653 100755 --- a/scripts/tests/run_test_suite.py +++ b/scripts/tests/run_test_suite.py @@ -257,6 +257,9 @@ def cmd_list(context): @click.option( '--microwave-oven-app', help='what microwave oven app to use') +@click.option( + '--rvc-app', + help='what rvc app to use') @click.option( '--chip-repl-yaml-tester', help='what python script to use for running yaml tests using chip-repl as controller') @@ -288,7 +291,7 @@ def cmd_list(context): help='Number of tests that are expected to fail in each iteration. Overall test will pass if the number of failures matches this. Nonzero values require --keep-going') @click.pass_context def cmd_run(context, iterations, all_clusters_app, lock_app, ota_provider_app, ota_requestor_app, - tv_app, bridge_app, lit_icd_app, microwave_oven_app, chip_repl_yaml_tester, chip_tool_with_python, pics_file, keep_going, test_timeout_seconds, expected_failures): + tv_app, bridge_app, lit_icd_app, microwave_oven_app, rvc_app, chip_repl_yaml_tester, chip_tool_with_python, pics_file, keep_going, test_timeout_seconds, expected_failures): if expected_failures != 0 and not keep_going: logging.exception(f"'--expected-failures {expected_failures}' used without '--keep-going'") sys.exit(2) @@ -321,6 +324,9 @@ def cmd_run(context, iterations, all_clusters_app, lock_app, ota_provider_app, o if microwave_oven_app is None: microwave_oven_app = paths_finder.get('chip-microwave-oven-app') + if rvc_app is None: + rvc_app = paths_finder.get('chip-rvc-app') + if chip_repl_yaml_tester is None: chip_repl_yaml_tester = paths_finder.get('yamltest_with_chip_repl_tester.py') @@ -341,6 +347,7 @@ def cmd_run(context, iterations, all_clusters_app, lock_app, ota_provider_app, o bridge_app=[bridge_app], lit_icd_app=[lit_icd_app], microwave_oven_app=[microwave_oven_app], + rvc_app=[rvc_app], chip_repl_yaml_tester_cmd=['python3'] + [chip_repl_yaml_tester], chip_tool_with_python_cmd=['python3'] + [chip_tool_with_python], ) diff --git a/src/app/AttributePathExpandIterator.cpp b/src/app/AttributePathExpandIterator.cpp index 5c1bb50c179f47..784499a41c4d74 100644 --- a/src/app/AttributePathExpandIterator.cpp +++ b/src/app/AttributePathExpandIterator.cpp @@ -52,7 +52,7 @@ extern bool emberAfEndpointIndexIsEnabled(uint16_t index); namespace chip { namespace app { -AttributePathExpandIterator::AttributePathExpandIterator(ObjectList * aAttributePath) +AttributePathExpandIterator::AttributePathExpandIterator(SingleLinkedListNode * aAttributePath) { mpAttributePath = aAttributePath; diff --git a/src/app/AttributePathExpandIterator.h b/src/app/AttributePathExpandIterator.h index dbf8382014ce9c..f11e6793822f84 100644 --- a/src/app/AttributePathExpandIterator.h +++ b/src/app/AttributePathExpandIterator.h @@ -69,7 +69,7 @@ namespace app { class AttributePathExpandIterator { public: - AttributePathExpandIterator(ObjectList * aAttributePath); + AttributePathExpandIterator(SingleLinkedListNode * aAttributePath); /** * Proceed the iterator to the next attribute path in the given cluster info. @@ -105,7 +105,7 @@ class AttributePathExpandIterator inline bool Valid() const { return mpAttributePath != nullptr; } private: - ObjectList * mpAttributePath; + SingleLinkedListNode * mpAttributePath; ConcreteAttributePath mOutputPath; diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index c0f30493824f3a..3dfbbbffe56daf 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -87,7 +87,11 @@ source_set("revision_info") { source_set("paths") { sources = [ "AttributePathParams.h", + "CommandPathParams.h", + "CommandPathRegistry.h", + "ConcreteAttributePath.h", "ConcreteClusterPath.h", + "ConcreteCommandPath.h", "ConcreteEventPath.h", "DataVersionFilter.h", "EventPathParams.h", @@ -96,6 +100,7 @@ source_set("paths") { # This source sets also depends on basic-types.h that is not in any dependency we can use public_deps = [ ":app_config", + "${chip_root}/src/app/util:types", "${chip_root}/src/lib/core", "${chip_root}/src/lib/core:types", ] @@ -222,12 +227,14 @@ static_library("app") { "CommandHandler.cpp", "CommandResponseHelper.h", "CommandResponseSender.cpp", + "CommandResponseSender.h", "CommandSender.cpp", "DefaultAttributePersistenceProvider.cpp", "DefaultAttributePersistenceProvider.h", "DeferredAttributePersistenceProvider.cpp", "DeferredAttributePersistenceProvider.h", "EventManagement.cpp", + "EventManagement.h", "FailSafeContext.cpp", "FailSafeContext.h", "OTAUserConsentCommon.h", @@ -242,6 +249,21 @@ static_library("app") { "TimerDelegates.h", "WriteClient.cpp", "WriteHandler.cpp", + + # TODO: the following items cannot be included due to interaction-model circularity + # (app depending on im and im including these headers): + # Name with _ so that linter does not recognize it + # "CommandHandler._h" + # "CommandSender._h", + # "ReadClient._h", + # "ReadHandler._h", + # "WriteClient._h", + # "WriteHandler._h" + + # TODO: the following items cannot be included due to platform includes not being + # able to depend on src/app + # Name with _ so that linter does not recognize it + # "_AttributeAccessInterface._h", ] public_deps = [ @@ -261,9 +283,13 @@ static_library("app") { if (chip_enable_read_client) { sources += [ "BufferedReadCallback.cpp", + "BufferedReadCallback.h", "ClusterStateCache.cpp", "ClusterStateCache.h", "ReadClient.cpp", + + # TODO: cannot include "ReadClient._h" because interaction-model backreference + # Name with _ so that linter does not recognize it ] } diff --git a/src/app/EventLoggingTypes.h b/src/app/EventLoggingTypes.h index 35fd37a25045ca..04a843ebcfbd60 100644 --- a/src/app/EventLoggingTypes.h +++ b/src/app/EventLoggingTypes.h @@ -19,11 +19,11 @@ #include #include -#include #include #include #include #include +#include #include inline constexpr size_t kNumPriorityLevel = 3; @@ -151,10 +151,10 @@ struct EventLoadOutContext EventNumber mStartingEventNumber = 0; Timestamp mPreviousTime; Timestamp mCurrentTime; - EventNumber mCurrentEventNumber = 0; - size_t mEventCount = 0; - const ObjectList * mpInterestedEventPaths = nullptr; - bool mFirst = true; + EventNumber mCurrentEventNumber = 0; + size_t mEventCount = 0; + const SingleLinkedListNode * mpInterestedEventPaths = nullptr; + bool mFirst = true; Access::SubjectDescriptor mSubjectDescriptor; }; } // namespace app diff --git a/src/app/EventManagement.cpp b/src/app/EventManagement.cpp index aa3abd67f828d8..8e6d53c24c9636 100644 --- a/src/app/EventManagement.cpp +++ b/src/app/EventManagement.cpp @@ -639,7 +639,7 @@ CHIP_ERROR EventManagement::CopyEventsSince(const TLVReader & aReader, size_t aD return err; } -CHIP_ERROR EventManagement::FetchEventsSince(TLVWriter & aWriter, const ObjectList * apEventPathList, +CHIP_ERROR EventManagement::FetchEventsSince(TLVWriter & aWriter, const SingleLinkedListNode * apEventPathList, EventNumber & aEventMin, size_t & aEventCount, const Access::SubjectDescriptor & aSubjectDescriptor) { diff --git a/src/app/EventManagement.h b/src/app/EventManagement.h index 228c26cca94a68..950efdc2bae867 100644 --- a/src/app/EventManagement.h +++ b/src/app/EventManagement.h @@ -31,10 +31,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -359,7 +359,7 @@ class EventManagement * available. * */ - CHIP_ERROR FetchEventsSince(chip::TLV::TLVWriter & aWriter, const ObjectList * apEventPathList, + CHIP_ERROR FetchEventsSince(chip::TLV::TLVWriter & aWriter, const SingleLinkedListNode * apEventPathList, EventNumber & aEventMin, size_t & aEventCount, const Access::SubjectDescriptor & aSubjectDescriptor); /** diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index ddc8a984f16b72..8e4b5a80e3df7d 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -450,7 +450,7 @@ CHIP_ERROR InteractionModelEngine::ParseAttributePaths(const Access::SubjectDesc // This avoids the 'parse all paths' approach that is employed in ReadHandler since we want to // avoid allocating out of the path store during this minimal initial processing stage. // - ObjectList paramsList; + SingleLinkedListNode paramsList; ReturnErrorOnFailure(path.Init(pathReader)); ReturnErrorOnFailure(path.ParsePath(paramsList.mValue)); @@ -1513,12 +1513,12 @@ bool InteractionModelEngine::HasConflictWriteRequests(const WriteHandler * apWri return false; } -void InteractionModelEngine::ReleaseAttributePathList(ObjectList *& aAttributePathList) +void InteractionModelEngine::ReleaseAttributePathList(SingleLinkedListNode *& aAttributePathList) { ReleasePool(aAttributePathList, mAttributePathPool); } -CHIP_ERROR InteractionModelEngine::PushFrontAttributePathList(ObjectList *& aAttributePathList, +CHIP_ERROR InteractionModelEngine::PushFrontAttributePathList(SingleLinkedListNode *& aAttributePathList, AttributePathParams & aAttributePath) { CHIP_ERROR err = PushFront(aAttributePathList, aAttributePath, mAttributePathPool); @@ -1530,10 +1530,10 @@ CHIP_ERROR InteractionModelEngine::PushFrontAttributePathList(ObjectList *& aAttributePaths) +void InteractionModelEngine::RemoveDuplicateConcreteAttributePath(SingleLinkedListNode *& aAttributePaths) { - ObjectList * prev = nullptr; - auto * path1 = aAttributePaths; + SingleLinkedListNode * prev = nullptr; + auto * path1 = aAttributePaths; while (path1 != nullptr) { @@ -1585,12 +1585,12 @@ void InteractionModelEngine::RemoveDuplicateConcreteAttributePath(ObjectList *& aEventPathList) +void InteractionModelEngine::ReleaseEventPathList(SingleLinkedListNode *& aEventPathList) { ReleasePool(aEventPathList, mEventPathPool); } -CHIP_ERROR InteractionModelEngine::PushFrontEventPathParamsList(ObjectList *& aEventPathList, +CHIP_ERROR InteractionModelEngine::PushFrontEventPathParamsList(SingleLinkedListNode *& aEventPathList, EventPathParams & aEventPath) { CHIP_ERROR err = PushFront(aEventPathList, aEventPath, mEventPathPool); @@ -1602,12 +1602,12 @@ CHIP_ERROR InteractionModelEngine::PushFrontEventPathParamsList(ObjectList *& aDataVersionFilterList) +void InteractionModelEngine::ReleaseDataVersionFilterList(SingleLinkedListNode *& aDataVersionFilterList) { ReleasePool(aDataVersionFilterList, mDataVersionFilterPool); } -CHIP_ERROR InteractionModelEngine::PushFrontDataVersionFilterList(ObjectList *& aDataVersionFilterList, +CHIP_ERROR InteractionModelEngine::PushFrontDataVersionFilterList(SingleLinkedListNode *& aDataVersionFilterList, DataVersionFilter & aDataVersionFilter) { CHIP_ERROR err = PushFront(aDataVersionFilterList, aDataVersionFilter, mDataVersionFilterPool); @@ -1620,12 +1620,13 @@ CHIP_ERROR InteractionModelEngine::PushFrontDataVersionFilterList(ObjectList -void InteractionModelEngine::ReleasePool(ObjectList *& aObjectList, ObjectPool, N> & aObjectPool) +void InteractionModelEngine::ReleasePool(SingleLinkedListNode *& aObjectList, + ObjectPool, N> & aObjectPool) { - ObjectList * current = aObjectList; + SingleLinkedListNode * current = aObjectList; while (current != nullptr) { - ObjectList * nextObject = current->mpNext; + SingleLinkedListNode * nextObject = current->mpNext; aObjectPool.ReleaseObject(current); current = nextObject; } @@ -1634,9 +1635,10 @@ void InteractionModelEngine::ReleasePool(ObjectList *& aObjectList, ObjectPoo } template -CHIP_ERROR InteractionModelEngine::PushFront(ObjectList *& aObjectList, T & aData, ObjectPool, N> & aObjectPool) +CHIP_ERROR InteractionModelEngine::PushFront(SingleLinkedListNode *& aObjectList, T & aData, + ObjectPool, N> & aObjectPool) { - ObjectList * object = aObjectPool.CreateObject(); + SingleLinkedListNode * object = aObjectPool.CreateObject(); if (object == nullptr) { return CHIP_ERROR_NO_MEMORY; diff --git a/src/app/InteractionModelEngine.h b/src/app/InteractionModelEngine.h index b222087867380f..1c05767299dfbb 100644 --- a/src/app/InteractionModelEngine.h +++ b/src/app/InteractionModelEngine.h @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -54,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -187,22 +187,22 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler, reporting::ReportScheduler * GetReportScheduler() { return mReportScheduler; } - void ReleaseAttributePathList(ObjectList *& aAttributePathList); + void ReleaseAttributePathList(SingleLinkedListNode *& aAttributePathList); - CHIP_ERROR PushFrontAttributePathList(ObjectList *& aAttributePathList, + CHIP_ERROR PushFrontAttributePathList(SingleLinkedListNode *& aAttributePathList, AttributePathParams & aAttributePath); // If a concrete path indicates an attribute that is also referenced by a wildcard path in the request, // the path SHALL be removed from the list. - void RemoveDuplicateConcreteAttributePath(ObjectList *& aAttributePaths); + void RemoveDuplicateConcreteAttributePath(SingleLinkedListNode *& aAttributePaths); - void ReleaseEventPathList(ObjectList *& aEventPathList); + void ReleaseEventPathList(SingleLinkedListNode *& aEventPathList); - CHIP_ERROR PushFrontEventPathParamsList(ObjectList *& aEventPathList, EventPathParams & aEventPath); + CHIP_ERROR PushFrontEventPathParamsList(SingleLinkedListNode *& aEventPathList, EventPathParams & aEventPath); - void ReleaseDataVersionFilterList(ObjectList *& aDataVersionFilterList); + void ReleaseDataVersionFilterList(SingleLinkedListNode *& aDataVersionFilterList); - CHIP_ERROR PushFrontDataVersionFilterList(ObjectList *& aDataVersionFilterList, + CHIP_ERROR PushFrontDataVersionFilterList(SingleLinkedListNode *& aDataVersionFilterList, DataVersionFilter & aDataVersionFilter); CHIP_ERROR RegisterCommandHandler(CommandHandlerInterface * handler); @@ -576,9 +576,9 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler, static void ResumeSubscriptionsTimerCallback(System::Layer * apSystemLayer, void * apAppState); template - void ReleasePool(ObjectList *& aObjectList, ObjectPool, N> & aObjectPool); + void ReleasePool(SingleLinkedListNode *& aObjectList, ObjectPool, N> & aObjectPool); template - CHIP_ERROR PushFront(ObjectList *& aObjectList, T & aData, ObjectPool, N> & aObjectPool); + CHIP_ERROR PushFront(SingleLinkedListNode *& aObjectList, T & aData, ObjectPool, N> & aObjectPool); Messaging::ExchangeManager * mpExchangeMgr = nullptr; @@ -606,13 +606,13 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler, "CHIP_IM_MAX_NUM_READS is too small to match the requirements of spec 8.5.1"); #endif - ObjectPool, + ObjectPool, CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_READS + CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS> mAttributePathPool; - ObjectPool, + ObjectPool, CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_READS + CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS> mEventPathPool; - ObjectPool, + ObjectPool, CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_READS + CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS> mDataVersionFilterPool; diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index b5fc34484ea8ff..63da2a53aa7470 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -134,7 +134,7 @@ void ReadHandler::OnSubscriptionResumed(const SessionHandle & sessionHandle, MoveToState(HandlerState::CanStartReporting); - ObjectList * attributePath = mpAttributePathList; + SingleLinkedListNode * attributePath = mpAttributePathList; while (attributePath) { mManagementCallback.GetInteractionModelEngine()->GetReportingEngine().SetDirty(attributePath->mValue); diff --git a/src/app/ReadHandler.h b/src/app/ReadHandler.h index 71070c357147df..c597bac8a58d70 100644 --- a/src/app/ReadHandler.h +++ b/src/app/ReadHandler.h @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -45,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -224,9 +224,9 @@ class ReadHandler : public Messaging::ExchangeDelegate ReadHandler(ManagementCallback & apCallback, Observer * observer); #endif - const ObjectList * GetAttributePathList() const { return mpAttributePathList; } - const ObjectList * GetEventPathList() const { return mpEventPathList; } - const ObjectList * GetDataVersionFilterList() const { return mpDataVersionFilterList; } + const SingleLinkedListNode * GetAttributePathList() const { return mpAttributePathList; } + const SingleLinkedListNode * GetEventPathList() const { return mpEventPathList; } + const SingleLinkedListNode * GetDataVersionFilterList() const { return mpDataVersionFilterList; } void GetReportingIntervals(uint16_t & aMinInterval, uint16_t & aMaxInterval) const { @@ -550,9 +550,9 @@ class ReadHandler : public Messaging::ExchangeDelegate Messaging::ExchangeManager * mExchangeMgr = nullptr; #endif // CHIP_CONFIG_UNSAFE_SUBSCRIPTION_EXCHANGE_MANAGER_USE - ObjectList * mpAttributePathList = nullptr; - ObjectList * mpEventPathList = nullptr; - ObjectList * mpDataVersionFilterList = nullptr; + SingleLinkedListNode * mpAttributePathList = nullptr; + SingleLinkedListNode * mpEventPathList = nullptr; + SingleLinkedListNode * mpDataVersionFilterList = nullptr; ManagementCallback & mManagementCallback; diff --git a/src/app/SubscriptionResumptionStorage.h b/src/app/SubscriptionResumptionStorage.h index 316adc3bd3c2e3..19342599f36bbc 100644 --- a/src/app/SubscriptionResumptionStorage.h +++ b/src/app/SubscriptionResumptionStorage.h @@ -78,15 +78,15 @@ class SubscriptionResumptionStorage bool mFabricFiltered; Platform::ScopedMemoryBufferWithSize mAttributePaths; Platform::ScopedMemoryBufferWithSize mEventPaths; - CHIP_ERROR SetAttributePaths(const ObjectList * pAttributePathList) + CHIP_ERROR SetAttributePaths(const SingleLinkedListNode * pAttributePathList) { mAttributePaths.Free(); if (!pAttributePathList) { return CHIP_NO_ERROR; } - const ObjectList * attributePath = pAttributePathList; - size_t attributePathCount = 0; + const SingleLinkedListNode * attributePath = pAttributePathList; + size_t attributePathCount = 0; while (attributePath) { attributePathCount++; @@ -103,15 +103,15 @@ class SubscriptionResumptionStorage } return CHIP_NO_ERROR; } - CHIP_ERROR SetEventPaths(const ObjectList * pEventPathList) + CHIP_ERROR SetEventPaths(const SingleLinkedListNode * pEventPathList) { mEventPaths.Free(); if (!pEventPathList) { return CHIP_NO_ERROR; } - const ObjectList * eventPath = pEventPathList; - size_t eventPathCount = 0; + const SingleLinkedListNode * eventPath = pEventPathList; + size_t eventPathCount = 0; while (eventPath) { eventPathCount++; diff --git a/src/app/clusters/energy-preference-server/energy-preference-server.cpp b/src/app/clusters/energy-preference-server/energy-preference-server.cpp new file mode 100644 index 00000000000000..7cb377a7221ba1 --- /dev/null +++ b/src/app/clusters/energy-preference-server/energy-preference-server.cpp @@ -0,0 +1,235 @@ +/** + * + * Copyright (c) 2024 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "energy-preference-server.h" + +#include // Needed for registerAttributeAccessOverride + +#include +#include +#include +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::EnergyPreference; +using namespace chip::app::Clusters::EnergyPreference::Structs; +using namespace chip::app::Clusters::EnergyPreference::Attributes; + +using Status = Protocols::InteractionModel::Status; + +namespace { + +class EnergyPrefAttrAccess : public AttributeAccessInterface +{ +public: + EnergyPrefAttrAccess() : AttributeAccessInterface(Optional::Missing(), EnergyPreference::Id) {} + + CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; +}; + +EnergyPrefAttrAccess gEnergyPrefAttrAccess; +Delegate * gsDelegate = nullptr; + +CHIP_ERROR EnergyPrefAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) +{ + VerifyOrDie(aPath.mClusterId == EnergyPreference::Id); + EndpointId endpoint = aPath.mEndpointId; + uint32_t ourFeatureMap = 0; + const bool featureMapIsGood = FeatureMap::Get(aPath.mEndpointId, &ourFeatureMap) == Status::Success; + const bool balanceSupported = featureMapIsGood && ((ourFeatureMap & to_underlying(Feature::kEnergyBalance)) != 0); + const bool lowPowerSupported = featureMapIsGood && ((ourFeatureMap & to_underlying(Feature::kLowPowerModeSensitivity)) != 0); + + switch (aPath.mAttributeId) + { + case EnergyBalances::Id: + if (!balanceSupported) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + + if (gsDelegate != nullptr) + { + return aEncoder.EncodeList([endpoint](const auto & encoder) -> CHIP_ERROR { + size_t index = 0; + CHIP_ERROR err = CHIP_NO_ERROR; + do + { + Percent step; + char buffer[64]; + Optional label{ MutableCharSpan(buffer) }; + if ((err = gsDelegate->GetEnergyBalanceAtIndex(endpoint, index, step, label)) == CHIP_NO_ERROR) + { + BalanceStruct::Type balance = { step, + label.HasValue() ? Optional(label.Value()) + : Optional() }; + ReturnErrorOnFailure(encoder.Encode(balance)); + index++; + } + } while (err == CHIP_NO_ERROR); + + if (err == CHIP_ERROR_NOT_FOUND) + { + return CHIP_NO_ERROR; + } + return err; + }); + } + return CHIP_ERROR_INCORRECT_STATE; + case EnergyPriorities::Id: + if (balanceSupported == false) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + + if (gsDelegate != nullptr) + { + return aEncoder.EncodeList([endpoint](const auto & encoder) -> CHIP_ERROR { + EnergyPriorityEnum priority; + size_t index = 0; + CHIP_ERROR err = CHIP_NO_ERROR; + while ((err = gsDelegate->GetEnergyPriorityAtIndex(endpoint, index, priority)) == CHIP_NO_ERROR) + { + ReturnErrorOnFailure(encoder.Encode(priority)); + index++; + } + if (err == CHIP_ERROR_NOT_FOUND) + { + return CHIP_NO_ERROR; + } + return err; + }); + } + return CHIP_ERROR_INCORRECT_STATE; + case LowPowerModeSensitivities::Id: + if (lowPowerSupported == false) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + + if (gsDelegate != nullptr) + { + return aEncoder.EncodeList([endpoint](const auto & encoder) -> CHIP_ERROR { + size_t index = 0; + CHIP_ERROR err = CHIP_NO_ERROR; + do + { + Percent step; + char buffer[64]; + Optional label{ MutableCharSpan(buffer) }; + if ((err = gsDelegate->GetLowPowerModeSensitivityAtIndex(endpoint, index, step, label)) == CHIP_NO_ERROR) + { + BalanceStruct::Type balance = { step, + label.HasValue() ? Optional(label.Value()) + : Optional() }; + ReturnErrorOnFailure(encoder.Encode(balance)); + index++; + } + } while (err == CHIP_NO_ERROR); + if (err == CHIP_ERROR_NOT_FOUND) + { + return CHIP_NO_ERROR; + } + return err; + }); + } + return CHIP_ERROR_INCORRECT_STATE; + default: // return CHIP_NO_ERROR and just read from the attribute store in default + break; + } + + return CHIP_NO_ERROR; +} + +} // anonymous namespace + +namespace chip::app::Clusters::EnergyPreference { + +void SetDelegate(Delegate * aDelegate) +{ + gsDelegate = aDelegate; +} + +Delegate * GetDelegate() +{ + return gsDelegate; +} + +} // namespace chip::app::Clusters::EnergyPreference + +Status MatterEnergyPreferenceClusterServerPreAttributeChangedCallback(const ConcreteAttributePath & attributePath, + EmberAfAttributeType attributeType, uint16_t size, + uint8_t * value) +{ + EndpointId endpoint = attributePath.mEndpointId; + Delegate * delegate = GetDelegate(); + uint32_t ourFeatureMap; + const bool featureMapIsGood = FeatureMap::Get(attributePath.mEndpointId, &ourFeatureMap) == Status::Success; + const bool balanceSupported = featureMapIsGood && ((ourFeatureMap & to_underlying(Feature::kEnergyBalance)) != 0); + const bool lowPowerSupported = featureMapIsGood && ((ourFeatureMap & to_underlying(Feature::kLowPowerModeSensitivity)) != 0); + + if (delegate == nullptr) + { + return Status::UnsupportedWrite; + } + + switch (attributePath.mAttributeId) + { + case CurrentEnergyBalance::Id: { + if (balanceSupported == false) + { + return Status::UnsupportedAttribute; + } + + uint8_t index = Encoding::Get8(value); + size_t arraySize = delegate->GetNumEnergyBalances(endpoint); + if (index >= arraySize) + { + return Status::ConstraintError; + } + + return Status::Success; + } + + case CurrentLowPowerModeSensitivity::Id: { + if (lowPowerSupported == false) + { + return Status::UnsupportedAttribute; + } + + uint8_t index = Encoding::Get8(value); + size_t arraySize = delegate->GetNumLowPowerModeSensitivities(endpoint); + if (index >= arraySize) + { + return Status::ConstraintError; + } + + return Status::Success; + } + default: + return Status::Success; + } +} + +void MatterEnergyPreferencePluginServerInitCallback() +{ + registerAttributeAccessOverride(&gEnergyPrefAttrAccess); +} diff --git a/src/app/clusters/energy-preference-server/energy-preference-server.h b/src/app/clusters/energy-preference-server/energy-preference-server.h new file mode 100644 index 00000000000000..771057847e372a --- /dev/null +++ b/src/app/clusters/energy-preference-server/energy-preference-server.h @@ -0,0 +1,107 @@ +/** + * + * 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 + +#include +#include +#include +#include + +namespace chip::app::Clusters::EnergyPreference { + +struct Delegate +{ + // Note: This delegate does not handle the "Current Active" indexes attributes storage. + // eg: Current Energy Balance and Current Low Power Mode Sensitivity. These can be handled using + // ember built in storage, or via the external callbacks as desired by the implementer. + + virtual ~Delegate() {} + + /** + * Get an Energy Balance. + * + * The delegate method is called by the cluster to fill out the + * values for the list in EnergyBalances attribute. Storage for + * both aOutStep and aOutLabel is provided by the caller. + * + * @param aEndpoint The endpoint to query. + * @param aIndex The index of the balance, with 0 representing the first one. + * @param aOutStep The Step value from BalanceStruct + * + * @param aOutLabel The Label value from BalanceStruct. Storage is + * provided by the caller, and is large enough to accomodate the + * longest label (64 chars), on successful return the size of the span must be + * adjusted to reflect the length of the value, or ClearValue() called on the Optional to indicate there is no label. + * + * @return CHIP_ERROR_NOT_FOUND if the index is out of range. + */ + virtual CHIP_ERROR GetEnergyBalanceAtIndex(chip::EndpointId aEndpoint, size_t aIndex, chip::Percent & aOutStep, + chip::Optional & aOutLabel) = 0; + + /** + * Get an Energy Priority. + * @param aEndpoint The endpoint to query. + * @param aIndex The index of the priority, with 0 representing the first one. + * @param aOutPriority The EnergyPriorityEnum to copy the data into. + * @return CHIP_ERROR_NOT_FOUND if the index is out of range. + */ + virtual CHIP_ERROR GetEnergyPriorityAtIndex(chip::EndpointId aEndpoint, size_t aIndex, + chip::app::Clusters::EnergyPreference::EnergyPriorityEnum & aOutPriority) = 0; + + /** + * Get a Power Sensitity Balance Struct data at the specified index. + * + * The delegate method is called by the cluster to fill out the + * values for the list in LowPowerSensitivities attribute. Storage for + * both aOutStep and aOutLabel is provided by the caller. + * + * @param aEndpoint The endpoint to query. + * @param aIndex The index of the priority, with 0 representing the first one. + * @param aOutStep The Step value from BalanceStruct + * + * @param aOutLabel The Label value from BalanceStruct. Storage is + * provided by the caller, and is large enough to accomodate the + * longest label (64 chars), on successful return the size of the span must be + * adjusted to reflect the length of the value, or ClearValue() called on the Optional to indicate there is no label. + * + * @return CHIP_ERROR_NOT_FOUND if the index is out of range. + */ + virtual CHIP_ERROR GetLowPowerModeSensitivityAtIndex(chip::EndpointId aEndpoint, size_t aIndex, chip::Percent & aOutStep, + chip::Optional & aOutLabel) = 0; + + /** + * Get the number of energy balances this endpoint has. + * @param aEndpoint The endpoint to query. + * @return the number of balance structs in the list. + */ + virtual size_t GetNumEnergyBalances(chip::EndpointId aEndpoint) = 0; + + /** + * Get the number of low power mode sensitivities this endpoint has. + * @param aEndpoint The endpoint to query. + * @return the number of balance structs in the list. + */ + virtual size_t GetNumLowPowerModeSensitivities(chip::EndpointId aEndpoint) = 0; +}; + +void SetDelegate(Delegate * aDelegate); +Delegate * GetDelegate(); + +} // namespace chip::app::Clusters::EnergyPreference diff --git a/src/app/common/BUILD.gn b/src/app/common/BUILD.gn index 193d4c362e537e..1af268a477efaf 100644 --- a/src/app/common/BUILD.gn +++ b/src/app/common/BUILD.gn @@ -27,7 +27,9 @@ static_library("cluster-objects") { ] public_deps = [ + "${chip_root}/src/app:paths", "${chip_root}/src/app/data-model", + "${chip_root}/src/app/util:types", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", "${chip_root}/src/protocols/interaction_model", diff --git a/src/app/common/templates/config-data.yaml b/src/app/common/templates/config-data.yaml index 20677184632c6c..875cdbcdbd1514 100644 --- a/src/app/common/templates/config-data.yaml +++ b/src/app/common/templates/config-data.yaml @@ -84,5 +84,6 @@ ClustersWithPreAttributeChangeFunctions: - Mode Select - Fan Control - Thermostat + - Energy Preference - Laundry Washer Controls - Laundry Dryer Controls diff --git a/src/app/data-model/BUILD.gn b/src/app/data-model/BUILD.gn index 49a49033f0e9f2..9b04882a60ec9c 100644 --- a/src/app/data-model/BUILD.gn +++ b/src/app/data-model/BUILD.gn @@ -37,8 +37,8 @@ source_set("data-model") { # of this, in part due to zap-generated code dependency. # # - app/util/attribute-storage-null-handling.h - # - app/ConcreteAttributePath.h # + "${chip_root}/src/app:paths", "${chip_root}/src/app/common:enums", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", diff --git a/src/app/reporting/Engine.cpp b/src/app/reporting/Engine.cpp index 80dec7ed6d3cd1..2dd730c358fe0a 100644 --- a/src/app/reporting/Engine.cpp +++ b/src/app/reporting/Engine.cpp @@ -58,7 +58,7 @@ void Engine::Shutdown() mGlobalDirtySet.ReleaseAll(); } -bool Engine::IsClusterDataVersionMatch(const ObjectList * aDataVersionFilterList, +bool Engine::IsClusterDataVersionMatch(const SingleLinkedListNode * aDataVersionFilterList, const ConcreteReadAttributePath & aPath) { bool existPathMatch = false; diff --git a/src/app/reporting/Engine.h b/src/app/reporting/Engine.h index 47483d9096bfec..fccf9e08ab020f 100644 --- a/src/app/reporting/Engine.h +++ b/src/app/reporting/Engine.h @@ -179,7 +179,7 @@ class Engine // of those will fail to match. This function should return false if either nothing in the list matches the given // endpoint+cluster in the path or there is an entry in the list that matches the endpoint+cluster in the path but does not // match the current data version of that cluster. - bool IsClusterDataVersionMatch(const ObjectList * aDataVersionFilterList, + bool IsClusterDataVersionMatch(const SingleLinkedListNode * aDataVersionFilterList, const ConcreteReadAttributePath & aPath); /** diff --git a/src/app/server/BUILD.gn b/src/app/server/BUILD.gn index 4d63afda77ad42..7c661464bbaea3 100644 --- a/src/app/server/BUILD.gn +++ b/src/app/server/BUILD.gn @@ -30,6 +30,7 @@ static_library("server") { sources = [ "AclStorage.cpp", "AclStorage.h", + "AppDelegate.h", "CommissioningModeProvider.h", "CommissioningWindowManager.cpp", "CommissioningWindowManager.h", diff --git a/src/app/tests/TestAttributePathExpandIterator.cpp b/src/app/tests/TestAttributePathExpandIterator.cpp index d4da4fc95a2b8c..e5505320193b81 100644 --- a/src/app/tests/TestAttributePathExpandIterator.cpp +++ b/src/app/tests/TestAttributePathExpandIterator.cpp @@ -20,12 +20,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include @@ -41,7 +41,7 @@ using P = app::ConcreteAttributePath; void TestAllWildcard(nlTestSuite * apSuite, void * apContext) { - app::ObjectList clusInfo; + SingleLinkedListNode clusInfo; app::ConcreteAttributePath path; P paths[] = { @@ -144,7 +144,7 @@ void TestAllWildcard(nlTestSuite * apSuite, void * apContext) void TestWildcardEndpoint(nlTestSuite * apSuite, void * apContext) { - app::ObjectList clusInfo; + SingleLinkedListNode clusInfo; clusInfo.mValue.mClusterId = Test::MockClusterId(3); clusInfo.mValue.mAttributeId = Test::MockAttributeId(3); @@ -167,7 +167,7 @@ void TestWildcardEndpoint(nlTestSuite * apSuite, void * apContext) void TestWildcardCluster(nlTestSuite * apSuite, void * apContext) { - app::ObjectList clusInfo; + SingleLinkedListNode clusInfo; clusInfo.mValue.mEndpointId = Test::kMockEndpoint3; clusInfo.mValue.mAttributeId = app::Clusters::Globals::Attributes::ClusterRevision::Id; @@ -193,7 +193,7 @@ void TestWildcardCluster(nlTestSuite * apSuite, void * apContext) void TestWildcardClusterGlobalAttributeNotInMetadata(nlTestSuite * apSuite, void * apContext) { - app::ObjectList clusInfo; + SingleLinkedListNode clusInfo; clusInfo.mValue.mEndpointId = Test::kMockEndpoint3; clusInfo.mValue.mAttributeId = app::Clusters::Globals::Attributes::AttributeList::Id; @@ -219,7 +219,7 @@ void TestWildcardClusterGlobalAttributeNotInMetadata(nlTestSuite * apSuite, void void TestWildcardAttribute(nlTestSuite * apSuite, void * apContext) { - app::ObjectList clusInfo; + SingleLinkedListNode clusInfo; clusInfo.mValue.mEndpointId = Test::kMockEndpoint2; clusInfo.mValue.mClusterId = Test::MockClusterId(3); @@ -252,7 +252,7 @@ void TestWildcardAttribute(nlTestSuite * apSuite, void * apContext) void TestNoWildcard(nlTestSuite * apSuite, void * apContext) { - app::ObjectList clusInfo; + SingleLinkedListNode clusInfo; clusInfo.mValue.mEndpointId = Test::kMockEndpoint2; clusInfo.mValue.mClusterId = Test::MockClusterId(3); clusInfo.mValue.mAttributeId = Test::MockAttributeId(3); @@ -277,21 +277,21 @@ void TestNoWildcard(nlTestSuite * apSuite, void * apContext) void TestMultipleClusInfo(nlTestSuite * apSuite, void * apContext) { - app::ObjectList clusInfo1; + SingleLinkedListNode clusInfo1; - app::ObjectList clusInfo2; + SingleLinkedListNode clusInfo2; clusInfo2.mValue.mClusterId = Test::MockClusterId(3); clusInfo2.mValue.mAttributeId = Test::MockAttributeId(3); - app::ObjectList clusInfo3; + SingleLinkedListNode clusInfo3; clusInfo3.mValue.mEndpointId = Test::kMockEndpoint3; clusInfo3.mValue.mAttributeId = app::Clusters::Globals::Attributes::ClusterRevision::Id; - app::ObjectList clusInfo4; + SingleLinkedListNode clusInfo4; clusInfo4.mValue.mEndpointId = Test::kMockEndpoint2; clusInfo4.mValue.mClusterId = Test::MockClusterId(3); - app::ObjectList clusInfo5; + SingleLinkedListNode clusInfo5; clusInfo5.mValue.mEndpointId = Test::kMockEndpoint2; clusInfo5.mValue.mClusterId = Test::MockClusterId(3); clusInfo5.mValue.mAttributeId = Test::MockAttributeId(3); diff --git a/src/app/tests/TestEventLogging.cpp b/src/app/tests/TestEventLogging.cpp index 08f950517acfde..baf43d6b398707 100644 --- a/src/app/tests/TestEventLogging.cpp +++ b/src/app/tests/TestEventLogging.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -37,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -133,7 +133,7 @@ static void CheckLogState(nlTestSuite * apSuite, chip::app::EventManagement & aL } static void CheckLogReadOut(nlTestSuite * apSuite, chip::app::EventManagement & alogMgmt, chip::EventNumber startingEventNumber, - size_t expectedNumEvents, chip::app::ObjectList * clusterInfo) + size_t expectedNumEvents, chip::SingleLinkedListNode * clusterInfo) { CHIP_ERROR err; chip::TLV::TLVReader reader; @@ -236,7 +236,7 @@ static void CheckLogEventWithEvictToNextBuffer(nlTestSuite * apSuite, void * apC NL_TEST_ASSERT(apSuite, (eid4 + 1) == eid5); NL_TEST_ASSERT(apSuite, (eid5 + 1) == eid6); - chip::app::ObjectList paths[2]; + chip::SingleLinkedListNode paths[2]; paths[0].mValue.mEndpointId = kTestEndpointId1; paths[0].mValue.mClusterId = kLivenessClusterId; @@ -257,7 +257,7 @@ static void CheckLogEventWithEvictToNextBuffer(nlTestSuite * apSuite, void * apC // interested paths are path list, expect to retrieve all events for those interested paths CheckLogReadOut(apSuite, logMgmt, 0, 6, paths); - chip::app::ObjectList pathsWithWildcard[2]; + chip::SingleLinkedListNode pathsWithWildcard[2]; paths[0].mValue.mEndpointId = kTestEndpointId1; paths[0].mValue.mClusterId = kLivenessClusterId; diff --git a/src/app/tests/TestEventLoggingNoUTCTime.cpp b/src/app/tests/TestEventLoggingNoUTCTime.cpp index 43df98a790e2ba..8360f9a0813e98 100644 --- a/src/app/tests/TestEventLoggingNoUTCTime.cpp +++ b/src/app/tests/TestEventLoggingNoUTCTime.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -36,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -177,7 +177,7 @@ static void CheckLogState(nlTestSuite * apSuite, chip::app::EventManagement & aL } static void CheckLogReadOut(nlTestSuite * apSuite, chip::app::EventManagement & alogMgmt, chip::EventNumber startingEventNumber, - size_t expectedNumEvents, chip::app::ObjectList * clusterInfo) + size_t expectedNumEvents, chip::SingleLinkedListNode * clusterInfo) { CHIP_ERROR err; chip::TLV::TLVReader reader; @@ -279,7 +279,7 @@ static void CheckLogEventWithEvictToNextBuffer(nlTestSuite * apSuite, void * apC NL_TEST_ASSERT(apSuite, (eid4 + 1) == eid5); NL_TEST_ASSERT(apSuite, (eid5 + 1) == eid6); - chip::app::ObjectList paths[2]; + chip::SingleLinkedListNode paths[2]; paths[0].mValue.mEndpointId = kTestEndpointId1; paths[0].mValue.mClusterId = kLivenessClusterId; @@ -300,7 +300,7 @@ static void CheckLogEventWithEvictToNextBuffer(nlTestSuite * apSuite, void * apC // interested paths are path list, expect to retrieve all events for those interested paths CheckLogReadOut(apSuite, logMgmt, 0, 6, paths); - chip::app::ObjectList pathsWithWildcard[2]; + chip::SingleLinkedListNode pathsWithWildcard[2]; paths[0].mValue.mEndpointId = kTestEndpointId1; paths[0].mValue.mClusterId = kLivenessClusterId; diff --git a/src/app/tests/TestFabricScopedEventLogging.cpp b/src/app/tests/TestFabricScopedEventLogging.cpp index f55ac63b687491..d016ad5183e1c0 100644 --- a/src/app/tests/TestFabricScopedEventLogging.cpp +++ b/src/app/tests/TestFabricScopedEventLogging.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -37,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -137,7 +137,7 @@ static void CheckLogState(nlTestSuite * apSuite, chip::app::EventManagement & aL } static void CheckLogReadOut(nlTestSuite * apSuite, chip::app::EventManagement & alogMgmt, chip::EventNumber startingEventNumber, - size_t expectedNumEvents, chip::app::ObjectList * clusterInfo, + size_t expectedNumEvents, chip::SingleLinkedListNode * clusterInfo, const chip::Access::SubjectDescriptor & aSubjectDescriptor) { CHIP_ERROR err; @@ -220,7 +220,7 @@ static void CheckLogEventWithEvictToNextBuffer(nlTestSuite * apSuite, void * apC NL_TEST_ASSERT(apSuite, (eid2 + 1) == eid3); NL_TEST_ASSERT(apSuite, (eid3 + 1) == eid4); - chip::app::ObjectList paths[2]; + chip::SingleLinkedListNode paths[2]; paths[0].mValue.mEndpointId = kTestEndpointId1; paths[0].mValue.mClusterId = kLivenessClusterId; @@ -247,7 +247,7 @@ static void CheckLogEventWithEvictToNextBuffer(nlTestSuite * apSuite, void * apC CheckLogReadOut(apSuite, logMgmt, 0, 1, paths, descriptor); // Fabric event + wildcard test, only have one fabric-scoped event with fabric 2 - chip::app::ObjectList pathsWithWildcard[2]; + chip::SingleLinkedListNode pathsWithWildcard[2]; paths[0].mValue.mEndpointId = kTestEndpointId1; paths[0].mValue.mClusterId = kLivenessClusterId; diff --git a/src/app/tests/TestInteractionModelEngine.cpp b/src/app/tests/TestInteractionModelEngine.cpp index f4450635ac0b8f..fcdc7d53e1594f 100644 --- a/src/app/tests/TestInteractionModelEngine.cpp +++ b/src/app/tests/TestInteractionModelEngine.cpp @@ -52,13 +52,13 @@ class TestInteractionModelEngine #if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS && CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION static void TestSubscriptionResumptionTimer(nlTestSuite * apSuite, void * apContext); #endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS && CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION - static int GetAttributePathListLength(ObjectList * apattributePathParamsList); + static int GetAttributePathListLength(SingleLinkedListNode * apattributePathParamsList); }; -int TestInteractionModelEngine::GetAttributePathListLength(ObjectList * apAttributePathParamsList) +int TestInteractionModelEngine::GetAttributePathListLength(SingleLinkedListNode * apAttributePathParamsList) { - int length = 0; - ObjectList * runner = apAttributePathParamsList; + int length = 0; + SingleLinkedListNode * runner = apAttributePathParamsList; while (runner != nullptr) { runner = runner->mpNext; @@ -74,7 +74,7 @@ void TestInteractionModelEngine::TestAttributePathParamsPushRelease(nlTestSuite err = InteractionModelEngine::GetInstance()->Init(&ctx.GetExchangeManager(), &ctx.GetFabricTable(), app::reporting::GetDefaultReportScheduler()); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - ObjectList * attributePathParamsList = nullptr; + SingleLinkedListNode * attributePathParamsList = nullptr; AttributePathParams attributePathParams1; AttributePathParams attributePathParams2; AttributePathParams attributePathParams3; @@ -112,7 +112,7 @@ void TestInteractionModelEngine::TestRemoveDuplicateConcreteAttribute(nlTestSuit err = InteractionModelEngine::GetInstance()->Init(&ctx.GetExchangeManager(), &ctx.GetFabricTable(), app::reporting::GetDefaultReportScheduler()); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - ObjectList * attributePathParamsList = nullptr; + SingleLinkedListNode * attributePathParamsList = nullptr; AttributePathParams attributePathParams1; AttributePathParams attributePathParams2; AttributePathParams attributePathParams3; diff --git a/src/app/tests/suites/DL_UsersAndCredentials.yaml b/src/app/tests/suites/DL_UsersAndCredentials.yaml index 0a344d4883eba6..e86fbbe56dc053 100644 --- a/src/app/tests/suites/DL_UsersAndCredentials.yaml +++ b/src/app/tests/suites/DL_UsersAndCredentials.yaml @@ -562,7 +562,7 @@ tests: - name: "UserUniqueID" value: 0xBABA - name: "UserStatus" - value: 2 + value: UserStatusEnum.UnknownEnumValue(2) - name: "UserType" value: null - name: "CredentialRule" @@ -1031,7 +1031,7 @@ tests: - name: "UserIndex" value: null - name: "UserStatus" - value: 2 + value: UserStatusEnum.UnknownEnumValue(2) - name: "UserType" value: null response: diff --git a/src/app/tests/suites/TestAccessControlConstraints.yaml b/src/app/tests/suites/TestAccessControlConstraints.yaml index 82e66b8d347c10..1a54ea48f92365 100644 --- a/src/app/tests/suites/TestAccessControlConstraints.yaml +++ b/src/app/tests/suites/TestAccessControlConstraints.yaml @@ -130,7 +130,7 @@ tests: { FabricIndex: 0, Privilege: 3, - AuthMode: 4, # INVALID + AuthMode: AccessControlEntryAuthModeEnum.UnknownEnumValue, Subjects: [], Targets: null, }, @@ -231,7 +231,7 @@ tests: }, { FabricIndex: 0, - Privilege: 6, # INVALID + Privilege: AccessControlEntryPrivilegeEnum.UnknownEnumValue, AuthMode: 2, # CASE Subjects: null, Targets: null, diff --git a/src/app/tests/suites/TestCluster.yaml b/src/app/tests/suites/TestCluster.yaml index d51aea86b777f6..017d6ce6b6daf4 100644 --- a/src/app/tests/suites/TestCluster.yaml +++ b/src/app/tests/suites/TestCluster.yaml @@ -1066,7 +1066,7 @@ tests: - name: "arg1" value: 20003 - name: "arg2" - value: 101 + value: SimpleEnum.UnknownEnumValue response: # Attempting to echo back the invalid enum value should fail. error: FAILURE @@ -2814,7 +2814,7 @@ tests: command: "writeAttribute" attribute: "nullable_enum_attr" arguments: - value: 255 + value: SimpleEnum.UnknownEnumValue(255) response: error: CONSTRAINT_ERROR diff --git a/src/app/tests/suites/TestDiagnosticLogs.yaml b/src/app/tests/suites/TestDiagnosticLogs.yaml index 57ab8cb0fa04f8..2e512d962678c3 100644 --- a/src/app/tests/suites/TestDiagnosticLogs.yaml +++ b/src/app/tests/suites/TestDiagnosticLogs.yaml @@ -443,7 +443,7 @@ tests: arguments: values: - name: "Intent" - value: 128 # undefined value + value: IntentEnum.UnknownEnumValue(128) - name: "RequestedProtocol" value: 0 # ResponsePayload response: @@ -456,7 +456,7 @@ tests: - name: "Intent" value: 0 # EndUserSupport - name: "RequestedProtocol" - value: 128 # undefined value + value: TransferProtocolEnum.UnknownEnumValue(128) response: error: "INVALID_COMMAND" diff --git a/src/app/tests/suites/certification/Test_TC_ACL_2_4.yaml b/src/app/tests/suites/certification/Test_TC_ACL_2_4.yaml index bd173e7eb81427..12a6829c642048 100644 --- a/src/app/tests/suites/certification/Test_TC_ACL_2_4.yaml +++ b/src/app/tests/suites/certification/Test_TC_ACL_2_4.yaml @@ -1164,7 +1164,7 @@ tests: FabricIndex: CurrentFabricIndexValue, }, { - Privilege: 6, + Privilege: AccessControlEntryPrivilegeEnum.UnknownEnumValue, AuthMode: 2, Subjects: null, Targets: null, @@ -1192,7 +1192,7 @@ tests: }, { Privilege: 3, - AuthMode: 4, + AuthMode: AccessControlEntryAuthModeEnum.UnknownEnumValue, Subjects: null, Targets: null, FabricIndex: CurrentFabricIndexValue, diff --git a/src/app/tests/suites/certification/Test_TC_ACL_2_9.yaml b/src/app/tests/suites/certification/Test_TC_ACL_2_9.yaml index 22ce1c1451f5a4..d2db93f33b1cd8 100644 --- a/src/app/tests/suites/certification/Test_TC_ACL_2_9.yaml +++ b/src/app/tests/suites/certification/Test_TC_ACL_2_9.yaml @@ -66,8 +66,8 @@ tests: value: [ { - Privilege: "4", - AuthMode: "2", + Privilege: AccessControlEntryPrivilegeEnum.Manage, + AuthMode: AccessControlEntryAuthModeEnum.CASE, Subjects: [CommissionerNodeId], Targets: null, FabricIndex: CurrentFabricIndexValue, @@ -94,8 +94,8 @@ tests: value: [ { - Privilege: "5", - AuthMode: "2", + Privilege: AccessControlEntryPrivilegeEnum.Administer, + AuthMode: AccessControlEntryAuthModeEnum.CASE, Subjects: [CommissionerNodeId], Targets: null, FabricIndex: CurrentFabricIndexValue, diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml index 9f2e34ea6d01ed..0c10f9fa7ba058 100644 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml +++ b/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml @@ -167,7 +167,7 @@ tests: - name: "UserIndex" value: null - name: "UserStatus" - value: 5 + value: UserStatusEnum.UnknownEnumValue(5) - name: "UserType" value: 10 response: diff --git a/src/app/tests/suites/certification/Test_TC_ILL_2_1.yaml b/src/app/tests/suites/certification/Test_TC_ILL_2_1.yaml index 6afdb920658f94..741fc878e8880f 100644 --- a/src/app/tests/suites/certification/Test_TC_ILL_2_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_ILL_2_1.yaml @@ -86,4 +86,4 @@ tests: constraints: type: enum8 minValue: 0 - maxValue: 254 + maxValue: LightSensorTypeEnum.UnknownEnumValue(254) diff --git a/src/app/tests/suites/certification/Test_TC_I_2_3.yaml b/src/app/tests/suites/certification/Test_TC_I_2_3.yaml index 379ed424638c9b..343539ce69e624 100644 --- a/src/app/tests/suites/certification/Test_TC_I_2_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_I_2_3.yaml @@ -237,7 +237,7 @@ tests: - name: "EffectIdentifier" value: 0 - name: "EffectVariant" - value: 66 + value: EffectVariantEnum.UnknownEnumValue(66) - label: "Check DUT executes a blink effect." cluster: "LogCommands" diff --git a/src/app/tests/suites/certification/Test_TC_LTIME_3_1.yaml b/src/app/tests/suites/certification/Test_TC_LTIME_3_1.yaml index ead4e9b246c853..b011a94ce9cef7 100644 --- a/src/app/tests/suites/certification/Test_TC_LTIME_3_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_LTIME_3_1.yaml @@ -352,7 +352,7 @@ tests: command: "writeAttribute" attribute: "ActiveCalendarType" arguments: - value: 50 + value: CalendarTypeEnum.UnknownEnumValue(50) response: error: CONSTRAINT_ERROR @@ -361,6 +361,6 @@ tests: command: "writeAttribute" attribute: "HourFormat" arguments: - value: 5 + value: HourFormatEnum.UnknownEnumValue(5) response: error: CONSTRAINT_ERROR diff --git a/src/app/tests/suites/certification/Test_TC_LUNIT_3_1.yaml b/src/app/tests/suites/certification/Test_TC_LUNIT_3_1.yaml index a572f7e143dc43..b67c22a871ced9 100644 --- a/src/app/tests/suites/certification/Test_TC_LUNIT_3_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_LUNIT_3_1.yaml @@ -94,6 +94,6 @@ tests: arguments: # Per spec, if [TEMP] feature is enabled, then this attribute can be # one of 0 (Farenheit), 1 (Celsius) or 2 (Kelvin) - value: 5 # INVALID + value: TempUnitEnum.UnknownEnumValue(5) response: error: CONSTRAINT_ERROR diff --git a/src/app/tests/suites/certification/Test_TC_TSTAT_2_1.yaml b/src/app/tests/suites/certification/Test_TC_TSTAT_2_1.yaml index 63aba52fe3f3f6..faf34fdea43e92 100644 --- a/src/app/tests/suites/certification/Test_TC_TSTAT_2_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_TSTAT_2_1.yaml @@ -468,8 +468,12 @@ tests: response: constraints: type: enum8 - minValue: 0 - maxValue: 9 + anyOf: + [ + ThermostatRunningModeEnum.Off(0), + ThermostatRunningModeEnum.Cool(3), + ThermostatRunningModeEnum.Heat(4), + ] - label: "Step 27: TH reads the StartOfWeek attribute from the DUT" PICS: TSTAT.S.F03 diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index f200ad302931ff..021f52e6547ec8 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -2477,97 +2477,132 @@ REFALM.S.E00=1 REFALM.S.C00.Rsp=1 REFALM.S.C01.Rsp=1 -# RVC CLEAN MODE CLUSTER - +# PICS for the RVC app +# These are required to be here because currently there isn't a way to select a different PICS +# file when running the yaml tests in CI RVCCLEANM.S=1 - -#Server RVCCLEANM.S.A0000=1 RVCCLEANM.S.A0001=1 - -#Feature -RVCCLEANM.S.F00=0 - -#commands RVCCLEANM.S.C00.Rsp=1 RVCCLEANM.S.C01.Tx=1 - +RVCCLEANM.S.F00=0 RVCCLEANM.S.M.CAN_TEST_MODE_FAILURE=1 -#PIXIT -PIXIT.RVCCLEANM.MODE_CHANGE_FAIL=1 -PIXIT.RVCCLEANM.MODE_CHANGE_OK=1 - -# RVC OPERATIONAL STATE CLUSTER 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=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=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 -RVCOPSTATE.S.E01=1 - -#Server RVCOPSTATE.S.A0000=1 RVCOPSTATE.S.A0001=1 -RVCOPSTATE.S.A0002=1 +RVCOPSTATE.S.A0002=0 RVCOPSTATE.S.A0003=1 RVCOPSTATE.S.A0004=1 RVCOPSTATE.S.A0005=1 - -#Commands +RVCOPSTATE.S.E00=1 +RVCOPSTATE.S.E01=1 RVCOPSTATE.S.C00.Rsp=1 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 -RVCOPSTATE.C.C04.Tx=1 - +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.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.C=0 +RVCOPSTATE.C.C00.Tx=0 +RVCOPSTATE.C.C01.Tx=0 +RVCOPSTATE.C.C02.Tx=0 +RVCOPSTATE.C.C04.Tx=0 -# RVC RUN MODE CLUSTER RVCRUNM.S=1 -RVCRUNM.S.F00=0 - -#Server RVCRUNM.S.A0000=1 RVCRUNM.S.A0001=1 - -#Commands RVCRUNM.S.C00.Rsp=1 RVCRUNM.S.C01.Tx=1 - +RVCRUNM.S.F00=0 RVCRUNM.S.M.CAN_TEST_MODE_FAILURE=1 RVCRUNM.S.M.CAN_MANUALLY_CONTROLLED=1 -#PIXIT -PIXIT.RVCRUNM.MODE_CHANGE_FAIL=1 -PIXIT.RVCRUNM.MODE_CHANGE_OK=1 +# These are useless as these values are set where the python tests are run. +# They are only here because a list test wants then to be. +PIXIT.RVCCLEANM.MODE_CHANGE_FAIL=0 +PIXIT.RVCCLEANM.MODE_CHANGE_OK=0 +PIXIT.RVCRUNM.MODE_CHANGE_FAIL=0 +PIXIT.RVCRUNM.MODE_CHANGE_OK=0 + +# These are the RVC PICS for the all-clustrs-app. +# These PICS are commented out because the yaml tests are being run against the rvc-app. +# RVCCLEANM.S=1 +# RVCCLEANM.S.A0000=1 +# RVCCLEANM.S.A0001=1 +# RVCCLEANM.S.F00=0 +# RVCCLEANM.S.C00.Rsp=1 +# RVCCLEANM.S.C01.Tx=1 +# RVCCLEANM.S.M.CAN_TEST_MODE_FAILURE=1 + +# RVCOPSTATE.S=1 +# RVCOPSTATE.C=1 +# RVCOPSTATE.S.M.ST_STOPPED=1 +# RVCOPSTATE.S.M.ST_RUNNING=1 +# RVCOPSTATE.S.M.ST_PAUSED=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=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 +# RVCOPSTATE.S.E00=1 +# RVCOPSTATE.S.E01=1 +# RVCOPSTATE.S.A0000=1 +# RVCOPSTATE.S.A0001=1 +# RVCOPSTATE.S.A0002=1 +# RVCOPSTATE.S.A0003=1 +# RVCOPSTATE.S.A0004=1 +# RVCOPSTATE.S.A0005=1 +# RVCOPSTATE.S.C00.Rsp=1 +# 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 +# RVCOPSTATE.C.C04.Tx=1 + +# RVCRUNM.S=1 +# RVCRUNM.S.F00=0 +# RVCRUNM.S.A0000=1 +# RVCRUNM.S.A0001=1 +# RVCRUNM.S.C00.Rsp=1 +# RVCRUNM.S.C01.Tx=1 +# RVCRUNM.S.M.CAN_TEST_MODE_FAILURE=1 +# RVCRUNM.S.M.CAN_MANUALLY_CONTROLLED=1 + #Refrigerator and Temperature Controlled Cabinet Mode Cluster(TCCM) diff --git a/src/app/util/BUILD.gn b/src/app/util/BUILD.gn index 31d6b9e881956a..821ba51a9badcc 100644 --- a/src/app/util/BUILD.gn +++ b/src/app/util/BUILD.gn @@ -14,3 +14,11 @@ import("//build_overrides/chip.gni") import("${chip_root}/src/app/common_flags.gni") + +source_set("types") { + sources = [ + "attribute-metadata.h", + "basic-types.h", + "types_stub.h", + ] +} diff --git a/src/app/util/mock/BUILD.gn b/src/app/util/mock/BUILD.gn index 5918318107fd35..be56bc69032844 100644 --- a/src/app/util/mock/BUILD.gn +++ b/src/app/util/mock/BUILD.gn @@ -20,7 +20,10 @@ config("mock_include") { source_set("mock_ember") { sources = [ + "Constants.h", + "Functions.h", "MockNodeConfig.cpp", + "MockNodeConfig.h", "attribute-storage.cpp", ] diff --git a/src/app/zap-templates/zcl/data-model/chip/energy-preference-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/energy-preference-cluster.xml index ceff9846978e63..32893bd82a68e9 100644 --- a/src/app/zap-templates/zcl/data-model/chip/energy-preference-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/energy-preference-cluster.xml @@ -22,6 +22,7 @@ limitations under the License. true This cluster provides an interface to specify preferences for how devices should consume energy. + EnergyBalances diff --git a/src/app/zap_cluster_list.json b/src/app/zap_cluster_list.json index 56adf0a1126f95..2edfb272ad23e1 100644 --- a/src/app/zap_cluster_list.json +++ b/src/app/zap_cluster_list.json @@ -192,7 +192,7 @@ "ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER": [ "ethernet-network-diagnostics-server" ], - "ENERGY_PREFERENCE_CLUSTER": [""], + "ENERGY_PREFERENCE_CLUSTER": ["energy-preference-server"], "FAN_CONTROL_CLUSTER": ["fan-control-server"], "FAULT_INJECTION_CLUSTER": ["fault-injection-server"], "FIXED_LABEL_CLUSTER": ["fixed-label-server"], diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 89864630b8e85e..235366f4206e78 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -4978,7 +4978,7 @@ provisional cluster EnergyEvse = 153 { /** This cluster provides an interface to specify preferences for how devices should consume energy. */ provisional cluster EnergyPreference = 155 { - revision 1; // NOTE: Default/not specifically set + revision 1; enum EnergyPriorityEnum : enum8 { kComfort = 0; diff --git a/src/controller/java/AndroidCallbacks.cpp b/src/controller/java/AndroidCallbacks.cpp index eb1584b531e292..01ef820f82c6ed 100644 --- a/src/controller/java/AndroidCallbacks.cpp +++ b/src/controller/java/AndroidCallbacks.cpp @@ -138,7 +138,6 @@ jobject GetNodeStateObj(JNIEnv * env, const char * nodeStateClassSignature, jobj JniReferences::GetInstance().FindMethod(env, wrapperCallback, "getNodeState", nodeStateClassSignature, &getNodeStateMethod); VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, ChipLogError(Controller, "Could not find getNodeState method")); - DeviceLayer::StackUnlock unlock; jobject ret = env->CallObjectMethod(wrapperCallback, getNodeStateMethod); VerifyOrReturnValue(!env->ExceptionCheck(), nullptr, env->ExceptionDescribe()); @@ -270,6 +269,7 @@ CHIP_ERROR ConvertReportTlvToJson(const uint32_t id, TLV::TLVReader & data, std: void ReportCallback::OnAttributeData(const app::ConcreteDataAttributePath & aPath, TLV::TLVReader * apData, const app::StatusIB & aStatus) { + DeviceLayer::StackUnlock unlock; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); @@ -408,6 +408,7 @@ void ReportCallback::UpdateClusterDataVersion() void ReportCallback::OnEventData(const app::EventHeader & aEventHeader, TLV::TLVReader * apData, const app::StatusIB * apStatus) { + DeviceLayer::StackUnlock unlock; CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); @@ -642,7 +643,6 @@ void ReportCallback::ReportError(const app::ConcreteAttributePath * attributePat eventClusterId = static_cast(eventPath->mClusterId); eventId = static_cast(eventPath->mEventId); } - env->CallVoidMethod(wrapperCallback, onErrorMethod, isAttributePath, attributeEndpointId, attributeClusterId, attributeId, isEventPath, eventEndpointId, eventClusterId, eventId, exception); VerifyOrReturn(!env->ExceptionCheck(), env->ExceptionDescribe()); diff --git a/src/include/platform/ThreadStackManager.h b/src/include/platform/ThreadStackManager.h index 86d895ec1cfe52..cda3c7acdccbd5 100644 --- a/src/include/platform/ThreadStackManager.h +++ b/src/include/platform/ThreadStackManager.h @@ -121,6 +121,26 @@ class ThreadStackManager CHIP_ERROR RemoveSrpService(const char * aInstanceName, const char * aName); CHIP_ERROR InvalidateAllSrpServices(); ///< Mark all SRP services as invalid CHIP_ERROR RemoveInvalidSrpServices(); ///< Remove SRP services marked as invalid + + /* + * @brief Utility function to clear all thread SRP host and services established between the SRP server and client. + * It is expected that a transaction is done between the SRP server and client so the clear request is applied on both ends + * + * A generic implementation is provided in `GenericThreadStackManagerImpl_OpenThread` with the SoC OT stack + */ + CHIP_ERROR ClearAllSrpHostAndServices(); + + /* + * @brief Used to synchronize on the SRP server response confirming the clearing of the host and service entries + * Should be called in ClearAllSrpHostAndServices once the request is sent. + */ + void WaitOnSrpClearAllComplete(); + + /* + * @brief Notify that the SRP server confirmed the clearing of the host and service entries + * Should be called in the SRP Client set callback in the removal confirmation. + */ + void NotifySrpClearAllComplete(); CHIP_ERROR SetupSrpHost(const char * aHostName); CHIP_ERROR ClearSrpHost(const char * aHostName); CHIP_ERROR SetSrpDnsCallbacks(DnsAsyncReturnCallback aInitCallback, DnsAsyncReturnCallback aErrorCallback, void * aContext); @@ -289,6 +309,21 @@ inline CHIP_ERROR ThreadStackManager::RemoveInvalidSrpServices() return static_cast(this)->_RemoveInvalidSrpServices(); } +inline CHIP_ERROR ThreadStackManager::ClearAllSrpHostAndServices() +{ + return static_cast(this)->_ClearAllSrpHostAndServices(); +} + +inline void ThreadStackManager::WaitOnSrpClearAllComplete() +{ + return static_cast(this)->_WaitOnSrpClearAllComplete(); +} + +inline void ThreadStackManager::NotifySrpClearAllComplete() +{ + return static_cast(this)->_NotifySrpClearAllComplete(); +} + inline CHIP_ERROR ThreadStackManager::SetupSrpHost(const char * aHostName) { return static_cast(this)->_SetupSrpHost(aHostName); diff --git a/src/lib/dnssd/Discovery_ImplPlatform.cpp b/src/lib/dnssd/Discovery_ImplPlatform.cpp index abbc4647ff3805..3369f8c00b3b3b 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.cpp +++ b/src/lib/dnssd/Discovery_ImplPlatform.cpp @@ -420,8 +420,13 @@ void DiscoveryImplPlatform::HandleDnssdInit(void * context, CHIP_ERROR initError void DiscoveryImplPlatform::HandleDnssdError(void * context, CHIP_ERROR error) { + DiscoveryImplPlatform * publisher = static_cast(context); + if (error == CHIP_ERROR_FORCED_RESET) { + // Restore dnssd state before restart, also needs to call ChipDnssdShutdown() + publisher->Shutdown(); + DeviceLayer::ChipDeviceEvent event; event.Type = DeviceLayer::DeviceEventType::kDnssdRestartNeeded; error = DeviceLayer::PlatformMgr().PostEvent(&event); diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index 2342b26ae66d70..02ca1eef593def 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -212,6 +212,7 @@ static_library("support") { "Iterators.h", "LambdaBridge.h", "LifetimePersistedCounter.h", + "LinkedList.h", "ObjectLifeCycle.h", "OwnerOf.h", "PersistedCounter.h", diff --git a/src/app/ObjectList.h b/src/lib/support/LinkedList.h similarity index 90% rename from src/app/ObjectList.h rename to src/lib/support/LinkedList.h index 416db0bb70a6b5..d830c2b3a23351 100644 --- a/src/app/ObjectList.h +++ b/src/lib/support/LinkedList.h @@ -22,13 +22,13 @@ #include namespace chip { -namespace app { +/// A very basic single-linked list template -struct ObjectList +struct SingleLinkedListNode { T mValue; - ObjectList * mpNext = nullptr; + SingleLinkedListNode * mpNext = nullptr; size_t Count() const { @@ -41,5 +41,4 @@ struct ObjectList } }; -} // namespace app } // namespace chip diff --git a/src/platform/ESP32/ThreadStackManagerImpl.cpp b/src/platform/ESP32/ThreadStackManagerImpl.cpp index eed07af6d68af1..0449607999668b 100644 --- a/src/platform/ESP32/ThreadStackManagerImpl.cpp +++ b/src/platform/ESP32/ThreadStackManagerImpl.cpp @@ -77,6 +77,30 @@ void ThreadStackManagerImpl::_UnlockThreadStack() esp_openthread_lock_release(); } +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT +void ThreadStackManagerImpl::_WaitOnSrpClearAllComplete() +{ + // Only 1 task can be blocked on a srpClearAll request + if (mSrpClearAllRequester == nullptr) + { + mSrpClearAllRequester = xTaskGetCurrentTaskHandle(); + // Wait on OnSrpClientNotification which confirms the clearing is done. + // It will notify this current task with NotifySrpClearAllComplete. + // However, we won't wait more than 2s. + ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(2000)); + mSrpClearAllRequester = nullptr; + } +} + +void ThreadStackManagerImpl::_NotifySrpClearAllComplete() +{ + if (mSrpClearAllRequester) + { + xTaskNotifyGive(mSrpClearAllRequester); + } +} +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + void ThreadStackManagerImpl::_ProcessThreadActivity() { // Intentionally empty. diff --git a/src/platform/ESP32/ThreadStackManagerImpl.h b/src/platform/ESP32/ThreadStackManagerImpl.h index 46795d658d6535..1287e7a5f3a1ba 100644 --- a/src/platform/ESP32/ThreadStackManagerImpl.h +++ b/src/platform/ESP32/ThreadStackManagerImpl.h @@ -68,10 +68,21 @@ class ThreadStackManagerImpl final : public ThreadStackManager, void _OnCHIPoBLEAdvertisingStart(); void _OnCHIPoBLEAdvertisingStop(); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + void _WaitOnSrpClearAllComplete(); + void _NotifySrpClearAllComplete(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + // ===== Methods that override the GenericThreadStackMa + private: friend ThreadStackManager & ::chip::DeviceLayer::ThreadStackMgr(void); friend ThreadStackManagerImpl & ::chip::DeviceLayer::ThreadStackMgrImpl(void); static ThreadStackManagerImpl sInstance; + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + TaskHandle_t mSrpClearAllRequester = nullptr; +#endif + ThreadStackManagerImpl() = default; }; diff --git a/src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.h b/src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.h index 870fcf2ed80657..059b701f6bda05 100644 --- a/src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.h +++ b/src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.h @@ -64,6 +64,10 @@ class GenericThreadStackManagerImpl_FreeRTOS bool _TryLockThreadStack(void); void _UnlockThreadStack(void); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + void _WaitOnSrpClearAllComplete(); + void _NotifySrpClearAllComplete(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT // ===== Members available to the implementation subclass. SemaphoreHandle_t mThreadStackLock; @@ -88,6 +92,10 @@ class GenericThreadStackManagerImpl_FreeRTOS #if defined(CHIP_CONFIG_FREERTOS_USE_STATIC_SEMAPHORE) && CHIP_CONFIG_FREERTOS_USE_STATIC_SEMAPHORE StaticSemaphore_t mThreadStackLockMutex; #endif + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + TaskHandle_t mSrpClearAllRequester = nullptr; +#endif }; // Instruct the compiler to instantiate the template only when explicitly told to do so. diff --git a/src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.hpp b/src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.hpp index 4dbee81b23af01..9008258989375e 100644 --- a/src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.hpp +++ b/src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.hpp @@ -101,6 +101,32 @@ void GenericThreadStackManagerImpl_FreeRTOS::_UnlockThreadStack(void) xSemaphoreGive(mThreadStackLock); } +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT +template +void GenericThreadStackManagerImpl_FreeRTOS::_WaitOnSrpClearAllComplete() +{ + // Only 1 task can be blocked on a srpClearAll request + if (mSrpClearAllRequester == nullptr) + { + mSrpClearAllRequester = xTaskGetCurrentTaskHandle(); + // Wait on OnSrpClientNotification which confirms the slearing is done. + // It will notify this current task with NotifySrpClearAllComplete. + // However, we won't wait more than 2s. + ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(2000)); + mSrpClearAllRequester = nullptr; + } +} + +template +void GenericThreadStackManagerImpl_FreeRTOS::_NotifySrpClearAllComplete() +{ + if (mSrpClearAllRequester) + { + xTaskNotifyGive(mSrpClearAllRequester); + } +} +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + template void GenericThreadStackManagerImpl_FreeRTOS::SignalThreadActivityPending() { diff --git a/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.cpp b/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.cpp index f0393a795ef63a..21297d75cf5252 100644 --- a/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.cpp +++ b/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.cpp @@ -54,6 +54,14 @@ CHIP_ERROR ThreadStackManagerImpl::_InitThreadStack() VerifyOrExit(result == WICED_SUCCESS, err = CHIP_ERROR_INTERNAL); otSysInit(0, NULL); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + mSrpClearAllSemaphore = wiced_rtos_create_mutex(); + VerifyOrExit(mSrpClearAllSemaphore != nullptr, err = CHIP_ERROR_NO_MEMORY); + + result = wiced_rtos_init_mutex(mSrpClearAllSemaphore); + VerifyOrExit(result == WICED_SUCCESS, err = CHIP_ERROR_INTERNAL); +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + err = GenericThreadStackManagerImpl_OpenThread::DoInit(NULL); exit: @@ -95,6 +103,21 @@ void ThreadStackManagerImpl::_UnlockThreadStack() VerifyOrReturn(result == WICED_SUCCESS || result == WICED_NOT_OWNED, ChipLogError(DeviceLayer, "%s %x", __func__, result)); } +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT +void ThreadStackManagerImpl::_WaitOnSrpClearAllComplete() +{ + const wiced_result_t result = wiced_rtos_lock_mutex(mSrpClearAllSemaphore); + VerifyOrReturn(result == WICED_SUCCESS, ChipLogError(DeviceLayer, "%s %x", __func__, result)); +} + +void ThreadStackManagerImpl::_NotifySrpClearAllComplete() +{ + const wiced_result_t result = wiced_rtos_unlock_mutex(mSrpClearAllSemaphore); + VerifyOrReturn(result == WICED_SUCCESS || result == WICED_NOT_OWNED, ChipLogError(DeviceLayer, "%s %x", __func__, result)); +} +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT +// ===== Methods that override the GenericThreadStackMa + void ThreadStackManagerImpl::ThreadTaskMain(void) { while (true) diff --git a/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.h b/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.h index cdb2cb8ee65fdc..5cd3fef1c60239 100644 --- a/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.h +++ b/src/platform/Infineon/CYW30739/ThreadStackManagerImpl.h @@ -58,6 +58,11 @@ class ThreadStackManagerImpl final : public ThreadStackManager, bool _TryLockThreadStack(); void _UnlockThreadStack(); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + void _WaitOnSrpClearAllComplete(); + void _NotifySrpClearAllComplete(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + // ===== Methods that override the GenericThreadStackMa private: // ===== Members for internal use by the following friends. @@ -67,6 +72,9 @@ class ThreadStackManagerImpl final : public ThreadStackManager, wiced_thread_t * mThread; EventFlags mEventFlags; wiced_mutex_t * mMutex; +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + wiced_mutex_t * mSrpClearAllSemaphore; +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT static ThreadStackManagerImpl sInstance; // ===== Private members for use by this class only. diff --git a/src/platform/Linux/ThreadStackManagerImpl.h b/src/platform/Linux/ThreadStackManagerImpl.h index 977c6b94d0027f..e262837dd84c76 100755 --- a/src/platform/Linux/ThreadStackManagerImpl.h +++ b/src/platform/Linux/ThreadStackManagerImpl.h @@ -57,6 +57,11 @@ class ThreadStackManagerImpl : public ThreadStackManager bool _TryLockThreadStack() { return false; } // Intentionally left blank void _UnlockThreadStack() {} // Intentionally left blank +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + void _WaitOnSrpClearAllComplete() {} + void _NotifySrpClearAllComplete() {} +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + bool _HaveRouteToAddress(const Inet::IPAddress & destAddr); void _OnPlatformEvent(const ChipDeviceEvent * event); diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h index 161c2b202a8310..8ce0805182dcaa 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h @@ -121,6 +121,7 @@ class GenericThreadStackManagerImpl_OpenThread CHIP_ERROR _RemoveSrpService(const char * aInstanceName, const char * aName); CHIP_ERROR _InvalidateAllSrpServices(); CHIP_ERROR _RemoveInvalidSrpServices(); + CHIP_ERROR _ClearAllSrpHostAndServices(); CHIP_ERROR _SetupSrpHost(const char * aHostName); CHIP_ERROR _ClearSrpHost(const char * aHostName); @@ -203,6 +204,8 @@ class GenericThreadStackManagerImpl_OpenThread SrpClient mSrpClient; + bool mIsSrpClearAllRequested = false; + static void OnSrpClientNotification(otError aError, const otSrpClientHostInfo * aHostInfo, const otSrpClientService * aServices, const otSrpClientService * aRemovedServices, void * aContext); static void OnSrpClientStateChange(const otSockAddr * aServerSockAddr, void * aContext); diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp index acc0c78d0c8eb7..21c44dd00279e3 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp @@ -1307,6 +1307,12 @@ void GenericThreadStackManagerImpl_OpenThread::OnSrpClientNotificatio ThreadStackMgrImpl().mSrpClient.mIsInitialized = true; ThreadStackMgrImpl().mSrpClient.mInitializedCallback(ThreadStackMgrImpl().mSrpClient.mCallbackContext, CHIP_NO_ERROR); + + if (ThreadStackMgrImpl().mIsSrpClearAllRequested) + { + ThreadStackMgrImpl().NotifySrpClearAllComplete(); + ThreadStackMgrImpl().mIsSrpClearAllRequested = false; + } } } @@ -1618,6 +1624,35 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_RemoveInvalidSr return error; } +/* + * @brief This is a utility function to remove all Thread client srp host and services + * established between the device and the srp server (in most cases the OTBR). + * The calling task is blocked until OnSrpClientNotification which confims the client received the request. + * The blocking mechanism is defined by the platform implementation of `WaitOnSrpClearAllComplete` and `NotifySrpClearAllComplete` + * + * Note: This function is meant to be used during the factory reset sequence. + * + */ +template +CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_ClearAllSrpHostAndServices() +{ + CHIP_ERROR error = CHIP_NO_ERROR; + Impl()->LockThreadStack(); + if (!mIsSrpClearAllRequested) + { + error = + MapOpenThreadError(otSrpClientRemoveHostAndServices(mOTInst, true /*aRemoveKeyLease*/, true /*aSendUnregToServer*/)); + mIsSrpClearAllRequested = true; + Impl()->UnlockThreadStack(); + Impl()->WaitOnSrpClearAllComplete(); + } + else + { + Impl()->UnlockThreadStack(); + } + return error; +} + template CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_SetupSrpHost(const char * aHostName) { diff --git a/src/platform/Tizen/ThreadStackManagerImpl.cpp b/src/platform/Tizen/ThreadStackManagerImpl.cpp index 47a4548507e332..e6252d92926190 100644 --- a/src/platform/Tizen/ThreadStackManagerImpl.cpp +++ b/src/platform/Tizen/ThreadStackManagerImpl.cpp @@ -646,6 +646,16 @@ CHIP_ERROR ThreadStackManagerImpl::_RemoveInvalidSrpServices() return CHIP_NO_ERROR; } +CHIP_ERROR ThreadStackManagerImpl::_ClearAllSrpHostAndServices() +{ + for (auto it = mSrpClientServices.begin(); it != mSrpClientServices.end();) + { + ReturnErrorOnFailure(_RemoveSrpService(it->mInstanceName, it->mName)); + it = mSrpClientServices.erase(it); + } + return CHIP_NO_ERROR; +} + void ThreadStackManagerImpl::_ThreadIpAddressCb(int index, char * ipAddr, thread_ipaddr_type_e ipAddrType, void * userData) { VerifyOrReturn(ipAddr != nullptr, ChipLogError(DeviceLayer, "FAIL: Invalid argument: Thread ipAddr not found")); diff --git a/src/platform/Tizen/ThreadStackManagerImpl.h b/src/platform/Tizen/ThreadStackManagerImpl.h index 05b300f574114b..07092f43b320eb 100644 --- a/src/platform/Tizen/ThreadStackManagerImpl.h +++ b/src/platform/Tizen/ThreadStackManagerImpl.h @@ -57,6 +57,11 @@ class ThreadStackManagerImpl : public ThreadStackManager bool _TryLockThreadStack() { return false; } // Intentionally left blank void _UnlockThreadStack() {} // Intentionally left blank +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + void _WaitOnSrpClearAllComplete() {} + void _NotifySrpClearAllComplete() {} +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + bool _HaveRouteToAddress(const Inet::IPAddress & destAddr); void _OnPlatformEvent(const ChipDeviceEvent * event); @@ -115,6 +120,7 @@ class ThreadStackManagerImpl : public ThreadStackManager CHIP_ERROR _RemoveSrpService(const char * aInstanceName, const char * aName); CHIP_ERROR _InvalidateAllSrpServices(); CHIP_ERROR _RemoveInvalidSrpServices(); + CHIP_ERROR _ClearAllSrpHostAndServices(); CHIP_ERROR _SetupSrpHost(const char * aHostName); CHIP_ERROR _ClearSrpHost(const char * aHostName); CHIP_ERROR _SetSrpDnsCallbacks(DnsAsyncReturnCallback aInitCallback, DnsAsyncReturnCallback aErrorCallback, void * aContext); diff --git a/src/platform/Zephyr/ThreadStackManagerImpl.cpp b/src/platform/Zephyr/ThreadStackManagerImpl.cpp index 3cfcfe3b7888b2..95bdfc8ea7044a 100644 --- a/src/platform/Zephyr/ThreadStackManagerImpl.cpp +++ b/src/platform/Zephyr/ThreadStackManagerImpl.cpp @@ -66,6 +66,10 @@ CHIP_ERROR ThreadStackManagerImpl::_InitThreadStack() return MapOpenThreadError(otError); }); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + k_sem_init(&mSrpClearAllSemaphore, 0, 1); +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + return CHIP_NO_ERROR; } @@ -85,5 +89,17 @@ void ThreadStackManagerImpl::_UnlockThreadStack() openthread_api_mutex_unlock(openthread_get_default_context()); } +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT +void ThreadStackManagerImpl::_WaitOnSrpClearAllComplete() +{ + k_sem_take(&mSrpClearAllSemaphore, K_SECONDS(2)); +} + +void ThreadStackManagerImpl::_NotifySrpClearAllComplete() +{ + k_sem_give(&mSrpClearAllSemaphore); +} +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Zephyr/ThreadStackManagerImpl.h b/src/platform/Zephyr/ThreadStackManagerImpl.h index c0c66b492c6b1d..ec9feb8b121d3e 100644 --- a/src/platform/Zephyr/ThreadStackManagerImpl.h +++ b/src/platform/Zephyr/ThreadStackManagerImpl.h @@ -71,6 +71,10 @@ class ThreadStackManagerImpl final : public ThreadStackManager, bool _TryLockThreadStack(); void _UnlockThreadStack(); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + void _WaitOnSrpClearAllComplete(); + void _NotifySrpClearAllComplete(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT // ===== Methods that override the GenericThreadStackManagerImpl_OpenThread abstract interface. void _ProcessThreadActivity() {} @@ -83,6 +87,10 @@ class ThreadStackManagerImpl final : public ThreadStackManager, friend ThreadStackManager & ::chip::DeviceLayer::ThreadStackMgr(void); friend ThreadStackManagerImpl & ::chip::DeviceLayer::ThreadStackMgrImpl(void); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + k_sem mSrpClearAllSemaphore; +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + static ThreadStackManagerImpl sInstance; // ===== Private members for use by this class only. diff --git a/src/platform/silabs/ConfigurationManagerImpl.cpp b/src/platform/silabs/ConfigurationManagerImpl.cpp index a3e1778c11ac3f..8412075de3a914 100644 --- a/src/platform/silabs/ConfigurationManagerImpl.cpp +++ b/src/platform/silabs/ConfigurationManagerImpl.cpp @@ -272,7 +272,7 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) #if CHIP_DEVICE_CONFIG_ENABLE_THREAD #if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT - ThreadStackMgrImpl().RemoveAllSrpServices(); + ThreadStackMgr().ClearAllSrpHostAndServices(); #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT ChipLogProgress(DeviceLayer, "Clearing Thread provision"); ThreadStackMgr().ErasePersistentInfo(); diff --git a/src/platform/silabs/ThreadStackManagerImpl.h b/src/platform/silabs/ThreadStackManagerImpl.h index b1436b3b75b27e..c56990fb0d3712 100644 --- a/src/platform/silabs/ThreadStackManagerImpl.h +++ b/src/platform/silabs/ThreadStackManagerImpl.h @@ -72,19 +72,11 @@ class ThreadStackManagerImpl final : public ThreadStackManager, using ThreadStackManager::InitThreadStack; CHIP_ERROR InitThreadStack(otInstance * otInst); -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT - void RemoveAllSrpServices(); -#endif private: // ===== Methods that implement the ThreadStackManager abstract interface. CHIP_ERROR _InitThreadStack(void); -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT - static void OnSrpClientRemoveCallback(otError aError, const otSrpClientHostInfo * aHostInfo, - const otSrpClientService * aServices, const otSrpClientService * aRemovedServices, - void * aContext); -#endif // ===== Members for internal use by the following friends. friend ThreadStackManager & ::chip::DeviceLayer::ThreadStackMgr(void); @@ -94,9 +86,6 @@ class ThreadStackManagerImpl final : public ThreadStackManager, static ThreadStackManagerImpl sInstance; static bool IsInitialized(); -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT - TaskHandle_t srpRemoveRequester = nullptr; -#endif // ===== Private members for use by this class only. diff --git a/src/platform/silabs/efr32/ThreadStackManagerImpl.cpp b/src/platform/silabs/efr32/ThreadStackManagerImpl.cpp index c4556036034e78..83767f9a0e1fb8 100644 --- a/src/platform/silabs/efr32/ThreadStackManagerImpl.cpp +++ b/src/platform/silabs/efr32/ThreadStackManagerImpl.cpp @@ -66,58 +66,6 @@ bool ThreadStackManagerImpl::IsInitialized() return sInstance.mThreadStackLock != NULL; } -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT -/* - * @brief Notifies `RemoveAllSrpServices` that the Srp Client removal has completed - * and unblock the calling task. - * - * No data is processed. - */ -void ThreadStackManagerImpl::OnSrpClientRemoveCallback(otError aError, const otSrpClientHostInfo * aHostInfo, - const otSrpClientService * aServices, - const otSrpClientService * aRemovedServices, void * aContext) -{ - if (ThreadStackMgrImpl().srpRemoveRequester) - { - xTaskNotifyGive(ThreadStackMgrImpl().srpRemoveRequester); - } -} - -/* - * @brief This is a utility function to remove all Thread client Srp services - * established between the device and the srp server (in most cases the OTBR). - * The calling task is blocked until OnSrpClientRemoveCallback. - * - * Note: This function is meant to be used during the factory reset sequence. - * It overrides the generic SrpClient callback `OnSrpClientNotification` with - * OnSrpClientRemoveCallback which doesn't process any of the callback data. - * - * If there is a usecase where this function would be needed in a non-Factory reset context, - * OnSrpClientRemoveCallback should be extended and tied back with the GenericThreadStackManagerImpl_OpenThread - * management of the srp clients. - */ -void ThreadStackManagerImpl::RemoveAllSrpServices() -{ - // This check ensure that only one srp services removal is running - if (ThreadStackMgrImpl().srpRemoveRequester == nullptr) - { - srpRemoveRequester = xTaskGetCurrentTaskHandle(); - otSrpClientSetCallback(OTInstance(), &OnSrpClientRemoveCallback, nullptr); - InvalidateAllSrpServices(); - if (RemoveInvalidSrpServices() == CHIP_NO_ERROR) - { - // Wait for the OnSrpClientRemoveCallback. - ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(2000)); - } - else - { - ChipLogError(DeviceLayer, "Failed to remove srp services"); - } - ThreadStackMgrImpl().srpRemoveRequester = nullptr; - } -} -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT - } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/telink/ThreadStackManagerImpl.cpp b/src/platform/telink/ThreadStackManagerImpl.cpp index e66735b1de68f2..13ba8be424563b 100644 --- a/src/platform/telink/ThreadStackManagerImpl.cpp +++ b/src/platform/telink/ThreadStackManagerImpl.cpp @@ -68,6 +68,10 @@ CHIP_ERROR ThreadStackManagerImpl::_InitThreadStack() return MapOpenThreadError(otError); }); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + k_sem_init(&mSrpClearAllSemaphore, 0, 1); +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + return CHIP_NO_ERROR; } @@ -87,6 +91,18 @@ void ThreadStackManagerImpl::_UnlockThreadStack() openthread_api_mutex_unlock(openthread_get_default_context()); } +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT +void ThreadStackManagerImpl::_WaitOnSrpClearAllComplete() +{ + k_sem_take(&mSrpClearAllSemaphore, K_SECONDS(2)); +} + +void ThreadStackManagerImpl::_NotifySrpClearAllComplete() +{ + k_sem_give(&mSrpClearAllSemaphore); +} +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + CHIP_ERROR ThreadStackManagerImpl::_AttachToThreadNetwork(const Thread::OperationalDataset & dataset, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback) diff --git a/src/platform/telink/ThreadStackManagerImpl.h b/src/platform/telink/ThreadStackManagerImpl.h index d1040542f3c616..21db9972f62dec 100644 --- a/src/platform/telink/ThreadStackManagerImpl.h +++ b/src/platform/telink/ThreadStackManagerImpl.h @@ -74,6 +74,10 @@ class ThreadStackManagerImpl final : public ThreadStackManager, bool _TryLockThreadStack(); void _UnlockThreadStack(); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + void _WaitOnSrpClearAllComplete(); + void _NotifySrpClearAllComplete(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT // ===== Methods that override the GenericThreadStackManagerImpl_OpenThread abstract interface. void _ProcessThreadActivity() {} @@ -95,6 +99,10 @@ class ThreadStackManagerImpl final : public ThreadStackManager, bool mRadioBlocked; bool mReadyToAttach; +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + k_sem mSrpClearAllSemaphore; +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + NetworkCommissioning::ThreadDriver::ScanCallback * mpScanCallback; }; diff --git a/src/platform/webos/ThreadStackManagerImpl.h b/src/platform/webos/ThreadStackManagerImpl.h index 876c339cceb6ae..a21d4cbf551251 100644 --- a/src/platform/webos/ThreadStackManagerImpl.h +++ b/src/platform/webos/ThreadStackManagerImpl.h @@ -50,6 +50,11 @@ class ThreadStackManagerImpl : public ThreadStackManager bool _TryLockThreadStack() { return false; } // Intentionally left blank void _UnlockThreadStack() {} // Intentionally left blank +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + void _WaitOnSrpClearAllComplete() {} + void _NotifySrpClearAllComplete() {} +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + bool _HaveRouteToAddress(const Inet::IPAddress & destAddr); void _OnPlatformEvent(const ChipDeviceEvent * event); diff --git a/src/python_testing/TC_RVCCLEANM_2_1.py b/src/python_testing/TC_RVCCLEANM_2_1.py index d000f0d5af697d..6ef91d89a06729 100644 --- a/src/python_testing/TC_RVCCLEANM_2_1.py +++ b/src/python_testing/TC_RVCCLEANM_2_1.py @@ -16,6 +16,7 @@ # import logging +from time import sleep import chip.clusters as Clusters from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches @@ -56,6 +57,9 @@ async def send_run_change_to_mode_cmd(self, newMode) -> Clusters.Objects.RvcRunM def write_to_app_pipe(self, command): with open(self.app_pipe, "w") as app_pipe: app_pipe.write(command + "\n") + # Delay for pipe command to be processed (otherwise tests are flaky) + # TODO(#31239): centralize pipe write logic and remove the need of sleep + sleep(0.001) def pics_TC_RVCCLEANM_2_1(self) -> list[str]: return ["RVCCLEANM.S"] diff --git a/src/python_testing/TC_RVCCLEANM_2_2.py b/src/python_testing/TC_RVCCLEANM_2_2.py index ae5c268d7a9668..7e1fa6aaf2667e 100644 --- a/src/python_testing/TC_RVCCLEANM_2_2.py +++ b/src/python_testing/TC_RVCCLEANM_2_2.py @@ -15,6 +15,8 @@ # limitations under the License. # +from time import sleep + import chip.clusters as Clusters from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main from mobly import asserts @@ -70,6 +72,9 @@ def pics_TC_RVCCLEANM_2_2(self) -> list[str]: def write_to_app_pipe(self, command): with open(self.app_pipe, "w") as app_pipe: app_pipe.write(command + "\n") + # Delay for pipe command to be processed (otherwise tests are flaky) + # TODO(#31239): centralize pipe write logic and remove the need of sleep + sleep(0.001) @async_test_body async def test_TC_RVCCLEANM_2_2(self): diff --git a/src/python_testing/TC_RVCOPSTATE_2_1.py b/src/python_testing/TC_RVCOPSTATE_2_1.py index b0d753ad216164..e9dd4659059fa0 100644 --- a/src/python_testing/TC_RVCOPSTATE_2_1.py +++ b/src/python_testing/TC_RVCOPSTATE_2_1.py @@ -16,6 +16,7 @@ # import logging +from time import sleep import chip.clusters as Clusters from chip.clusters.Types import NullValue @@ -63,6 +64,9 @@ async def send_pause_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands. def write_to_app_pipe(self, command): with open(self.app_pipe, "w") as app_pipe: app_pipe.write(command + "\n") + # Allow some time for the command to take effect. + # This removes the test flakyness which is very annoying for everyone in CI. + sleep(0.001) def TC_RVCOPSTATE_2_1(self) -> list[str]: return ["RVCOPSTATE.S"] diff --git a/src/python_testing/TC_RVCOPSTATE_2_3.py b/src/python_testing/TC_RVCOPSTATE_2_3.py index 4d275ac5adc5b9..aa755315fb7d46 100644 --- a/src/python_testing/TC_RVCOPSTATE_2_3.py +++ b/src/python_testing/TC_RVCOPSTATE_2_3.py @@ -130,6 +130,9 @@ async def send_run_change_to_mode_cmd(self, new_mode) -> Clusters.Objects.RvcRun def write_to_app_pipe(self, command): with open(self.app_pipe, "w") as app_pipe: app_pipe.write(command + "\n") + # Delay for pipe command to be processed (otherwise tests are flaky) + # TODO(#31239): centralize pipe write logic and remove the need of sleep + sleep(0.001) # Prints the instruction and waits for a user input to continue def print_instruction(self, step_number, instruction): diff --git a/src/python_testing/TC_RVCOPSTATE_2_4.py b/src/python_testing/TC_RVCOPSTATE_2_4.py index 3314eaade876bb..7352fbd089f172 100644 --- a/src/python_testing/TC_RVCOPSTATE_2_4.py +++ b/src/python_testing/TC_RVCOPSTATE_2_4.py @@ -16,6 +16,7 @@ # import logging +from time import sleep import chip.clusters as Clusters from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches @@ -81,6 +82,9 @@ async def send_run_change_to_mode_cmd(self, new_mode): def write_to_app_pipe(self, command): with open(self.app_pipe, "w") as app_pipe: app_pipe.write(command + "\n") + # Delay for pipe command to be processed (otherwise tests are flaky) + # TODO(#31239): centralize pipe write logic and remove the need of sleep + sleep(0.001) def pics_TC_RVCOPSTATE_2_4(self) -> list[str]: return ["RVCOPSTATE.S"] diff --git a/src/python_testing/TC_RVCRUNM_2_1.py b/src/python_testing/TC_RVCRUNM_2_1.py index a9b4c44ba4f88c..1f3bccb528f137 100644 --- a/src/python_testing/TC_RVCRUNM_2_1.py +++ b/src/python_testing/TC_RVCRUNM_2_1.py @@ -16,6 +16,7 @@ # import logging +from time import sleep import chip.clusters as Clusters from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches @@ -51,6 +52,9 @@ async def send_change_to_mode_cmd(self, newMode) -> Clusters.Objects.RvcRunMode. def write_to_app_pipe(self, command): with open(self.app_pipe, "w") as app_pipe: app_pipe.write(command + "\n") + # Delay for pipe command to be processed (otherwise tests are flaky) + # TODO(#31239): centralize pipe write logic and remove the need of sleep + sleep(0.001) def pics_TC_RVCRUNM_2_1(self) -> list[str]: return ["RVCRUNM.S"] diff --git a/src/python_testing/TC_RVCRUNM_2_2.py b/src/python_testing/TC_RVCRUNM_2_2.py index 4868865c367d19..d85d1ae53cb928 100644 --- a/src/python_testing/TC_RVCRUNM_2_2.py +++ b/src/python_testing/TC_RVCRUNM_2_2.py @@ -15,6 +15,8 @@ # limitations under the License. # +from time import sleep + import chip.clusters as Clusters from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main from mobly import asserts @@ -91,6 +93,9 @@ async def read_op_state_operational_state(self) -> Clusters.Objects.RvcOperation def write_to_app_pipe(self, command): with open(self.app_pipe, "w") as app_pipe: app_pipe.write(command + "\n") + # Delay for pipe command to be processed (otherwise tests are flaky) + # TODO(#31239): centralize pipe write logic and remove the need of sleep + sleep(0.001) def pics_TC_RVCRUNM_2_2(self) -> list[str]: return ["RVCRUNM.S"] diff --git a/third_party/libwebsockets/repo b/third_party/libwebsockets/repo index 49bfef2ecd51b8..b71a6621b0b14b 160000 --- a/third_party/libwebsockets/repo +++ b/third_party/libwebsockets/repo @@ -1 +1 @@ -Subproject commit 49bfef2ecd51b854b63e35d913849b6bb518a7f6 +Subproject commit b71a6621b0b14bfc8fcbe804b036a9543af5e910 diff --git a/third_party/mbedtls/repo b/third_party/mbedtls/repo index ede909f99ab6e6..039c903e7b2882 160000 --- a/third_party/mbedtls/repo +++ b/third_party/mbedtls/repo @@ -1 +1 @@ -Subproject commit ede909f99ab6e6a958a41e365251c2a1d2c4ed4d +Subproject commit 039c903e7b2882af8e85ce5e090fd44e6a9d2289 diff --git a/third_party/openthread/repo b/third_party/openthread/repo index b212a0a748070c..33574ad4175ffb 160000 --- a/third_party/openthread/repo +++ b/third_party/openthread/repo @@ -1 +1 @@ -Subproject commit b212a0a748070ccbda765c3ebed2aab8b6b08fce +Subproject commit 33574ad4175ffb088bcca047f4c8d5fb240d1495 diff --git a/third_party/ot-br-posix/repo b/third_party/ot-br-posix/repo index c5a7a35e3bd2f3..9bdaa9101663c2 160000 --- a/third_party/ot-br-posix/repo +++ b/third_party/ot-br-posix/repo @@ -1 +1 @@ -Subproject commit c5a7a35e3bd2f3da8cce1e2e2a3bbe5cdeedb729 +Subproject commit 9bdaa9101663c2ce9016fb5e2b5010442b17ca26