diff --git a/.github/actions/bootstrap/action.yaml b/.github/actions/bootstrap/action.yaml index 66e6645fff4992..8f94830b8c0e51 100644 --- a/.github/actions/bootstrap/action.yaml +++ b/.github/actions/bootstrap/action.yaml @@ -1,8 +1,13 @@ name: Bootstrap description: Bootstrap +inputs: + platform: + description: "Platform name" + required: false + default: none runs: using: "composite" steps: - name: Bootstrap shell: bash - run: bash scripts/bootstrap.sh + run: bash scripts/bootstrap.sh -p all,${{ inputs.platform }} diff --git a/.github/actions/checkout-submodules-and-bootstrap/action.yaml b/.github/actions/checkout-submodules-and-bootstrap/action.yaml index 22b3629f0e7052..8226b7e7bd3d41 100644 --- a/.github/actions/checkout-submodules-and-bootstrap/action.yaml +++ b/.github/actions/checkout-submodules-and-bootstrap/action.yaml @@ -24,6 +24,8 @@ runs: uses: ./.github/actions/bootstrap-cache - name: Bootstrap uses: ./.github/actions/bootstrap + with: + platform: ${{ inputs.platform }} - name: Upload Bootstrap Logs uses: ./.github/actions/upload-bootstrap-logs with: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c462203ae6cd0d..48135fd924afa5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -427,7 +427,7 @@ jobs: - name: Build Python REPL and example apps run: | - scripts/run_in_build_env.sh './scripts/build_python.sh --install_virtual_env out/venv --extra_packages "mobly"' + scripts/run_in_build_env.sh './scripts/build_python.sh --install_virtual_env out/venv' ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py \ --target linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test \ diff --git a/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp index 66f86e5b28ab99..e6e18ab9edb32a 100644 --- a/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp @@ -15,9 +15,173 @@ * limitations under the License. */ -#include +#include +#include -bool emberAfPluginSmokeCoAlarmSelfTestRequestCommand(chip::EndpointId endpointId) +#include + +using namespace chip; +using namespace chip::app::Clusters::SmokeCoAlarm; +using namespace chip::DeviceLayer; + +namespace { + +constexpr const uint16_t kSelfTestingTimeoutSec = 10; + +} // namespace + +static std::array sPriorityOrder = { + ExpressedStateEnum::kSmokeAlarm, ExpressedStateEnum::kInterconnectSmoke, ExpressedStateEnum::kCOAlarm, + ExpressedStateEnum::kInterconnectCO, ExpressedStateEnum::kHardwareFault, ExpressedStateEnum::kTesting, + ExpressedStateEnum::kEndOfService, ExpressedStateEnum::kBatteryAlert +}; + +void EndSelfTestingEventHandler(System::Layer * systemLayer, void * appState) +{ + SmokeCoAlarmServer::Instance().SetTestInProgress(1, false); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + + ChipLogProgress(Support, "[Smoke-CO-Alarm] => Self test complete"); +} + +bool emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId) { + SmokeCoAlarmServer::Instance().SetTestInProgress(1, true); + + ChipLogProgress(Support, "[Smoke-CO-Alarm] => Self test running"); + + DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds32(kSelfTestingTimeoutSec), EndSelfTestingEventHandler, nullptr); + + return true; +} + +bool HandleSmokeCOTestEventTrigger(uint64_t eventTrigger) +{ + SmokeCOTrigger trigger = static_cast(eventTrigger); + + switch (trigger) + { + case SmokeCOTrigger::kForceSmokeCritical: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke (critical)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kCritical), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceSmokeWarning: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke (warning)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kWarning), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceSmokeInterconnect: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke interconnect (warning)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetInterconnectSmokeAlarm(1, AlarmStateEnum::kWarning), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceCOCritical: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force CO (critical)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetCOState(1, AlarmStateEnum::kCritical), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceCOWarning: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force CO (warning)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetCOState(1, AlarmStateEnum::kWarning), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceCOInterconnect: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force CO (warning)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetInterconnectCOAlarm(1, AlarmStateEnum::kWarning), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceSmokeContaminationHigh: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke contamination (critical)"); + SmokeCoAlarmServer::Instance().SetContaminationState(1, ContaminationStateEnum::kCritical); + break; + case SmokeCOTrigger::kForceSmokeContaminationLow: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke contamination (warning)"); + SmokeCoAlarmServer::Instance().SetContaminationState(1, ContaminationStateEnum::kLow); + break; + case SmokeCOTrigger::kForceSmokeSensitivityHigh: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke sensistivity (high)"); + SmokeCoAlarmServer::Instance().SetSmokeSensitivityLevel(1, SensitivityEnum::kHigh); + break; + case SmokeCOTrigger::kForceSmokeSensitivityLow: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke sensitivity (low)"); + SmokeCoAlarmServer::Instance().SetSmokeSensitivityLevel(1, SensitivityEnum::kLow); + break; + case SmokeCOTrigger::kForceMalfunction: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force malfunction"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetHardwareFaultAlert(1, true), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceLowBatteryWarning: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force low battery (warning)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetBatteryAlert(1, AlarmStateEnum::kWarning), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceLowBatteryCritical: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force low battery (critical)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetBatteryAlert(1, AlarmStateEnum::kCritical), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceEndOfLife: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force end-of-life"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetEndOfServiceAlert(1, EndOfServiceEnum::kExpired), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceSilence: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force silence"); + SmokeCoAlarmServer::Instance().SetDeviceMuted(1, MuteStateEnum::kMuted); + break; + case SmokeCOTrigger::kClearSmoke: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear smoke"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kNormal), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearCO: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear CO"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetCOState(1, AlarmStateEnum::kNormal), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearSmokeInterconnect: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear smoke interconnect"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetInterconnectSmokeAlarm(1, AlarmStateEnum::kNormal), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearCOInterconnect: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear CO interconnect"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetInterconnectCOAlarm(1, AlarmStateEnum::kNormal), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearMalfunction: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear malfunction"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetHardwareFaultAlert(1, false), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearEndOfLife: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear end-of-life"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetEndOfServiceAlert(1, EndOfServiceEnum::kNormal), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearSilence: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear silence"); + SmokeCoAlarmServer::Instance().SetDeviceMuted(1, MuteStateEnum::kNotMuted); + break; + case SmokeCOTrigger::kClearBatteryLevelLow: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear low battery"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetBatteryAlert(1, AlarmStateEnum::kNormal), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearContamination: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force SmokeContamination (warning)"); + SmokeCoAlarmServer::Instance().SetContaminationState(1, ContaminationStateEnum::kNormal); + break; + case SmokeCOTrigger::kClearSensitivity: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear Smoke Sensitivity"); + SmokeCoAlarmServer::Instance().SetSmokeSensitivityLevel(1, SensitivityEnum::kStandard); + break; + default: + + return false; + } + return true; } diff --git a/examples/all-clusters-app/linux/args.gni b/examples/all-clusters-app/linux/args.gni index c4c9a18cec9cf5..1bcd86f18843b8 100644 --- a/examples/all-clusters-app/linux/args.gni +++ b/examples/all-clusters-app/linux/args.gni @@ -27,3 +27,4 @@ chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] matter_enable_tracing_support = true matter_log_json_payload_decode_full = true matter_log_json_payload_hex = true +chip_enable_smoke_co_trigger = true diff --git a/examples/all-clusters-app/tizen/BUILD.gn b/examples/all-clusters-app/tizen/BUILD.gn index 484732400b64f1..8bf7f00152148f 100644 --- a/examples/all-clusters-app/tizen/BUILD.gn +++ b/examples/all-clusters-app/tizen/BUILD.gn @@ -34,6 +34,7 @@ source_set("chip-all-clusters-common") { deps = [ "${chip_root}/examples/all-clusters-app/all-clusters-common", + "${chip_root}/examples/platform/tizen:app-main", "${chip_root}/src/lib/shell:shell_core", ] diff --git a/examples/all-clusters-minimal-app/tizen/BUILD.gn b/examples/all-clusters-minimal-app/tizen/BUILD.gn index 5485fdd469d223..99f857e86303ea 100644 --- a/examples/all-clusters-minimal-app/tizen/BUILD.gn +++ b/examples/all-clusters-minimal-app/tizen/BUILD.gn @@ -31,6 +31,7 @@ source_set("chip-all-clusters-common") { deps = [ "${chip_root}/examples/all-clusters-minimal-app/all-clusters-common", + "${chip_root}/examples/platform/tizen:app-main", "${chip_root}/src/lib/shell:shell_core", ] diff --git a/examples/platform/linux/AppMain.cpp b/examples/platform/linux/AppMain.cpp index 22ff4d2db71cb6..ea52a49e79634a 100644 --- a/examples/platform/linux/AppMain.cpp +++ b/examples/platform/linux/AppMain.cpp @@ -75,6 +75,9 @@ #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR #include #endif +#if CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER +#include +#endif #include #include @@ -522,6 +525,12 @@ void ChipLinuxAppMainLoop(AppMainLoopImplementation * impl) static OTATestEventTriggerDelegate otaTestEventTriggerDelegate{ ByteSpan( LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey) }; otherDelegate = &otaTestEventTriggerDelegate; +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER + static SmokeCOTestEventTriggerDelegate smokeCOTestEventTriggerDelegate{ + ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey), otherDelegate + }; + otherDelegate = &smokeCOTestEventTriggerDelegate; #endif // For general testing of TestEventTrigger, we have a common "core" event trigger delegate. static SampleTestEventTriggerDelegate testEventTriggerDelegate; diff --git a/examples/platform/linux/BUILD.gn b/examples/platform/linux/BUILD.gn index 8427fe8aa80104..44a96b12c00604 100644 --- a/examples/platform/linux/BUILD.gn +++ b/examples/platform/linux/BUILD.gn @@ -19,6 +19,10 @@ import("${chip_root}/src/lib/core/core.gni") import("${chip_root}/src/lib/lib.gni") import("${chip_root}/src/tracing/tracing_args.gni") +declare_args() { + chip_enable_smoke_co_trigger = false +} + config("app-main-config") { include_dirs = [ "." ] } @@ -29,6 +33,10 @@ source_set("ota-test-event-trigger") { ] } +source_set("smco-test-event-trigger") { + sources = [ "${chip_root}/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h" ] +} + source_set("app-main") { defines = [ "ENABLE_TRACING=${matter_enable_tracing_support}" ] sources = [ @@ -51,6 +59,7 @@ source_set("app-main") { ] public_deps = [ + ":smco-test-event-trigger", "${chip_root}/src/lib", "${chip_root}/src/platform/logging:force_stdio", ] @@ -85,6 +94,10 @@ source_set("app-main") { ] } + if (chip_enable_smoke_co_trigger) { + defines += [ "CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER=1" ] + } + public_configs = [ ":app-main-config" ] } diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index 41d3a0c3e3fec5..a59f660a8a7788 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -157,6 +157,7 @@ class AppFabricTableDelegate : public FabricTable::Delegate { if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) { + bool isCommissioningFailed = chip::Server::GetInstance().GetCommissioningWindowManager().IsCommissioningWindowOpen(); ChipLogProgress(DeviceLayer, "Performing erasing of settings partition"); #ifdef CONFIG_CHIP_FACTORY_RESET_ERASE_NVS @@ -168,9 +169,12 @@ class AppFabricTableDelegate : public FabricTable::Delegate status = nvs_clear(static_cast(storage)); } - if (!status) + if (!isCommissioningFailed) { - status = nvs_mount(static_cast(storage)); + if (!status) + { + status = nvs_mount(static_cast(storage)); + } } if (status) @@ -187,6 +191,10 @@ class AppFabricTableDelegate : public FabricTable::Delegate ConnectivityMgr().ErasePersistentInfo(); #endif + if (isCommissioningFailed) + { + PlatformMgr().Shutdown(); + } } } }; diff --git a/integrations/docker/images/base/chip-build/version b/integrations/docker/images/base/chip-build/version index abc531aac97603..a3bb1d9c725371 100644 --- a/integrations/docker/images/base/chip-build/version +++ b/integrations/docker/images/base/chip-build/version @@ -1 +1 @@ -6 : Add support for K32W1 SDK +7 : Fix TI sysconfig root in vscode image diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile index 47d7cc0b606742..6c3872df43102e 100644 --- a/integrations/docker/images/chip-cert-bins/Dockerfile +++ b/integrations/docker/images/chip-cert-bins/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:22.04 as chip-build-cert LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip ARG TARGETPLATFORM # COMMITHASH defines the target commit to build from. May be passed in using --build-arg. -ARG COMMITHASH=7b99e6399c6069037c613782d78132c69b9dcabb +ARG COMMITHASH=c1ec2d777456924dcaa59b53351b00d73caf378f # Ensure TARGETPLATFORM is set RUN case ${TARGETPLATFORM} in \ @@ -268,5 +268,11 @@ COPY --from=chip-build-cert-bins /root/connectedhomeip/out/chip-app1 chip-app1 # Stage 3.1 Setup the Matter Python environment COPY --from=chip-build-cert-bins /root/connectedhomeip/out/python_lib python_lib COPY --from=chip-build-cert-bins /root/connectedhomeip/src/python_testing python_testing -RUN pip install click websockets lark diskcache + +COPY --from=chip-build-cert-bins /root/connectedhomeip/scripts/tests/requirements.txt /tmp/requirements.txt +RUN pip install -r /tmp/requirements.txt && rm /tmp/requirements.txt + +COPY --from=chip-build-cert-bins /root/connectedhomeip/src/python_testing/requirements.txt /tmp/requirements.txt +RUN pip install -r /tmp/requirements.txt && rm /tmp/requirements.txt + RUN pip install --no-cache-dir python_lib/controller/python/chip*.whl diff --git a/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile b/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile index 87a12ffa36a72c..5bc74d4410c668 100644 --- a/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile +++ b/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile @@ -23,10 +23,10 @@ RUN set -x \ && : # last line RUN set -x \ - && mkdir -p k32w1 + && mkdir -p k32w1 \ && wget https://cache.nxp.com/lgfiles/bsps/SDK_2_12_5_K32W148-EVK.zip \ && unzip SDK_2_12_5_K32W148-EVK.zip -d k32w1 \ - && rm -rf SDK_2_12_5_K32W148-EVK.zip \ + && rm -rf SDK_2_12_5_K32W148-EVK.zip FROM ghcr.io/project-chip/chip-build:${VERSION} diff --git a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile index 6eb6087e597dd6..4f924867fdc05c 100644 --- a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile +++ b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile @@ -113,7 +113,7 @@ ENV QEMU_ESP32_DIR=/opt/espressif/qemu ENV SYSROOT_AARCH64=/opt/ubuntu-22.04.1-aarch64-sysroot ENV TELINK_ZEPHYR_BASE=/opt/telink/zephyrproject/zephyr ENV TELINK_ZEPHYR_SDK_DIR=/opt/telink/zephyr-sdk-0.16.1 -ENV TI_SYSCONFIG_ROOT=/opt/ti/sysconfig_1.13.0 +ENV TI_SYSCONFIG_ROOT=/opt/ti/sysconfig_1.15.0 ENV ZEPHYR_BASE=/opt/NordicSemiconductor/nrfconnect/zephyr ENV ZEPHYR_SDK_INSTALL_DIR=/opt/NordicSemiconductor/nRF5_tools/zephyr-sdk-0.16.0 ENV ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb diff --git a/scripts/build_python.sh b/scripts/build_python.sh index 08ad42965d5b99..5a0a12f9df84fe 100755 --- a/scripts/build_python.sh +++ b/scripts/build_python.sh @@ -64,7 +64,8 @@ Input Options: represents where the virtual environment is to be created. -c, --clean_virtual_env When installing a virtual environment, create/clean it first. Defaults to yes. - --include_pytest_deps Install requirements.python_tests.txt. + --include_pytest_deps Install requirements.txt for running scripts/tests and + src/python_testing scripts. Defaults to yes. --extra_packages PACKAGES Install extra Python packages from PyPI --include_yamltests Whether to install the matter_yamltests wheel. @@ -214,7 +215,8 @@ if [ -n "$install_virtual_env" ]; then if [ "$install_pytest_requirements" = "yes" ]; then echo_blue "Installing python test dependencies ..." - "$ENVIRONMENT_ROOT"/bin/pip install -r "$CHIP_ROOT/scripts/setup/requirements.python_tests.txt" + "$ENVIRONMENT_ROOT"/bin/pip install -r "$CHIP_ROOT/scripts/tests/requirements.txt" + "$ENVIRONMENT_ROOT"/bin/pip install -r "$CHIP_ROOT/src/python_testing/requirements.txt" fi echo "" diff --git a/scripts/py_matter_idl/setup.cfg b/scripts/py_matter_idl/setup.cfg index 2a7d386375a2e7..57f93c3dd9aa82 100644 --- a/scripts/py_matter_idl/setup.cfg +++ b/scripts/py_matter_idl/setup.cfg @@ -21,6 +21,10 @@ description = Parse matter idl files [options] packages = find: zip_safe = False +install_requires= + lark + jinja2 + stringcase [options.package_data] matter_idl = diff --git a/scripts/py_matter_yamltests/setup.cfg b/scripts/py_matter_yamltests/setup.cfg index 497022ce1459d9..a3c7983e7299cd 100644 --- a/scripts/py_matter_yamltests/setup.cfg +++ b/scripts/py_matter_yamltests/setup.cfg @@ -20,5 +20,8 @@ description = Parse matter yaml tests files [options] packages = find: - zip_safe = False +install_requires= + diskcache + lark + websockets diff --git a/scripts/setup/requirements.all.txt b/scripts/setup/requirements.all.txt index 378959cce0f17e..2cccfdbf84db03 100644 --- a/scripts/setup/requirements.all.txt +++ b/scripts/setup/requirements.all.txt @@ -8,16 +8,9 @@ virtualenv -c constraints.esp32.txt -r requirements.esp32.txt --r requirements.mbed.txt --r requirements.bouffalolab.txt --r requirements.openiotsdk.txt --r requirements.infineon.txt --r requirements.ti.txt --r requirements.telink.txt -r requirements.zephyr.txt -r requirements.cirque.txt -r requirements.memory.txt --r requirements.yaml_tests.txt # device controller wheel package wheel; sys_platform == 'linux' @@ -26,6 +19,14 @@ pyobjc-core; sys_platform == 'darwin' pyobjc-framework-cocoa; sys_platform == 'darwin' pyobjc-framework-corebluetooth; sys_platform == 'darwin' +# python unit tests run directly without installing +# built venv +# +# TODO: this should change in the Future +diskcache +lark +websockets + # mobly tests portpicker mobly diff --git a/scripts/setup/requirements.python_tests.txt b/scripts/setup/requirements.python_tests.txt deleted file mode 100644 index 92d6db9016814e..00000000000000 --- a/scripts/setup/requirements.python_tests.txt +++ /dev/null @@ -1,16 +0,0 @@ -# scripts/tests -click -colorama -diskcache -websockets - -# scripts/py_matter_idl -# TODO: these should be wheel dependencies -lark -jinja2 -stringcase - -# src/python_testing -mobly -pyasn1 -pyasn1_modules diff --git a/scripts/setup/requirements.yaml_tests.txt b/scripts/setup/requirements.yaml_tests.txt deleted file mode 100644 index 7fc0c5f653c194..00000000000000 --- a/scripts/setup/requirements.yaml_tests.txt +++ /dev/null @@ -1,2 +0,0 @@ -diskcache -websockets diff --git a/scripts/tests/requirements.txt b/scripts/tests/requirements.txt new file mode 100644 index 00000000000000..d3c26e9cba23c6 --- /dev/null +++ b/scripts/tests/requirements.txt @@ -0,0 +1,5 @@ +# Python requirements for scripts in this location +click +colorama +diskcache +websockets diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index d484d7ce654e9b..d20e28a83bbee8 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -287,6 +287,13 @@ template("chip_data_model") { "${_app_root}/clusters/${cluster}/resource-monitoring-cluster-objects.cpp", "${_app_root}/clusters/${cluster}/resource-monitoring-cluster-objects.h", ] + } else if (cluster == "smoke-co-alarm-server") { + sources += [ + "${_app_root}/clusters/${cluster}/${cluster}.cpp", + "${_app_root}/clusters/${cluster}/${cluster}.h", + "${_app_root}/clusters/${cluster}/SmokeCOTestEventTriggerDelegate.cpp", + "${_app_root}/clusters/${cluster}/SmokeCOTestEventTriggerDelegate.h", + ] } else { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ] } diff --git a/src/app/clusters/mode-base-server/mode-base-server.cpp b/src/app/clusters/mode-base-server/mode-base-server.cpp index b5b8a403b9ba3e..2b9cc232f87e8d 100644 --- a/src/app/clusters/mode-base-server/mode-base-server.cpp +++ b/src/app/clusters/mode-base-server/mode-base-server.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include using namespace chip; @@ -52,7 +51,7 @@ Instance::Instance(Delegate * aDelegate, EndpointId aEndpointId, ClusterId aClus Instance::~Instance() { - UnregisterInstance(); + UnregisterThisInstance(); chip::app::InteractionModelEngine::GetInstance()->UnregisterCommandHandler(this); unregisterAttributeAccessOverride(this); } @@ -69,7 +68,7 @@ CHIP_ERROR Instance::Init() ReturnErrorOnFailure(chip::app::InteractionModelEngine::GetInstance()->RegisterCommandHandler(this)); VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); - RegisterInstance(); + RegisterThisInstance(); ReturnErrorOnFailure(mDelegate->Init()); // If the StartUpMode is set, the CurrentMode attribute SHALL be set to the StartUpMode value, when the server is powered up. @@ -350,7 +349,7 @@ CHIP_ERROR Instance::Write(const ConcreteDataAttributePath & attributePath, Attr return CHIP_ERROR_INCORRECT_STATE; } -void Instance::RegisterInstance() +void Instance::RegisterThisInstance() { if (!gModeBaseAliasesInstances.Contains(this)) { @@ -358,7 +357,7 @@ void Instance::RegisterInstance() } } -void Instance::UnregisterInstance() +void Instance::UnregisterThisInstance() { gModeBaseAliasesInstances.Remove(this); } @@ -369,6 +368,11 @@ void Instance::HandleChangeToMode(HandlerContext & ctx, const Commands::ChangeTo Commands::ChangeToModeResponse::Type response; + // If the NewMode field doesn't match the Mode field of any entry of the SupportedModes list, + // the ChangeToModeResponse command's Status field SHALL indicate UnsupportedMode and + // the StatusText field SHALL be included and MAY be used to indicate the issue, with a human readable string, + // or include an empty string. + // We are leaving the StatusText empty since the Status is descriptive enough. if (!IsSupportedMode(newMode)) { ChipLogError(Zcl, "ModeBase: Failed to find the option with mode %u", newMode); @@ -377,6 +381,17 @@ void Instance::HandleChangeToMode(HandlerContext & ctx, const Commands::ChangeTo return; } + // If the NewMode field is the same as the value of the CurrentMode attribute + // the ChangeToModeResponse command SHALL have the Status field set to Success and + // the StatusText field MAY be supplied with a human readable string or include an empty string. + // We are leaving the StatusText empty since the Status is descriptive enough. + if (newMode == GetCurrentMode()) + { + response.status = to_underlying(ModeBase::StatusCode::kSuccess); + ctx.mCommandHandler.AddResponse(ctx.mRequestPath, response); + return; + } + mDelegate->HandleChangeToMode(newMode, response); if (response.status == to_underlying(StatusCode::kSuccess)) diff --git a/src/app/clusters/mode-base-server/mode-base-server.h b/src/app/clusters/mode-base-server/mode-base-server.h index 10a2a97c07080f..ef88ee8269dd46 100644 --- a/src/app/clusters/mode-base-server/mode-base-server.h +++ b/src/app/clusters/mode-base-server/mode-base-server.h @@ -124,11 +124,12 @@ class Instance : public CommandHandlerInterface, public AttributeAccessInterface private: Delegate * mDelegate; - EndpointId mEndpointId{}; - ClusterId mClusterId{}; + EndpointId mEndpointId; + ClusterId mClusterId; // Attribute data store - uint8_t mCurrentMode; + uint8_t mCurrentMode = 0; // This is a temporary value and may not be valid. We will change this to the value of the first + // mode in the list at the start of the Init function to ensure that it represents a valid mode. DataModel::Nullable mStartUpMode; DataModel::Nullable mOnMode; uint32_t mFeature; @@ -146,14 +147,14 @@ class Instance : public CommandHandlerInterface, public AttributeAccessInterface CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override; /** - * Register this ModeBase instance. + * Register this ModeBase instance in gModeBaseAliasesInstances. */ - void RegisterInstance(); + void RegisterThisInstance(); /** - * Unregister this ModeBase instance. + * Unregister this ModeBase instance in gModeBaseAliasesInstances. */ - void UnregisterInstance(); + void UnregisterThisInstance(); /** * Internal change-to-mode command handler function. diff --git a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.cpp b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.cpp new file mode 100644 index 00000000000000..597737b14bb768 --- /dev/null +++ b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.cpp @@ -0,0 +1,42 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "SmokeCOTestEventTriggerDelegate.h" + +using namespace chip::app::Clusters::SmokeCoAlarm; + +namespace chip { + +bool SmokeCOTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const +{ + return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); +} + +CHIP_ERROR SmokeCOTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) +{ + if (HandleSmokeCOTestEventTrigger(eventTrigger)) + { + return CHIP_NO_ERROR; + } + if (mOtherDelegate != nullptr) + { + return mOtherDelegate->HandleEventTrigger(eventTrigger); + } + return CHIP_ERROR_INVALID_ARGUMENT; +} + +} // namespace chip diff --git a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h new file mode 100644 index 00000000000000..599eb6ab2fc080 --- /dev/null +++ b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h @@ -0,0 +1,83 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +namespace chip { + +enum class SmokeCOTrigger : uint64_t +{ + // Force alarm commands + kForceSmokeWarning = 0xffffffff00000090, + kForceCOWarning = 0xffffffff00000091, + kForceSmokeInterconnect = 0xffffffff00000092, + kForceMalfunction = 0xffffffff00000093, + kForceCOInterconnect = 0xffffffff00000094, + kForceLowBatteryWarning = 0xffffffff00000095, + kForceSmokeContaminationHigh = 0xffffffff00000096, + kForceSmokeContaminationLow = 0xffffffff00000097, + kForceSmokeSensitivityHigh = 0xffffffff00000098, + kForceSmokeSensitivityLow = 0xffffffff00000099, + kForceEndOfLife = 0xffffffff0000009a, + kForceSilence = 0xffffffff0000009b, + kForceSmokeCritical = 0xffffffff0000009c, + kForceCOCritical = 0xffffffff0000009d, + kForceLowBatteryCritical = 0xffffffff0000009e, + // Clear alarm commands + kClearSmoke = 0xffffffff000000a0, + kClearCO = 0xffffffff000000a1, + kClearSmokeInterconnect = 0xffffffff000000a2, + kClearMalfunction = 0xffffffff000000a3, + kClearCOInterconnect = 0xffffffff000000a4, + kClearBatteryLevelLow = 0xffffffff000000a5, + kClearContamination = 0xffffffff000000a6, + kClearSensitivity = 0xffffffff000000a8, + kClearEndOfLife = 0xffffffff000000aa, + kClearSilence = 0xffffffff000000ab +}; + +class SmokeCOTestEventTriggerDelegate : public TestEventTriggerDelegate +{ +public: + explicit SmokeCOTestEventTriggerDelegate(const ByteSpan & enableKey, TestEventTriggerDelegate * otherDelegate) : + mEnableKey(enableKey), mOtherDelegate(otherDelegate) + {} + + bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; + CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; + +private: + ByteSpan mEnableKey; + TestEventTriggerDelegate * mOtherDelegate; +}; + +} // namespace chip + +/** + * @brief User handler for handling the test event trigger + * + * @note If TestEventTrigger is enabled, it needs to be implemented in the app + * + * @param eventTrigger Event trigger to handle + * + * @retval true on success + * @retval false if error happened + */ +bool HandleSmokeCOTestEventTrigger(uint64_t eventTrigger); diff --git a/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.cpp b/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.cpp index c5f109fac63a31..19f1da4f8a8d76 100644 --- a/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.cpp +++ b/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.cpp @@ -22,23 +22,12 @@ */ #include "smoke-co-alarm-server.h" + #include -#include -#include #include -#include -#include -#include -#include - -#include -#include -#include -#include using namespace chip; using namespace chip::app; -using namespace chip::app::DataModel; using namespace chip::app::Clusters::SmokeCoAlarm; using chip::Protocols::InteractionModel::Status; @@ -72,6 +61,55 @@ bool SmokeCoAlarmServer::SetExpressedState(EndpointId endpointId, ExpressedState return success; } +void SmokeCoAlarmServer::SetExpressedStateByPriority(EndpointId endpointId, + const std::array & priorityOrder) +{ + AlarmStateEnum alarmState = AlarmStateEnum::kNormal; + EndOfServiceEnum endOfServiceState = EndOfServiceEnum::kNormal; + bool active = false; + + for (ExpressedStateEnum priority : priorityOrder) + { + switch (priority) + { + case ExpressedStateEnum::kSmokeAlarm: + VerifyOrReturn(GetSmokeState(endpointId, alarmState)); + break; + case ExpressedStateEnum::kCOAlarm: + VerifyOrReturn(GetCOState(endpointId, alarmState)); + break; + case ExpressedStateEnum::kBatteryAlert: + VerifyOrReturn(GetBatteryAlert(endpointId, alarmState)); + break; + case ExpressedStateEnum::kTesting: + VerifyOrReturn(GetTestInProgress(endpointId, active)); + break; + case ExpressedStateEnum::kHardwareFault: + VerifyOrReturn(GetHardwareFaultAlert(endpointId, active)); + break; + case ExpressedStateEnum::kEndOfService: + VerifyOrReturn(GetEndOfServiceAlert(endpointId, endOfServiceState)); + break; + case ExpressedStateEnum::kInterconnectSmoke: + VerifyOrReturn(GetInterconnectSmokeAlarm(endpointId, alarmState)); + break; + case ExpressedStateEnum::kInterconnectCO: + VerifyOrReturn(GetInterconnectCOAlarm(endpointId, alarmState)); + break; + default: + break; + } + + if ((alarmState != AlarmStateEnum::kNormal) || (endOfServiceState != EndOfServiceEnum::kNormal) || active) + { + VerifyOrDo(SetExpressedState(endpointId, priority), ChipLogError(NotSpecified, "Set ExpressedState failed")); + return; + } + } + + VerifyOrDo(SetExpressedState(endpointId, ExpressedStateEnum::kNormal), ChipLogError(NotSpecified, "Set ExpressedState failed")); +} + bool SmokeCoAlarmServer::SetSmokeState(EndpointId endpointId, AlarmStateEnum newSmokeState) { AlarmStateEnum smokeState; diff --git a/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h b/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h index 529df2ed766807..0df9583371b67a 100644 --- a/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h +++ b/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h @@ -25,10 +25,7 @@ #include #include -#include #include -#include -#include /** * @brief Smoke CO Alarm Server Plugin class @@ -38,6 +35,9 @@ class SmokeCoAlarmServer public: static SmokeCoAlarmServer & Instance(); + /* Expected byte size of the PriorityOrder */ + static constexpr size_t kPriorityOrderLength = 8; + using AlarmStateEnum = chip::app::Clusters::SmokeCoAlarm::AlarmStateEnum; using ContaminationStateEnum = chip::app::Clusters::SmokeCoAlarm::ContaminationStateEnum; using EndOfServiceEnum = chip::app::Clusters::SmokeCoAlarm::EndOfServiceEnum; @@ -61,6 +61,14 @@ class SmokeCoAlarmServer */ bool SetExpressedState(chip::EndpointId endpointId, ExpressedStateEnum newExpressedState); + /** + * @brief Set the highest level of Expressed State according to priorityOrder + * @param endpointId ID of the endpoint + * @param priorityOrder Priority order of expressed state from highest to lowest + */ + void SetExpressedStateByPriority(chip::EndpointId endpointId, + const std::array & priorityOrder); + bool SetSmokeState(chip::EndpointId endpointId, AlarmStateEnum newSmokeState); bool SetCOState(chip::EndpointId endpointId, AlarmStateEnum newCOState); bool SetBatteryAlert(chip::EndpointId endpointId, AlarmStateEnum newBatteryAlert); diff --git a/src/app/util/af-enums.h b/src/app/util/af-enums.h index 646ea32c5565d7..27a9c76855bfee 100644 --- a/src/app/util/af-enums.h +++ b/src/app/util/af-enums.h @@ -67,5 +67,6 @@ enum EmberAfStatus : uint8_t EMBER_ZCL_STATUS_PATHS_EXHAUSTED = 0xC8, EMBER_ZCL_STATUS_TIMED_REQUEST_MISMATCH = 0xC9, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED = 0xCA, + EMBER_ZCL_STATE_INVALID_IN_STATE = 0xCB, EMBER_ZCL_STATUS_WRITE_IGNORED = 0xF0, // NOT SPEC COMPLIANT FOR TEST ONLY }; diff --git a/src/controller/java/src/chip/devicecontroller/model/EventState.java b/src/controller/java/src/chip/devicecontroller/model/EventState.java index 23988c7884687f..72b14c1391dc93 100644 --- a/src/controller/java/src/chip/devicecontroller/model/EventState.java +++ b/src/controller/java/src/chip/devicecontroller/model/EventState.java @@ -40,7 +40,7 @@ public EventState( long eventNumber, int priorityLevel, int timestampType, - long systemTimeStamp, + long timestampValue, Object valueObject, byte[] tlv, String jsonString) { diff --git a/src/platform/ESP32/ConnectivityManagerImpl.h b/src/platform/ESP32/ConnectivityManagerImpl.h index 97d07b894cb9c2..0add13da49886c 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.h +++ b/src/platform/ESP32/ConnectivityManagerImpl.h @@ -167,6 +167,12 @@ class ConnectivityManagerImpl final : public ConnectivityManager, void OnStationIPv6AddressAvailable(const ip_event_got_ip6_t & got_ip); #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + void OnEthernetIPv4AddressAvailable(const ip_event_got_ip_t & got_ip); + void OnEthernetIPv4AddressLost(void); + void OnEthernetIPv6AddressAvailable(const ip_event_got_ip6_t & got_ip); +#endif // CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + // ===== Members for internal use by the following friends. friend ConnectivityManager & ConnectivityMgr(void); diff --git a/src/platform/ESP32/ConnectivityManagerImpl_Ethernet.cpp b/src/platform/ESP32/ConnectivityManagerImpl_Ethernet.cpp index ec8d729d417d85..d8f7137047ebac 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_Ethernet.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_Ethernet.cpp @@ -55,15 +55,52 @@ CHIP_ERROR ConnectivityManagerImpl::InitEthernet() return CHIP_NO_ERROR; } +void ConnectivityManagerImpl::OnEthernetIPv4AddressAvailable(const ip_event_got_ip_t & got_ip) +{ + ChipLogProgress(DeviceLayer, "IPv4 address available on Ethernet interface: " IPSTR "/" IPSTR " gateway " IPSTR, + IP2STR(&got_ip.ip_info.ip), IP2STR(&got_ip.ip_info.netmask), IP2STR(&got_ip.ip_info.gw)); + + ChipDeviceEvent event; + event.Type = DeviceEventType::kInterfaceIpAddressChanged; + event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Assigned; + PlatformMgr().PostEventOrDie(&event); +} + +void ConnectivityManagerImpl::OnEthernetIPv4AddressLost(void) +{ + ChipLogProgress(DeviceLayer, "IPv4 address lost on Ethernet interface"); + + ChipDeviceEvent event; + event.Type = DeviceEventType::kInterfaceIpAddressChanged; + event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Lost; + PlatformMgr().PostEventOrDie(&event); +} + +void ConnectivityManagerImpl::OnEthernetIPv6AddressAvailable(const ip_event_got_ip6_t & got_ip) +{ + ChipLogProgress(DeviceLayer, "IPv6 address available on Ethernet interface: " IPV6STR, IPV62STR(got_ip.ip6_info.ip)); + + ChipDeviceEvent event; + event.Type = DeviceEventType::kInterfaceIpAddressChanged; + event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned; + PlatformMgr().PostEventOrDie(&event); +} + void ConnectivityManagerImpl::OnEthernetPlatformEvent(const ChipDeviceEvent * event) { switch (event->Platform.ESPSystemEvent.Id) { case IP_EVENT_ETH_GOT_IP: - ChipLogProgress(DeviceLayer, "Ethernet Link Up"); + OnEthernetIPv4AddressAvailable(event->Platform.ESPSystemEvent.Data.IpGotIp); break; case IP_EVENT_ETH_LOST_IP: - ChipLogProgress(DeviceLayer, "Ethernet Link Down"); + OnEthernetIPv4AddressLost(); + break; + case IP_EVENT_GOT_IP6: + if (strcmp(esp_netif_get_ifkey(event->Platform.ESPSystemEvent.Data.IpGotIp6.esp_netif), "ETH_DEF") == 0) + { + OnEthernetIPv6AddressAvailable(event->Platform.ESPSystemEvent.Data.IpGotIp6); + } break; case ETHERNET_EVENT_START: ChipLogProgress(DeviceLayer, "Ethernet Started"); diff --git a/src/platform/bouffalolab/common/BLEManagerImpl.cpp b/src/platform/bouffalolab/common/BLEManagerImpl.cpp index 73a6f8ff466650..b233721953161e 100644 --- a/src/platform/bouffalolab/common/BLEManagerImpl.cpp +++ b/src/platform/bouffalolab/common/BLEManagerImpl.cpp @@ -146,6 +146,12 @@ CHIP_ERROR BLEManagerImpl::_Init() return CHIP_NO_ERROR; } +void BLEManagerImpl::_Shutdown() +{ + // Release BLE Stack resources + mFlags.Set(Flags::kChipoBleShutDown); +} + void BLEManagerImpl::DriveBLEState(intptr_t arg) { BLEMgrImpl().DriveBLEState(); @@ -435,7 +441,7 @@ CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(const ChipDeviceEvent * event) { case BT_HCI_ERR_REMOTE_USER_TERM_CONN: // Do not treat proper connection termination as an error and exit. - VerifyOrExit(!ConfigurationMgr().IsFullyProvisioned(), ); + VerifyOrExit(!ConfigurationMgr().IsFullyProvisioned(), BLEMgrImpl()._Shutdown()); disconReason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED; break; case BT_HCI_ERR_LOCALHOST_TERM_CONN: @@ -457,7 +463,19 @@ CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(const ChipDeviceEvent * event) ChipDeviceEvent disconnectEvent; disconnectEvent.Type = DeviceEventType::kCHIPoBLEConnectionClosed; ReturnErrorOnFailure(PlatformMgr().PostEvent(&disconnectEvent)); - + if (mFlags.Has(Flags::kChipoBleShutDown)) + { + int ret = bt_disable(); + if (ret) + { + ChipLogError(DeviceLayer, "CHIPoBLE Shutdown faild =%d", ret); + } + else + { + mFlags.Clear(Flags::kChipoBleShutDown); + } + return CHIP_NO_ERROR; + } // Force a reconfiguration of advertising in case we switched to non-connectable mode when // the BLE connection was established. mFlags.Set(Flags::kAdvertisingRefreshNeeded); diff --git a/src/platform/bouffalolab/common/BLEManagerImpl.h b/src/platform/bouffalolab/common/BLEManagerImpl.h index 1589d88006a19d..d5d571ef7949cd 100644 --- a/src/platform/bouffalolab/common/BLEManagerImpl.h +++ b/src/platform/bouffalolab/common/BLEManagerImpl.h @@ -44,7 +44,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla std::conditional_t::value, bt_gatt_indicate_params *, const bt_gatt_attr *>; CHIP_ERROR _Init(void); - void _Shutdown() {} + void _Shutdown(); bool _IsAdvertisingEnabled(void); CHIP_ERROR _SetAdvertisingEnabled(bool val); bool _IsAdvertising(void); @@ -85,6 +85,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla kAdvertisingRefreshNeeded = 0x0010, /**< The advertising state/configuration has changed, but the SoftDevice has yet to be updated. */ kChipoBleGattServiceRegister = 0x0020, /**< The system has currently CHIPoBLE GATT service registered. */ + kChipoBleShutDown = 0x0040, /**< The system has disable ble stack. */ }; struct ServiceData; diff --git a/src/platform/bouffalolab/common/ConfigurationManagerImpl.cpp b/src/platform/bouffalolab/common/ConfigurationManagerImpl.cpp index d4c06dc2d3868e..b9719b795d15c3 100644 --- a/src/platform/bouffalolab/common/ConfigurationManagerImpl.cpp +++ b/src/platform/bouffalolab/common/ConfigurationManagerImpl.cpp @@ -34,7 +34,17 @@ ConfigurationManagerImpl & ConfigurationManagerImpl::GetDefaultInstance() static ConfigurationManagerImpl sInstance; return sInstance; } - +bool ConfigurationManagerImpl::IsFullyProvisioned() +{ + return +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION + ConnectivityMgr().IsWiFiStationProvisioned() && +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + ConnectivityMgr().IsThreadProvisioned() && +#endif + true; +} CHIP_ERROR ConfigurationManagerImpl::Init() { CHIP_ERROR err; diff --git a/src/platform/bouffalolab/common/ConfigurationManagerImpl.h b/src/platform/bouffalolab/common/ConfigurationManagerImpl.h index b9d207fc1ec9d2..d882f76f89e3bf 100644 --- a/src/platform/bouffalolab/common/ConfigurationManagerImpl.h +++ b/src/platform/bouffalolab/common/ConfigurationManagerImpl.h @@ -36,6 +36,7 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp CHIP_ERROR StoreRebootCount(uint32_t rebootCount); CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours); CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours); + bool IsFullyProvisioned(); private: // ===== Members that implement the ConfigurationManager private interface. diff --git a/src/protocols/interaction_model/StatusCodeList.h b/src/protocols/interaction_model/StatusCodeList.h index 62891c2e7b978d..1c37440e5c6eaa 100644 --- a/src/protocols/interaction_model/StatusCodeList.h +++ b/src/protocols/interaction_model/StatusCodeList.h @@ -69,5 +69,6 @@ CHIP_IM_STATUS_CODE(UnsupportedEvent , UNSUPPORTED_EVENT , 0xc7) CHIP_IM_STATUS_CODE(PathsExhausted , PATHS_EXHAUSTED , 0xc8) CHIP_IM_STATUS_CODE(TimedRequestMismatch , TIMED_REQUEST_MISMATCH , 0xc9) CHIP_IM_STATUS_CODE(FailsafeRequired , FAILSAFE_REQUIRED , 0xca) +CHIP_IM_STATUS_CODE(InvalidInState , INVALID_IN_STATE , 0xcb) CHIP_IM_STATUS_CODE(WriteIgnored , WRITE_IGNORED , 0xF0) // non-spec error code and use only internally // clang-format on diff --git a/src/python_testing/requirements.txt b/src/python_testing/requirements.txt new file mode 100644 index 00000000000000..84196f3f9e48f2 --- /dev/null +++ b/src/python_testing/requirements.txt @@ -0,0 +1,3 @@ +mobly +pyasn1 +pyasn1_modules