From c48a43521f9d00cc63328d1461bba8ccd5ffa9d2 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 15 Jan 2024 15:25:07 -0500 Subject: [PATCH 1/5] Add support for not complaining about abi changes in `provisional` clusters (#31372) * Ignore changes in provisional clusters for backwards compatibility * Restyle --- .../matter_idl/backwards_compatibility.py | 14 +++++++++++++- .../matter_idl/test_backwards_compatibility.py | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/scripts/py_matter_idl/matter_idl/backwards_compatibility.py b/scripts/py_matter_idl/matter_idl/backwards_compatibility.py index 9a6684c8031b9a..99adaf7a64bc0b 100644 --- a/scripts/py_matter_idl/matter_idl/backwards_compatibility.py +++ b/scripts/py_matter_idl/matter_idl/backwards_compatibility.py @@ -17,7 +17,7 @@ import logging from typing import Callable, Dict, List, Optional, Protocol, TypeVar -from matter_idl.matter_idl_types import Attribute, Bitmap, Cluster, Command, Enum, Event, Field, Idl, Struct +from matter_idl.matter_idl_types import ApiMaturity, Attribute, Bitmap, Cluster, Command, Enum, Event, Field, Idl, Struct class Compatibility(enum.Enum): @@ -52,6 +52,13 @@ def attribute_name(attribute: Attribute) -> str: return attribute.definition.name +def not_stable(maturity: ApiMaturity): + """Determine if the given api maturity allows binary/api changes or not.""" + # TODO: internal and deprecated not currently widely used, + # so we enforce stability on them for now. + return maturity == ApiMaturity.PROVISIONAL + + class CompatibilityChecker: def __init__(self, original: Idl, updated: Idl): self._original_idl = original @@ -271,6 +278,11 @@ def _check_cluster_list_compatible(self, original: List[Cluster], updated: List[ for original_cluster in original: updated_cluster = updated_clusters.get(original_cluster.name) + + if not_stable(updated_cluster.api_maturity) or not_stable(original_cluster.api_maturity): + # no point in checking + continue + self._check_cluster_compatible(original_cluster, updated_cluster) def _check_cluster_compatible(self, original_cluster: Cluster, updated_cluster: Optional[Cluster]): diff --git a/scripts/py_matter_idl/matter_idl/test_backwards_compatibility.py b/scripts/py_matter_idl/matter_idl/test_backwards_compatibility.py index dece1632ac4719..e94e79abd5fce5 100755 --- a/scripts/py_matter_idl/matter_idl/test_backwards_compatibility.py +++ b/scripts/py_matter_idl/matter_idl/test_backwards_compatibility.py @@ -104,6 +104,13 @@ def test_clusters_enum_add_remove(self): "server cluster A = 16 { enum X : ENUM8 { A = 1; }}", Compatibility.FORWARD_FAIL) + def test_provisional_cluster(self): + self.ValidateUpdate( + "Provisional cluster changes are ok.", + "provisional server cluster A = 16 { enum X : ENUM8 { A = 1; B = 2; } info event A = 1 { int8u x = 1;} }", + "provisional server cluster A = 16 { enum X : ENUM8 { A = 1; B = 3; } info event A = 2 { int16u x = 1;} }", + Compatibility.ALL_OK) + def test_clusters_enum_code(self): self.ValidateUpdate( "Adding an enum is ok. Also validates code formatting", From 7ef397ed52c009ead017ef6db55448a19a84d29b Mon Sep 17 00:00:00 2001 From: Tennessee Carmel-Veilleux Date: Mon, 15 Jan 2024 17:45:38 -0500 Subject: [PATCH 2/5] Make supported Wi-Fi bands API less error prone (#31349) * Make supported Wi-Fi bands API less error prone - Return a bitmask rather than mutating a span which could have led to misuse. - Make Network Commissioning cluster revision programmatic to avoid rev 1 leftovers (illegal starting at 1.3). - Fix an internal error case on writes. Fixes #30107 Issue #30110 Testing done: - Existing integration tests still pass with refactor. * Restyled by clang-format * Fix CI * Address review comments * Fix CI --------- Co-authored-by: Restyled.io Co-authored-by: tennessee.carmelveilleux@gmail.com --- .../network-commissioning.cpp | 36 +++++++++++------- .../certification/Test_TC_CNET_1_3.yaml | 2 +- src/include/platform/NetworkCommissioning.h | 38 +++++++++++-------- .../nrfconnect/wifi/NrfWiFiDriver.cpp | 18 ++++----- src/platform/nrfconnect/wifi/NrfWiFiDriver.h | 2 +- .../zap-generated/test/Commands.h | 2 +- 6 files changed, 56 insertions(+), 42 deletions(-) diff --git a/src/app/clusters/network-commissioning/network-commissioning.cpp b/src/app/clusters/network-commissioning/network-commissioning.cpp index 52990915d492dd..87edf85f5c06c9 100644 --- a/src/app/clusters/network-commissioning/network-commissioning.cpp +++ b/src/app/clusters/network-commissioning/network-commissioning.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2021-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +16,8 @@ * limitations under the License. */ +#include + #include "network-commissioning.h" #include @@ -54,8 +56,7 @@ namespace { // For WiFi and Thread scan results, each item will cost ~60 bytes in TLV, thus 15 is a safe upper bound of scan results. constexpr size_t kMaxNetworksInScanResponse = 15; -// The maximum number of Wi-Fi bands a device can support. -constexpr size_t kMaxWiFiBands = 6; +constexpr uint16_t kCurrentClusterRevision = 2; #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC constexpr size_t kPossessionNonceSize = 32; @@ -269,22 +270,31 @@ CHIP_ERROR Instance::Read(const ConcreteReadAttributePath & aPath, AttributeValu case Attributes::FeatureMap::Id: return aEncoder.Encode(mFeatureFlags); + case Attributes::ClusterRevision::Id: + return aEncoder.Encode(kCurrentClusterRevision); + case Attributes::SupportedWiFiBands::Id: - VerifyOrReturnError(mFeatureFlags.Has(Feature::kWiFiNetworkInterface), CHIP_NO_ERROR); - VerifyOrReturnError(mpDriver.Valid(), CHIP_NO_ERROR); +#if (!CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION && !CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP) + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); +#else + VerifyOrReturnError(mFeatureFlags.Has(Feature::kWiFiNetworkInterface), CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute)); - return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR { - WiFiBand bandsBuffer[kMaxWiFiBands]; - Span bands(bandsBuffer); - ReturnErrorOnFailure(mpDriver.Get()->GetSupportedWiFiBands(bands)); + return aEncoder.EncodeList([this](const auto & encoder) { + uint32_t bands = mpDriver.Get()->GetSupportedWiFiBandsMask(); - for (WiFiBand band : bands) + // Extract every band from the bitmap of supported bands, starting positionally on the right. + for (uint32_t band_bit_pos = 0; band_bit_pos < std::numeric_limits::digits; ++band_bit_pos) { - ReturnErrorOnFailure(encoder.Encode(band)); + uint32_t band_mask = static_cast(1UL << band_bit_pos); + if ((bands & band_mask) != 0) + { + ReturnErrorOnFailure(encoder.Encode(static_cast(band_bit_pos))); + } } - return CHIP_NO_ERROR; }); +#endif + break; case Attributes::SupportedThreadFeatures::Id: VerifyOrReturnError(mFeatureFlags.Has(Feature::kThreadNetworkInterface), CHIP_NO_ERROR); @@ -310,7 +320,7 @@ CHIP_ERROR Instance::Write(const ConcreteDataAttributePath & aPath, AttributeVal ReturnErrorOnFailure(aDecoder.Decode(value)); return mpBaseDriver->SetEnabled(value); default: - return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; + return CHIP_IM_GLOBAL_STATUS(InvalidAction); } } diff --git a/src/app/tests/suites/certification/Test_TC_CNET_1_3.yaml b/src/app/tests/suites/certification/Test_TC_CNET_1_3.yaml index 0422d108ac71ff..b28b4fbb548f2a 100644 --- a/src/app/tests/suites/certification/Test_TC_CNET_1_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_CNET_1_3.yaml @@ -37,7 +37,7 @@ tests: command: "readAttribute" attribute: "ClusterRevision" response: - value: 1 + value: 2 constraints: type: int16u diff --git a/src/include/platform/NetworkCommissioning.h b/src/include/platform/NetworkCommissioning.h index be33a98779ed58..6c2741d81201c5 100644 --- a/src/include/platform/NetworkCommissioning.h +++ b/src/include/platform/NetworkCommissioning.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ #include #include +#include namespace chip { namespace DeviceLayer { @@ -129,9 +131,13 @@ using NetworkIterator = Iterator; using WiFiScanResponseIterator = Iterator; using ThreadScanResponseIterator = Iterator; using Status = app::Clusters::NetworkCommissioning::NetworkCommissioningStatusEnum; -using WiFiBand = app::Clusters::NetworkCommissioning::WiFiBandEnum; -using WiFiSecurity = app::Clusters::NetworkCommissioning::WiFiSecurityBitmap; -using ThreadCapabilities = app::Clusters::NetworkCommissioning::ThreadCapabilitiesBitmap; +using WiFiBandEnum = app::Clusters::NetworkCommissioning::WiFiBandEnum; +// For backwards compatibility with pre-rename enum values. +using WiFiBand = WiFiBandEnum; +using WiFiSecurityBitmap = app::Clusters::NetworkCommissioning::WiFiSecurityBitmap; +// For backwards compatibility with pre-rename bitmap values. +using WiFiSecurity = WiFiSecurityBitmap; +using ThreadCapabilities = app::Clusters::NetworkCommissioning::ThreadCapabilitiesBitmap; // BaseDriver and WirelessDriver are the common interfaces for a network driver, platform drivers should not implement this // directly, instead, users are expected to implement WiFiDriver, ThreadDriver and EthernetDriver. @@ -352,24 +358,26 @@ class WiFiDriver : public Internal::WirelessDriver #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC /** - * @brief Provide all the frequency bands supported by the Wi-Fi interface + * @brief Provide all the frequency bands supported by the Wi-Fi interface. * * The default implementation returns the 2.4 GHz band support. - * Note: WiFi platforms should implement this function in their WiFiDriver to provide their complete device capabilities + * Note: WiFi platforms should implement this function in their WiFiDriver to provide their complete device capabilities. * - * @param bands Reference to a span that is used to return the supported bands. - * The span is initialized with a fixed-size buffer. - * The implementation is expected to resize the span to match the number of returned results. + * The returned bit mask has values of WiFiBandEnum packed into the bits. For example: * - * @return CHIP_NO_ERROR on success or a CHIP_ERROR on failure. + * - Bit 0 = (WiFiBandEnum::k2g4 == 0) --> (1 << 0) == (1 << WiFiBandEnum::k2g4) + * - Bit 2 = (WiFiBandEnum::k5g == 2) --> (1 << 2) == (1 << WiFiBandEnum::k5g) + * - If both 2.4G and 5G are supported --> ((1 << k2g4) || (1 << k5g)) == (1 || 4) == 5 + * + * On error, return 0 (no bands supported). This should never happen... Note that + * certification tests will REQUIRE at least one bit set in the set. + * + * @return a bitmask of supported Wi-Fi bands where each bit is associated with a WiFiBandEnum value. */ - virtual CHIP_ERROR GetSupportedWiFiBands(Span & bands) + virtual uint32_t GetSupportedWiFiBandsMask() const { - ReturnErrorCodeIf(bands.empty(), CHIP_ERROR_BUFFER_TOO_SMALL); - bands.front() = WiFiBand::k2g4; - bands.reduce_size(1); - - return CHIP_NO_ERROR; + // Default to 2.4G support (100% example platform coverage as of Matter 1.3) listed. + return static_cast(1UL << chip::to_underlying(WiFiBandEnum::k2g4)); } ~WiFiDriver() override = default; diff --git a/src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp b/src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp index d8eb9b17d473b3..1efe5c863f8753 100644 --- a/src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp +++ b/src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp @@ -17,10 +17,13 @@ #include "NrfWiFiDriver.h" +#include + #include #include #include +#include #include using namespace ::chip; @@ -276,20 +279,13 @@ void NrfWiFiDriver::ScanNetworks(ByteSpan ssid, WiFiDriver::ScanCallback * callb } } -CHIP_ERROR NrfWiFiDriver::GetSupportedWiFiBands(Span & bands) +uint32_t NrfWiFiDriver::GetSupportedWiFiBandsMask() const { - static constexpr WiFiBand kBands[] = { - WiFiBand::k2g4, + uint32_t bands = static_cast(1UL << chip::to_underlying(WiFiBandEnum::k2g4)); #ifndef CONFIG_BOARD_NRF7001 - WiFiBand::k5g, + bands |= static_cast(1UL << chip::to_underlying(WiFiBandEnum::k5g)); #endif - }; - - VerifyOrReturnError(ArraySize(kBands) <= bands.size(), CHIP_ERROR_BUFFER_TOO_SMALL); - memcpy(bands.data(), kBands, sizeof(kBands)); - bands.reduce_size(ArraySize(kBands)); - - return CHIP_NO_ERROR; + return bands; } } // namespace NetworkCommissioning diff --git a/src/platform/nrfconnect/wifi/NrfWiFiDriver.h b/src/platform/nrfconnect/wifi/NrfWiFiDriver.h index 1dd73a967d1f3e..7fe1ff1695351d 100644 --- a/src/platform/nrfconnect/wifi/NrfWiFiDriver.h +++ b/src/platform/nrfconnect/wifi/NrfWiFiDriver.h @@ -86,7 +86,7 @@ class NrfWiFiDriver final : public WiFiDriver Status AddOrUpdateNetwork(ByteSpan ssid, ByteSpan credentials, MutableCharSpan & outDebugText, uint8_t & outNetworkIndex) override; void ScanNetworks(ByteSpan ssid, ScanCallback * callback) override; - CHIP_ERROR GetSupportedWiFiBands(Span & bands) override; + uint32_t GetSupportedWiFiBandsMask() const override; static NrfWiFiDriver & Instance() { diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index a69442a3e058a9..fcffb2ec55a525 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -46111,7 +46111,7 @@ class Test_TC_CNET_1_3 : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); } VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); From a4612073703b81a826b4f1600376c5a289676d2f Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Tue, 16 Jan 2024 16:01:12 +0530 Subject: [PATCH 3/5] [ESP32] Implement GetSupportedWiFiBandsMask() API (#31437) --- src/platform/ESP32/NetworkCommissioningDriver.cpp | 6 ++++++ src/platform/ESP32/NetworkCommissioningDriver.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/platform/ESP32/NetworkCommissioningDriver.cpp b/src/platform/ESP32/NetworkCommissioningDriver.cpp index 80e54d74803e7e..2871c4c3f2031d 100644 --- a/src/platform/ESP32/NetworkCommissioningDriver.cpp +++ b/src/platform/ESP32/NetworkCommissioningDriver.cpp @@ -433,6 +433,12 @@ void ESPWiFiDriver::ScanNetworks(ByteSpan ssid, WiFiDriver::ScanCallback * callb } } +uint32_t ESPWiFiDriver::GetSupportedWiFiBandsMask() const +{ + uint32_t bands = static_cast(1UL << chip::to_underlying(WiFiBandEnum::k2g4)); + return bands; +} + CHIP_ERROR ESPWiFiDriver::SetLastDisconnectReason(const ChipDeviceEvent * event) { VerifyOrReturnError(event->Type == DeviceEventType::kESPSystemEvent && event->Platform.ESPSystemEvent.Base == WIFI_EVENT && diff --git a/src/platform/ESP32/NetworkCommissioningDriver.h b/src/platform/ESP32/NetworkCommissioningDriver.h index 5a2ca8f44d61c1..447d6346dcbd1c 100644 --- a/src/platform/ESP32/NetworkCommissioningDriver.h +++ b/src/platform/ESP32/NetworkCommissioningDriver.h @@ -112,6 +112,7 @@ class ESPWiFiDriver final : public WiFiDriver Status AddOrUpdateNetwork(ByteSpan ssid, ByteSpan credentials, MutableCharSpan & outDebugText, uint8_t & outNetworkIndex) override; void ScanNetworks(ByteSpan ssid, ScanCallback * callback) override; + uint32_t GetSupportedWiFiBandsMask() const override; CHIP_ERROR ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, const char * key, uint8_t keyLen); void OnConnectWiFiNetwork(); From 943b870f7270992a1c404596a4afe98e6581cce7 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 16 Jan 2024 06:58:13 -0500 Subject: [PATCH 4/5] [Telink] Remove define of CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER. (#31390) * Remove define of CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER. This define should not be at a platform level and should only be pulled in via dependencies. * [Telink] Fix build * [Telink] Remove CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER from all CMake files * [Telink] Needs BOOTLOADER_MCUBOOT for DFU without Matter OTA --------- Co-authored-by: Andrii Bilynskyi Co-authored-by: Alex Tsitsiura --- config/telink/chip-module/CMakeLists.txt | 1 - .../air-quality-sensor-app/telink/CMakeLists.txt | 8 ++++---- examples/all-clusters-app/telink/CMakeLists.txt | 8 ++++---- .../all-clusters-minimal-app/telink/CMakeLists.txt | 8 ++++---- examples/bridge-app/telink/CMakeLists.txt | 9 ++++----- examples/chef/telink/CMakeLists.txt | 8 ++++---- examples/contact-sensor-app/telink/CMakeLists.txt | 8 ++++---- examples/light-switch-app/telink/CMakeLists.txt | 8 ++++---- examples/lighting-app/telink/CMakeLists.txt | 8 ++++---- examples/lock-app/telink/CMakeLists.txt | 8 ++++---- examples/ota-requestor-app/telink/CMakeLists.txt | 8 ++++---- .../platform/telink/common/src/AppTaskCommon.cpp | 12 ++++++++++++ .../platform/telink/util/include}/OTAUtil.h | 0 .../platform/telink/util/src}/OTAUtil.cpp | 0 examples/pump-app/telink/CMakeLists.txt | 8 ++++---- examples/pump-controller-app/telink/CMakeLists.txt | 8 ++++---- examples/shell/telink/CMakeLists.txt | 8 ++++---- examples/smoke-co-alarm-app/telink/CMakeLists.txt | 8 ++++---- .../telink/CMakeLists.txt | 8 ++++---- examples/thermostat/telink/CMakeLists.txt | 8 ++++---- examples/window-app/telink/CMakeLists.txt | 8 ++++---- src/platform/telink/BLEManagerImpl.h | 7 ------- src/platform/telink/BUILD.gn | 9 --------- src/platform/telink/args.gni | 3 --- 24 files changed, 80 insertions(+), 89 deletions(-) rename {src/platform/telink => examples/platform/telink/util/include}/OTAUtil.h (100%) rename {src/platform/telink => examples/platform/telink/util/src}/OTAUtil.cpp (100%) diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index f9f4b933cccf5d..418dbc07e0ba0b 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -97,7 +97,6 @@ matter_add_gn_arg_bool ("chip_config_network_layer_ble" CONFIG_BT) matter_add_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_NET_IPV4) matter_add_gn_arg_bool ("chip_enable_nfc" CONFIG_CHIP_NFC_COMMISSIONING) matter_add_gn_arg_bool ("chip_enable_ota_requestor" CONFIG_CHIP_OTA_REQUESTOR) -matter_add_gn_arg_bool ("chip_enable_bootloader_mcuboot" CONFIG_BOOTLOADER_MCUBOOT) matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS) matter_add_gn_arg_bool ("chip_error_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 1) matter_add_gn_arg_bool ("chip_progress_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 3) diff --git a/examples/air-quality-sensor-app/telink/CMakeLists.txt b/examples/air-quality-sensor-app/telink/CMakeLists.txt index 908bea9eb73a98..5ed8c314f1b334 100644 --- a/examples/air-quality-sensor-app/telink/CMakeLists.txt +++ b/examples/air-quality-sensor-app/telink/CMakeLists.txt @@ -86,10 +86,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/util/include ${CHIP_ROOT}/examples/air-quality-sensor-app/air-quality-sensor-common/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp src/ZclCallbacks.cpp @@ -107,3 +103,7 @@ chip_configure_data_model(app INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../air-quality-sensor-common/air-quality-sensor-app.zap ) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/all-clusters-app/telink/CMakeLists.txt b/examples/all-clusters-app/telink/CMakeLists.txt index 7448fd76c4d91f..3571869e8949aa 100644 --- a/examples/all-clusters-app/telink/CMakeLists.txt +++ b/examples/all-clusters-app/telink/CMakeLists.txt @@ -72,10 +72,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/common/include ${TELINK_COMMON}/util/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/smco-stub.cpp @@ -101,3 +97,7 @@ chip_configure_data_model(app INCLUDE_SERVER ZAP_FILE ${ALL_CLUSTERS_COMMON_DIR}/all-clusters-app.zap ) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/all-clusters-minimal-app/telink/CMakeLists.txt b/examples/all-clusters-minimal-app/telink/CMakeLists.txt index a7bb51ba0e67fe..a68471e379a842 100644 --- a/examples/all-clusters-minimal-app/telink/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/telink/CMakeLists.txt @@ -70,10 +70,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/common/include ${TELINK_COMMON}/util/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/smco-stub.cpp @@ -90,3 +86,7 @@ chip_configure_data_model(app INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../all-clusters-common/all-clusters-minimal-app.zap ) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/bridge-app/telink/CMakeLists.txt b/examples/bridge-app/telink/CMakeLists.txt index 1b65dc3bf543e7..f4da959953def8 100644 --- a/examples/bridge-app/telink/CMakeLists.txt +++ b/examples/bridge-app/telink/CMakeLists.txt @@ -69,11 +69,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/util/include ${TELINK_COMMON}/app/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" - -DCHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT=16 -) - target_sources(app PRIVATE src/AppTask.cpp src/ZclCallbacks.cpp @@ -90,3 +85,7 @@ chip_configure_data_model(app INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../bridge-common/bridge-app.zap ) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/chef/telink/CMakeLists.txt b/examples/chef/telink/CMakeLists.txt index 7722f26a11d96e..5d30d424ea3dfd 100755 --- a/examples/chef/telink/CMakeLists.txt +++ b/examples/chef/telink/CMakeLists.txt @@ -92,10 +92,6 @@ if (CONFIG_CHIP_LIB_SHELL) ) endif() -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp ${TELINK_COMMON}/common/src/mainCommon.cpp @@ -113,6 +109,10 @@ chip_configure_data_model(app ZAP_FILE ${CHEF}/devices/${SAMPLE_NAME}.zap ) +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() + if (CONFIG_CHIP_PW_RPC) # Make all targets created below depend on zephyr_interface to inherit MCU-related compilation flags diff --git a/examples/contact-sensor-app/telink/CMakeLists.txt b/examples/contact-sensor-app/telink/CMakeLists.txt index 128d7afbf89744..c29ef949914036 100755 --- a/examples/contact-sensor-app/telink/CMakeLists.txt +++ b/examples/contact-sensor-app/telink/CMakeLists.txt @@ -68,10 +68,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/common/include ${TELINK_COMMON}/util/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp src/ContactSensorManager.cpp @@ -87,3 +83,7 @@ chip_configure_data_model(app INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../contact-sensor-common/contact-sensor-app.zap ) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/light-switch-app/telink/CMakeLists.txt b/examples/light-switch-app/telink/CMakeLists.txt index dd2bfed8dae203..5dd8720ce8d59f 100755 --- a/examples/light-switch-app/telink/CMakeLists.txt +++ b/examples/light-switch-app/telink/CMakeLists.txt @@ -69,10 +69,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/util/include ${TELINK_COMMON}/app/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp src/ZclCallbacks.cpp @@ -89,6 +85,10 @@ chip_configure_data_model(app ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../light-switch-common/light-switch-app.zap ) +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() + # Fix for unused swap parameter in: zephyr/include/zephyr/arch/riscv/irq.h:70 add_compile_options(-Wno-error=unused-parameter) diff --git a/examples/lighting-app/telink/CMakeLists.txt b/examples/lighting-app/telink/CMakeLists.txt index 2a7e46fc3d8076..2017d797558eb6 100644 --- a/examples/lighting-app/telink/CMakeLists.txt +++ b/examples/lighting-app/telink/CMakeLists.txt @@ -101,10 +101,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/util/include ${TELINK_COMMON}/app/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp src/ZclCallbacks.cpp @@ -122,6 +118,10 @@ chip_configure_data_model(app ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../lighting-common/lighting-app.zap ) +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() + # Fix for unused swap parameter in: zephyr/include/zephyr/arch/riscv/irq.h:70 add_compile_options(-Wno-error=unused-parameter) diff --git a/examples/lock-app/telink/CMakeLists.txt b/examples/lock-app/telink/CMakeLists.txt index 70ac496507afe7..58a9e4fb5bab8f 100755 --- a/examples/lock-app/telink/CMakeLists.txt +++ b/examples/lock-app/telink/CMakeLists.txt @@ -69,10 +69,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/util/include ${TELINK_COMMON}/app/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp src/ZclCallbacks.cpp @@ -89,3 +85,7 @@ chip_configure_data_model(app INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../lock-common/lock-app.zap ) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/ota-requestor-app/telink/CMakeLists.txt b/examples/ota-requestor-app/telink/CMakeLists.txt index 81c559cfa73127..31be460d8a346c 100644 --- a/examples/ota-requestor-app/telink/CMakeLists.txt +++ b/examples/ota-requestor-app/telink/CMakeLists.txt @@ -69,10 +69,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/util/include ${TELINK_COMMON}/app/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp src/ZclCallbacks.cpp @@ -87,3 +83,7 @@ chip_configure_data_model(app INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../ota-requestor-common/ota-requestor-app.zap ) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index 1ba800e5e1bcf0..a77f4363df65f5 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -30,6 +30,10 @@ #include #include +#if CONFIG_BOOTLOADER_MCUBOOT +#include +#endif + #if CONFIG_CHIP_OTA_REQUESTOR #include #endif @@ -246,6 +250,14 @@ CHIP_ERROR AppTaskCommon::StartApp(void) StartThreadButtonEventHandler(); #endif +#ifdef CONFIG_BOOTLOADER_MCUBOOT + if (!chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned()) + { + LOG_INF("Confirm image."); + OtaConfirmNewImage(); + } +#endif /* CONFIG_BOOTLOADER_MCUBOOT */ + while (true) { GetEvent(&event); diff --git a/src/platform/telink/OTAUtil.h b/examples/platform/telink/util/include/OTAUtil.h similarity index 100% rename from src/platform/telink/OTAUtil.h rename to examples/platform/telink/util/include/OTAUtil.h diff --git a/src/platform/telink/OTAUtil.cpp b/examples/platform/telink/util/src/OTAUtil.cpp similarity index 100% rename from src/platform/telink/OTAUtil.cpp rename to examples/platform/telink/util/src/OTAUtil.cpp diff --git a/examples/pump-app/telink/CMakeLists.txt b/examples/pump-app/telink/CMakeLists.txt index 8d42d5f79762c5..5c3ad5d3d3f41e 100755 --- a/examples/pump-app/telink/CMakeLists.txt +++ b/examples/pump-app/telink/CMakeLists.txt @@ -69,10 +69,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/util/include ${TELINK_COMMON}/app/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp src/PumpManager.cpp @@ -87,3 +83,7 @@ chip_configure_data_model(app INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../pump-common/pump-app.zap ) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/pump-controller-app/telink/CMakeLists.txt b/examples/pump-controller-app/telink/CMakeLists.txt index dca66f8dd31702..684bb89776eed5 100755 --- a/examples/pump-controller-app/telink/CMakeLists.txt +++ b/examples/pump-controller-app/telink/CMakeLists.txt @@ -69,10 +69,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/util/include ${TELINK_COMMON}/app/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp src/PumpManager.cpp @@ -87,3 +83,7 @@ chip_configure_data_model(app INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../pump-controller-common/pump-controller-app.zap ) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/shell/telink/CMakeLists.txt b/examples/shell/telink/CMakeLists.txt index 0bd2d490411bec..c5cb3eb65be136 100755 --- a/examples/shell/telink/CMakeLists.txt +++ b/examples/shell/telink/CMakeLists.txt @@ -66,12 +66,12 @@ target_include_directories(app PRIVATE ${GEN_DIR}/app-common ${APP_ROOT}/shell_common/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE ${APP_ROOT}/shell_common/globals.cpp ${APP_ROOT}/shell_common/cmd_misc.cpp ${APP_ROOT}/shell_common/cmd_otcli.cpp ${APP_ROOT}/standalone/main.cpp) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/smoke-co-alarm-app/telink/CMakeLists.txt b/examples/smoke-co-alarm-app/telink/CMakeLists.txt index e916aa52f9425b..96cb66c2ac19e7 100755 --- a/examples/smoke-co-alarm-app/telink/CMakeLists.txt +++ b/examples/smoke-co-alarm-app/telink/CMakeLists.txt @@ -68,10 +68,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/common/include ${TELINK_COMMON}/util/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp src/SmokeCoAlarmManager.cpp @@ -87,3 +83,7 @@ chip_configure_data_model(app INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../smoke-co-alarm-common/smoke-co-alarm-app.zap ) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/temperature-measurement-app/telink/CMakeLists.txt b/examples/temperature-measurement-app/telink/CMakeLists.txt index e409b2e2bc59de..fe847592ed985f 100644 --- a/examples/temperature-measurement-app/telink/CMakeLists.txt +++ b/examples/temperature-measurement-app/telink/CMakeLists.txt @@ -85,10 +85,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/app/include ) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp ${TELINK_COMMON}/common/src/mainCommon.cpp @@ -104,3 +100,7 @@ chip_configure_data_model(app INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../temperature-measurement-common/temperature-measurement.zap ) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/thermostat/telink/CMakeLists.txt b/examples/thermostat/telink/CMakeLists.txt index 71f14895b28a55..d46ba248bd77bc 100755 --- a/examples/thermostat/telink/CMakeLists.txt +++ b/examples/thermostat/telink/CMakeLists.txt @@ -84,10 +84,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/util/include ${TELINK_COMMON}/app/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp src/TemperatureManager.cpp @@ -105,3 +101,7 @@ chip_configure_data_model(app INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../thermostat-common/thermostat.zap ) + +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/window-app/telink/CMakeLists.txt b/examples/window-app/telink/CMakeLists.txt index 781e487c9a4ff6..629a0a06779dcc 100644 --- a/examples/window-app/telink/CMakeLists.txt +++ b/examples/window-app/telink/CMakeLists.txt @@ -69,10 +69,6 @@ target_include_directories(app PRIVATE ${TELINK_COMMON}/util/include ${TELINK_COMMON}/app/include) -add_definitions( - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" -) - target_sources(app PRIVATE src/AppTask.cpp src/ZclCallbacks.cpp @@ -90,6 +86,10 @@ chip_configure_data_model(app ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../common/window-app.zap ) +if(CONFIG_BOOTLOADER_MCUBOOT) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() + # Fix for unused swap parameter in: zephyr/include/zephyr/arch/riscv/irq.h:70 add_compile_options(-Wno-error=unused-parameter) diff --git a/src/platform/telink/BLEManagerImpl.h b/src/platform/telink/BLEManagerImpl.h index 63e501eadaae7a..1e1c4c94d67638 100644 --- a/src/platform/telink/BLEManagerImpl.h +++ b/src/platform/telink/BLEManagerImpl.h @@ -33,10 +33,6 @@ #include #include -#ifdef CONFIG_BOOTLOADER_MCUBOOT -#include "OTAUtil.h" -#endif /* CONFIG_BOOTLOADER_MCUBOOT */ - namespace chip { namespace DeviceLayer { namespace Internal { @@ -186,9 +182,6 @@ class InternalScanCallback : public DeviceLayer::NetworkCommissioning::ThreadDri NetworkCommissioning::ThreadScanResponseIterator * networks) { mBLEManagerImpl->StartAdvertisingProcess(); -#ifdef CONFIG_BOOTLOADER_MCUBOOT - OtaConfirmNewImage(); -#endif /* CONFIG_BOOTLOADER_MCUBOOT */ }; private: diff --git a/src/platform/telink/BUILD.gn b/src/platform/telink/BUILD.gn index ec645d1773ce9f..5561fb4e906ac9 100644 --- a/src/platform/telink/BUILD.gn +++ b/src/platform/telink/BUILD.gn @@ -60,8 +60,6 @@ static_library("telink") { public_deps = [ "${chip_root}/src/platform:platform_base" ] deps = [ "${chip_root}/src/platform/logging:headers" ] - defines = [ "CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" ] - if (chip_enable_factory_data) { sources += [ "FactoryDataParser.c", @@ -94,11 +92,4 @@ static_library("telink") { "OTAImageProcessorImpl.h", ] } - - if (chip_enable_bootloader_mcuboot) { - sources += [ - "OTAUtil.cpp", - "OTAUtil.h", - ] - } } diff --git a/src/platform/telink/args.gni b/src/platform/telink/args.gni index 82197d9cecdbd4..8a0a79b3a59761 100644 --- a/src/platform/telink/args.gni +++ b/src/platform/telink/args.gni @@ -19,7 +19,4 @@ chip_inet_config_enable_ipv4 = false declare_args() { # Enable factory data support chip_enable_factory_data = false - - # Enable Zephyr application to be booted by MCUboot - chip_enable_bootloader_mcuboot = false } From f358e9023eeff73d8cc86b8e65709b314fe948dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Josefsen?= <69624991+ReneJosefsen@users.noreply.github.com> Date: Tue, 16 Jan 2024 14:06:57 +0100 Subject: [PATCH 5/5] Update and add additional BOOLCFG test scripts (#31105) * Rename and update 2.1 * Added 3.1 test script * Fix restyle * Added BOOLCFG_1_1 YAML test * Fix restyle * Fix restyle2 * Fix restyle3 * Fixed BOOLCFG YAML * Fix restyle * Fix restyle2 * Restyle * Added BOOLCFG 4.1 test script * Additional test scripts and minor fixes * Added missing step descriptions in 4.3 * Minor read function rename * Minor adjustment to 4.2 step 3d * Added 4.4 test script * Remove print from test script * Adjusted test step id * Adding 5.1 test script * Fix wrong test step description for 5.1 * Adding 5.2 test script * Remove unused import * Adjusted variable name and test step * Added test event trigger for 4.2 * Adding test event triggers for 4.3 * Adding test event triggers for 4.4 * Adding test event triggers for 5.1 * Adding test event triggers for 5.2 and fixed step description * Apply suggestions from code review Co-authored-by: C Freeman * Remove debug code * Converted test skipping to for loop * Updated 2.1 based on review comments * Remove unused variable declaration in 3.1 * Remove unused variable declaration in 4.1 * Restyle * Adjustment to 1.1 test based on latest spec * Added BOOLCFG PICS to ci-pics-values * Added BOOLCFG to PICS.yaml * Fixed invalid PICS --------- Co-authored-by: C Freeman --- src/app/tests/suites/certification/PICS.yaml | 66 ++++ .../certification/Test_TC_BOOLCFG_1_1.yaml | 292 ++++++++++++++++++ .../tests/suites/certification/ci-pics-values | 18 ++ .../python/chip/clusters/__init__.py | 2 +- src/python_testing/TC_BOOLCFG_2_1.py | 134 ++++++++ src/python_testing/TC_BOOLCFG_3_1.py | 135 ++++++++ src/python_testing/TC_BOOLCFG_4_1.py | 101 ++++++ src/python_testing/TC_BOOLCFG_4_2.py | 176 +++++++++++ src/python_testing/TC_BOOLCFG_4_3.py | 285 +++++++++++++++++ src/python_testing/TC_BOOLCFG_4_4.py | 207 +++++++++++++ src/python_testing/TC_BOOLCFG_5_1.py | 177 +++++++++++ src/python_testing/TC_BOOLCFG_5_2.py | 170 ++++++++++ src/python_testing/TC_BSENCFG_2_1.py | 72 ----- 13 files changed, 1762 insertions(+), 73 deletions(-) create mode 100644 src/app/tests/suites/certification/Test_TC_BOOLCFG_1_1.yaml create mode 100644 src/python_testing/TC_BOOLCFG_2_1.py create mode 100644 src/python_testing/TC_BOOLCFG_3_1.py create mode 100644 src/python_testing/TC_BOOLCFG_4_1.py create mode 100644 src/python_testing/TC_BOOLCFG_4_2.py create mode 100644 src/python_testing/TC_BOOLCFG_4_3.py create mode 100644 src/python_testing/TC_BOOLCFG_4_4.py create mode 100644 src/python_testing/TC_BOOLCFG_5_1.py create mode 100644 src/python_testing/TC_BOOLCFG_5_2.py delete mode 100644 src/python_testing/TC_BSENCFG_2_1.py diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index dd68224dc4cb68..7e67a7027b7443 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -9355,3 +9355,69 @@ PICS: - label: "Does the device implement sending the Resume command?" id: RVCOPSTATE.C.C04.Tx + + # + #Boolean State Configuration + # + - label: + "Does the device implement the Boolean State Configuration cluster as + a server?" + id: BOOLCFG.S + + #Features + - label: "Does the device support visual alarms?" + id: BOOLCFG.S.F00 + + - label: "Does the device support audible alarms??" + id: BOOLCFG.S.F01 + + - label: + "Does the device support the ability to suppress or acknowledge + alarms?" + id: BOOLCFG.S.F02 + + - label: + "Does the device support the ability to set level of threshold + detection sensitivity?" + id: BOOLCFG.S.F03 + + #Attributes + - label: "Does the device implement the CurrentSensitivityLevel attribute?" + id: BOOLCFG.S.A0000 + + - label: + "Does the device implement the SupportedSensitivityLevels attribute?" + id: BOOLCFG.S.A0001 + + - label: "Does the device implement the DefaultSensitivityLevel attribute?" + id: BOOLCFG.S.A0002 + + - label: "Does the device implement the AlarmsActive attribute?" + id: BOOLCFG.S.A0003 + + - label: "Does the device implement the AlarmsSuppressed attribute?" + id: BOOLCFG.S.A0004 + + - label: "Does the device implement the AlarmsEnabled attribute?" + id: BOOLCFG.S.A0005 + + - label: "Does the device implement the AlarmsSupported attribute?" + id: BOOLCFG.S.A0006 + + - label: "Does the device implement the SensorFault attribute?" + id: BOOLCFG.S.A0007 + + #Commands received + - label: "Does the device implement receiving the SuppressAlarm command?" + id: BOOLCFG.S.C00.Rsp + + - label: + "Does the device implement receiving the EnableDisableAlarm command?" + id: BOOLCFG.S.C01.Rsp + + #Events + - label: "Does the device implement the AlarmsStateChanged event?" + id: BOOLCFG.S.E00 + + - label: "Does the device implement the SensorFault event?" + id: BOOLCFG.S.E01 diff --git a/src/app/tests/suites/certification/Test_TC_BOOLCFG_1_1.yaml b/src/app/tests/suites/certification/Test_TC_BOOLCFG_1_1.yaml new file mode 100644 index 00000000000000..d8294f379d108a --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_BOOLCFG_1_1.yaml @@ -0,0 +1,292 @@ +# 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. + +name: 69.1.1. [TC-BOOLCFG-1.1] Global attributes with server as DUT + +PICS: + - BOOLCFG.S + +config: + nodeId: 0x12344321 + cluster: "Boolean State Configuration" + endpoint: 1 + +tests: + - label: "Step 1: Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: "Step 2: Read the global attribute: ClusterRevision" + command: "readAttribute" + attribute: "ClusterRevision" + response: + value: 1 + constraints: + type: int16u + + - label: "Step 3a: Read the global attribute: FeatureMap" + command: "readAttribute" + attribute: "FeatureMap" + PICS: + ( !BOOLCFG.S.F00 && !BOOLCFG.S.F01 && !BOOLCFG.S.F02 && !BOOLCFG.S.F03 + ) + response: + value: 0 + constraints: + type: bitmap32 + + - label: + "Step 3b: Given BOOLCFG.S.F00(VIS) ensure featuremap has the correct + bit set" + command: "readAttribute" + attribute: "FeatureMap" + PICS: BOOLCFG.S.F00 + response: + constraints: + type: bitmap32 + hasMasksSet: [0x1] + + - label: + "Step 3c: Given BOOLCFG.S.F01(AUD) ensure featuremap has the correct + bit set" + command: "readAttribute" + attribute: "FeatureMap" + PICS: BOOLCFG.S.F01 + response: + constraints: + type: bitmap32 + hasMasksSet: [0x2] + + - label: + "Step 3d: Given BOOLCFG.S.F02(SPRS) ensure featuremap has the correct + bit set" + command: "readAttribute" + attribute: "FeatureMap" + PICS: BOOLCFG.S.F02 + response: + constraints: + type: bitmap32 + hasMasksSet: [0x4] + + - label: + "Step 3d: Given BOOLCFG.S.F03(SENSLVL) ensure featuremap has the + correct bit set" + command: "readAttribute" + attribute: "FeatureMap" + PICS: BOOLCFG.S.F03 + response: + constraints: + type: bitmap32 + hasMasksSet: [0x8] + + - label: "Step 4a: Read the global attribute: AttributeList" + PICS: PICS_EVENT_LIST_ENABLED + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [65528, 65529, 65530, 65531, 65532, 65533] + + - label: "Step 4a: Read the global attribute: AttributeList" + PICS: "!PICS_EVENT_LIST_ENABLED" + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [65528, 65529, 65531, 65532, 65533] + + - label: + "Step 4b: Read the feature dependent(BOOLCFG.S.F00) attribute in + AttributeList" + PICS: BOOLCFG.S.F00 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [3, 6] + + - label: + "Step 4c: Read the feature dependent(BOOLCFG.S.F00) optional attribute + in AttributeList" + PICS: BOOLCFG.S.F00 && BOOLCFG.S.A0005 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [5] + + - label: + "Step 4d: Read the feature dependent(BOOLCFG.S.F01) attribute in + AttributeList" + PICS: BOOLCFG.S.F01 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [3, 6] + + - label: + "Step 4e: Read the feature dependent(BOOLCFG.S.F01) optional attribute + in AttributeList" + PICS: BOOLCFG.S.F01 && BOOLCFG.S.A0005 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [5] + + - label: + "Step 4f: Read the feature dependent(BOOLCFG.S.F02) attribute in + AttributeList" + PICS: BOOLCFG.S.F02 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [4] + + - label: + "Step 4g: Read the feature dependent(BOOLCFG.S.F03) attribute in + AttributeList" + PICS: BOOLCFG.S.F03 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [0, 1] + + - label: + "Step 4h: Read the feature dependent(BOOLCFG.S.F03) optional attribute + in AttributeList" + PICS: BOOLCFG.S.F03 && BOOLCFG.S.A0002 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [2] + + - label: + "Step 4i: TH reads optional (SensorFault) attribute in AttributeList" + PICS: BOOLCFG.S.A0007 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [7] + + - label: "Step 5a: Read the global attribute: EventList" + PICS: + PICS_EVENT_LIST_ENABLED && !BOOLCFG.S.F00 && !BOOLCFG.S.F01 && + !BOOLCFG.S.E01 + command: "readAttribute" + attribute: "EventList" + response: + value: [] + constraints: + type: list + + - label: + "Step 5b: Read the feature dependent(BOOLCFG.S.F00) + (AlarmsStateChanged) event in EventList" + PICS: PICS_EVENT_LIST_ENABLED && BOOLCFG.S.F00 + command: "readAttribute" + attribute: "EventList" + response: + constraints: + type: list + contains: [0] + + - label: + "Step 5c: Read the feature dependent(BOOLCFG.S.F01) + (AlarmsStateChanged) event in EventList" + PICS: PICS_EVENT_LIST_ENABLED && BOOLCFG.S.F01 + command: "readAttribute" + attribute: "EventList" + response: + constraints: + type: list + contains: [0] + + - label: "Step 5d: Read the optional (SensorFault) event in EventList" + PICS: PICS_EVENT_LIST_ENABLED && BOOLCFG.S.E01 + command: "readAttribute" + attribute: "EventList" + response: + constraints: + type: list + contains: [1] + + - label: "Step 6a: Read the global attribute: AcceptedCommandList" + PICS: ( !BOOLCFG.S.F00 && !BOOLCFG.S.F01 && !BOOLCFG.S.F02 ) + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + value: [] + constraints: + type: list + + - label: + "Step 6b: Read the feature dependent(BOOLCFG.S.F02) (SuppressAlarm) + command in AcceptedCommandList" + PICS: BOOLCFG.S.F02 + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [0] + + - label: + "Step 6c: Read the feature dependent(BOOLCFG.S.F00) + (EnableDisableAlarm) command in AcceptedCommandList" + PICS: BOOLCFG.S.F00 + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [1] + + - label: + "Step 6d: Read the feature dependent(BOOLCFG.S.F01) + (EnableDisableAlarm) command in AcceptedCommandList" + PICS: BOOLCFG.S.F01 + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [1] + + - label: "Step 7: Read the global attribute: GeneratedCommandList" + command: "readAttribute" + attribute: "GeneratedCommandList" + response: + value: [] + constraints: + type: list diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 86fb9fb792b2fa..079781a0c2d59e 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -2655,3 +2655,21 @@ REFALM.S.A0003=1 REFALM.S.E00=1 REFALM.S.C00.Rsp=1 REFALM.S.C01.Rsp=1 + +BOOLCFG.S=1 +BOOLCFG.S.F00=1 +BOOLCFG.S.F01=1 +BOOLCFG.S.F02=1 +BOOLCFG.S.F03=1 +BOOLCFG.S.A0000=1 +BOOLCFG.S.A0001=1 +BOOLCFG.S.A0002=1 +BOOLCFG.S.A0003=1 +BOOLCFG.S.A0004=1 +BOOLCFG.S.A0005=1 +BOOLCFG.S.A0006=1 +BOOLCFG.S.A0007=1 +BOOLCFG.S.E00=1 +BOOLCFG.S.E01=1 +BOOLCFG.S.C00.Rsp=1 +BOOLCFG.S.C01.Rsp=1 diff --git a/src/controller/python/chip/clusters/__init__.py b/src/controller/python/chip/clusters/__init__.py index 89e9107d7398f6..7f17d80b9391e6 100644 --- a/src/controller/python/chip/clusters/__init__.py +++ b/src/controller/python/chip/clusters/__init__.py @@ -48,7 +48,7 @@ __all__ = [Attribute, CHIPClusters, Command, AccessControl, AccountLogin, Actions, ActivatedCarbonFilterMonitoring, AdministratorCommissioning, AirQuality, ApplicationBasic, ApplicationLauncher, AudioOutput, BallastConfiguration, BarrierControl, BasicInformation, - BinaryInputBasic, Binding, BooleanStateConfiguration, BooleanState, BridgedDeviceBasicInformation, CarbonDioxideConcentrationMeasurement, + BinaryInputBasic, Binding, BooleanState, BooleanStateConfiguration, BridgedDeviceBasicInformation, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, Channel, ColorControl, ContentLauncher, Descriptor, DeviceEnergyManagement, DiagnosticLogs, DishwasherAlarm, DishwasherMode, DoorLock, ElectricalMeasurement, EnergyEvse, EthernetNetworkDiagnostics, FanControl, FaultInjection, FixedLabel, FlowMeasurement, diff --git a/src/python_testing/TC_BOOLCFG_2_1.py b/src/python_testing/TC_BOOLCFG_2_1.py new file mode 100644 index 00000000000000..d6ed97540056db --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_2_1.py @@ -0,0 +1,134 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import functools +import logging +from operator import ior + +import chip.clusters as Clusters +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_BOOLCFG_2_1(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_2_1(self) -> str: + return "[TC-BOOLCFG-2.1] Attributes with DUT as Server" + + def steps_TC_BOOLCFG_2_1(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Read attribute list to determine supported attributes"), + TestStep(3, "Read SupportedSensitivityLevels attribute, if supported"), + TestStep(4, "Read CurrentSensitivityLevel attribute, if supported"), + TestStep(5, "Read DefaultSensitivityLevel attribute, if supported"), + TestStep(6, "Read AlarmsActive attribute, if supported"), + TestStep(7, "Read AlarmsSuppressed attribute, if supported"), + TestStep(8, "Read AlarmsEnabled attribute, if supported"), + TestStep(9, "Read AlarmsSupported attribute, if supported"), + TestStep(10, "Read SensorFault attribute, if supported"), + ] + return steps + + def pics_TC_BOOLCFG_2_1(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_2_1(self): + + endpoint = self.user_params.get("endpoint", 1) + all_alarm_mode_bitmap_bits = functools.reduce( + ior, [b.value for b in Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap]) + all_sensor_fault_bitmap_bits = functools.reduce( + ior, [b.value for b in Clusters.BooleanStateConfiguration.Bitmaps.SensorFaultBitmap]) + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step(2) + attribute_list = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + number_of_supported_levels = 0 + + self.step(3) + if attributes.SupportedSensitivityLevels.attribute_id in attribute_list: + number_of_supported_levels = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.SupportedSensitivityLevels) + asserts.assert_less_equal(number_of_supported_levels, 10, "SupportedSensitivityLevels attribute is out of range") + asserts.assert_greater_equal(number_of_supported_levels, 2, "SupportedSensitivityLevels attribute is out of range") + else: + logging.info("Test step skipped") + + self.step(4) + if attributes.CurrentSensitivityLevel.attribute_id in attribute_list: + current_sensitivity_level_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentSensitivityLevel) + asserts.assert_less_equal(current_sensitivity_level_dut, number_of_supported_levels, + "CurrentSensitivityLevel is not in valid range") + else: + logging.info("Test step skipped") + + self.step(5) + if attributes.DefaultSensitivityLevel.attribute_id in attribute_list: + default_sensitivity_level_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.DefaultSensitivityLevel) + asserts.assert_less_equal(default_sensitivity_level_dut, number_of_supported_levels, + "DefaultSensitivityLevel is not in valid range") + else: + logging.info("Test step skipped") + + self.step(6) + if attributes.AlarmsActive.attribute_id in attribute_list: + alarms_active_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(alarms_active_dut & ~all_alarm_mode_bitmap_bits, 0, "AlarmsActive is not in valid range") + else: + logging.info("Test step skipped") + + self.step(7) + if attributes.AlarmsSuppressed.attribute_id in attribute_list: + alarms_suppressed_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSuppressed) + asserts.assert_equal(alarms_suppressed_dut & ~all_alarm_mode_bitmap_bits, 0, "AlarmsSuppressed is not in valid range") + else: + logging.info("Test step skipped") + + self.step(8) + if attributes.AlarmsEnabled.attribute_id in attribute_list: + alarms_enabled_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsEnabled) + asserts.assert_equal(alarms_enabled_dut & ~all_alarm_mode_bitmap_bits, 0, "AlarmsEnabled is not in valid range") + else: + logging.info("Test step skipped") + + self.step(9) + if attributes.AlarmsSupported.attribute_id in attribute_list: + alarms_supported_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSupported) + asserts.assert_equal(alarms_supported_dut & ~all_alarm_mode_bitmap_bits, 0, "AlarmsSupported is not in valid range") + else: + logging.info("Test step skipped") + + self.step(10) + if attributes.SensorFault.attribute_id in attribute_list: + sensor_fault_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.SensorFault) + asserts.assert_equal(sensor_fault_dut & ~all_sensor_fault_bitmap_bits, 0, "SensorFault is not in valid range") + else: + logging.info("Test step skipped") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_3_1.py b/src/python_testing/TC_BOOLCFG_3_1.py new file mode 100644 index 00000000000000..ceeeba33c6ee2d --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_3_1.py @@ -0,0 +1,135 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging +from random import choice + +import chip.clusters as Clusters +from chip.interaction_model import Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_BOOLCFG_3_1(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_3_1(self) -> str: + return "[TC-BOOLCFG-3.1] SensitivityLevel with DUT as Server" + + def steps_TC_BOOLCFG_3_1(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep("2a", "Read FeatureMap attribute"), + TestStep("2b", "Read AttributeList attribute"), + TestStep(3, "Read SupportedSensitivityLevels attribute"), + TestStep(4, "Read DefaultSensitivityLevel attribute, if supported"), + TestStep(5, "Read CurrentSensitivityLevel attribute"), + TestStep(6, "TH loops through the number of supported sensitivity levels"), + TestStep(7, "Write CurrentSensitivityLevel attribute to non-default value"), + TestStep(8, "Write CurrentSensitivityLevel attribute to default value"), + TestStep(9, "Write CurrentSensitivityLevel attribute to 10"), + TestStep(10, "Write CurrentSensitivityLevel attribute to 255"), + TestStep(11, "Write CurrentSensitivityLevel attribute to the initial current value"), + ] + return steps + + def pics_TC_BOOLCFG_3_1(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_3_1(self): + + endpoint = self.user_params.get("endpoint", 1) + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step("2a") + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + self.step("2b") + attribute_list = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + is_sens_level_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kSensitivityLevel + + self.step(3) + if is_sens_level_feature_supported: + numberOfSupportedLevels = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.SupportedSensitivityLevels) + else: + logging.info("Test step skipped") + + default_level = 0 + + self.step(4) + if attributes.DefaultSensitivityLevel.attribute_id in attribute_list: + default_level = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.DefaultSensitivityLevel) + else: + logging.info("Test step skipped") + + current_level = 0 + + self.step(5) + if is_sens_level_feature_supported: + current_level = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentSensitivityLevel) + else: + logging.info("Test step skipped") + + self.step(6) + if is_sens_level_feature_supported: + for sens_level in range(numberOfSupportedLevels): + logging.info(f"Write sensitivity level ({sens_level}) to CurrentSensitivityLevel)") + result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.CurrentSensitivityLevel(sens_level))]) + asserts.assert_equal(result[0].Status, Status.Success, "CurrentSensitivityLevel write failed") + + self.step(7) + if attributes.DefaultSensitivityLevel.attribute_id in attribute_list: + selected_non_default_level = choice([i for i in range(numberOfSupportedLevels) if i not in [default_level]]) + logging.info(f"Write non-default sensitivity level ({selected_non_default_level}) to CurrentSensitivityLevel)") + result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.CurrentSensitivityLevel(selected_non_default_level))]) + asserts.assert_equal(result[0].Status, Status.Success, "CurrentSensitivityLevel write failed") + + self.step(8) + if attributes.DefaultSensitivityLevel.attribute_id in attribute_list: + logging.info(f"Write default sensitivity level ({default_level}) to CurrentSensitivityLevel)") + result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.CurrentSensitivityLevel(default_level))]) + asserts.assert_equal(result[0].Status, Status.Success, "CurrentSensitivityLevel write failed") + + self.step(9) + if is_sens_level_feature_supported: + result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.CurrentSensitivityLevel(numberOfSupportedLevels))]) + asserts.assert_equal(result[0].Status, Status.ConstraintError, + "CurrentSensitivityLevel did not return CONSTRAINT_ERROR") + + self.step(10) + if is_sens_level_feature_supported: + result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.CurrentSensitivityLevel(255))]) + asserts.assert_equal(result[0].Status, Status.ConstraintError, + "CurrentSensitivityLevel did not return CONSTRAINT_ERROR") + + self.step(11) + if is_sens_level_feature_supported: + result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.CurrentSensitivityLevel(current_level))]) + asserts.assert_equal(result[0].Status, Status.Success, "CurrentSensitivityLevel write failed") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_4_1.py b/src/python_testing/TC_BOOLCFG_4_1.py new file mode 100644 index 00000000000000..74f81b7bfd79bd --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_4_1.py @@ -0,0 +1,101 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging + +import chip.clusters as Clusters +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_BOOLCFG_4_1(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_4_1(self) -> str: + return "[TC-BOOLCFG-4.1] AlarmsSupported attribute with DUT as Server" + + def steps_TC_BOOLCFG_4_1(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Read FeatureMap attribute"), + TestStep(3, "Read AlarmsSupported attribute"), + TestStep("4a", "Verify AlarmsSupported attribute bit 0"), + TestStep("4b", "Verify AlarmsSupported attribute bit 0"), + TestStep("5a", "Verify AlarmsSupported attribute bit 1"), + TestStep("5b", "Verify AlarmsSupported attribute bit 1"), + ] + return steps + + def pics_TC_BOOLCFG_4_1(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_4_1(self): + + endpoint = self.user_params.get("endpoint", 1) + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step(2) + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + is_vis_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kVisual + is_aud_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAudible + + self.step(3) + if is_vis_feature_supported or is_aud_feature_supported: + supportedAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSupported) + else: + logging.info("Test step skipped") + + self.step("4a") + if is_vis_feature_supported: + asserts.assert_not_equal((supportedAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), 0, + "Bit 0 in AlarmsSupported does not match feature map value") + else: + logging.info("Test step skipped") + + self.step("4b") + if not is_vis_feature_supported: + asserts.assert_equal((supportedAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), 0, + "Bit 0 in AlarmsSupported does not match feature map value") + else: + logging.info("Test step skipped") + + self.step("5a") + if is_aud_feature_supported: + asserts.assert_not_equal((supportedAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible), 0, + "Bit 1 in AlarmsSupported does not match feature map value") + else: + logging.info("Test step skipped") + + self.step("5b") + if not is_aud_feature_supported: + asserts.assert_equal((supportedAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible), 0, + "Bit 1 in AlarmsSupported does not match feature map value") + else: + logging.info("Test step skipped") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_4_2.py b/src/python_testing/TC_BOOLCFG_4_2.py new file mode 100644 index 00000000000000..06f5ecad6adbad --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_4_2.py @@ -0,0 +1,176 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging + +import chip.clusters as Clusters +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +sensorTrigger = 0x0080_0000_0000_0000 +sensorUntrigger = 0x0080_0000_0000_0001 + + +class TC_BOOLCFG_4_2(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_4_2(self) -> str: + return "[TC-BOOLCFG-4.2] AlarmsActive attribute with DUT as Server" + + def steps_TC_BOOLCFG_4_2(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep("2a", "Read FeatureMap attribute"), + TestStep("2b", "Read AttributeList attribute"), + TestStep("3a", "Create variable named enabledAlarms"), + TestStep("3b", "If VIS is supported, set bit 0 to 1"), + TestStep("3c", "If AUD is supported, set bit 1 to 1"), + TestStep("3d", "Set AlarmsEnabled attribute to value of enabledAlarms using EnableDisableAlarm command"), + TestStep(4, "Send TestEventTrigger with SensorTrigger event"), + TestStep(5, "Read AlarmsActive attribute"), + TestStep("6a", "Verify VIS alarm is active, if supported"), + TestStep("6b", "Verify VIS alarm is not active, if not supported"), + TestStep("7a", "Verify AUD alarm is active, if supported"), + TestStep("7b", "Verify AUD alarm is not active, if not supported"), + TestStep(8, "Send TestEventTrigger with SensorUntrigger event"), + TestStep(9, "Read AlarmsActive attribute"), + ] + return steps + + def pics_TC_BOOLCFG_4_2(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_4_2(self): + + asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, + "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " + "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + + endpoint = self.user_params.get("endpoint", 1) + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step("2a") + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + is_vis_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kVisual + is_aud_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAudible + + self.step("2b") + attribute_list = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + self.step("3a") + enabledAlarms = 0 + + self.step("3b") + if attributes.AlarmsEnabled.attribute_id in attribute_list and is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual + else: + logging.info("Test step skipped") + + self.step("3c") + if attributes.AlarmsEnabled.attribute_id in attribute_list and is_aud_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible + else: + logging.info("Test step skipped") + + self.step("3d") + if attributes.AlarmsEnabled.attribute_id in attribute_list: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(4) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(5) + activeAlarms = 0 + + if is_vis_feature_supported or is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_not_equal(activeAlarms, 0, "AlarmsActive is 0") + else: + logging.info("Test step skipped") + + self.step("6a") + if is_vis_feature_supported: + asserts.assert_not_equal( + (activeAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), 0, "Bit 0 in AlarmsActive is not 1") + else: + logging.info("Test step skipped") + + self.step("6b") + if not is_vis_feature_supported: + asserts.assert_equal((activeAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), + 0, "Bit 0 in AlarmsActive is not 0") + else: + logging.info("Test step skipped") + + self.step("7a") + if is_aud_feature_supported: + asserts.assert_not_equal( + (activeAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible), 0, "Bit 1 in AlarmsActive is not 1") + else: + logging.info("Test step skipped") + + self.step("7b") + if not is_aud_feature_supported: + asserts.assert_equal((activeAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible), + 0, "Bit 1 in AlarmsActive is not 0") + else: + logging.info("Test step skipped") + + self.step(8) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(9) + if is_vis_feature_supported or is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, 0, "AlarmsActive is not 0") + else: + logging.info("Test step skipped") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_4_3.py b/src/python_testing/TC_BOOLCFG_4_3.py new file mode 100644 index 00000000000000..40a44a004a67e5 --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_4_3.py @@ -0,0 +1,285 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging + +import chip.clusters as Clusters +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +sensorTrigger = 0x0080_0000_0000_0000 +sensorUntrigger = 0x0080_0000_0000_0001 + + +class TC_BOOLCFG_4_3(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_4_3(self) -> str: + return "[TC-BOOLCFG-4.3] AlarmsEnabled functionality for inactive alarms with DUT as Server" + + def steps_TC_BOOLCFG_4_3(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep("2a", "Read FeatureMap attribute"), + TestStep("2b", "Read AttributeList attribute"), + TestStep(3, "Verify AlarmsEnabled is supported"), + TestStep(4, "Create enabledAlarms and set to 0"), + TestStep("5a", "Enable VIS alarm in enabledAlarms"), + TestStep("5b", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(6, "Send TestEventTrigger with SensorTrigger event"), + TestStep(7, "Read AlarmsActive attribute"), + TestStep(8, "Send TestEventTrigger with SensorUntrigger event"), + TestStep(9, "Read AlarmsActive attribute"), + TestStep(10, "Set enabledAlarms to 0"), + TestStep(11, "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(12, "Send TestEventTrigger with SensorTrigger event"), + TestStep(13, "Read AlarmsActive attribute"), + TestStep(14, "Send TestEventTrigger with SensorUntrigger event"), + TestStep("15a", "Enable AUD alarm in enabledAlarms"), + TestStep("15b", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(16, "Send TestEventTrigger with SensorTrigger event"), + TestStep(17, "Read AlarmsActive attribute"), + TestStep(18, "Send TestEventTrigger with SensorUntrigger event"), + TestStep(19, "Read AlarmsActive attribute"), + TestStep(20, "Set enabledAlarms to 0"), + TestStep(21, "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(22, "Send TestEventTrigger with SensorTrigger event"), + TestStep(23, "Read AlarmsActive attribute"), + TestStep(24, "Send TestEventTrigger with SensorUntrigger event"), + ] + return steps + + def pics_TC_BOOLCFG_4_3(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_4_3(self): + + asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, + "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " + "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + + endpoint = self.user_params.get("endpoint", 1) + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step("2a") + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + is_vis_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kVisual + is_aud_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAudible + + self.step("2b") + attribute_list = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + self.step(3) + if attributes.AlarmsEnabled.attribute_id not in attribute_list: + logging.info("AlarmsEnabled not supported skipping test case") + + # Skipping all remainig steps + for step in self.get_test_steps(self.current_test_info.name)[self.current_step_index:]: + self.step(step.test_plan_number) + logging.info("Test step skipped") + + return + else: + logging.info("Test step skipped") + + self.step(4) + enabledAlarms = 0 + + self.step("5a") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual + else: + logging.info("Test step skipped") + + self.step("5b") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(6) + if is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(7) + if is_vis_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual, + "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(8) + if is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(9) + if is_vis_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, 0, "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(10) + enabledAlarms = 0 + + self.step(11) + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(12) + if is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(13) + if is_vis_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, 0, "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(14) + if is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step("15a") + if is_aud_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible + else: + logging.info("Test step skipped") + + self.step("15b") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(16) + if is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(17) + if is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible, + "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(18) + if is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(19) + if is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, 0, "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(20) + enabledAlarms = 0 + + self.step(21) + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(22) + if is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(23) + if is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, 0, "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(24) + if is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_4_4.py b/src/python_testing/TC_BOOLCFG_4_4.py new file mode 100644 index 00000000000000..cd76848d59e801 --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_4_4.py @@ -0,0 +1,207 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging + +import chip.clusters as Clusters +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +sensorTrigger = 0x0080_0000_0000_0000 +sensorUntrigger = 0x0080_0000_0000_0001 + + +class TC_BOOLCFG_4_4(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_4_4(self) -> str: + return "[TC-BOOLCFG-4.4] AlarmsEnabled functionality for active alarms with DUT as Server" + + def steps_TC_BOOLCFG_4_4(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep("2a", "Read FeatureMap attribute"), + TestStep("2b", "Read AttributeList attribute"), + TestStep(3, "Verify AlarmsEnabled is supported"), + TestStep(4, "Create enabledAlarms and set to 0"), + TestStep("5a", "Enable VIS alarm in enabledAlarms"), + TestStep("5b", "Enable AUD alarm in enabledAlarms"), + TestStep("5c", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(6, "Send TestEventTrigger with SensorTrigger event"), + TestStep(7, "Read AlarmsActive attribute"), + TestStep(8, "Verify VIS alarm is active"), + TestStep("9a", "Disable VIS alarm in enabledAlarms"), + TestStep("9b", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(10, "Read AlarmsActive attribute"), + TestStep(11, "Verify AUD alarm is active"), + TestStep("12a", "Disable VIS alarm in enabledAlarms"), + TestStep("12b", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(13, "Read AlarmsActive attribute"), + TestStep(14, "Send TestEventTrigger with SensorUntrigger event"), + ] + return steps + + def pics_TC_BOOLCFG_4_4(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_4_4(self): + + asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, + "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " + "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + + endpoint = self.user_params.get("endpoint", 1) + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step("2a") + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + is_vis_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kVisual + is_aud_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAudible + + self.step("2b") + attribute_list = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + self.step(3) + if attributes.AlarmsEnabled.attribute_id not in attribute_list: + logging.info("AlarmsEnabled not supported skipping test case") + + # Skipping all remainig steps + for step in self.get_test_steps(self.current_test_info.name)[self.current_step_index:]: + self.step(step.test_plan_number) + logging.info("Test step skipped") + + return + else: + logging.info("Test step skipped") + + self.step(4) + enabledAlarms = 0 + + self.step("5a") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual + else: + logging.info("Test step skipped") + + self.step("5b") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible + else: + logging.info("Test step skipped") + + self.step("5c") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(6) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(7) + activeAlarms = 0 + + if is_vis_feature_supported or is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_not_equal(activeAlarms, 0, "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(8) + if is_vis_feature_supported: + asserts.assert_not_equal((activeAlarms & 0b01), 0, "Bit 0 in AlarmsActive is not 1") + else: + logging.info("Test step skipped") + + self.step("9a") + if is_vis_feature_supported: + enabledAlarms &= ~(Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual) + else: + logging.info("Test step skipped") + + self.step("9b") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(10) + if is_vis_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal((activeAlarms & 0b01), 0, "Bit 0 in AlarmsActive is not 0") + else: + logging.info("Test step skipped") + + self.step(11) + if is_aud_feature_supported: + asserts.assert_not_equal((activeAlarms & 0b10), 0, "Bit 1 in AlarmsActive is not 1") + else: + logging.info("Test step skipped") + + self.step("12a") + if is_aud_feature_supported: + enabledAlarms &= ~(Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible) + else: + logging.info("Test step skipped") + + self.step("12b") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(13) + if is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal((activeAlarms & 0b10), 0, "Bit 1 in AlarmsActive is not 0") + else: + logging.info("Test step skipped") + + self.step(14) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_5_1.py b/src/python_testing/TC_BOOLCFG_5_1.py new file mode 100644 index 00000000000000..7e7dac0e1e8adf --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_5_1.py @@ -0,0 +1,177 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging + +import chip.clusters as Clusters +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +sensorTrigger = 0x0080_0000_0000_0000 +sensorUntrigger = 0x0080_0000_0000_0001 + + +class TC_BOOLCFG_5_1(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_5_1(self) -> str: + return "[TC-BOOLCFG-5.1] SuppressAlarm functionality for inactive alarms with DUT as Server" + + def steps_TC_BOOLCFG_5_1(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Read FeatureMap attribute"), + TestStep(3, "Verify SPRS feature is supported"), + TestStep(4, "Create enabledAlarms and set to 0"), + TestStep("5a", "Enable VIS alarm in enabledAlarms"), + TestStep("5b", "Enable AUD alarm in enabledAlarms"), + TestStep("5c", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(6, "Send TestEventTrigger with SensorUntrigger event"), + TestStep("7a", "Suppress VIS alarm using SuppressAlarm command"), + TestStep("7b", "Suppress VIS alarm using SuppressAlarm command"), + TestStep(8, "Read AlarmsSuppressed attribute"), + TestStep("9a", "Suppress AUD alarm using SuppressAlarm command"), + TestStep("9b", "Suppress AUD alarm using SuppressAlarm command"), + TestStep(10, "Read AlarmsSuppressed attribute"), + ] + return steps + + def pics_TC_BOOLCFG_5_1(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_5_1(self): + + asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, + "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " + "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + + endpoint = self.user_params.get("endpoint", 1) + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step(2) + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + is_sprs_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAlarmSuppress + is_vis_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kVisual + is_aud_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAudible + + self.step(3) + if not is_sprs_feature_supported: + logging.info("AlarmSuppress feature not supported skipping test case") + + # Skipping all remainig steps + for step in self.get_test_steps(self.current_test_info.name)[self.current_step_index:]: + self.step(step.test_plan_number) + logging.info("Test step skipped") + + return + else: + logging.info("Test step skipped") + + self.step(4) + enabledAlarms = 0 + + self.step("5a") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual + else: + logging.info("Test step skipped") + + self.step("5b") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible + else: + logging.info("Test step skipped") + + self.step("5c") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(6) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step("7a") + if is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.SuppressAlarm(alarmsToSuppress=Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), endpoint=endpoint) + asserts.fail("Received Success response when an INVALID_IN_STATE was expected") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidInState, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step("7b") + if not is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.SuppressAlarm(alarmsToSuppress=Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), endpoint=endpoint) + asserts.fail("Received Success response when an CONSTRAINT_ERROR was expected") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.ConstraintError, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(8) + alarms_suppressed_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSuppressed) + asserts.assert_equal(alarms_suppressed_dut, 0, "AlarmsSuppressed is not the expected value") + + self.step("9a") + if is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.SuppressAlarm(alarmsToSuppress=Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible), endpoint=endpoint) + asserts.fail("Received Success response when an INVALID_IN_STATE was expected") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidInState, "Unexpected error returned") + pass + + self.step("9b") + if not is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.SuppressAlarm(alarmsToSuppress=Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), endpoint=endpoint) + asserts.fail("Received Success response when an CONSTRAINT_ERROR was expected") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.ConstraintError, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(10) + alarms_suppressed_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSuppressed) + asserts.assert_equal(alarms_suppressed_dut, 0, "AlarmsSuppressed is not the expected value") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_5_2.py b/src/python_testing/TC_BOOLCFG_5_2.py new file mode 100644 index 00000000000000..3a4dd41b46bbf0 --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_5_2.py @@ -0,0 +1,170 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging + +import chip.clusters as Clusters +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +sensorTrigger = 0x0080_0000_0000_0000 +sensorUntrigger = 0x0080_0000_0000_0001 + + +class TC_BOOLCFG_5_2(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_5_2(self) -> str: + return "[TC-BOOLCFG-5.2] SuppressAlarm functionality for active alarms with DUT as Server" + + def steps_TC_BOOLCFG_5_2(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Read FeatureMap attribute"), + TestStep(3, "Verify SPRS feature is supported"), + TestStep(4, "Create enabledAlarms and set to 0"), + TestStep("5a", "Enable VIS alarm in enabledAlarms"), + TestStep("5b", "Enable AUD alarm in enabledAlarms"), + TestStep("5c", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(6, "Send TestEventTrigger with SensorTrigger event"), + TestStep(7, "Suppress VIS alarm using SuppressAlarm command"), + TestStep(8, "Read AlarmsSuppressed attribute"), + TestStep(9, "Suppress AUD alarm using SuppressAlarm command"), + TestStep(10, "Read AlarmsActive attribute"), + TestStep(11, "Send TestEventTrigger with SensorUntrigger event") + ] + return steps + + def pics_TC_BOOLCFG_5_2(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_5_2(self): + + asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, + "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " + "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + + endpoint = self.user_params.get("endpoint", 1) + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step(2) + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + is_sprs_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAlarmSuppress + is_vis_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kVisual + is_aud_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAudible + + self.step(3) + if not is_sprs_feature_supported: + logging.info("AlarmSuppress feature not supported skipping test case") + + # Skipping all remainig steps + for step in self.get_test_steps(self.current_test_info.name)[self.current_step_index:]: + self.step(step.test_plan_number) + logging.info("Test step skipped") + + return + else: + logging.info("Test step skipped") + + self.step(4) + enabledAlarms = 0 + + self.step("5a") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual + else: + logging.info("Test step skipped") + + self.step("5b") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible + else: + logging.info("Test step skipped") + + self.step("5c") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(6) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(7) + if is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.SuppressAlarm(alarmsToSuppress=Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(8) + if is_vis_feature_supported: + alarms_suppressed_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSuppressed) + asserts.assert_not_equal((alarms_suppressed_dut & 0b01), 0, "Bit 0 in AlarmsSuppressed is not 1") + else: + logging.info("Test step skipped") + + self.step(9) + if is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.SuppressAlarm(alarmsToSuppress=Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(10) + if is_aud_feature_supported: + alarms_suppressed_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSuppressed) + asserts.assert_not_equal((alarms_suppressed_dut & 0b10), 0, "Bit 1 in AlarmsSuppressed is not 1") + else: + logging.info("Test step skipped") + + self.step(11) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BSENCFG_2_1.py b/src/python_testing/TC_BSENCFG_2_1.py deleted file mode 100644 index 0312b131a77590..00000000000000 --- a/src/python_testing/TC_BSENCFG_2_1.py +++ /dev/null @@ -1,72 +0,0 @@ -# -# Copyright (c) 2023 Project CHIP Authors -# All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import logging - -import chip.clusters as Clusters -from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main -from mobly import asserts - - -class TC_BSENCFG_2_1(MatterBaseTest): - async def read_ts_attribute_expect_success(self, endpoint, attribute): - cluster = Clusters.Objects.BooleanStateConfiguration - return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) - - @async_test_body - async def test_TC_BSENCFG_2_1(self): - - endpoint = self.user_params.get("endpoint", 1) - - self.print_step(1, "Commissioning, already done") - attributes = Clusters.BooleanStateConfiguration.Attributes - - self.print_step(2, "Read attribute list to determine supported attributes") - attribute_list = await self.read_ts_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) - - self.print_step(3, "Read SensitivityLevel attribute, if supported") - if attributes.SensitivityLevel.attribute_id in attribute_list: - sensitivity_level_dut = await self.read_ts_attribute_expect_success(endpoint=endpoint, attribute=attributes.SensitivityLevel) - asserts.assert_less(sensitivity_level_dut, Clusters.Objects.BooleanStateConfiguration.Enums.SensitivityEnum.kUnknownEnumValue, - "SensitivityLevel is not in valid range") - else: - logging.info("Test step skipped") - - self.print_step(4, "Read AlarmsActive attribute, if supported") - if attributes.AlarmsActive.attribute_id in attribute_list: - alarms_active_dut = await self.read_ts_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) - asserts.assert_less_equal(alarms_active_dut, 0b00000011, "AlarmsActive is not in valid range") - else: - logging.info("Test step skipped") - - self.print_step(5, "Read AlarmsSuppressed attribute, if supported") - if attributes.AlarmsSuppressed.attribute_id in attribute_list: - alarms_suppressed_dut = await self.read_ts_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSuppressed) - asserts.assert_less_equal(alarms_suppressed_dut, 0b00000011, "AlarmsSuppressed is not in valid range") - else: - logging.info("Test step skipped") - - self.print_step(5, "Read AlarmsEnabled attribute, if supported") - if attributes.AlarmsEnabled.attribute_id in attribute_list: - alarms_enabled_dut = await self.read_ts_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsEnabled) - asserts.assert_less_equal(alarms_enabled_dut, 0b00000011, "AlarmsEnabled is not in valid range") - else: - logging.info("Test step skipped") - - -if __name__ == "__main__": - default_matter_test_main()