From c8c31e26259dab62f9f77b23549421dc3f0161ef Mon Sep 17 00:00:00 2001 From: srningap <107042150+srningap@users.noreply.github.com> Date: Fri, 21 Apr 2023 18:22:28 +0530 Subject: [PATCH 001/200] [Silabs] WiFi- Addressed build failures with wiseMCU package v1.0.1.4 (#26161) * Adds declarations for 917SoC which causing the build failure with 1.0.1.4 WisemcuSDK * removed a macro redefinition * adding warnings flags back, which removed for 1.0.18 package --- examples/platform/silabs/SiWx917/LEDWidget.h | 4 +++- third_party/silabs/SiWx917_sdk.gni | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/platform/silabs/SiWx917/LEDWidget.h b/examples/platform/silabs/SiWx917/LEDWidget.h index f033cb26c50f64..596f64af094d7a 100644 --- a/examples/platform/silabs/SiWx917/LEDWidget.h +++ b/examples/platform/silabs/SiWx917/LEDWidget.h @@ -19,9 +19,11 @@ #pragma once -#include "rsi_board.h" #include +extern "C" void RSI_Board_LED_Set(int, int); +extern "C" void RSI_Board_LED_Toggle(int); + class LEDWidget { public: diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index 22a24c9fa69215..75d776b720b8fe 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -128,7 +128,6 @@ template("siwx917_sdk") { "LWIP_ICMP=1", "LWIP_IGMP=1", "LWIP_DHCP=1", - "LWIP_DNS=0", ] } else { defines += [ "LWIP_IPV4=0" ] @@ -181,7 +180,14 @@ template("siwx917_sdk") { cflags += [ "-Wno-maybe-uninitialized", "-Wno-shadow", + "-Wno-empty-body", + "-Wno-cpp", + "-Wno-missing-braces", + "-Wno-sign-compare", "-Wno-error", + "-Wno-unknown-warning-option", + "-Wno-unused-variable", + "-Wno-unused-function", ] if (defined(invoker.defines)) { From 41abac7eb835915bebd7840ab6bed6629a1ef4c9 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Fri, 21 Apr 2023 17:32:59 +0300 Subject: [PATCH 002/200] [Telink] Update Telink Docker image (Zephyr update) (#26190) --- integrations/docker/images/chip-build-telink/Dockerfile | 2 +- integrations/docker/images/chip-build/version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/docker/images/chip-build-telink/Dockerfile b/integrations/docker/images/chip-build-telink/Dockerfile index 8492c85611a871..14c9d8dd3a8f17 100644 --- a/integrations/docker/images/chip-build-telink/Dockerfile +++ b/integrations/docker/images/chip-build-telink/Dockerfile @@ -23,7 +23,7 @@ RUN set -x \ && : # last line # Setup Zephyr -ARG ZEPHYR_REVISION=79e02527e04b369180ceef7c4cd682b24889801e +ARG ZEPHYR_REVISION=abb88b989a7ee31c04d99615cd91c946c81c0aa5 WORKDIR /opt/telink/zephyrproject RUN set -x \ && python3 -m pip install -U --no-cache-dir \ diff --git a/integrations/docker/images/chip-build/version b/integrations/docker/images/chip-build/version index 239c2611130e59..33084d044249a3 100644 --- a/integrations/docker/images/chip-build/version +++ b/integrations/docker/images/chip-build/version @@ -1 +1 @@ -0.7.1 Version bump reason: [ESP32] Update ESP-IDF to v4.4.4 release +0.7.2 Version bump reason: [Telink] Update Telink Docker image (Zephyr update) From e663f94c7f06332a64e6fc4c4eb31fd9819abaf5 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 21 Apr 2023 10:35:41 -0400 Subject: [PATCH 003/200] Assert the Matter lock is held in non-threadsafe SystemLayer methods. (#26180) ScheduleWork uses timers, and timers access a timer list member that is not protected against data races in any way. --- src/system/SystemLayer.h | 12 ++++++++---- src/system/SystemLayerImplFreeRTOS.cpp | 7 +++++++ src/system/SystemLayerImplSelect.cpp | 6 ++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/system/SystemLayer.h b/src/system/SystemLayer.h index 632037f45a328f..4321edeb02b883 100644 --- a/src/system/SystemLayer.h +++ b/src/system/SystemLayer.h @@ -96,7 +96,8 @@ class DLL_EXPORT Layer /** * @brief - * This method starts a one-shot timer. + * This method starts a one-shot timer. This method must be called while in the Matter context (from + * the Matter event loop, or while holding the Matter stack lock). * * @note * Only a single timer is allowed to be started with the same @a aComplete and @a aAppState @@ -114,8 +115,9 @@ class DLL_EXPORT Layer virtual CHIP_ERROR StartTimer(Clock::Timeout aDelay, TimerCompleteCallback aComplete, void * aAppState) = 0; /** - * @brief - * This method cancels a one-shot timer, started earlier through @p StartTimer(). + * @brief This method cancels a one-shot timer, started earlier through @p StartTimer(). This method must + * be called while in the Matter context (from the Matter event loop, or while holding the Matter + * stack lock). * * @note * The cancellation could fail silently if the timer specified by the combination of the callback @@ -129,7 +131,9 @@ class DLL_EXPORT Layer /** * @brief - * Schedules a function with a signature identical to `OnCompleteFunct` to be run as soon as possible in the CHIP context. + * Schedules a function with a signature identical to `OnCompleteFunct` to be run as soon as possible in the Matter context. + * This must only be called when already in the Matter context (from the Matter event loop, or while holding the Matter + * stack lock). * * @param[in] aComplete A pointer to a callback function to be called when this timer fires. * @param[in] aAppState A pointer to an application state object to be passed to the callback function as argument. diff --git a/src/system/SystemLayerImplFreeRTOS.cpp b/src/system/SystemLayerImplFreeRTOS.cpp index 1a9692302c9c48..ecc8d9504b0f14 100644 --- a/src/system/SystemLayerImplFreeRTOS.cpp +++ b/src/system/SystemLayerImplFreeRTOS.cpp @@ -22,6 +22,7 @@ */ #include +#include #include #include #include @@ -51,6 +52,8 @@ void LayerImplFreeRTOS::Shutdown() CHIP_ERROR LayerImplFreeRTOS::StartTimer(Clock::Timeout delay, TimerCompleteCallback onComplete, void * appState) { + assertChipStackLockedByCurrentThread(); + VerifyOrReturnError(mLayerState.IsInitialized(), CHIP_ERROR_INCORRECT_STATE); CHIP_SYSTEM_FAULT_INJECT(FaultInjection::kFault_TimeoutImmediate, delay = Clock::kZero); @@ -75,6 +78,8 @@ CHIP_ERROR LayerImplFreeRTOS::StartTimer(Clock::Timeout delay, TimerCompleteCall void LayerImplFreeRTOS::CancelTimer(TimerCompleteCallback onComplete, void * appState) { + assertChipStackLockedByCurrentThread(); + VerifyOrReturn(mLayerState.IsInitialized()); TimerList::Node * timer = mTimerList.Remove(onComplete, appState); @@ -86,6 +91,8 @@ void LayerImplFreeRTOS::CancelTimer(TimerCompleteCallback onComplete, void * app CHIP_ERROR LayerImplFreeRTOS::ScheduleWork(TimerCompleteCallback onComplete, void * appState) { + assertChipStackLockedByCurrentThread(); + VerifyOrReturnError(mLayerState.IsInitialized(), CHIP_ERROR_INCORRECT_STATE); // Ideally we would not use a timer here at all, but if we try to just diff --git a/src/system/SystemLayerImplSelect.cpp b/src/system/SystemLayerImplSelect.cpp index 88883a2a027520..171f14f8a6cfb7 100644 --- a/src/system/SystemLayerImplSelect.cpp +++ b/src/system/SystemLayerImplSelect.cpp @@ -122,6 +122,8 @@ void LayerImplSelect::Signal() CHIP_ERROR LayerImplSelect::StartTimer(Clock::Timeout delay, TimerCompleteCallback onComplete, void * appState) { + assertChipStackLockedByCurrentThread(); + VerifyOrReturnError(mLayerState.IsInitialized(), CHIP_ERROR_INCORRECT_STATE); CHIP_SYSTEM_FAULT_INJECT(FaultInjection::kFault_TimeoutImmediate, delay = System::Clock::kZero); @@ -167,6 +169,8 @@ CHIP_ERROR LayerImplSelect::StartTimer(Clock::Timeout delay, TimerCompleteCallba void LayerImplSelect::CancelTimer(TimerCompleteCallback onComplete, void * appState) { + assertChipStackLockedByCurrentThread(); + VerifyOrReturn(mLayerState.IsInitialized()); TimerList::Node * timer = mTimerList.Remove(onComplete, appState); @@ -194,6 +198,8 @@ void LayerImplSelect::CancelTimer(TimerCompleteCallback onComplete, void * appSt CHIP_ERROR LayerImplSelect::ScheduleWork(TimerCompleteCallback onComplete, void * appState) { + assertChipStackLockedByCurrentThread(); + VerifyOrReturnError(mLayerState.IsInitialized(), CHIP_ERROR_INCORRECT_STATE); #if CHIP_SYSTEM_CONFIG_USE_DISPATCH From 65f075c73127d8ec3b2d9a6f11a2ac4256e355e1 Mon Sep 17 00:00:00 2001 From: Timothy Maes Date: Fri, 21 Apr 2023 18:26:57 +0200 Subject: [PATCH 004/200] fix: Warning GCC 12.2 in mbed_alt (#26193) --- third_party/qpg_sdk/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/qpg_sdk/repo b/third_party/qpg_sdk/repo index 1f0c845a7de8ad..e5c17b34e011a0 160000 --- a/third_party/qpg_sdk/repo +++ b/third_party/qpg_sdk/repo @@ -1 +1 @@ -Subproject commit 1f0c845a7de8ad2b81f07bfa4c83e6a8f22dbe99 +Subproject commit e5c17b34e011a0997a4b1614008aacff4f97e5b6 From de0dfcfbc42fe574774dc440a0e89a8884b28573 Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Sun, 23 Apr 2023 19:50:31 -0400 Subject: [PATCH 005/200] Fix assert on SystemLayer().StartTimer call by aquiring the chipStack Lock before the call (#26200) --- src/platform/Linux/BLEManagerImpl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index c9ae6ae36bf771..2cc5c6a69d19c5 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -796,7 +796,11 @@ void BLEManagerImpl::OnDeviceScanned(BluezDevice1 * device, const chip::Ble::Chi } mBLEScanConfig.mBleScanState = BleScanState::kConnecting; + + chip::DeviceLayer::PlatformMgr().LockChipStack(); DeviceLayer::SystemLayer().StartTimer(kConnectTimeout, HandleConnectTimeout, mpEndpoint); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + mDeviceScanner->StopScan(); ConnectDevice(device, mpEndpoint); From 51f90c934b4b9a35c0deff28b8ca59d6718543f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 09:48:22 -0400 Subject: [PATCH 006/200] Bump third_party/mbedtls/repo from `b76bcfb` to `e323fb3` (#26212) Bumps [third_party/mbedtls/repo](https://github.com/ARMmbed/mbedtls) from `b76bcfb` to `e323fb3`. - [Release notes](https://github.com/ARMmbed/mbedtls/releases) - [Commits](https://github.com/ARMmbed/mbedtls/compare/b76bcfb22869da08c2fa4f242295523f65881807...e323fb3ab5bf9dbdec8731c29108697e8d611755) --- updated-dependencies: - dependency-name: third_party/mbedtls/repo dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- third_party/mbedtls/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/mbedtls/repo b/third_party/mbedtls/repo index b76bcfb22869da..e323fb3ab5bf9d 160000 --- a/third_party/mbedtls/repo +++ b/third_party/mbedtls/repo @@ -1 +1 @@ -Subproject commit b76bcfb22869da08c2fa4f242295523f65881807 +Subproject commit e323fb3ab5bf9dbdec8731c29108697e8d611755 From f331ffba29f316396a3ee7bb8c72b526a2aac68c Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 24 Apr 2023 10:15:24 -0400 Subject: [PATCH 007/200] Log payloads for read/subscribe even if we reject them. (#26188) Right now we only log read/subscribe payloads when we are actaully handling the read/subscribe. But that means when they are rejected it's hard to tell what might have caused them to get rejected. This just moves the logging to much earlier in the processing. --- src/app/InteractionModelEngine.cpp | 7 +++++++ src/app/ReadHandler.cpp | 14 ++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index 08f3266f522b1d..2a5dd2f3216932 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -441,6 +441,10 @@ Protocols::InteractionModel::Status InteractionModelEngine::OnReadInitialRequest SubscribeRequestMessage::Parser subscribeRequestParser; VerifyOrReturnError(subscribeRequestParser.Init(reader) == CHIP_NO_ERROR, Status::InvalidAction); +#if CHIP_CONFIG_IM_PRETTY_PRINT + subscribeRequestParser.PrettyPrint(); +#endif + VerifyOrReturnError(subscribeRequestParser.GetKeepSubscriptions(&keepExistingSubscriptions) == CHIP_NO_ERROR, Status::InvalidAction); if (!keepExistingSubscriptions) @@ -538,6 +542,9 @@ Protocols::InteractionModel::Status InteractionModelEngine::OnReadInitialRequest ReadRequestMessage::Parser readRequestParser; VerifyOrReturnError(readRequestParser.Init(reader) == CHIP_NO_ERROR, Status::InvalidAction); +#if CHIP_CONFIG_IM_PRETTY_PRINT + readRequestParser.PrettyPrint(); +#endif { size_t requestedAttributePathCount = 0; size_t requestedEventPathCount = 0; diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index 5dc2ce668fec09..ef594e3badd163 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -394,9 +394,10 @@ CHIP_ERROR ReadHandler::ProcessReadRequest(System::PacketBufferHandle && aPayloa reader.Init(std::move(aPayload)); ReturnErrorOnFailure(readRequestParser.Init(reader)); -#if CHIP_CONFIG_IM_PRETTY_PRINT - readRequestParser.PrettyPrint(); -#endif + + // No need to pretty-print here. We pretty-print read requests in the read + // case of InteractionModelEngine::OnReadInitialRequest, so we do it even if + // we reject a read request. err = readRequestParser.GetAttributeRequests(&attributePathListParser); if (err == CHIP_END_OF_TLV) @@ -647,9 +648,10 @@ CHIP_ERROR ReadHandler::ProcessSubscribeRequest(System::PacketBufferHandle && aP SubscribeRequestMessage::Parser subscribeRequestParser; ReturnErrorOnFailure(subscribeRequestParser.Init(reader)); -#if CHIP_CONFIG_IM_PRETTY_PRINT - subscribeRequestParser.PrettyPrint(); -#endif + + // No need to pretty-print here. We pretty-print subscribe requests in the + // subscribe case of InteractionModelEngine::OnReadInitialRequest, so we do + // it even if we reject a subscribe request. AttributePathIBs::Parser attributePathListParser; CHIP_ERROR err = subscribeRequestParser.GetAttributeRequests(&attributePathListParser); From 228b35dedc92ee49d5ddd9c352e02873564c905a Mon Sep 17 00:00:00 2001 From: Markus Becker Date: Mon, 24 Apr 2023 16:15:39 +0200 Subject: [PATCH 008/200] ot cli command is called networkkey now (#26210) See https://github.com/openthread/openthread/blob/main/src/cli/README.md#networkkey --- docs/guides/nrfconnect_examples_cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/nrfconnect_examples_cli.md b/docs/guides/nrfconnect_examples_cli.md index 91b633287db737..5d785ef15d594c 100644 --- a/docs/guides/nrfconnect_examples_cli.md +++ b/docs/guides/nrfconnect_examples_cli.md @@ -83,7 +83,7 @@ available options for the given command. are accessible from the shell, but they must preceded by `ot`. For example: ```shell -uart:~$ ot masterkey +uart:~$ ot networkkey 00112233445566778899aabbccddeeff Done ``` From fa303cd9bc2329400374d6ecb3333f29b24f21a9 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Mon, 24 Apr 2023 16:24:48 +0200 Subject: [PATCH 009/200] Fix schema not found error on vendor specific data (#26120) --- src/controller/python/chip/clusters/Attribute.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/controller/python/chip/clusters/Attribute.py b/src/controller/python/chip/clusters/Attribute.py index 1bd60cbf23501d..3660d31234f0fe 100644 --- a/src/controller/python/chip/clusters/Attribute.py +++ b/src/controller/python/chip/clusters/Attribute.py @@ -146,7 +146,7 @@ def __init__(self, ClusterType: Cluster = None, AttributeType: ClusterAttributeD break if (self.ClusterType is None or self.AttributeType is None): - raise Exception("Schema not found") + raise KeyError(f"No Schema found for Attribute {Path}") # Next, let's figure out the label. for field in self.ClusterType.descriptor.Fields: @@ -156,7 +156,7 @@ def __init__(self, ClusterType: Cluster = None, AttributeType: ClusterAttributeD self.AttributeName = field.Label if (self.AttributeName is None): - raise Exception("Schema not found") + raise KeyError(f"Unable to resolve name for Attribute {Path}") self.Path = Path self.ClusterId = self.ClusterType.id @@ -745,8 +745,14 @@ def _handleReportEnd(self): if (self._subscription_handler is not None): for change in self._changedPathSet: + try: + attribute_path = TypedAttributePath(Path=change) + except (KeyError, ValueError) as err: + # path could not be resolved into a TypedAttributePath + logging.getLogger(__name__).exception(err) + continue self._subscription_handler.OnAttributeChangeCb( - TypedAttributePath(Path=change), self._subscription_handler) + attribute_path, self._subscription_handler) # Clear it out once we've notified of all changes in this transaction. self._changedPathSet = set() From 05d79a2fe28af1bd68103148d69cb28c3422135b Mon Sep 17 00:00:00 2001 From: Jean-Francois Penven <67962328+jepenven-silabs@users.noreply.github.com> Date: Mon, 24 Apr 2023 10:51:53 -0400 Subject: [PATCH 010/200] Add Silabs Platform abstraction (#26196) --- src/platform/silabs/SiWx917/BUILD.gn | 3 + src/platform/silabs/efr32/BUILD.gn | 3 + .../silabs/platformAbstraction/GSDK_SPAM.cpp | 76 +++++++++++++++++++ .../platformAbstraction/SilabsPlatform.h | 63 +++++++++++++++ .../platformAbstraction/SilabsPlatformBase.h | 56 ++++++++++++++ .../platformAbstraction/WiseMCU_SPAM.cpp | 66 ++++++++++++++++ 6 files changed, 267 insertions(+) create mode 100644 src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp create mode 100644 src/platform/silabs/platformAbstraction/SilabsPlatform.h create mode 100644 src/platform/silabs/platformAbstraction/SilabsPlatformBase.h create mode 100644 src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp diff --git a/src/platform/silabs/SiWx917/BUILD.gn b/src/platform/silabs/SiWx917/BUILD.gn index fadfbbd1177f39..346c4ad20652ff 100644 --- a/src/platform/silabs/SiWx917/BUILD.gn +++ b/src/platform/silabs/SiWx917/BUILD.gn @@ -53,6 +53,9 @@ static_library("SiWx917") { "${silabs_platform_dir}/SilabsConfig.cpp", "${silabs_platform_dir}/SilabsConfig.h", "${silabs_platform_dir}/SystemPlatformConfig.h", + "${silabs_platform_dir}/platformAbstraction/SilabsPlatform.h", + "${silabs_platform_dir}/platformAbstraction/SilabsPlatformBase.h", + "${silabs_platform_dir}/platformAbstraction/WiseMCU_SPAM.cpp", "../../FreeRTOS/SystemTimeSupport.cpp", "../../SingletonConfigurationManager.cpp", "BLEManagerImpl.cpp", diff --git a/src/platform/silabs/efr32/BUILD.gn b/src/platform/silabs/efr32/BUILD.gn index 61a1ddc26fc7e2..7b80bf07111915 100644 --- a/src/platform/silabs/efr32/BUILD.gn +++ b/src/platform/silabs/efr32/BUILD.gn @@ -57,6 +57,9 @@ static_library("efr32") { "${silabs_platform_dir}/SilabsConfig.cpp", "${silabs_platform_dir}/SilabsConfig.h", "${silabs_platform_dir}/SystemPlatformConfig.h", + "${silabs_platform_dir}/platformAbstraction/GSDK_SPAM.cpp", + "${silabs_platform_dir}/platformAbstraction/SilabsPlatform.h", + "${silabs_platform_dir}/platformAbstraction/SilabsPlatformBase.h", "../../FreeRTOS/SystemTimeSupport.cpp", "../../SingletonConfigurationManager.cpp", "ConfigurationManagerImpl.cpp", diff --git a/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp b/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp new file mode 100644 index 00000000000000..e0f954e101a90d --- /dev/null +++ b/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "init_efrPlatform.h" +#include + +namespace chip { +namespace DeviceLayer { +namespace Silabs { + +SilabsPlatform SilabsPlatform::sSilabsPlatformAbstractionManager; + +CHIP_ERROR SilabsPlatform::Init(void) +{ + init_efrPlatform(); + return CHIP_NO_ERROR; +} + +#ifdef ENABLE_WSTK_LEDS + +#include "sl_simple_led_instances.h" + +void SilabsPlatform::InitLed(void) +{ + sl_simple_led_init_instances(); +} + +CHIP_ERROR SilabsPlatform::SetLed(bool state, uint8_t led) +{ + if (led >= SL_SIMPLE_LED_COUNT) + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + + (state) ? sl_led_turn_on(SL_SIMPLE_LED_INSTANCE(led)) : sl_led_turn_off(SL_SIMPLE_LED_INSTANCE(led)); + return CHIP_NO_ERROR; +} + +bool SilabsPlatform::GetLedState(uint8_t led) +{ + if (led >= SL_SIMPLE_LED_COUNT) + { + return 0; + } + + return sl_led_get_state(SL_SIMPLE_LED_INSTANCE(led)); +} + +CHIP_ERROR SilabsPlatform::ToggleLed(uint8_t led) +{ + if (led >= SL_SIMPLE_LED_COUNT) + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + sl_led_toggle(SL_SIMPLE_LED_INSTANCE(led)); + return CHIP_NO_ERROR; +} +#endif // ENABLE_WSTK_LEDS + +} // namespace Silabs +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/platformAbstraction/SilabsPlatform.h b/src/platform/silabs/platformAbstraction/SilabsPlatform.h new file mode 100644 index 00000000000000..f5dabc9d4bd72a --- /dev/null +++ b/src/platform/silabs/platformAbstraction/SilabsPlatform.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +namespace chip { +namespace DeviceLayer { +namespace Silabs { + +class SilabsPlatform : virtual public SilabsPlatformAbstractionBase +{ + +public: + // Generic Peripherical methods + CHIP_ERROR Init(void) override; + + // LEDS +#ifdef ENABLE_WSTK_LEDS + void InitLed(void) override; + CHIP_ERROR SetLed(bool state, uint8_t led) override; + bool GetLedState(uint8_t led) override; + CHIP_ERROR ToggleLed(uint8_t led) override; +#endif + +private: + friend SilabsPlatform & GetPlatform(void); + + // To make underlying SDK thread safe + void SilabsPlatformLock(void); + void SilabsPlatformUnlock(void); + + SilabsPlatform(){}; + virtual ~SilabsPlatform() = default; + + static SilabsPlatform sSilabsPlatformAbstractionManager; +}; + +inline SilabsPlatform & GetPlatform(void) +{ + return SilabsPlatform::sSilabsPlatformAbstractionManager; +} + +} // namespace Silabs +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h b/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h new file mode 100644 index 00000000000000..548fffac9e3599 --- /dev/null +++ b/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include + +namespace chip { +namespace DeviceLayer { +namespace Silabs { + +class SilabsPlatformAbstractionBase +{ + +public: + // Generic Peripherical methods + virtual CHIP_ERROR Init(void) = 0; + virtual CHIP_ERROR InitLCD() { return CHIP_ERROR_NOT_IMPLEMENTED; } + virtual CHIP_ERROR SetGPIO(uint32_t port, uint32_t pin, bool state) { return CHIP_ERROR_NOT_IMPLEMENTED; } + virtual bool GetGPIO(uint32_t port, uint32_t pin) { return false; } + + // Buttons + + // LEDS + virtual void InitLed(void) {} + virtual CHIP_ERROR SetLed(bool state, uint8_t led) { return CHIP_ERROR_NOT_IMPLEMENTED; } + virtual bool GetLedState(uint8_t led) { return 0; } + virtual CHIP_ERROR ToggleLed(uint8_t led) { return CHIP_ERROR_NOT_IMPLEMENTED; } + + // BLE Specific Method + +protected: + SilabsPlatformAbstractionBase(){}; + ~SilabsPlatformAbstractionBase(){}; +}; + +} // namespace Silabs +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp new file mode 100644 index 00000000000000..97004960f94d06 --- /dev/null +++ b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "init_ccpPlatform.h" + +// TODO add includes ? +extern "C" void RSI_Board_LED_Set(int, bool); +extern "C" void RSI_Board_LED_Toggle(int); + +namespace chip { +namespace DeviceLayer { +namespace Silabs { + +SilabsPlatform SilabsPlatform::sSilabsPlatformAbstractionManager; + +CHIP_ERROR SilabsPlatform::Init(void) +{ + init_ccpPlatform(); +} + +#ifdef ENABLE_WSTK_LEDS +void SilabsPlatform::InitLed(void) +{ + // TODO ? + SilabsPlatformAbstractionBase::InitLed(); +} + +CHIP_ERROR SilabsPlatform::SetLed(bool state, uint8_t led) override +{ + // TODO add range check ? + RSI_Board_LED_Set(led, state); + return CHIP_NO_ERROR; +} + +bool SilabsPlatform::GetLedState(uint8_t led) +{ + // TODO ? + return SilabsPlatformAbstractionBase::GetLedState(led); +} + +CHIP_ERROR SilabsPlatform::ToggleLed(uint8_t led) override +{ + // TODO add range check ? + RSI_Board_LED_Toggle(led) return CHIP_NO_ERROR; +} +#endif // ENABLE_WSTK_LEDS + +} // namespace Silabs +} // namespace DeviceLayer +} // namespace chip From 8306cb97069d18fd62329c669f3a9ca3a625a09d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 10:24:55 -0700 Subject: [PATCH 011/200] Bump third_party/openthread/repo from `e63c5d3` to `6bfcc0d` (#26211) Bumps [third_party/openthread/repo](https://github.com/openthread/openthread) from `e63c5d3` to `6bfcc0d`. - [Release notes](https://github.com/openthread/openthread/releases) - [Commits](https://github.com/openthread/openthread/compare/e63c5d321ad138f40fbca52afeb5c8d875fb445c...6bfcc0d7d495fcc7bcf1cdd4070bee14c391ef95) --- updated-dependencies: - dependency-name: third_party/openthread/repo dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- third_party/openthread/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/openthread/repo b/third_party/openthread/repo index e63c5d321ad138..6bfcc0d7d495fc 160000 --- a/third_party/openthread/repo +++ b/third_party/openthread/repo @@ -1 +1 @@ -Subproject commit e63c5d321ad138f40fbca52afeb5c8d875fb445c +Subproject commit 6bfcc0d7d495fcc7bcf1cdd4070bee14c391ef95 From 343634a8fcc88826fd9ae09d44fd5a1666646509 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 24 Apr 2023 13:37:18 -0400 Subject: [PATCH 012/200] Fix the "not storing data" mode of ClusterStateCache to actually work. (#26187) Since we were storing no data, we were computing clusterSize to 0 for all clusters in GetSortedFilters, and then we were not adding any DataVersion filters into our requests at all. The fix is that in "don't store data" mode we still store how big the data would have been, so we can correctly prioritize our DataVersion filters. Without this fix, the change in https://github.com/project-chip/connectedhomeip/pull/26181 fails CI. That CI also acts as a test for this functionality, once https://github.com/project-chip/connectedhomeip/pull/26181 happens. --- src/app/ClusterStateCache.cpp | 75 +++++++++++++++++++++++++++-------- src/app/ClusterStateCache.h | 13 +++++- 2 files changed, 69 insertions(+), 19 deletions(-) diff --git a/src/app/ClusterStateCache.cpp b/src/app/ClusterStateCache.cpp index 302f70e44eea00..2644c1a89bbbe8 100644 --- a/src/app/ClusterStateCache.cpp +++ b/src/app/ClusterStateCache.cpp @@ -24,6 +24,31 @@ namespace chip { namespace app { +namespace { + +// Determine how much space a StatusIB takes up on the wire. +size_t SizeOfStatusIB(const StatusIB & aStatus) +{ + // 1 byte: anonymous tag control byte for struct. + // 1 byte: control byte for uint8 value. + // 1 byte: context-specific tag for uint8 value. + // 1 byte: the uint8 value. + // 1 byte: end of container. + size_t size = 5; + + if (aStatus.mClusterStatus.HasValue()) + { + // 1 byte: control byte for uint8 value. + // 1 byte: context-specific tag for uint8 value. + // 1 byte: the uint8 value. + size += 3; + } + + return size; +} + +} // anonymous namespace + CHIP_ERROR ClusterStateCache::GetElementTLVSize(TLV::TLVReader * apData, size_t & aSize) { Platform::ScopedMemoryBufferWithSize backingBuffer; @@ -57,10 +82,11 @@ CHIP_ERROR ClusterStateCache::UpdateCache(const ConcreteDataAttributePath & aPat if (apData) { + size_t elementSize = 0; + ReturnErrorOnFailure(GetElementTLVSize(apData, elementSize)); + if (mCacheData) { - size_t elementSize = 0; - ReturnErrorOnFailure(GetElementTLVSize(apData, elementSize)); Platform::ScopedMemoryBufferWithSize backingBuffer; backingBuffer.Calloc(elementSize); VerifyOrReturnError(backingBuffer.Get() != nullptr, CHIP_ERROR_NO_MEMORY); @@ -68,7 +94,11 @@ CHIP_ERROR ClusterStateCache::UpdateCache(const ConcreteDataAttributePath & aPat ReturnErrorOnFailure(writer.CopyElement(TLV::AnonymousTag(), *apData)); ReturnErrorOnFailure(writer.Finalize(backingBuffer)); - state.Set>(std::move(backingBuffer)); + state.Set(std::move(backingBuffer)); + } + else + { + state.Set(elementSize); } // // Clear out the committed data version and only set it again once we have received all data for this cluster. @@ -106,6 +136,10 @@ CHIP_ERROR ClusterStateCache::UpdateCache(const ConcreteDataAttributePath & aPat { state.Set(aStatus); } + else + { + state.Set(SizeOfStatusIB(aStatus)); + } } // @@ -117,9 +151,10 @@ CHIP_ERROR ClusterStateCache::UpdateCache(const ConcreteDataAttributePath & aPat mAddedEndpoints.push_back(aPath.mEndpointId); } + mCache[aPath.mEndpointId][aPath.mClusterId].mAttributes[aPath.mAttributeId] = std::move(state); + if (mCacheData) { - mCache[aPath.mEndpointId][aPath.mClusterId].mAttributes[aPath.mAttributeId] = std::move(state); mChangedAttributeSet.insert(aPath); } @@ -235,8 +270,12 @@ CHIP_ERROR ClusterStateCache::Get(const ConcreteAttributePath & path, TLV::TLVRe return CHIP_ERROR_IM_STATUS_CODE_RECEIVED; } - reader.Init(attributeState->Get>().Get(), - attributeState->Get>().AllocatedSize()); + if (!attributeState->Is()) + { + return CHIP_ERROR_KEY_NOT_FOUND; + } + + reader.Init(attributeState->Get().Get(), attributeState->Get().AllocatedSize()); return reader.Next(); } @@ -419,27 +458,25 @@ void ClusterStateCache::GetSortedFilters(std::vector()) { - clusterSize += - 5; // 1 byte: anonymous tag control byte for struct. 1 byte: control byte for uint8 value. 1 byte: - // context-specific tag for uint8 value.1 byte: the uint8 value. 1 byte: end of container. - if (attributeIter.second.Get().mClusterStatus.HasValue()) - { - clusterSize += 3; // 1 byte: control byte for uint8 value. 1 byte: context-specific tag for uint8 value. 1 - // byte: the uint8 value. - } + clusterSize += SizeOfStatusIB(attributeIter.second.Get()); + } + else if (attributeIter.second.Is()) + { + clusterSize += attributeIter.second.Get(); } else { + VerifyOrDie(attributeIter.second.Is()); TLV::TLVReader bufReader; - bufReader.Init(attributeIter.second.Get>().Get(), - attributeIter.second.Get>().AllocatedSize()); + bufReader.Init(attributeIter.second.Get().Get(), + attributeIter.second.Get().AllocatedSize()); ReturnOnFailure(bufReader.Next()); // Skip to the end of the element. ReturnOnFailure(bufReader.Skip()); @@ -448,8 +485,11 @@ void ClusterStateCache::GetSortedFilters(std::vector & x, const std::pair & y) { return x.second > y.second; diff --git a/src/app/ClusterStateCache.h b/src/app/ClusterStateCache.h index b0a2d2b540345f..b6fb2029c85b49 100644 --- a/src/app/ClusterStateCache.h +++ b/src/app/ClusterStateCache.h @@ -500,7 +500,16 @@ class ClusterStateCache : protected ReadClient::Callback CHIP_ERROR GetLastReportDataPath(ConcreteClusterPath & aPath); private: - using AttributeState = Variant, StatusIB>; + // An attribute state can be one of three things: + // * If we got a path-specific error for the attribute, the corresponding + // status. + // * If we got data for the attribute and we are storing data ourselves, the + // data. + // * If we got data for the attribute and we are not storing data + // oureselves, the size of the data, so we can still prioritize sending + // DataVersions correctly. + using AttributeData = Platform::ScopedMemoryBufferWithSize; + using AttributeState = Variant; // mPendingDataVersion represents a tentative data version for a cluster that we have gotten some reports for. // // mCurrentDataVersion represents a known data version for a cluster. In order for this to have a @@ -632,7 +641,7 @@ class ClusterStateCache : protected ReadClient::Callback std::map mEventStatusCache; BufferedReadCallback mBufferedReader; ConcreteClusterPath mLastReportDataPath = ConcreteClusterPath(kInvalidEndpointId, kInvalidClusterId); - bool mCacheData = true; + const bool mCacheData = true; }; }; // namespace app From b42d23a253a1f91d6c58121791a024288394a56b Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 24 Apr 2023 15:27:11 -0400 Subject: [PATCH 013/200] Minor cleanup around read/subscribe(To)AttributePaths. (#26171) 1) Use initWithArray:copyItems:YES when copying arrays, instead of hand-rolling the copy. 2) For read, empty paths should just lead to an empty result, not an error, just like they would if the read actually happened. Fixes https://github.com/project-chip/connectedhomeip/issues/26169 --- src/darwin/Framework/CHIP/MTRBaseDevice.h | 11 +++--- src/darwin/Framework/CHIP/MTRBaseDevice.mm | 39 +++++++++------------- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.h b/src/darwin/Framework/CHIP/MTRBaseDevice.h index e9caa66561f484..0d4fbdd1f498f2 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.h +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.h @@ -287,9 +287,10 @@ MTR_NEWLY_AVAILABLE * * Lists of attribute and event paths to read can be provided via attributePaths and eventPaths. * - * The completion will be called with an error if the input parameters are invalid (e.g., both attributePaths and eventPaths are - * empty.) or the entire read interaction fails. Otherwise it will be called with values, which may be empty (e.g. if no paths - * matched the wildcard paths passed in) or may include per-path errors if particular paths failed. + * The completion will be called with an error if the entire read interaction fails. Otherwise it + * will be called with an array of values. This array may be empty (e.g. if no paths matched the + * wildcard paths passed in, or if empty lists of paths were passed in) or may include per-path + * errors if particular paths failed. * * If the sum of the lengths of attributePaths and eventPaths exceeds 9, the read may fail due to the device not supporting that * many read paths. @@ -394,8 +395,8 @@ MTR_NEWLY_AVAILABLE * * Lists of attribute and event paths to subscribe to can be provided via attributePaths and eventPaths. * - * The reportHandler will be called with an error if the inputs are invalid (e.g., both attributePaths and eventPaths are - * empty), or if the subscription fails entirely. + * The reportHandler will be called with an error if the subscription fails + * entirely (including when both attributePaths and eventPaths are empty). * * The reportHandler will be called with arrays of response-value dictionaries * (which may be data or errors) as path-specific data is received. diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.mm b/src/darwin/Framework/CHIP/MTRBaseDevice.mm index 4522c63d7989c1..f3251dbbc4db8f 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.mm +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.mm @@ -917,26 +917,21 @@ - (void)readAttributePaths:(NSArray * _Nullable)attri completion:(MTRDeviceResponseHandler)completion { if ((attributePaths == nil || [attributePaths count] == 0) && (eventPaths == nil || [eventPaths count] == 0)) { + // No paths, just return an empty array. dispatch_async(queue, ^{ - completion(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_ARGUMENT]); + completion(@[], nil); }); return; } - NSMutableArray * attributes = nil; + NSArray * attributes = nil; if (attributePaths != nil) { - attributes = [[NSMutableArray alloc] init]; - for (MTRAttributeRequestPath * attributePath in attributePaths) { - [attributes addObject:[attributePath copy]]; - } + attributes = [[NSArray alloc] initWithArray:attributePaths copyItems:YES]; } - NSMutableArray * events = nil; + NSArray * events = nil; if (eventPaths != nil) { - events = [[NSMutableArray alloc] init]; - for (MTRAttributeRequestPath * eventPath in eventPaths) { - [events addObject:[eventPath copy]]; - } + events = [[NSArray alloc] initWithArray:eventPaths copyItems:YES]; } params = (params == nil) ? nil : [params copy]; auto * bridge = new MTRDataValueDictionaryCallbackBridge(queue, completion, @@ -1006,9 +1001,9 @@ - (void)readAttributePaths:(NSArray * _Nullable)attri chip::app::ReadPrepareParams readParams(session); [params toReadPrepareParams:readParams]; readParams.mpAttributePathParamsList = attributePathParamsList.Get(); - readParams.mAttributePathParamsListSize = [attributePaths count]; + readParams.mAttributePathParamsListSize = [attributes count]; readParams.mpEventPathParamsList = eventPathParamsList.Get(); - readParams.mEventPathParamsListSize = [eventPaths count]; + readParams.mEventPathParamsListSize = [events count]; AttributePathParams * attributePathParamsListToFree = attributePathParamsList.Get(); EventPathParams * eventPathParamsListToFree = eventPathParamsList.Get(); @@ -1288,8 +1283,10 @@ - (void)subscribeToAttributePaths:(NSArray * _Nullabl resubscriptionScheduled:(MTRDeviceResubscriptionScheduledHandler _Nullable)resubscriptionScheduled { if ((attributePaths == nil || [attributePaths count] == 0) && (eventPaths == nil || [eventPaths count] == 0)) { + // Per spec a server would respond InvalidAction to this, so just go + // ahead and do that. dispatch_async(queue, ^{ - reportHandler(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_ARGUMENT]); + reportHandler(nil, [MTRError errorForIMStatus:StatusIB(Status::InvalidAction)]); }); return; } @@ -1303,20 +1300,14 @@ - (void)subscribeToAttributePaths:(NSArray * _Nullabl } // Copy params before going async. - NSMutableArray * attributes = nil; + NSArray * attributes = nil; if (attributePaths != nil) { - attributes = [[NSMutableArray alloc] init]; - for (MTRAttributeRequestPath * attributePath in attributePaths) { - [attributes addObject:[attributePath copy]]; - } + attributes = [[NSArray alloc] initWithArray:attributePaths copyItems:YES]; } - NSMutableArray * events = nil; + NSArray * events = nil; if (eventPaths != nil) { - events = [[NSMutableArray alloc] init]; - for (MTRAttributeRequestPath * eventPath in eventPaths) { - [events addObject:[eventPath copy]]; - } + events = [[NSArray alloc] initWithArray:eventPaths copyItems:YES]; } params = (params == nil) ? nil : [params copy]; From 6025455464090462cd0f97e15d0bc383f115553c Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Mon, 24 Apr 2023 16:13:45 -0400 Subject: [PATCH 014/200] Bump third_party/pigweed/repo from `73cac22` to `b88cd71` (#26133) * Pin new pigweed branch * Fix issues caught in CI * Fix CI * Clean up * Fix QPG plaform CI issues * Fix CI issues for Ameba * Fix Ameba CI for real this time * Restyle * Fix k32w0 and mw320 CI * Restyle * CI fixes for TI platform stuff * Fixes CI for Infineon * Fix/efr32 ci with pw roll up (#113) * add syscall_stubs to efr32 test driver to support gcc 12 * fix release pw rpc build, and test driver * Fix CI for Infineon cyw30739 * Roll to latest pigweed commit * Clean up for review * Fix CI * Restyle * Fix CI --------- Co-authored-by: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> --- examples/all-clusters-app/nxp/mw320/BUILD.gn | 7 +- .../nxp/k32w/k32w0/BUILD.gn | 1 + examples/lighting-app/nxp/k32w/k32w0/BUILD.gn | 1 + examples/lock-app/nxp/k32w/k32w0/BUILD.gn | 1 + examples/platform/linux/system_rpc_server.cc | 11 +- examples/platform/nxp/mw320/BUILD.gn | 27 --- examples/platform/silabs/efr32/BUILD.gn | 4 +- examples/shell/nxp/k32w/k32w0/BUILD.gn | 1 + .../Ameba/DiagnosticDataProviderImpl.cpp | 87 ++++--- src/platform/BUILD.gn | 4 + src/platform/SyscallStubs.cpp | 221 ++++++++++++++++++ src/platform/cc32xx/CC32XXConfig.cpp | 2 +- src/test_driver/efr32/BUILD.gn | 6 +- third_party/infineon/cyw30739_sdk/BUILD.gn | 5 + third_party/infineon/psoc6/BUILD.gn | 10 + third_party/infineon/psoc6/syscalls_stubs.cpp | 221 ++++++++++++++++++ third_party/nlfaultinjection/BUILD.gn | 8 + third_party/nxp/k32w0_sdk/k32w0_sdk.gni | 10 +- third_party/pigweed/repo | 2 +- third_party/qpg_sdk/BUILD.gn | 1 + third_party/silabs/efr32_sdk.gni | 6 +- third_party/ti_simplelink_sdk/BUILD.gn | 8 + .../ti_simplelink_sdk/syscalls_stubs.cpp | 221 ++++++++++++++++++ 23 files changed, 779 insertions(+), 86 deletions(-) delete mode 100644 examples/platform/nxp/mw320/BUILD.gn create mode 100644 src/platform/SyscallStubs.cpp create mode 100644 third_party/infineon/psoc6/syscalls_stubs.cpp create mode 100644 third_party/ti_simplelink_sdk/syscalls_stubs.cpp diff --git a/examples/all-clusters-app/nxp/mw320/BUILD.gn b/examples/all-clusters-app/nxp/mw320/BUILD.gn index 84d41622d7d8f1..0884310a04d18a 100644 --- a/examples/all-clusters-app/nxp/mw320/BUILD.gn +++ b/examples/all-clusters-app/nxp/mw320/BUILD.gn @@ -63,6 +63,8 @@ mw320_executable("shell_mw320") { "${chip_root}/src/setup_payload", ] + deps = [ "${chip_root}/src/platform:syscalls_stub" ] + include_dirs = [ "${chip_root}/src/platform/nxp/mw320", "${examples_plat_dir}/app/project_include", @@ -84,7 +86,10 @@ mw320_executable("shell_mw320") { ldscript = "${examples_plat_dir}/app/ldscripts/88MW320_xx_xxxx_flash.ld" - ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] + ldflags = [ + "-T" + rebase_path(ldscript, root_build_dir), + "-Wl,--no-warn-rwx-segment", + ] defines = [ "MW320_SHELL_STREAMER", "SHELL_STREAMER_APP_SPECIFIC", diff --git a/examples/contact-sensor-app/nxp/k32w/k32w0/BUILD.gn b/examples/contact-sensor-app/nxp/k32w/k32w0/BUILD.gn index bfc232e963525a..0087777552cdce 100644 --- a/examples/contact-sensor-app/nxp/k32w/k32w0/BUILD.gn +++ b/examples/contact-sensor-app/nxp/k32w/k32w0/BUILD.gn @@ -108,6 +108,7 @@ k32w0_executable("contact_sensor_app") { "${chip_root}/examples/contact-sensor-app/contact-sensor-common", "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/lib", + "${chip_root}/src/platform:syscalls_stub", "${chip_root}/third_party/mbedtls:mbedtls", "${k32w0_platform_dir}/app/support:freertos_mbedtls_utils", ] diff --git a/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn b/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn index 5daf13dfc7110c..3ccf6f3df1b282 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn +++ b/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn @@ -110,6 +110,7 @@ k32w0_executable("light_app") { "${chip_root}/examples/lighting-app/nxp/zap/", "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/lib", + "${chip_root}/src/platform:syscalls_stub", "${chip_root}/third_party/mbedtls:mbedtls", "${k32w0_platform_dir}/app/support:freertos_mbedtls_utils", ] diff --git a/examples/lock-app/nxp/k32w/k32w0/BUILD.gn b/examples/lock-app/nxp/k32w/k32w0/BUILD.gn index 2260f4cf1b58fd..70753788008300 100644 --- a/examples/lock-app/nxp/k32w/k32w0/BUILD.gn +++ b/examples/lock-app/nxp/k32w/k32w0/BUILD.gn @@ -109,6 +109,7 @@ k32w0_executable("lock_app") { "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/crypto", "${chip_root}/src/lib", + "${chip_root}/src/platform:syscalls_stub", "${chip_root}/third_party/mbedtls:mbedtls", "${chip_root}/third_party/simw-top-mini:se05x", "${k32w0_platform_dir}/app/support:freertos_mbedtls_utils", diff --git a/examples/platform/linux/system_rpc_server.cc b/examples/platform/linux/system_rpc_server.cc index dee4bb6d7d957e..ff8e52ec94d65e 100644 --- a/examples/platform/linux/system_rpc_server.cc +++ b/examples/platform/linux/system_rpc_server.cc @@ -37,6 +37,7 @@ namespace { constexpr size_t kMaxTransmissionUnit = 512; uint16_t socket_port = 33000; +stream::ServerSocket server_socket; stream::SocketStream socket_stream; hdlc::RpcChannelOutput hdlc_channel_output(socket_stream, hdlc::kDefaultRpcAddress, "HDLC channel"); @@ -63,7 +64,10 @@ void Init() }); PW_LOG_INFO("Starting pw_rpc server on port %d", socket_port); - PW_CHECK_OK(socket_stream.Serve(socket_port)); + PW_CHECK_OK(server_socket.Listen(socket_port)); + auto accept_result = server_socket.Accept(); + PW_CHECK_OK(accept_result.status()); + socket_stream = *std::move(accept_result); } rpc::Server & Server() @@ -88,7 +92,10 @@ Status Start() // An out of range status indicates the remote end has disconnected. // Start to serve the connection again, which will allow another // remote to connect. - PW_CHECK_OK(socket_stream.Serve(socket_port)); + PW_CHECK_OK(server_socket.Listen(socket_port)); + auto accept_result = server_socket.Accept(); + PW_CHECK_OK(accept_result.status()); + socket_stream = *std::move(accept_result); } continue; } diff --git a/examples/platform/nxp/mw320/BUILD.gn b/examples/platform/nxp/mw320/BUILD.gn deleted file mode 100644 index 2cfcbd4dcced8a..00000000000000 --- a/examples/platform/nxp/mw320/BUILD.gn +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2020 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build_overrides/chip.gni") -import("//build_overrides/mw320_sdk.gni") - -import("${mw320_sdk_build_root}/mw320_sdk.gni") - -config("chip_examples_project_config") { - include_dirs = [ "app/project_include" ] -} - -source_set("config_mw320_chip_examples") { - # sources = [ "app/project_include/CHIPProjectConfig.h" ] - public_configs = [ ":chip_examples_project_config" ] -} diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index fd33406f6911b1..48fb282c8fbb5f 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -228,9 +228,7 @@ config("efr32-common-config") { defines += [ "HEAP_MONITORING" ] } - # Do not warn for LOAD segment with RWX permissions - # Uncomment this cflag when pigweed update is done and GCC 12.2 is used. - #ldflags = [ "-Wl,--no-warn-rwx-segment" ] + ldflags = [ "-Wl,--no-warn-rwx-segment" ] } config("silabs-wifi-config") { diff --git a/examples/shell/nxp/k32w/k32w0/BUILD.gn b/examples/shell/nxp/k32w/k32w0/BUILD.gn index 19e52dcd502c7b..8b062831685aea 100644 --- a/examples/shell/nxp/k32w/k32w0/BUILD.gn +++ b/examples/shell/nxp/k32w/k32w0/BUILD.gn @@ -67,6 +67,7 @@ k32w0_executable("shell_app") { "${chip_root}/examples/common/QRCode", "${chip_root}/examples/lock-app/lock-common", "${chip_root}/examples/shell/shell_common:shell_common", + "${chip_root}/src/platform:syscalls_stub", "${chip_root}/third_party/mbedtls:mbedtls", "${chip_root}/third_party/simw-top-mini:se05x", "${k32w0_platform_dir}/app/support:freertos_mbedtls_utils", diff --git a/src/platform/Ameba/DiagnosticDataProviderImpl.cpp b/src/platform/Ameba/DiagnosticDataProviderImpl.cpp index ad6ae4e31ec4f8..b9f2f018e6987d 100644 --- a/src/platform/Ameba/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Ameba/DiagnosticDataProviderImpl.cpp @@ -186,56 +186,49 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** NetworkInterface * head = NULL; struct ifaddrs * ifaddr = nullptr; - if (xnetif == NULL) + // xnetif is never null, no need to check. If we do check with -Werror=address, we get compiler error. + for (struct netif * ifa = xnetif; ifa != NULL; ifa = ifa->next) { - ChipLogError(DeviceLayer, "Failed to get network interfaces"); - } - else - { - for (struct netif * ifa = xnetif; ifa != NULL; ifa = ifa->next) + NetworkInterface * ifp = new NetworkInterface(); + + Platform::CopyString(ifp->Name, ifa->name); + + ifp->name = CharSpan::fromCharString(ifp->Name); + ifp->isOperational = true; + if ((ifa->flags) & NETIF_FLAG_ETHERNET) + ifp->type = EMBER_ZCL_INTERFACE_TYPE_ENUM_ETHERNET; + else + ifp->type = EMBER_ZCL_INTERFACE_TYPE_ENUM_WI_FI; + ifp->offPremiseServicesReachableIPv4.SetNull(); + ifp->offPremiseServicesReachableIPv6.SetNull(); + + memcpy(ifp->MacAddress, ifa->hwaddr, sizeof(ifa->hwaddr)); + + if (0) { - NetworkInterface * ifp = new NetworkInterface(); - - Platform::CopyString(ifp->Name, ifa->name); - - ifp->name = CharSpan::fromCharString(ifp->Name); - ifp->isOperational = true; - if ((ifa->flags) & NETIF_FLAG_ETHERNET) - ifp->type = EMBER_ZCL_INTERFACE_TYPE_ENUM_ETHERNET; - else - ifp->type = EMBER_ZCL_INTERFACE_TYPE_ENUM_WI_FI; - ifp->offPremiseServicesReachableIPv4.SetNull(); - ifp->offPremiseServicesReachableIPv6.SetNull(); - - memcpy(ifp->MacAddress, ifa->hwaddr, sizeof(ifa->hwaddr)); - - if (0) - { - ChipLogError(DeviceLayer, "Failed to get network hardware address"); - } - else - { - // Set 48-bit IEEE MAC Address - ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6); - } - - if (ifa->ip_addr.u_addr.ip4.addr != 0) - { - memcpy(ifp->Ipv4AddressesBuffer[0], &(ifa->ip_addr.u_addr.ip4.addr), kMaxIPv4AddrSize); - ifp->Ipv4AddressSpans[0] = ByteSpan(ifp->Ipv4AddressesBuffer[0], kMaxIPv4AddrSize); - ifp->IPv4Addresses = chip::app::DataModel::List(ifp->Ipv4AddressSpans, 1); - } - - if (ifa->ip6_addr->u_addr.ip6.addr != 0) - { - memcpy(ifp->Ipv6AddressesBuffer[0], &(ifa->ip6_addr->u_addr.ip6.addr), kMaxIPv6AddrSize); - ifp->Ipv6AddressSpans[0] = ByteSpan(ifp->Ipv6AddressesBuffer[0], kMaxIPv6AddrSize); - ifp->IPv6Addresses = chip::app::DataModel::List(ifp->Ipv6AddressSpans, 1); - } - - ifp->Next = head; - head = ifp; + ChipLogError(DeviceLayer, "Failed to get network hardware address"); } + else + { + // Set 48-bit IEEE MAC Address + ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6); + } + + if (ifa->ip_addr.u_addr.ip4.addr != 0) + { + memcpy(ifp->Ipv4AddressesBuffer[0], &(ifa->ip_addr.u_addr.ip4.addr), kMaxIPv4AddrSize); + ifp->Ipv4AddressSpans[0] = ByteSpan(ifp->Ipv4AddressesBuffer[0], kMaxIPv4AddrSize); + ifp->IPv4Addresses = chip::app::DataModel::List(ifp->Ipv4AddressSpans, 1); + } + + // ifa->ip6_addr->u_addr.ip6.addr is never null, no need to check. If we do check with -Werror=address, we get compiler + // error. + memcpy(ifp->Ipv6AddressesBuffer[0], &(ifa->ip6_addr->u_addr.ip6.addr), kMaxIPv6AddrSize); + ifp->Ipv6AddressSpans[0] = ByteSpan(ifp->Ipv6AddressesBuffer[0], kMaxIPv6AddrSize); + ifp->IPv6Addresses = chip::app::DataModel::List(ifp->Ipv6AddressSpans, 1); + + ifp->Next = head; + head = ifp; } *netifpp = head; diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 678cbb8778fc79..b4876e13103364 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -487,3 +487,7 @@ if (chip_device_platform != "none") { public_deps = [ ":platform_buildconfig" ] } } + +source_set("syscalls_stub") { + sources = [ "SyscallStubs.cpp" ] +} diff --git a/src/platform/SyscallStubs.cpp b/src/platform/SyscallStubs.cpp new file mode 100644 index 00000000000000..8ce83ddc3ecbeb --- /dev/null +++ b/src/platform/SyscallStubs.cpp @@ -0,0 +1,221 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + This file is only used to implement weak syscall stubs + that gcc-arm-none-eabi 12.2.1 expect to link when using Libc + (newlib/libc_nano) +*/ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int _open(const char * pathname, int flags, int mode); +int _close(int file); +int _fstat(int file, struct stat * st); +int _isatty(int file); +int _lseek(int file, int ptr, int dir); +int _read(int file, char * ptr, int len); +int _write(int file, const char * ptr, int len); + +/************************************************************************** + * @brief + * Open a file. + * + * @param[in] file + * File you want to open. + * + * @return + * Returns -1 since there is not logic here to open file. + **************************************************************************/ +int __attribute__((weak)) _open(const char * pathname, int flags, int mode) +{ + (void) pathname; + (void) flags; + (void) mode; + return -1; +} + +/************************************************************************** + * @brief + * Close a file. + * + * @param[in] file + * File you want to close. + * + * @return + * Returns 0 when the file is closed. + **************************************************************************/ +int __attribute__((weak)) _close(int file) +{ + (void) file; + return 0; +} + +/************************************************************************** + * @brief Exit the program. + * @param[in] status The value to return to the parent process as the + * exit status (not used). + **************************************************************************/ +void __attribute__((weak)) _exit(int status) +{ + (void) status; + while (true) + { + } /* Hang here forever... */ +} + +/************************************************************************* + * @brief + * Status of an open file. + * + * @param[in] file + * Check status for this file. + * + * @param[in] st + * Status information. + * + * @return + * Returns 0 when st_mode is set to character special. + ************************************************************************/ +int __attribute__((weak)) _fstat(int file, struct stat * st) +{ + (void) file; + (void) st; + return 0; +} + +/************************************************************************** + * @brief Get process ID. + *************************************************************************/ +int __attribute__((weak)) _getpid(void) +{ + return 1; +} + +/************************************************************************** + * @brief + * Query whether output stream is a terminal. + * + * @param[in] file + * Descriptor for the file. + * + * @return + * Returns 1 when query is done. + **************************************************************************/ +int __attribute__((weak)) _isatty(int file) +{ + (void) file; + return 1; +} + +/************************************************************************** + * @brief Send signal to process. + * @param[in] pid Process id (not used). + * @param[in] sig Signal to send (not used). + *************************************************************************/ +int __attribute__((weak)) _kill(int pid, int sig) +{ + (void) pid; + (void) sig; + return -1; +} + +/************************************************************************** + * @brief + * Set position in a file. + * + * @param[in] file + * Descriptor for the file. + * + * @param[in] ptr + * Poiter to the argument offset. + * + * @param[in] dir + * Directory whence. + * + * @return + * Returns 0 when position is set. + *************************************************************************/ +int __attribute__((weak)) _lseek(int file, int ptr, int dir) +{ + (void) file; + (void) ptr; + (void) dir; + return 0; +} + +/************************************************************************** + * @brief + * Read from a file. + * + * @param[in] file + * Descriptor for the file you want to read from. + * + * @param[in] ptr + * Pointer to the chacaters that are beeing read. + * + * @param[in] len + * Number of characters to be read. + * + * @return + * Number of characters that have been read. + *************************************************************************/ +int __attribute__((weak)) _read(int file, char * ptr, int len) +{ + (void) file; + (void) ptr; + (void) len; + return 0; +} + +/************************************************************************** + * @brief + * Write to a file. + * + * @param[in] file + * Descriptor for the file you want to write to. + * + * @param[in] ptr + * Pointer to the text you want to write + * + * @param[in] len + * Number of characters to be written. + * + * @return + * Number of characters that have been written. + **************************************************************************/ +int __attribute__((weak)) _write(int file, const char * ptr, int len) +{ + (void) file; + (void) ptr; + + return len; +} + +#ifdef __cplusplus +} +#endif diff --git a/src/platform/cc32xx/CC32XXConfig.cpp b/src/platform/cc32xx/CC32XXConfig.cpp index ad0e52ce5571c0..b6ed391b25fea0 100644 --- a/src/platform/cc32xx/CC32XXConfig.cpp +++ b/src/platform/cc32xx/CC32XXConfig.cpp @@ -282,7 +282,7 @@ class CC32XXKVSList // value is stored in the LL, we do not need the value variable above - delete value; + delete[] value; } } }; diff --git a/src/test_driver/efr32/BUILD.gn b/src/test_driver/efr32/BUILD.gn index 8ffd6d346033c7..08a5e4186903c5 100644 --- a/src/test_driver/efr32/BUILD.gn +++ b/src/test_driver/efr32/BUILD.gn @@ -72,6 +72,7 @@ silabs_executable("efr32_device_tests") { "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", "${examples_common_plat_dir}/PigweedLogger.cpp", "${examples_common_plat_dir}/heap_4_silabs.c", + "${examples_common_plat_dir}/syscalls_stubs.cpp", "${examples_plat_dir}/init_efrPlatform.cpp", "${examples_plat_dir}/uart.cpp", "src/main.cpp", @@ -111,7 +112,10 @@ silabs_executable("efr32_device_tests") { inputs = [ ldscript ] - ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] + ldflags = [ + "-T" + rebase_path(ldscript, root_build_dir), + "-Wl,--no-warn-rwx-segment", + ] output_dir = root_out_dir } diff --git a/third_party/infineon/cyw30739_sdk/BUILD.gn b/third_party/infineon/cyw30739_sdk/BUILD.gn index 75b9e272840b63..46ca83b4eae8e4 100644 --- a/third_party/infineon/cyw30739_sdk/BUILD.gn +++ b/third_party/infineon/cyw30739_sdk/BUILD.gn @@ -25,8 +25,13 @@ declare_args() { assert(cyw30739_sdk_target != "", "cyw30739_sdk_target must be specified") +config("cyw30739_sdk_no_warn_rwx") { + ldflags = [ "-Wl,--no-warn-rwx-segment" ] +} + group("cyw30739_sdk") { public_deps = [ cyw30739_sdk_target ] + all_dependent_configs = [ ":cyw30739_sdk_no_warn_rwx" ] } config("mbedtls_cyw30739_config") { diff --git a/third_party/infineon/psoc6/BUILD.gn b/third_party/infineon/psoc6/BUILD.gn index ebb79e618655c3..59464a8e2a7cf5 100644 --- a/third_party/infineon/psoc6/BUILD.gn +++ b/third_party/infineon/psoc6/BUILD.gn @@ -67,6 +67,9 @@ config("psoc6_sdk_config") { asmflags = mtb_json.asflags ldflags = filter_exclude(mtb_json.ldflags, [ "-T*" ]) + # TODO, once the issue is properly fixed we should no longer need this warning. + cflags_c += [ "-Wno-error=array-parameter" ] + # Pull out linker flags with paths (-T flags) and make paths absolute # OTA app provides it's own linker script if (!chip_enable_ota_requestor) { @@ -82,6 +85,8 @@ config("psoc6_sdk_config") { } } + ldflags += [ "-Wl,--no-warn-rwx-segment" ] + # --specs=nano.specs is getting added twice and causing compile issues so remove from cxx flags here. cflags_c -= [ "--specs=nano.specs" ] cflags_cc -= [ "--specs=nano.specs" ] @@ -89,7 +94,12 @@ config("psoc6_sdk_config") { ldflags -= [ "--specs=nano.specs" ] } +source_set("syscalls_stub") { + sources = [ "syscalls_stubs.cpp" ] +} + group("psoc6_build") { public_configs = [ ":psoc6_sdk_config" ] public_deps = [ psoc6_target_project ] + deps = [ ":syscalls_stub" ] } diff --git a/third_party/infineon/psoc6/syscalls_stubs.cpp b/third_party/infineon/psoc6/syscalls_stubs.cpp new file mode 100644 index 00000000000000..8ce83ddc3ecbeb --- /dev/null +++ b/third_party/infineon/psoc6/syscalls_stubs.cpp @@ -0,0 +1,221 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + This file is only used to implement weak syscall stubs + that gcc-arm-none-eabi 12.2.1 expect to link when using Libc + (newlib/libc_nano) +*/ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int _open(const char * pathname, int flags, int mode); +int _close(int file); +int _fstat(int file, struct stat * st); +int _isatty(int file); +int _lseek(int file, int ptr, int dir); +int _read(int file, char * ptr, int len); +int _write(int file, const char * ptr, int len); + +/************************************************************************** + * @brief + * Open a file. + * + * @param[in] file + * File you want to open. + * + * @return + * Returns -1 since there is not logic here to open file. + **************************************************************************/ +int __attribute__((weak)) _open(const char * pathname, int flags, int mode) +{ + (void) pathname; + (void) flags; + (void) mode; + return -1; +} + +/************************************************************************** + * @brief + * Close a file. + * + * @param[in] file + * File you want to close. + * + * @return + * Returns 0 when the file is closed. + **************************************************************************/ +int __attribute__((weak)) _close(int file) +{ + (void) file; + return 0; +} + +/************************************************************************** + * @brief Exit the program. + * @param[in] status The value to return to the parent process as the + * exit status (not used). + **************************************************************************/ +void __attribute__((weak)) _exit(int status) +{ + (void) status; + while (true) + { + } /* Hang here forever... */ +} + +/************************************************************************* + * @brief + * Status of an open file. + * + * @param[in] file + * Check status for this file. + * + * @param[in] st + * Status information. + * + * @return + * Returns 0 when st_mode is set to character special. + ************************************************************************/ +int __attribute__((weak)) _fstat(int file, struct stat * st) +{ + (void) file; + (void) st; + return 0; +} + +/************************************************************************** + * @brief Get process ID. + *************************************************************************/ +int __attribute__((weak)) _getpid(void) +{ + return 1; +} + +/************************************************************************** + * @brief + * Query whether output stream is a terminal. + * + * @param[in] file + * Descriptor for the file. + * + * @return + * Returns 1 when query is done. + **************************************************************************/ +int __attribute__((weak)) _isatty(int file) +{ + (void) file; + return 1; +} + +/************************************************************************** + * @brief Send signal to process. + * @param[in] pid Process id (not used). + * @param[in] sig Signal to send (not used). + *************************************************************************/ +int __attribute__((weak)) _kill(int pid, int sig) +{ + (void) pid; + (void) sig; + return -1; +} + +/************************************************************************** + * @brief + * Set position in a file. + * + * @param[in] file + * Descriptor for the file. + * + * @param[in] ptr + * Poiter to the argument offset. + * + * @param[in] dir + * Directory whence. + * + * @return + * Returns 0 when position is set. + *************************************************************************/ +int __attribute__((weak)) _lseek(int file, int ptr, int dir) +{ + (void) file; + (void) ptr; + (void) dir; + return 0; +} + +/************************************************************************** + * @brief + * Read from a file. + * + * @param[in] file + * Descriptor for the file you want to read from. + * + * @param[in] ptr + * Pointer to the chacaters that are beeing read. + * + * @param[in] len + * Number of characters to be read. + * + * @return + * Number of characters that have been read. + *************************************************************************/ +int __attribute__((weak)) _read(int file, char * ptr, int len) +{ + (void) file; + (void) ptr; + (void) len; + return 0; +} + +/************************************************************************** + * @brief + * Write to a file. + * + * @param[in] file + * Descriptor for the file you want to write to. + * + * @param[in] ptr + * Pointer to the text you want to write + * + * @param[in] len + * Number of characters to be written. + * + * @return + * Number of characters that have been written. + **************************************************************************/ +int __attribute__((weak)) _write(int file, const char * ptr, int len) +{ + (void) file; + (void) ptr; + + return len; +} + +#ifdef __cplusplus +} +#endif diff --git a/third_party/nlfaultinjection/BUILD.gn b/third_party/nlfaultinjection/BUILD.gn index 02f3a7fba06e16..740ee69c4d6d28 100644 --- a/third_party/nlfaultinjection/BUILD.gn +++ b/third_party/nlfaultinjection/BUILD.gn @@ -18,6 +18,13 @@ config("nlfaultinjection_config") { include_dirs = [ "repo/include" ] } +config("nlfaultinjection_disable_warnings_config") { + cflags = [ + # We are intentionally inducing faults with this library so it makes sense to ignore errors. + "-Wno-error=array-bounds", + ] +} + static_library("nlfaultinjection") { sources = [ "repo/include/nlfaultinjection.hpp", @@ -27,6 +34,7 @@ static_library("nlfaultinjection") { deps = [ "${nlassert_root}:nlassert" ] public_configs = [ ":nlfaultinjection_config" ] + configs += [ ":nlfaultinjection_disable_warnings_config" ] output_name = "libnlfaultinjection" output_dir = "${root_out_dir}/lib" diff --git a/third_party/nxp/k32w0_sdk/k32w0_sdk.gni b/third_party/nxp/k32w0_sdk/k32w0_sdk.gni index c42bfd85baa780..b9900540a79169 100644 --- a/third_party/nxp/k32w0_sdk/k32w0_sdk.gni +++ b/third_party/nxp/k32w0_sdk/k32w0_sdk.gni @@ -455,7 +455,15 @@ template("k32w0_sdk") { "-Wno-parentheses-equality", ] } else { - cflags += [ "-fno-optimize-strlen" ] + cflags += [ + "-fno-optimize-strlen", + + # TODO After upgrading the compiler we started to see new error from address + # warning. To allow PR that rolls up compiler we have suppress this warning + # as an error temporarily. + # see https://github.com/project-chip/connectedhomeip/issues/26221 + "-Wno-error=address", + ] } # Now add our "system-header" include dirs diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index 73cac22f49069a..b88cd71d271c41 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit 73cac22f49069a18fbec3bb60cb5f762b32ce20b +Subproject commit b88cd71d271c41e34a36dfc1c435e1e6ee3bc72a diff --git a/third_party/qpg_sdk/BUILD.gn b/third_party/qpg_sdk/BUILD.gn index 55e3bb4b5217f6..26cf78cf4e52be 100755 --- a/third_party/qpg_sdk/BUILD.gn +++ b/third_party/qpg_sdk/BUILD.gn @@ -163,6 +163,7 @@ config("qpg_retain_bootloader") { ldflags = [ "-Wl,-u_binary_bl_userlicense_bin_start", "-Wl,-u_binary_bootloader_bin_start", + "-Wl,--no-warn-rwx-segment", ] } diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index baf89660ce836b..97de1caf125afe 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -504,8 +504,10 @@ template("efr32_sdk") { "-Wno-shadow", # see https://github.com/project-chip/connectedhomeip/issues/26058 - # Uncomment this cflag when pigweed update is done and GCC 12.2 is used. - # "-Wno-error=array-parameter", + "-Wno-error=array-parameter", + + # see https://github.com/project-chip/connectedhomeip/issues/26170 + "-Wno-error=array-bounds", ] if (silabs_family == "efr32mg24" || silabs_family == "mgm24") { diff --git a/third_party/ti_simplelink_sdk/BUILD.gn b/third_party/ti_simplelink_sdk/BUILD.gn index 2451ab80e67195..d0b8d79372ea31 100644 --- a/third_party/ti_simplelink_sdk/BUILD.gn +++ b/third_party/ti_simplelink_sdk/BUILD.gn @@ -34,6 +34,10 @@ group("ti_simplelink_sysconfig") { public_deps = [ ti_simplelink_sysconfig_target ] } +source_set("syscalls_stub") { + sources = [ "syscalls_stubs.cpp" ] +} + config("ti_simplelink_mbedtls_config") { if (ti_simplelink_device_family == "cc13x2_26x2" || ti_simplelink_device_family == "cc13x2x7_26x2x7") { @@ -67,6 +71,8 @@ mbedtls_target("mbedtls") { public_configs = [ ":ti_simplelink_mbedtls_config" ] public_deps = [ ti_simplelink_sysconfig_target ] + + deps = [ ":syscalls_stub" ] } config("ti_simplelink_freertos_config") { @@ -108,4 +114,6 @@ freertos_target("freertos") { public_deps = [ "${chip_root}/third_party/ti_simplelink_sdk:ti_simplelink_sysconfig" ] } + + deps = [ ":syscalls_stub" ] } diff --git a/third_party/ti_simplelink_sdk/syscalls_stubs.cpp b/third_party/ti_simplelink_sdk/syscalls_stubs.cpp new file mode 100644 index 00000000000000..8ce83ddc3ecbeb --- /dev/null +++ b/third_party/ti_simplelink_sdk/syscalls_stubs.cpp @@ -0,0 +1,221 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + This file is only used to implement weak syscall stubs + that gcc-arm-none-eabi 12.2.1 expect to link when using Libc + (newlib/libc_nano) +*/ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int _open(const char * pathname, int flags, int mode); +int _close(int file); +int _fstat(int file, struct stat * st); +int _isatty(int file); +int _lseek(int file, int ptr, int dir); +int _read(int file, char * ptr, int len); +int _write(int file, const char * ptr, int len); + +/************************************************************************** + * @brief + * Open a file. + * + * @param[in] file + * File you want to open. + * + * @return + * Returns -1 since there is not logic here to open file. + **************************************************************************/ +int __attribute__((weak)) _open(const char * pathname, int flags, int mode) +{ + (void) pathname; + (void) flags; + (void) mode; + return -1; +} + +/************************************************************************** + * @brief + * Close a file. + * + * @param[in] file + * File you want to close. + * + * @return + * Returns 0 when the file is closed. + **************************************************************************/ +int __attribute__((weak)) _close(int file) +{ + (void) file; + return 0; +} + +/************************************************************************** + * @brief Exit the program. + * @param[in] status The value to return to the parent process as the + * exit status (not used). + **************************************************************************/ +void __attribute__((weak)) _exit(int status) +{ + (void) status; + while (true) + { + } /* Hang here forever... */ +} + +/************************************************************************* + * @brief + * Status of an open file. + * + * @param[in] file + * Check status for this file. + * + * @param[in] st + * Status information. + * + * @return + * Returns 0 when st_mode is set to character special. + ************************************************************************/ +int __attribute__((weak)) _fstat(int file, struct stat * st) +{ + (void) file; + (void) st; + return 0; +} + +/************************************************************************** + * @brief Get process ID. + *************************************************************************/ +int __attribute__((weak)) _getpid(void) +{ + return 1; +} + +/************************************************************************** + * @brief + * Query whether output stream is a terminal. + * + * @param[in] file + * Descriptor for the file. + * + * @return + * Returns 1 when query is done. + **************************************************************************/ +int __attribute__((weak)) _isatty(int file) +{ + (void) file; + return 1; +} + +/************************************************************************** + * @brief Send signal to process. + * @param[in] pid Process id (not used). + * @param[in] sig Signal to send (not used). + *************************************************************************/ +int __attribute__((weak)) _kill(int pid, int sig) +{ + (void) pid; + (void) sig; + return -1; +} + +/************************************************************************** + * @brief + * Set position in a file. + * + * @param[in] file + * Descriptor for the file. + * + * @param[in] ptr + * Poiter to the argument offset. + * + * @param[in] dir + * Directory whence. + * + * @return + * Returns 0 when position is set. + *************************************************************************/ +int __attribute__((weak)) _lseek(int file, int ptr, int dir) +{ + (void) file; + (void) ptr; + (void) dir; + return 0; +} + +/************************************************************************** + * @brief + * Read from a file. + * + * @param[in] file + * Descriptor for the file you want to read from. + * + * @param[in] ptr + * Pointer to the chacaters that are beeing read. + * + * @param[in] len + * Number of characters to be read. + * + * @return + * Number of characters that have been read. + *************************************************************************/ +int __attribute__((weak)) _read(int file, char * ptr, int len) +{ + (void) file; + (void) ptr; + (void) len; + return 0; +} + +/************************************************************************** + * @brief + * Write to a file. + * + * @param[in] file + * Descriptor for the file you want to write to. + * + * @param[in] ptr + * Pointer to the text you want to write + * + * @param[in] len + * Number of characters to be written. + * + * @return + * Number of characters that have been written. + **************************************************************************/ +int __attribute__((weak)) _write(int file, const char * ptr, int len) +{ + (void) file; + (void) ptr; + + return len; +} + +#ifdef __cplusplus +} +#endif From 20cb8dd32902baa80be60855cb2cbc5dc6b732ba Mon Sep 17 00:00:00 2001 From: achaulk-goog <107196446+achaulk-goog@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:50:11 -0400 Subject: [PATCH 015/200] Update bridge app codegen to handle Optional<> (#26229) --- scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py b/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py index f48c5eac5cc080..5325ce8043f10e 100644 --- a/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py @@ -88,7 +88,7 @@ def get_field_type(definition: Field, cluster: Cluster, idl: Idl): cType = 'std::vector<{}>'.format(cType) if definition.is_nullable: cType = '::chip::app::DataModel::Nullable<{}>'.format(cType) - if definition.is_nullable: + if definition.is_optional: cType = '::chip::Optional<{}>'.format(cType) return cType From ecf6b98d6c82a0b4de7c1b5a29753fc9108c654a Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 24 Apr 2023 17:55:12 -0400 Subject: [PATCH 016/200] Stop storing two copies of attribute/event data in MTRDevice. (#26181) We have our own attribute value cache; we're just using ClusterStateCache to track DataVersions and event numbers. --- src/darwin/Framework/CHIP/MTRDevice.mm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index a43cd41bcb1de4..b9df4f0fdf40ab 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -569,14 +569,12 @@ - (void)_setupSubscription }); }); - // Set up a cluster state cache. We really just want this for the - // logic it has for tracking data versions and event numbers so we - // minimize the amount of data we request on resubscribes; we - // don't care about the data it stores. Ideally we could use the - // dataversion-management logic without needing to store the data - // separately from the data store we already have, or we would - // stop storing our data separately. - auto clusterStateCache = std::make_unique(*callback.get()); + // Set up a cluster state cache. We just want this for the logic it has for + // tracking data versions and event numbers so we minimize the amount of data we + // request on resubscribes, so tell it not to store data. + auto clusterStateCache = std::make_unique(*callback.get(), + /* highestReceivedEventNumber = */ NullOptional, + /* cacheData = */ false); auto readClient = std::make_unique(InteractionModelEngine::GetInstance(), exchangeManager, clusterStateCache->GetBufferedCallback(), ReadClient::InteractionType::Subscribe); From fe07225d5080b690bd7555fc8492c48a5d91e8ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Apr 2023 01:52:48 +0000 Subject: [PATCH 017/200] Bump igsekor/pyspelling-any from 0.0.2 to 1.0.4 (#25121) Bumps [igsekor/pyspelling-any](https://github.com/igsekor/pyspelling-any) from 0.0.2 to 1.0.4. - [Release notes](https://github.com/igsekor/pyspelling-any/releases) - [Commits](https://github.com/igsekor/pyspelling-any/compare/v0.0.2...v1.0.4) --- updated-dependencies: - dependency-name: igsekor/pyspelling-any dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/spell.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spell.yml b/.github/workflows/spell.yml index 2ccd0133f89225..f073c203385e53 100644 --- a/.github/workflows/spell.yml +++ b/.github/workflows/spell.yml @@ -52,4 +52,4 @@ jobs: token: ${{ github.token }} attempt_limit: 3 attempt_delay: 2000 - - uses: igsekor/pyspelling-any@v0.0.2 + - uses: igsekor/pyspelling-any@v1.0.4 From bcf1b80f82f68e1b7de218a13b485e3a387b9d31 Mon Sep 17 00:00:00 2001 From: Jean-Francois Penven <67962328+jepenven-silabs@users.noreply.github.com> Date: Tue, 25 Apr 2023 01:05:09 -0400 Subject: [PATCH 018/200] [Silabs] merge LEDWidget (#26222) * Silabs merge LEDWidget * Fix CI --- examples/chef/efr32/src/AppTask.cpp | 8 +- .../silabs/SiWx917/src/AppTask.cpp | 2 - .../silabs/efr32/src/AppTask.cpp | 3 - .../silabs/SiWx917/src/AppTask.cpp | 6 -- .../lighting-app/silabs/efr32/src/AppTask.cpp | 15 +--- .../lighting-app/silabs/efr32/src/main.cpp | 7 +- .../lock-app/silabs/SiWx917/src/AppTask.cpp | 11 --- .../lock-app/silabs/efr32/src/AppTask.cpp | 17 +--- .../silabs/{SiWx917 => }/LEDWidget.cpp | 14 ++- .../platform/silabs/{efr32 => }/LEDWidget.h | 6 +- examples/platform/silabs/SiWx917/BUILD.gn | 5 +- .../silabs/SiWx917/BaseApplication.cpp | 17 ---- examples/platform/silabs/SiWx917/LEDWidget.h | 44 --------- examples/platform/silabs/efr32/BUILD.gn | 5 +- .../platform/silabs/efr32/BaseApplication.cpp | 2 +- examples/platform/silabs/efr32/LEDWidget.cpp | 89 ------------------- .../thermostat/silabs/efr32/src/AppTask.cpp | 3 - .../silabs/SiWx917/include/WindowAppImpl.h | 4 - .../silabs/SiWx917/src/WindowAppImpl.cpp | 41 +++------ .../silabs/efr32/include/WindowAppImpl.h | 5 -- .../silabs/efr32/src/WindowAppImpl.cpp | 46 +++------- .../silabs/platformAbstraction/GSDK_SPAM.cpp | 11 ++- .../platformAbstraction/WiseMCU_SPAM.cpp | 11 +-- 23 files changed, 61 insertions(+), 311 deletions(-) rename examples/platform/silabs/{SiWx917 => }/LEDWidget.cpp (84%) rename examples/platform/silabs/{efr32 => }/LEDWidget.h (92%) delete mode 100644 examples/platform/silabs/SiWx917/LEDWidget.h delete mode 100644 examples/platform/silabs/efr32/LEDWidget.cpp diff --git a/examples/chef/efr32/src/AppTask.cpp b/examples/chef/efr32/src/AppTask.cpp index 111340eeb66e5a..397fab5d482f7d 100644 --- a/examples/chef/efr32/src/AppTask.cpp +++ b/examples/chef/efr32/src/AppTask.cpp @@ -21,10 +21,7 @@ #include "AppConfig.h" #include "AppEvent.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -51,10 +48,7 @@ #include -#ifdef ENABLE_WSTK_LEDS -#define SYSTEM_STATE_LED &sl_led_led0 -#endif // ENABLE_WSTK_LEDS - +#define SYSTEM_STATE_LED 0 #define APP_FUNCTION_BUTTON &sl_button_btn0 using namespace chip; diff --git a/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp b/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp index 2fbad4ed4d3286..d53505b3374775 100644 --- a/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp @@ -26,9 +26,7 @@ #include "AppEvent.h" #include "BindingHandler.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS #include "LightSwitchMgr.h" diff --git a/examples/light-switch-app/silabs/efr32/src/AppTask.cpp b/examples/light-switch-app/silabs/efr32/src/AppTask.cpp index 4f2aca11f0712b..fab53ca052baf6 100644 --- a/examples/light-switch-app/silabs/efr32/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/efr32/src/AppTask.cpp @@ -26,10 +26,7 @@ #include "AppEvent.h" #include "BindingHandler.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #include "LightSwitchMgr.h" diff --git a/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp b/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp index 8da8003549c216..409890949085dd 100644 --- a/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp @@ -36,19 +36,15 @@ #include -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" #define APP_ACTION_LED 1 -#endif // ENABLE_WSTK_LEDS using namespace chip; using namespace ::chip::DeviceLayer; namespace { -#ifdef ENABLE_WSTK_LEDS LEDWidget sLightLED; -#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; @@ -143,10 +139,8 @@ CHIP_ERROR AppTask::Init() LightMgr().SetCallbacks(ActionInitiated, ActionCompleted); -#ifdef ENABLE_WSTK_LEDS sLightLED.Init(APP_ACTION_LED); sLightLED.Set(LightMgr().IsLightOn()); -#endif // ENABLE_WSTK_LEDS return err; } diff --git a/examples/lighting-app/silabs/efr32/src/AppTask.cpp b/examples/lighting-app/silabs/efr32/src/AppTask.cpp index 1169e09619eb32..58197087f4b2cb 100755 --- a/examples/lighting-app/silabs/efr32/src/AppTask.cpp +++ b/examples/lighting-app/silabs/efr32/src/AppTask.cpp @@ -21,10 +21,7 @@ #include "AppConfig.h" #include "AppEvent.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #include #include @@ -41,13 +38,11 @@ #include -#ifdef ENABLE_WSTK_LEDS #if defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) -#define LIGHT_LED &sl_led_led1 +#define LIGHT_LED 1 #else -#define LIGHT_LED &sl_led_led0 +#define LIGHT_LED 0 #endif -#endif // ENABLE_WSTK_LEDS #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT @@ -60,9 +55,7 @@ using namespace ::chip::DeviceLayer; namespace { -#ifdef ENABLE_WSTK_LEDS LEDWidget sLightLED; -#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; @@ -157,10 +150,8 @@ CHIP_ERROR AppTask::Init() LightMgr().SetCallbacks(ActionInitiated, ActionCompleted); -#ifdef ENABLE_WSTK_LEDS sLightLED.Init(LIGHT_LED); sLightLED.Set(LightMgr().IsLightOn()); -#endif // ENABLE_WSTK_LEDS // Update the LCD with the Stored value. Show QR Code if not provisioned #ifdef DISPLAY_ENABLED @@ -298,9 +289,7 @@ void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor) bool lightOn = aAction == LightingManager::ON_ACTION; SILABS_LOG("Turning light %s", (lightOn) ? "On" : "Off") -#ifdef ENABLE_WSTK_LEDS sLightLED.Set(lightOn); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(lightOn); diff --git a/examples/lighting-app/silabs/efr32/src/main.cpp b/examples/lighting-app/silabs/efr32/src/main.cpp index 73d81d7c2979c5..7bfae98d5b397f 100644 --- a/examples/lighting-app/silabs/efr32/src/main.cpp +++ b/examples/lighting-app/silabs/efr32/src/main.cpp @@ -20,7 +20,6 @@ #include #include "AppConfig.h" -#include "init_efrPlatform.h" #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT #include "sl_simple_button_instances.h" #endif @@ -35,11 +34,14 @@ #include #endif +#include + #define BLE_DEV_NAME "SiLabs-Light" using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; using namespace ::chip::Credentials; +using namespace chip::DeviceLayer::Silabs; #define UNUSED_PARAMETER(a) (a = a) @@ -51,7 +53,8 @@ static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; // ================================================================================ int main(void) { - init_efrPlatform(); + GetPlatform().Init(); + if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) appError(CHIP_ERROR_INTERNAL); diff --git a/examples/lock-app/silabs/SiWx917/src/AppTask.cpp b/examples/lock-app/silabs/SiWx917/src/AppTask.cpp index abc276588bdab6..a85ac491927d3f 100644 --- a/examples/lock-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/lock-app/silabs/SiWx917/src/AppTask.cpp @@ -24,9 +24,7 @@ #include "EventHandlerLibShell.h" #endif // ENABLE_CHIP_SHELL -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -53,9 +51,7 @@ #include -#ifdef ENABLE_WSTK_LEDS #define LOCK_STATE_LED 1 -#endif // ENABLE_WSTK_LEDS using chip::app::Clusters::DoorLock::DlLockState; using chip::app::Clusters::DoorLock::OperationErrorEnum; @@ -67,9 +63,7 @@ using namespace ::chip::DeviceLayer::Internal; using namespace SI917DoorLock::LockInitParams; namespace { -#ifdef ENABLE_WSTK_LEDS LEDWidget sLockLED; -#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; } // namespace @@ -238,11 +232,8 @@ CHIP_ERROR AppTask::Init() LockMgr().SetCallbacks(ActionInitiated, ActionCompleted); -#ifdef ENABLE_WSTK_LEDS - // Initialize LEDs sLockLED.Init(LOCK_STATE_LED); sLockLED.Set(state.Value() == DlLockState::kUnlocked); -#endif // ENABLE_WSTK_LEDS chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast(nullptr)); @@ -371,9 +362,7 @@ void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor) { bool locked = (aAction == LockManager::LOCK_ACTION); SILABS_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock"); -#ifdef ENABLE_WSTK_LEDS sLockLED.Set(!locked); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(locked); diff --git a/examples/lock-app/silabs/efr32/src/AppTask.cpp b/examples/lock-app/silabs/efr32/src/AppTask.cpp index ef01ebedff6885..ed1b51df6831d4 100644 --- a/examples/lock-app/silabs/efr32/src/AppTask.cpp +++ b/examples/lock-app/silabs/efr32/src/AppTask.cpp @@ -24,10 +24,7 @@ #include "EventHandlerLibShell.h" #endif // ENABLE_CHIP_SHELL -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -53,11 +50,8 @@ #include #include - -#ifdef ENABLE_WSTK_LEDS -#define SYSTEM_STATE_LED &sl_led_led0 -#define LOCK_STATE_LED &sl_led_led1 -#endif // ENABLE_WSTK_LEDS +#define SYSTEM_STATE_LED 0 +#define LOCK_STATE_LED 1 #define APP_FUNCTION_BUTTON &sl_button_btn0 #define APP_LOCK_SWITCH &sl_button_btn1 @@ -72,9 +66,7 @@ using namespace ::chip::DeviceLayer::Internal; using namespace EFR32DoorLock::LockInitParams; namespace { -#ifdef ENABLE_WSTK_LEDS LEDWidget sLockLED; -#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; } // namespace @@ -243,11 +235,8 @@ CHIP_ERROR AppTask::Init() LockMgr().SetCallbacks(ActionInitiated, ActionCompleted); -#ifdef ENABLE_WSTK_LEDS - // Initialize LEDs sLockLED.Init(LOCK_STATE_LED); sLockLED.Set(state.Value() == DlLockState::kUnlocked); -#endif // ENABLE_WSTK_LEDS // Update the LCD with the Stored value. Show QR Code if not provisioned #ifdef DISPLAY_ENABLED @@ -395,9 +384,7 @@ void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor) { bool locked = (aAction == LockManager::LOCK_ACTION); SILABS_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock"); -#ifdef ENABLE_WSTK_LEDS sLockLED.Set(!locked); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(locked); diff --git a/examples/platform/silabs/SiWx917/LEDWidget.cpp b/examples/platform/silabs/LEDWidget.cpp similarity index 84% rename from examples/platform/silabs/SiWx917/LEDWidget.cpp rename to examples/platform/silabs/LEDWidget.cpp index bb80fa3f9dfcd1..3156a3bdbc8afc 100644 --- a/examples/platform/silabs/SiWx917/LEDWidget.cpp +++ b/examples/platform/silabs/LEDWidget.cpp @@ -20,10 +20,18 @@ #include "LEDWidget.h" #include +#include using namespace ::chip::System; +using namespace chip::DeviceLayer::Silabs; -void LEDWidget::Init(int led) +void LEDWidget::InitGpio(void) +{ + // Sets gpio pin mode for ALL board Leds. + GetPlatform().InitLed(); +} + +void LEDWidget::Init(const uint8_t led) { mLastChangeTimeMS = 0; mBlinkOnTimeMS = 0; @@ -36,14 +44,14 @@ void LEDWidget::Init(int led) void LEDWidget::Invert(void) { - RSI_Board_LED_Toggle(mLed); + GetPlatform().ToggleLed(mLed); mLedStatus = !mLedStatus; } void LEDWidget::Set(bool state) { mLastChangeTimeMS = mBlinkOnTimeMS = mBlinkOffTimeMS = 0; - state ? RSI_Board_LED_Set(mLed, true) : RSI_Board_LED_Set(mLed, false); + GetPlatform().SetLed(state, mLed); mLedStatus = state; } diff --git a/examples/platform/silabs/efr32/LEDWidget.h b/examples/platform/silabs/LEDWidget.h similarity index 92% rename from examples/platform/silabs/efr32/LEDWidget.h rename to examples/platform/silabs/LEDWidget.h index d779cb9d3ef4b6..856c52c47d8209 100644 --- a/examples/platform/silabs/efr32/LEDWidget.h +++ b/examples/platform/silabs/LEDWidget.h @@ -19,14 +19,13 @@ #pragma once -#include "sl_led.h" #include class LEDWidget { public: static void InitGpio(void); - void Init(const sl_led_t * led); + void Init(uint8_t led); void Set(bool state); void Invert(void); void Blink(uint32_t changeRateMS); @@ -37,5 +36,6 @@ class LEDWidget uint64_t mLastChangeTimeMS; uint32_t mBlinkOnTimeMS; uint32_t mBlinkOffTimeMS; - const sl_led_t * mLed; + uint8_t mLed; + bool mLedStatus; }; diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 098829c4cde527..7404436fbc90d8 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -236,6 +236,7 @@ source_set("siwx917-common") { ] sources = [ + "${silabs_common_plat_dir}/LEDWidget.cpp", "${silabs_common_plat_dir}/heap_4_silabs.c", "${wifi_sdk_dir}/dhcp_client.cpp", "${wifi_sdk_dir}/ethernetif.cpp", @@ -252,10 +253,6 @@ source_set("siwx917-common") { sources += [ "BaseApplication.cpp" ] } - if (use_wstk_leds) { - sources += [ "LEDWidget.cpp" ] - } - if (chip_enable_pw_rpc || chip_build_libshell) { sources += [ "uart.cpp" ] } diff --git a/examples/platform/silabs/SiWx917/BaseApplication.cpp b/examples/platform/silabs/SiWx917/BaseApplication.cpp index 4ed8ea273e0a5f..f0dde1ffc39e80 100644 --- a/examples/platform/silabs/SiWx917/BaseApplication.cpp +++ b/examples/platform/silabs/SiWx917/BaseApplication.cpp @@ -25,9 +25,7 @@ #include "AppEvent.h" #include "AppTask.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -68,9 +66,7 @@ #define APP_TASK_PRIORITY 2 #define APP_EVENT_QUEUE_SIZE 10 #define EXAMPLE_VENDOR_ID 0xcafe -#ifdef ENABLE_WSTK_LEDS #define APP_STATE_LED 0 -#endif // ENABLE_WSTK_LEDS using namespace chip; using namespace ::chip::DeviceLayer; @@ -87,9 +83,7 @@ TimerHandle_t sLightTimer; TaskHandle_t sAppTaskHandle; QueueHandle_t sAppEventQueue; -#ifdef ENABLE_WSTK_LEDS LEDWidget sStatusLED; -#endif // ENABLE_WSTK_LEDS #ifdef SL_WIFI app::Clusters::NetworkCommissioning::Instance @@ -204,9 +198,7 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj) SILABS_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); SILABS_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); -#ifdef ENABLE_WSTK_LEDS sStatusLED.Init(APP_STATE_LED); -#endif // ENABLE_WSTK_LEDS ConfigurationMgr().LogDeviceConfig(); @@ -302,7 +294,6 @@ void BaseApplication::LightEventHandler() // the LEDs at an even rate of 100ms. // // Otherwise, blink the LED ON for a very short time. -#ifdef ENABLE_WSTK_LEDS if (mFunction != kFunction_FactoryReset) { if ((gIdentifyptr != nullptr) && (gIdentifyptr->mActive)) @@ -348,7 +339,6 @@ void BaseApplication::LightEventHandler() } sStatusLED.Animate(); -#endif // ENABLE_WSTK_LEDS } void BaseApplication::ButtonHandler(AppEvent * aEvent) @@ -382,13 +372,10 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) break; } -#ifdef ENABLE_WSTK_LEDS // Turn off status LED before starting blink to make sure blink is // co-ordinated. sStatusLED.Set(false); sStatusLED.Blink(500); -#endif // ENABLE_WSTK_LEDS - SILABS_LOG("Factory reset triggering in %d sec release button to cancel", count--); // Delay of 1sec before checking the button status again @@ -397,9 +384,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) if (count > 0) { -#ifdef ENABLE_WSTK_LEDS sStatusLED.Set(false); -#endif SILABS_LOG("Factory Reset has been Canceled"); // button held past Timeout wait till button is released } @@ -467,9 +452,7 @@ void BaseApplication::StartStatusLEDTimer() void BaseApplication::StopStatusLEDTimer() { -#ifdef ENABLE_WSTK_LEDS sStatusLED.Set(false); -#endif // ENABLE_WSTK_LEDS if (xTimerStop(sLightTimer, pdMS_TO_TICKS(100)) != pdPASS) { diff --git a/examples/platform/silabs/SiWx917/LEDWidget.h b/examples/platform/silabs/SiWx917/LEDWidget.h deleted file mode 100644 index 596f64af094d7a..00000000000000 --- a/examples/platform/silabs/SiWx917/LEDWidget.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -extern "C" void RSI_Board_LED_Set(int, int); -extern "C" void RSI_Board_LED_Toggle(int); - -class LEDWidget -{ -public: - void Init(int led); - void Set(bool state); - void Invert(void); - void Blink(uint32_t changeRateMS); - void Blink(uint32_t onTimeMS, uint32_t offTimeMS); - void Animate(); - -private: - uint64_t mLastChangeTimeMS; - uint32_t mBlinkOnTimeMS; - uint32_t mBlinkOffTimeMS; - int mLed; - // created a temporary mLedStatus since Led status is not updating from the platform API(RSI_EGPIO_GetPin) - bool mLedStatus; -}; diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index 48fb282c8fbb5f..d74792a1cba233 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -280,6 +280,7 @@ source_set("efr32-common") { include_dirs = [ "." ] sources = [ + "${silabs_common_plat_dir}/LEDWidget.cpp", "${silabs_common_plat_dir}/heap_4_silabs.c", "${silabs_common_plat_dir}/syscalls_stubs.cpp", "efr32_utils.cpp", @@ -291,10 +292,6 @@ source_set("efr32-common") { sources += [ "BaseApplication.cpp" ] } - if (use_wstk_leds) { - sources += [ "LEDWidget.cpp" ] - } - if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli) { sources += [ "uart.cpp" ] } diff --git a/examples/platform/silabs/efr32/BaseApplication.cpp b/examples/platform/silabs/efr32/BaseApplication.cpp index bbb18fc005883a..e29797607f7e35 100644 --- a/examples/platform/silabs/efr32/BaseApplication.cpp +++ b/examples/platform/silabs/efr32/BaseApplication.cpp @@ -73,7 +73,7 @@ #define EXAMPLE_VENDOR_ID 0xcafe #if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) -#define SYSTEM_STATE_LED &sl_led_led0 +#define SYSTEM_STATE_LED 0 #endif // ENABLE_WSTK_LEDS #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT #define APP_FUNCTION_BUTTON &sl_button_btn0 diff --git a/examples/platform/silabs/efr32/LEDWidget.cpp b/examples/platform/silabs/efr32/LEDWidget.cpp deleted file mode 100644 index 10ffcac363520d..00000000000000 --- a/examples/platform/silabs/efr32/LEDWidget.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "LEDWidget.h" - -extern "C" { -#include "sl_simple_led_instances.h" -} - -#include - -using namespace ::chip::System; - -void LEDWidget::InitGpio(void) -{ - // Sets gpio pin mode for ALL board Leds. - sl_simple_led_init_instances(); -} - -void LEDWidget::Init(const sl_led_t * led) -{ - mLastChangeTimeMS = 0; - mBlinkOnTimeMS = 0; - mBlinkOffTimeMS = 0; - mLed = led; - - Set(false); -} - -void LEDWidget::Invert(void) -{ - if (mLed) - { - sl_led_toggle(mLed); - } -} - -void LEDWidget::Set(bool state) -{ - mLastChangeTimeMS = mBlinkOnTimeMS = mBlinkOffTimeMS = 0; - if (mLed) - { - state ? sl_led_turn_on(mLed) : sl_led_turn_off(mLed); - } -} - -void LEDWidget::Blink(uint32_t changeRateMS) -{ - Blink(changeRateMS, changeRateMS); -} - -void LEDWidget::Blink(uint32_t onTimeMS, uint32_t offTimeMS) -{ - mBlinkOnTimeMS = onTimeMS; - mBlinkOffTimeMS = offTimeMS; - Animate(); -} - -void LEDWidget::Animate() -{ - if (mBlinkOnTimeMS != 0 && mBlinkOffTimeMS != 0) - { - uint64_t nowMS = chip::System::SystemClock().GetMonotonicMilliseconds64().count(); - uint64_t stateDurMS = sl_led_get_state(mLed) ? mBlinkOnTimeMS : mBlinkOffTimeMS; - uint64_t nextChangeTimeMS = mLastChangeTimeMS + stateDurMS; - - if (nextChangeTimeMS < nowMS) - { - Invert(); - mLastChangeTimeMS = nowMS; - } - } -} diff --git a/examples/thermostat/silabs/efr32/src/AppTask.cpp b/examples/thermostat/silabs/efr32/src/AppTask.cpp index 2ccaec5fed2e1c..21cee0c90cc122 100644 --- a/examples/thermostat/silabs/efr32/src/AppTask.cpp +++ b/examples/thermostat/silabs/efr32/src/AppTask.cpp @@ -25,10 +25,7 @@ #include "AppConfig.h" #include "AppEvent.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "ThermostatUI.h" diff --git a/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h b/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h index 0acb38a4b1de22..827e3b120e7992 100644 --- a/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h +++ b/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h @@ -19,9 +19,7 @@ #include -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS #include #include @@ -90,10 +88,8 @@ class WindowAppImpl : public WindowApp TaskHandle_t mHandle = nullptr; QueueHandle_t mQueue = nullptr; -#ifdef ENABLE_WSTK_LEDS LEDWidget mStatusLED; LEDWidget mActionLED; -#endif // ENABLE_WSTK_LEDS // Get QR Code and emulate its content using NFC tag char mQRCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1]; diff --git a/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp b/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp index 108fd77f9f8e37..2d65b5a2117451 100644 --- a/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp +++ b/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp @@ -203,10 +203,9 @@ CHIP_ERROR WindowAppImpl::Init() } // Initialize LEDs -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Init(APP_STATE_LED); mActionLED.Init(APP_ACTION_LED); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED slLCD.Init(); @@ -393,21 +392,19 @@ void WindowAppImpl::UpdateLEDs() Cover & cover = GetCover(); if (mResetWarning) { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Set(false); mStatusLED.Blink(500); mActionLED.Set(false); mActionLED.Blink(500); -#endif // ENABLE_WSTK_LEDS } else { if (mState.isWinking) { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Blink(200, 200); -#endif // ENABLE_WSTK_LEDS } else #if CHIP_ENABLE_OPENTHREAD @@ -417,22 +414,11 @@ void WindowAppImpl::UpdateLEDs() #endif { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Blink(950, 50); -#endif // ENABLE_WSTK_LEDS - } - else if (mState.haveBLEConnections) - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(100, 100); -#endif // ENABLE_WSTK_LEDS - } - else - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(50, 950); -#endif // ENABLE_WSTK_LEDS } + else if (mState.haveBLEConnections) { mStatusLED.Blink(100, 100); } + else { mStatusLED.Blink(50, 950); } // Action LED NPercent100ths current; @@ -450,27 +436,23 @@ void WindowAppImpl::UpdateLEDs() if (OperationalState::Stall != cover.mLiftOpState) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Blink(100); -#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsUpOrOpen == liftLimit) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Set(true); -#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsDownOrClose == liftLimit) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Set(false); -#endif // ENABLE_WSTK_LEDS } else { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Blink(1000); -#endif // ENABLE_WSTK_LEDS } } } @@ -519,10 +501,9 @@ void WindowAppImpl::UpdateLCD() void WindowAppImpl::OnMainLoop() { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Animate(); mActionLED.Animate(); -#endif // ENABLE_WSTK_LEDS } //------------------------------------------------------------------------------ diff --git a/examples/window-app/silabs/efr32/include/WindowAppImpl.h b/examples/window-app/silabs/efr32/include/WindowAppImpl.h index a43f68ed85f6ef..27a26dba9a4399 100644 --- a/examples/window-app/silabs/efr32/include/WindowAppImpl.h +++ b/examples/window-app/silabs/efr32/include/WindowAppImpl.h @@ -19,10 +19,7 @@ #include -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #include #include @@ -85,10 +82,8 @@ class WindowAppImpl : public WindowApp TaskHandle_t mHandle = nullptr; QueueHandle_t mQueue = nullptr; -#ifdef ENABLE_WSTK_LEDS LEDWidget mStatusLED; LEDWidget mActionLED; -#endif // ENABLE_WSTK_LEDS // Get QR Code and emulate its content using NFC tag char mQRCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1]; diff --git a/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp b/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp index 77d3d6800c5d0a..734a4b4bc5d1a3 100644 --- a/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp +++ b/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp @@ -33,10 +33,6 @@ #endif // QR_CODE_ENABLED #include -#ifdef ENABLE_WSTK_LEDS -#include -#endif // ENABLE_WSTK_LEDS - #include #ifdef SL_WIFI @@ -60,8 +56,8 @@ SilabsLCD slLCD; using namespace chip::app::Clusters::WindowCovering; using namespace chip; using namespace ::chip::DeviceLayer; -#define APP_STATE_LED &sl_led_led0 -#define APP_ACTION_LED &sl_led_led1 +#define APP_STATE_LED 0 +#define APP_ACTION_LED 1 #ifdef SL_WIFI chip::app::Clusters::NetworkCommissioning::Instance @@ -208,11 +204,9 @@ CHIP_ERROR WindowAppImpl::Init() } // Initialize LEDs -#ifdef ENABLE_WSTK_LEDS LEDWidget::InitGpio(); mStatusLED.Init(APP_STATE_LED); mActionLED.Init(APP_ACTION_LED); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED slLCD.Init(); @@ -397,21 +391,17 @@ void WindowAppImpl::UpdateLEDs() Cover & cover = GetCover(); if (mResetWarning) { -#ifdef ENABLE_WSTK_LEDS mStatusLED.Set(false); mStatusLED.Blink(500); mActionLED.Set(false); mActionLED.Blink(500); -#endif // ENABLE_WSTK_LEDS } else { if (mState.isWinking) { -#ifdef ENABLE_WSTK_LEDS mStatusLED.Blink(200, 200); -#endif // ENABLE_WSTK_LEDS } else #if CHIP_ENABLE_OPENTHREAD @@ -421,22 +411,11 @@ void WindowAppImpl::UpdateLEDs() #endif { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Blink(950, 50); -#endif // ENABLE_WSTK_LEDS - } - else if (mState.haveBLEConnections) - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(100, 100); -#endif // ENABLE_WSTK_LEDS - } - else - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(50, 950); -#endif // ENABLE_WSTK_LEDS } + else if (mState.haveBLEConnections) { mStatusLED.Blink(100, 100); } + else { mStatusLED.Blink(50, 950); } // Action LED NPercent100ths current; @@ -454,27 +433,23 @@ void WindowAppImpl::UpdateLEDs() if (OperationalState::Stall != cover.mLiftOpState) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Blink(100); -#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsUpOrOpen == liftLimit) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Set(true); -#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsDownOrClose == liftLimit) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Set(false); -#endif // ENABLE_WSTK_LEDS } else { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Blink(1000); -#endif // ENABLE_WSTK_LEDS } } } @@ -523,10 +498,9 @@ void WindowAppImpl::UpdateLCD() void WindowAppImpl::OnMainLoop() { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Animate(); mActionLED.Animate(); -#endif // ENABLE_WSTK_LEDS } //------------------------------------------------------------------------------ diff --git a/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp b/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp index e0f954e101a90d..007977a6d66639 100644 --- a/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp +++ b/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp @@ -18,6 +18,12 @@ #include "init_efrPlatform.h" #include +#ifdef ENABLE_WSTK_LEDS +extern "C" { +#include "sl_simple_led_instances.h" +} +#endif + namespace chip { namespace DeviceLayer { namespace Silabs { @@ -31,9 +37,6 @@ CHIP_ERROR SilabsPlatform::Init(void) } #ifdef ENABLE_WSTK_LEDS - -#include "sl_simple_led_instances.h" - void SilabsPlatform::InitLed(void) { sl_simple_led_init_instances(); @@ -54,7 +57,7 @@ bool SilabsPlatform::GetLedState(uint8_t led) { if (led >= SL_SIMPLE_LED_COUNT) { - return 0; + return false; } return sl_led_get_state(SL_SIMPLE_LED_INSTANCE(led)); diff --git a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp index 97004960f94d06..816c9a6df4459d 100644 --- a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp +++ b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp @@ -37,27 +37,28 @@ CHIP_ERROR SilabsPlatform::Init(void) #ifdef ENABLE_WSTK_LEDS void SilabsPlatform::InitLed(void) { - // TODO ? + // TODO SilabsPlatformAbstractionBase::InitLed(); } CHIP_ERROR SilabsPlatform::SetLed(bool state, uint8_t led) override { - // TODO add range check ? + // TODO add range check RSI_Board_LED_Set(led, state); return CHIP_NO_ERROR; } bool SilabsPlatform::GetLedState(uint8_t led) { - // TODO ? + // TODO return SilabsPlatformAbstractionBase::GetLedState(led); } CHIP_ERROR SilabsPlatform::ToggleLed(uint8_t led) override { - // TODO add range check ? - RSI_Board_LED_Toggle(led) return CHIP_NO_ERROR; + // TODO add range check + RSI_Board_LED_Toggle(led); + return CHIP_NO_ERROR; } #endif // ENABLE_WSTK_LEDS From 710c951da5218c54a07cf7862c63644821ea88de Mon Sep 17 00:00:00 2001 From: Sergei Lissianoi <54454955+selissia@users.noreply.github.com> Date: Tue, 25 Apr 2023 08:27:27 -0400 Subject: [PATCH 019/200] Reset the OTARequestor state if the downloaded image is invalid (#26230) --- src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp | 4 ++++ src/platform/silabs/efr32/OTAImageProcessorImpl.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp b/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp index a838564d919520..2cfcc9694267e9 100644 --- a/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp +++ b/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp @@ -190,6 +190,8 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) if (err != SL_BOOTLOADER_OK) { ChipLogError(SoftwareUpdate, "ERROR: bootloader_verifyImage() error %ld", err); + // Call the OTARequestor API to reset the state + GetRequestorInstance()->CancelImageUpdate(); return; } @@ -198,6 +200,8 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) if (err != SL_BOOTLOADER_OK) { ChipLogError(SoftwareUpdate, "ERROR: bootloader_setImageToBootload() error %ld", err); + // Call the OTARequestor API to reset the state + GetRequestorInstance()->CancelImageUpdate(); return; } diff --git a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp index 83b815568b24fa..6d2bce9fdfb41b 100644 --- a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp +++ b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp @@ -201,6 +201,8 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) if (err != SL_BOOTLOADER_OK) { ChipLogError(SoftwareUpdate, "ERROR: bootloader_verifyImage() error %ld", err); + // Call the OTARequestor API to reset the state + GetRequestorInstance()->CancelImageUpdate(); return; } @@ -209,6 +211,8 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) if (err != SL_BOOTLOADER_OK) { ChipLogError(SoftwareUpdate, "ERROR: bootloader_setImageToBootload() error %ld", err); + // Call the OTARequestor API to reset the state + GetRequestorInstance()->CancelImageUpdate(); return; } From d8b703f79702a9ff9c1d89eec77c8db9485d8982 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Tue, 25 Apr 2023 09:29:37 -0400 Subject: [PATCH 020/200] Fix Disconnect RPC for ESP 32 (#26231) * Fix Disconnect RPC for ESP 32 * Restyle --- examples/platform/esp32/Rpc.cpp | 10 +++++++--- src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/examples/platform/esp32/Rpc.cpp b/examples/platform/esp32/Rpc.cpp index 3d865ed13bdc7a..1ad91dddef4253 100644 --- a/examples/platform/esp32/Rpc.cpp +++ b/examples/platform/esp32/Rpc.cpp @@ -204,8 +204,11 @@ class Esp32WiFi final : public WiFi size_t password_size = std::min(sizeof(password) - 1, static_cast(request.secret.size)); memcpy(password, request.secret.bytes, password_size); password[password_size] = '\0'; - if (chip::DeviceLayer::NetworkCommissioning::ESPWiFiDriver::GetInstance().ConnectWiFiNetwork( - ssid, strlen(ssid), password, strlen(password)) != CHIP_NO_ERROR) + chip::DeviceLayer::PlatformMgr().LockChipStack(); + CHIP_ERROR error = chip::DeviceLayer::NetworkCommissioning::ESPWiFiDriver::GetInstance().ConnectWiFiNetwork( + ssid, strlen(ssid), password, strlen(password)); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + if (error != CHIP_NO_ERROR) { return pw::Status::Internal(); } @@ -214,8 +217,9 @@ class Esp32WiFi final : public WiFi pw::Status Disconnect(const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override { + chip::DeviceLayer::PlatformMgr().LockChipStack(); chip::DeviceLayer::ConnectivityMgr().ClearWiFiStationProvision(); - chip::DeviceLayer::ConnectivityMgr().SetWiFiStationMode(chip::DeviceLayer::ConnectivityManager::kWiFiStationMode_Disabled); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); return pw::OkStatus(); } diff --git a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp index 4c962d24a5e5b0..48251a27129962 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp @@ -105,6 +105,12 @@ void ConnectivityManagerImpl::_ClearWiFiStationProvision(void) { if (mWiFiStationMode != kWiFiStationMode_ApplicationControlled) { + CHIP_ERROR error = chip::DeviceLayer::Internal::ESP32Utils::ClearWiFiStationProvision(); + if (error != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "ClearWiFiStationProvision failed: %s", chip::ErrorStr(error)); + return; + } DeviceLayer::SystemLayer().ScheduleWork(DriveStationState, NULL); #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, NULL); From 3212d3556f68f18969bf45b3951743457c232ef0 Mon Sep 17 00:00:00 2001 From: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com> Date: Tue, 25 Apr 2023 19:47:15 +0530 Subject: [PATCH 021/200] adding the lock and unlock chip stack and some build fixes for 917 SoC (#26245) --- examples/platform/silabs/SiWx917/BaseApplication.cpp | 3 +++ examples/platform/silabs/efr32/BaseApplication.cpp | 3 +++ src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/platform/silabs/SiWx917/BaseApplication.cpp b/examples/platform/silabs/SiWx917/BaseApplication.cpp index f0dde1ffc39e80..62b5f4cc1bc361 100644 --- a/examples/platform/silabs/SiWx917/BaseApplication.cpp +++ b/examples/platform/silabs/SiWx917/BaseApplication.cpp @@ -166,7 +166,10 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj) SILABS_LOG("APP: Done WiFi Init"); /* We will init server when we get IP */ + chip::DeviceLayer::PlatformMgr().LockChipStack(); sWiFiNetworkCommissioningInstance.Init(); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + #endif // Create FreeRTOS sw timer for Function Selection. diff --git a/examples/platform/silabs/efr32/BaseApplication.cpp b/examples/platform/silabs/efr32/BaseApplication.cpp index e29797607f7e35..6ce48e736d121e 100644 --- a/examples/platform/silabs/efr32/BaseApplication.cpp +++ b/examples/platform/silabs/efr32/BaseApplication.cpp @@ -178,7 +178,10 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj) SILABS_LOG("APP: Done WiFi Init"); /* We will init server when we get IP */ + chip::DeviceLayer::PlatformMgr().LockChipStack(); sWiFiNetworkCommissioningInstance.Init(); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + #endif // Create FreeRTOS sw timer for Function Selection. diff --git a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp index 816c9a6df4459d..7b5af3e6e87c2b 100644 --- a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp +++ b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp @@ -41,7 +41,7 @@ void SilabsPlatform::InitLed(void) SilabsPlatformAbstractionBase::InitLed(); } -CHIP_ERROR SilabsPlatform::SetLed(bool state, uint8_t led) override +CHIP_ERROR SilabsPlatform::SetLed(bool state, uint8_t led) { // TODO add range check RSI_Board_LED_Set(led, state); @@ -54,7 +54,7 @@ bool SilabsPlatform::GetLedState(uint8_t led) return SilabsPlatformAbstractionBase::GetLedState(led); } -CHIP_ERROR SilabsPlatform::ToggleLed(uint8_t led) override +CHIP_ERROR SilabsPlatform::ToggleLed(uint8_t led) { // TODO add range check RSI_Board_LED_Toggle(led); From b2069493e8b296fe2f844479557d0c1aff8b8037 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 25 Apr 2023 10:50:24 -0400 Subject: [PATCH 022/200] Switch to using zcl_struct_items_by_struct_and_cluster_name in templates. (#26226) Our existing uses of zcl_struct_items_by_struct_name were broken if two different clusters used structs with the same name: we would end up enumerating all the struct fields from both structs in a bunch of places. The fix is to use zcl_struct_items_by_struct_and_cluster_name, which takes as input the struct name _and_ the cluster name. No visible codegen changes for now, because we have no such name collisions so far, due to it leading to incorrect codegen. Instead we have been working around it by having our naming not match the spec. This required a few changes other than just the change of helper: 1. The valueEquals in chip-tool did not use to take a cluster name. That needed to be added, and threaded through the call-chain from the place where a cluster name is available, as well as through the recursive invocations of valueEquals. 2. In the java codegen, the cluster name being passed in to encode_value and decode_value was the already-upper-camel-cased version, which does not work as input to zcl_struct_items_by_struct_and_cluster_name. Callsites were changed to pass in the raw cluster name, and actual uses of the name were changed to asUpperCamelCase as needed. 3. While testing, using actual name collisions, a bug was found in the Python codegen: the id of the command being processed was being used when the id of the cluster was intended. --- .../checks/maybeCheckExpectedValue.zapt | 2 +- .../tests/partials/command_value.zapt | 4 ++-- .../tests/partials/test_step_response.zapt | 2 +- .../tests/partials/value_equals.zapt | 18 +++++++------- .../templates/partials/decodable_value.zapt | 4 ++-- .../tests/partials/check_test_value.zapt | 4 ++-- .../templates/tests/partials/test_value.zapt | 4 ++-- .../docker/images/chip-cert-bins/Dockerfile | 2 +- scripts/setup/zap.json | 2 +- scripts/tools/zap/zap_execution.py | 2 +- .../CHIPAttributeTLVValueDecoder-src.zapt | 2 +- .../java/templates/CHIPClustersWrite-JNI.zapt | 2 +- .../CHIPEventTLVValueDecoder-src.zapt | 2 +- .../templates/CHIPInvokeCallbacks-src.zapt | 2 +- .../java/templates/CHIPReadCallbacks-src.zapt | 4 ++-- .../java/templates/partials/decode_value.zapt | 24 +++++++++---------- .../java/templates/partials/encode_value.zapt | 6 ++--- .../templates/python-CHIPClusters-py.zapt | 8 +++---- .../CHIP/templates/partials/decode_value.zapt | 4 ++-- .../CHIP/templates/partials/encode_value.zapt | 4 ++-- 20 files changed, 51 insertions(+), 51 deletions(-) diff --git a/examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt b/examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt index e303eda9cd7a99..a75e7d7be6bcd3 100644 --- a/examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt +++ b/examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt @@ -1,3 +1,3 @@ {{~#if hasExpectedValue}} - {{~>valueEquals actual=(asPropertyValue dontUnwrapValue=true) label=(asLowerCamelCase name) expected=expectedValue depth=0~}} + {{~>valueEquals actual=(asPropertyValue dontUnwrapValue=true) label=(asLowerCamelCase name) expected=expectedValue cluster=cluster depth=0~}} {{~/if~}} diff --git a/examples/chip-tool/templates/tests/partials/command_value.zapt b/examples/chip-tool/templates/tests/partials/command_value.zapt index d5a1159cceb7fb..150b34294e5e2c 100644 --- a/examples/chip-tool/templates/tests/partials/command_value.zapt +++ b/examples/chip-tool/templates/tests/partials/command_value.zapt @@ -29,11 +29,11 @@ {{else}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type ns}} {{#if_include_struct_item_value ../definedValue name}} {{>commandValue ns=parent.ns container=(concat parent.container "." (asLowerCamelCase label)) definedValue=(lookup ../definedValue name) depth=(incrementDepth ../depth)}} {{/if_include_struct_item_value}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{container}} = diff --git a/examples/chip-tool/templates/tests/partials/test_step_response.zapt b/examples/chip-tool/templates/tests/partials/test_step_response.zapt index eae82bf13bc463..0f520b856794e7 100644 --- a/examples/chip-tool/templates/tests/partials/test_step_response.zapt +++ b/examples/chip-tool/templates/tests/partials/test_step_response.zapt @@ -29,7 +29,7 @@ switch(mTestSubStepIndex) {{asDecodableType}} value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); {{#chip_tests_item_response_parameters}} - {{>maybeCheckExpectedValue}} + {{>maybeCheckExpectedValue cluster=../cluster}} {{>maybeCheckExpectedConstraints}} {{>maybeSaveAs}} {{/chip_tests_item_response_parameters}} diff --git a/examples/chip-tool/templates/tests/partials/value_equals.zapt b/examples/chip-tool/templates/tests/partials/value_equals.zapt index 5cda33b2b92df9..614ed51ffc9ba4 100644 --- a/examples/chip-tool/templates/tests/partials/value_equals.zapt +++ b/examples/chip-tool/templates/tests/partials/value_equals.zapt @@ -1,6 +1,6 @@ {{#if isOptional}} VerifyOrReturn(CheckValuePresent("{{label}}", {{actual}})); - {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isOptional=false depth=(incrementDepth depth)}} + {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isOptional=false cluster=cluster depth=(incrementDepth depth)}} {{else if isNullable}} {{#if (isLiteralNull expected)}} VerifyOrReturn(CheckValueNull("{{label}}", {{actual}})); @@ -14,15 +14,15 @@ else { VerifyOrReturn(CheckValueNonNull("{{label}}", {{actual}})); - {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=(concat expected ".Value()") isNullable=false keepAsExpected=true depth=(incrementDepth depth)}} + {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=(concat expected ".Value()") isNullable=false keepAsExpected=true cluster=cluster depth=(incrementDepth depth)}} } {{else}} VerifyOrReturn(CheckValueNonNull("{{label}}", {{actual}})); - {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false keepAsExpected=true depth=(incrementDepth depth)}} + {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false keepAsExpected=true cluster=cluster depth=(incrementDepth depth)}} {{/if}} {{else}} VerifyOrReturn(CheckValueNonNull("{{label}}", {{actual}})); - {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false depth=(incrementDepth depth)}} + {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false cluster=cluster depth=(incrementDepth depth)}} {{/if}} {{/if}} {{else if isArray}} @@ -31,14 +31,14 @@ auto iter_{{depth}} = {{actual}}.begin(); {{#each expected}} VerifyOrReturn(CheckNextListItemDecodes("{{../label}}", iter_{{../depth}}, {{@index}})); - {{>valueEquals label=(concat ../label "[" @index "]") actual=(concat "iter_" ../depth ".GetValue()") expected=this isArray=false type=../type chipType=../chipType depth=(incrementDepth ../depth) parent=../parent}} + {{>valueEquals label=(concat ../label "[" @index "]") actual=(concat "iter_" ../depth ".GetValue()") expected=this isArray=false type=../type chipType=../chipType cluster=../cluster depth=(incrementDepth ../depth) parent=../parent}} {{/each}} VerifyOrReturn(CheckNoMoreListItems("{{label}}", iter_{{depth}}, {{expected.length}})); } {{else if isEvent}} {{#zcl_events_fields_by_event_name type}} {{#if (hasProperty ../expected label)}} - {{>valueEquals label=(concat ../label "." (asLowerCamelCase label)) actual=(concat ../actual "." (asLowerCamelCase label)) expected=(lookup ../expected label) depth=(incrementDepth ../depth)}} + {{>valueEquals label=(concat ../label "." (asLowerCamelCase label)) actual=(concat ../actual "." (asLowerCamelCase label)) expected=(lookup ../expected label) cluster=../cluster depth=(incrementDepth ../depth)}} {{/if}} {{/zcl_events_fields_by_event_name}} {{else}} @@ -46,11 +46,11 @@ {{! Iterate over the actual types in the struct, so we pick up the right type/optionality/nullability information for them for our recursive call. }} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{#if (hasProperty ../expected label)}} - {{>valueEquals label=(concat ../label "." (asLowerCamelCase label)) actual=(concat ../actual "." (asLowerCamelCase label)) expected=(lookup ../expected label) depth=(incrementDepth ../depth)}} + {{>valueEquals label=(concat ../label "." (asLowerCamelCase label)) actual=(concat ../actual "." (asLowerCamelCase label)) expected=(lookup ../expected label) cluster=../cluster depth=(incrementDepth ../depth)}} {{/if}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{! Maybe we should add a check for properties in the expected object (other than "global") that are not present in the struct ? }} {{else}} diff --git a/examples/darwin-framework-tool/templates/partials/decodable_value.zapt b/examples/darwin-framework-tool/templates/partials/decodable_value.zapt index 76a8e54369f509..8d0442000a070c 100644 --- a/examples/darwin-framework-tool/templates/partials/decodable_value.zapt +++ b/examples/darwin-framework-tool/templates/partials/decodable_value.zapt @@ -23,9 +23,9 @@ {{else}} {{#if_is_struct type}} {{target}} = [{{asObjectiveCClass type cluster forceNotList=true}} new]; - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{>decodable_value target=(concat ../target "." (asStructPropertyName label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster depth=(incrementDepth ../depth) }} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{#if_is_strongly_typed_chip_enum type}} {{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:chip::to_underlying({{source}})]; diff --git a/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt b/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt index e84e485fcdb792..26aa91ac9ce056 100644 --- a/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt +++ b/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt @@ -28,11 +28,11 @@ {{! Iterate over the actual types in the struct, so we pick up the right type/optionality/nullability information for them for our recursive call. }} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{#if (hasProperty ../expected label)}} {{>check_test_value actual=(concat "((MTR" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../actual ")." (asStructPropertyName label)) expected=(lookup ../expected label) cluster=../cluster}} {{/if}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{! Maybe we should add a check for properties in the expected object (other than "global") that are not present in the struct ? }} {{else}} diff --git a/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt b/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt index 623f5e0e6c38d2..30c342cecb809d 100644 --- a/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt +++ b/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt @@ -19,14 +19,14 @@ {{else}} {{#if_is_struct type}} {{target}} = [[MTR{{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}} alloc] init]; - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{#if_include_struct_item_value ../definedValue name}} {{! target may be some place where we lost type information (e.g. an id), so add explicit cast when trying to assign to our properties. }} {{>test_value target=(concat "((MTR" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../target ")." (asStructPropertyName label)) definedValue=(lookup ../definedValue name) cluster=../cluster depth=(incrementDepth ../depth)}} {{/if_include_struct_item_value}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{target}} = diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile index 8e9db74f22455a..218438bb81ec79 100644 --- a/integrations/docker/images/chip-cert-bins/Dockerfile +++ b/integrations/docker/images/chip-cert-bins/Dockerfile @@ -7,7 +7,7 @@ ARG COMMITHASH=7b99e6399c6069037c613782d78132c69b9dcabb # ZAP Development install, so that it runs on both x64 and arm64 # Generally this should match with the ZAP version that is used for codegen within the # specified SHA -ARG ZAP_VERSION=v2023.04.18-nightly +ARG ZAP_VERSION=v2023.04.21-nightly # Ensure TARGETPLATFORM is set RUN case ${TARGETPLATFORM} in \ diff --git a/scripts/setup/zap.json b/scripts/setup/zap.json index 4ed3e0d4ab1ce2..df3f76ff5b5d0f 100644 --- a/scripts/setup/zap.json +++ b/scripts/setup/zap.json @@ -8,7 +8,7 @@ "mac-arm64", "windows-amd64" ], - "tags": ["version:2@v2023.04.18-nightly.1"] + "tags": ["version:2@v2023.04.21-nightly.1"] } ] } diff --git a/scripts/tools/zap/zap_execution.py b/scripts/tools/zap/zap_execution.py index 29d8e83c957d37..3fdeeab5a1da93 100644 --- a/scripts/tools/zap/zap_execution.py +++ b/scripts/tools/zap/zap_execution.py @@ -23,7 +23,7 @@ # Use scripts/tools/zap/version_update.py to manage ZAP versioning as many # files may need updating for versions # -MIN_ZAP_VERSION = '2023.4.18' +MIN_ZAP_VERSION = '2023.4.21' class ZapTool: diff --git a/src/controller/java/templates/CHIPAttributeTLVValueDecoder-src.zapt b/src/controller/java/templates/CHIPAttributeTLVValueDecoder-src.zapt index ce42d5d1140680..c4ecf0256ace49 100644 --- a/src/controller/java/templates/CHIPAttributeTLVValueDecoder-src.zapt +++ b/src/controller/java/templates/CHIPAttributeTLVValueDecoder-src.zapt @@ -51,7 +51,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR { return nullptr; } - {{>decode_value target="value" source="cppValue" cluster=(asUpperCamelCase parent.name) depth=0 earlyReturn="nullptr"}} + {{>decode_value target="value" source="cppValue" cluster=parent.name depth=0 earlyReturn="nullptr"}} return value; } {{/zcl_attributes_server}} diff --git a/src/controller/java/templates/CHIPClustersWrite-JNI.zapt b/src/controller/java/templates/CHIPClustersWrite-JNI.zapt index 9be7cfb69dcd39..2a77e14c42d1bb 100644 --- a/src/controller/java/templates/CHIPClustersWrite-JNI.zapt +++ b/src/controller/java/templates/CHIPClustersWrite-JNI.zapt @@ -45,7 +45,7 @@ JNI_METHOD(void, {{asUpperCamelCase ../name}}Cluster, write{{asUpperCamelCase na std::vector> cleanupByteArrays; std::vector> cleanupStrings; - {{>encode_value target="cppValue" source="value" cluster=(asUpperCamelCase parent.name) depth=0}} + {{>encode_value target="cppValue" source="value" cluster=parent.name depth=0}} std::unique_ptr onSuccess(Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); diff --git a/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt b/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt index 58554412612858..a9e78ba6590ff8 100644 --- a/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt +++ b/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt @@ -51,7 +51,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } {{#zcl_event_fields}} - {{>decode_value target=(concat "value_" (asLowerCamelCase name)) source=(concat "cppValue." (asLowerCamelCase name)) cluster=(asUpperCamelCase parent.parent.name) depth=0 earlyReturn="nullptr"}} + {{>decode_value target=(concat "value_" (asLowerCamelCase name)) source=(concat "cppValue." (asLowerCamelCase name)) cluster=parent.parent.name depth=0 earlyReturn="nullptr"}} {{/zcl_event_fields}} jclass {{asLowerCamelCase name}}StructClass; diff --git a/src/controller/java/templates/CHIPInvokeCallbacks-src.zapt b/src/controller/java/templates/CHIPInvokeCallbacks-src.zapt index 9f4d999174ce21..29a6769214ee7e 100644 --- a/src/controller/java/templates/CHIPInvokeCallbacks-src.zapt +++ b/src/controller/java/templates/CHIPInvokeCallbacks-src.zapt @@ -64,7 +64,7 @@ void CHIP{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Callbac VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); {{#zcl_command_arguments}} - {{>decode_value source=(concat "dataResponse." (asLowerCamelCase name)) target=(asSymbol label) cluster=(asUpperCamelCase parent.parent.name) depth=0}} + {{>decode_value source=(concat "dataResponse." (asLowerCamelCase name)) target=(asSymbol label) cluster=parent.parent.name depth=0}} {{/zcl_command_arguments}} env->CallVoidMethod(javaCallbackRef, javaMethod{{#zcl_command_arguments}}, {{asSymbol label}}{{/zcl_command_arguments}}); diff --git a/src/controller/java/templates/CHIPReadCallbacks-src.zapt b/src/controller/java/templates/CHIPReadCallbacks-src.zapt index 60bc0b09447780..5a643e5369079d 100644 --- a/src/controller/java/templates/CHIPReadCallbacks-src.zapt +++ b/src/controller/java/templates/CHIPReadCallbacks-src.zapt @@ -139,7 +139,7 @@ void CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallb err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); - {{>decode_value source="list" target="arrayListObj" cluster=(asUpperCamelCase parent.name) depth=0}} + {{>decode_value source="list" target="arrayListObj" cluster=parent.name depth=0}} env->ExceptionClear(); env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); @@ -165,7 +165,7 @@ void CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallb err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "({{#if isArray}}{{else if isStruct}}{{else if isOptional}}Ljava/util/Optional;{{else if (isOctetString type)}}[B{{else if (isCharString type)}}Ljava/lang/String;{{else}}{{asJniSignatureBasic type true}}{{/if}})V", &javaMethod); VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); - {{>decode_value source="value" target="javaValue" cluster=(asUpperCamelCase parent.name) depth=0}} + {{>decode_value source="value" target="javaValue" cluster=parent.name depth=0}} env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); } diff --git a/src/controller/java/templates/partials/decode_value.zapt b/src/controller/java/templates/partials/decode_value.zapt index d1c51b5edeee33..8837a43711e578 100644 --- a/src/controller/java/templates/partials/decode_value.zapt +++ b/src/controller/java/templates/partials/decode_value.zapt @@ -27,32 +27,32 @@ if ({{source}}.IsNull()) { } {{else}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{>decode_value target=(concat ../target "_" (asLowerCamelCase label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster depth=(incrementDepth ../depth) omitDeclaration=false earlyReturn=../earlyReturn}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} jclass {{asLowerCamelCase type}}StructClass_{{depth}}; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs${{cluster}}Cluster{{asUpperCamelCase type}}", {{asLowerCamelCase type}}StructClass_{{depth}}); + err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}", {{asLowerCamelCase type}}StructClass_{{depth}}); if (err != CHIP_NO_ERROR) { - ChipLogError(Zcl, "Could not find class ChipStructs${{cluster}}Cluster{{asUpperCamelCase type}}"); + ChipLogError(Zcl, "Could not find class ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}"); return {{earlyReturn}}; } jmethodID {{asLowerCamelCase type}}StructCtor_{{depth}} = env->GetMethodID({{asLowerCamelCase type}}StructClass_{{depth}}, "" - , "({{#zcl_struct_items_by_struct_name type}}{{asJniSignature type null ../cluster true}}{{/zcl_struct_items_by_struct_name}})V"); + , "({{#zcl_struct_items_by_struct_and_cluster_name type cluster}}{{asJniSignature type null (asUpperCamelCase ../cluster) true}}{{/zcl_struct_items_by_struct_and_cluster_name}})V"); if ({{asLowerCamelCase type}}StructCtor_{{depth}} == nullptr) { - ChipLogError(Zcl, "Could not find ChipStructs${{cluster}}Cluster{{asUpperCamelCase type}} constructor"); + ChipLogError(Zcl, "Could not find ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}} constructor"); return {{earlyReturn}}; } {{target}} = env->NewObject({{asLowerCamelCase type}}StructClass_{{depth}}, {{asLowerCamelCase type}}StructCtor_{{depth}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} , {{../target}}_{{asLowerCamelCase label}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} ); {{else}} {{#if_is_strongly_typed_chip_enum type}} - std::string {{target}}ClassName = "{{asJniClassName type null cluster}}"; - std::string {{target}}CtorSignature = "({{asJniSignature type null cluster false}})V"; + std::string {{target}}ClassName = "{{asJniClassName type null (asUpperCamelCase cluster)}}"; + std::string {{target}}CtorSignature = "({{asJniSignature type null (asUpperCamelCase cluster) false}})V"; chip::JniReferences::GetInstance().CreateBoxedObject<{{asUnderlyingBasicType type}}>({{target}}ClassName.c_str(), {{target}}CtorSignature.c_str(), static_cast<{{asUnderlyingBasicType type}}>({{source}}), {{target}}); {{else}} {{#if (isOctetString type)}} @@ -62,8 +62,8 @@ if ({{source}}.IsNull()) { {{else if (isCharString type)}} LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF({{source}}, {{target}})); {{else}} - std::string {{target}}ClassName = "{{asJniClassName type null cluster}}"; - std::string {{target}}CtorSignature = "({{asJniSignature type null cluster false}})V"; + std::string {{target}}ClassName = "{{asJniClassName type null (asUpperCamelCase cluster)}}"; + std::string {{target}}CtorSignature = "({{asJniSignature type null (asUpperCamelCase cluster) false}})V"; {{#if_is_strongly_typed_bitmap type}} chip::JniReferences::GetInstance().CreateBoxedObject<{{asUnderlyingBasicType type}}>({{target}}ClassName.c_str(), {{target}}CtorSignature.c_str(), {{source}}.Raw(), {{target}}); {{else}} diff --git a/src/controller/java/templates/partials/encode_value.zapt b/src/controller/java/templates/partials/encode_value.zapt index 181688acb2c6f0..8540e487d9ca58 100644 --- a/src/controller/java/templates/partials/encode_value.zapt +++ b/src/controller/java/templates/partials/encode_value.zapt @@ -42,11 +42,11 @@ {{target}} = cleanupStrings.back()->charSpan(); {{else}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} jobject {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}; - chip::JniReferences::GetInstance().GetObjectField({{../source}}, "{{asLowerCamelCase label}}", "{{asJniSignature type null ../cluster true}}", {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}); + chip::JniReferences::GetInstance().GetObjectField({{../source}}, "{{asLowerCamelCase label}}", "{{asJniSignature type null (asUpperCamelCase ../cluster) true}}", {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}); {{>encode_value target=(concat ../target "." (asLowerCamelCase label)) source=(concat ../source "_" (asLowerCamelCase label) "Item_" ../depth) cluster=../cluster depth=(incrementDepth ../depth)}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{#if_chip_enum type}} {{target}} = static_cast>(chip::JniReferences::GetInstance().{{asJavaType type null parent.parent.name forceNotList=true}}ToPrimitive({{source}})); diff --git a/src/controller/python/templates/python-CHIPClusters-py.zapt b/src/controller/python/templates/python-CHIPClusters-py.zapt index 4b1443e7211de4..9917fecb1ba5b2 100644 --- a/src/controller/python/templates/python-CHIPClusters-py.zapt +++ b/src/controller/python/templates/python-CHIPClusters-py.zapt @@ -27,11 +27,11 @@ class ChipClusters: "args": { {{#zcl_command_arguments}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} - "{{asLowerCamelCase label}}": "{{#if (isCharString type)}}str{{else}}{{as_underlying_python_zcl_type type ../../id}}{{/if}}", - {{/zcl_struct_items_by_struct_name}} + {{#zcl_struct_items_by_struct_and_cluster_name type ../../name}} + "{{asLowerCamelCase label}}": "{{#if (isCharString type)}}str{{else}}{{as_underlying_python_zcl_type type ../../../id}}{{/if}}", + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} - "{{asLowerCamelCase label}}": "{{#if (isCharString type)}}str{{else}}{{as_underlying_python_zcl_type type ../id}}{{/if}}", + "{{asLowerCamelCase label}}": "{{#if (isCharString type)}}str{{else}}{{as_underlying_python_zcl_type type ../../id}}{{/if}}", {{/if_is_struct}} {{/zcl_command_arguments}} }, diff --git a/src/darwin/Framework/CHIP/templates/partials/decode_value.zapt b/src/darwin/Framework/CHIP/templates/partials/decode_value.zapt index 50477cd01d70a4..29e64683ba5062 100644 --- a/src/darwin/Framework/CHIP/templates/partials/decode_value.zapt +++ b/src/darwin/Framework/CHIP/templates/partials/decode_value.zapt @@ -29,9 +29,9 @@ {{else}} {{#if_is_struct type}} {{target}} = [{{asObjectiveCClass type cluster forceNotList=true}} new]; - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{>decode_value target=(concat ../target "." (asStructPropertyName label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster errorCode=../errorCode depth=(incrementDepth ../depth) }} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{#if_is_strongly_typed_chip_enum type}} {{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:chip::to_underlying({{source}})]; diff --git a/src/darwin/Framework/CHIP/templates/partials/encode_value.zapt b/src/darwin/Framework/CHIP/templates/partials/encode_value.zapt index 0c54e8124e19a1..79d38dc87f3c91 100644 --- a/src/darwin/Framework/CHIP/templates/partials/encode_value.zapt +++ b/src/darwin/Framework/CHIP/templates/partials/encode_value.zapt @@ -45,9 +45,9 @@ {{target}} = [self asCharSpan:{{source}}]; {{else}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{>encode_value target=(concat ../target "." (asLowerCamelCase label)) source=(concat ../source "." (asStructPropertyName label)) cluster=../cluster errorCode=../errorCode depth=(incrementDepth ../depth)}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{#if_is_strongly_typed_chip_enum type}} {{target}} = static_cast>({{source}}.{{asObjectiveCNumberType source type true}}Value); From 4850ad8ffa185543129e2d1d70d65fa56b64b65f Mon Sep 17 00:00:00 2001 From: shripad621git <79364691+shripad621git@users.noreply.github.com> Date: Tue, 25 Apr 2023 20:45:08 +0530 Subject: [PATCH 023/200] Suppressing the logs related to events' Long dispatch time and Log related changes in Logging.cpp. (#26227) -Provided the config option specific to ESP32 to set the threshold for events dispatching time. -Set the config option by default to 0 to suppress the Long dispatch time logs. -The log related changes mainly changes the way the logs are converted into the idf specific format. -The arguments are directly used from chip_log instead of converting them to a string and then calling the IDF API. -This also removes the need for the extra buffer, and also removes the limit for the 256 length for the log + arguments size. --- config/esp32/components/chip/Kconfig | 8 ++++++++ src/platform/ESP32/CHIPPlatformConfig.h | 1 + src/platform/ESP32/Logging.cpp | 27 +++++++++++++++++++------ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 3b6d84a5c776fc..e92764e5dfa078 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -108,6 +108,14 @@ menu "CHIP Core" help Build CHIP test binaries. + config DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS + int "Set threshold in ms" + default 700 + help + Time threshold for events dispatching. By default set to 0 to + to disable event dispatching time measurement and suppress the + logs for Long dispatch time. + # TODO: add log level selection endmenu # "General Options" diff --git a/src/platform/ESP32/CHIPPlatformConfig.h b/src/platform/ESP32/CHIPPlatformConfig.h index be023dfde901ae..9f7faedb8a0ff7 100644 --- a/src/platform/ESP32/CHIPPlatformConfig.h +++ b/src/platform/ESP32/CHIPPlatformConfig.h @@ -51,6 +51,7 @@ // The following values are configured via the ESP-IDF Kconfig mechanism. +#define CHIP_DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS CONFIG_DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS #define CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS #define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS CONFIG_MAX_EXCHANGE_CONTEXTS #define CHIP_CONFIG_SECURITY_TEST_MODE CONFIG_SECURITY_TEST_MODE diff --git a/src/platform/ESP32/Logging.cpp b/src/platform/ESP32/Logging.cpp index b2fbaac3cfbd1a..7f96a70dabecb2 100644 --- a/src/platform/ESP32/Logging.cpp +++ b/src/platform/ESP32/Logging.cpp @@ -26,20 +26,35 @@ void ENFORCE_FORMAT(3, 0) LogV(const char * module, uint8_t category, const char snprintf(tag, sizeof(tag), "chip[%s]", module); tag[sizeof(tag) - 1] = 0; - char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; - vsnprintf(formattedMsg, sizeof(formattedMsg), msg, v); - switch (category) { case kLogCategory_Error: - ESP_LOGE(tag, "%s", formattedMsg); + if (esp_log_default_level >= ESP_LOG_ERROR) + { + printf(LOG_COLOR_E "E"); // set color + printf(" (%u) %s: ", esp_log_timestamp(), tag); // add timestamp + esp_log_writev(ESP_LOG_ERROR, tag, msg, v); + printf(LOG_RESET_COLOR "\n"); + } break; case kLogCategory_Progress: default: - ESP_LOGI(tag, "%s", formattedMsg); + if (esp_log_default_level >= ESP_LOG_INFO) + { + printf(LOG_COLOR_I "I"); // set color + printf(" (%u) %s: ", esp_log_timestamp(), tag); // add timestamp + esp_log_writev(ESP_LOG_INFO, tag, msg, v); + printf(LOG_RESET_COLOR "\n"); + } break; case kLogCategory_Detail: - ESP_LOGD(tag, "%s", formattedMsg); + if (esp_log_default_level >= ESP_LOG_DEBUG) + { + printf(LOG_COLOR_D "D"); // set color + printf(" (%u) %s: ", esp_log_timestamp(), tag); // add timestamp + esp_log_writev(ESP_LOG_DEBUG, tag, msg, v); + printf(LOG_RESET_COLOR "\n"); + } break; } } From 3124f51bc2c9fee6930ec3cb5cc31a0cf85a9c14 Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Tue, 25 Apr 2023 17:16:32 +0200 Subject: [PATCH 024/200] [Linux] Fix event loop task consecutive start/stop (#26195) * [Linux] Fix event loop task consecutive start/stop * Wait for lambdas before stopping loop task * Add comment for sleep() usage in test --- .../GenericPlatformManagerImpl_POSIX.ipp | 4 ++ src/platform/tests/TestPlatformMgr.cpp | 48 +++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp b/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp index 6050950bf4c261..1b09d298eb2867 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp +++ b/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp @@ -59,6 +59,8 @@ CHIP_ERROR GenericPlatformManagerImpl_POSIX::_InitChipStack() // Call up to the base class _InitChipStack() to perform the bulk of the initialization. ReturnErrorOnFailure(GenericPlatformManagerImpl::_InitChipStack()); + mShouldRunEventLoop.store(true, std::memory_order_relaxed); + int ret = pthread_cond_init(&mEventQueueStoppedCond, nullptr); VerifyOrReturnError(ret == 0, CHIP_ERROR_POSIX(ret)); @@ -225,6 +227,8 @@ CHIP_ERROR GenericPlatformManagerImpl_POSIX::_StartEventLoopTask() VerifyOrReturnError(err == 0, CHIP_ERROR_POSIX(err)); #endif + mShouldRunEventLoop.store(true, std::memory_order_relaxed); + // // We need to grab the lock here since we have to protect setting // mHasValidChipTask, which will be read right away upon creating the diff --git a/src/platform/tests/TestPlatformMgr.cpp b/src/platform/tests/TestPlatformMgr.cpp index cd2caab4b96eb9..449e96d30eddbd 100644 --- a/src/platform/tests/TestPlatformMgr.cpp +++ b/src/platform/tests/TestPlatformMgr.cpp @@ -28,6 +28,8 @@ #include #include +#include + #include #include #include @@ -55,14 +57,52 @@ static void TestPlatformMgr_InitShutdown(nlTestSuite * inSuite, void * inContext static void TestPlatformMgr_BasicEventLoopTask(nlTestSuite * inSuite, void * inContext) { + std::atomic counterRun{ 0 }; + CHIP_ERROR err = PlatformMgr().InitChipStack(); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - err = PlatformMgr().StartEventLoopTask(); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Start/stop the event loop task a few times. + for (size_t i = 0; i < 3; i++) + { + err = PlatformMgr().StartEventLoopTask(); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + std::atomic counterSync{ 2 }; + + // Verify that the event loop will not exit until we tell it to by + // scheduling few lambdas (for the test to pass, the event loop will + // have to process more than one event). + DeviceLayer::SystemLayer().ScheduleLambda([&]() { + counterRun++; + counterSync--; + }); + + // Sleep for a short time to allow the event loop to process the + // scheduled event and go to idle state. Without this sleep, the + // event loop may process both scheduled lambdas during single + // iteration of the event loop which would defeat the purpose of + // this test on POSIX platforms where the event loop is implemented + // using a "do { ... } while (shouldRun)" construct. + chip::test_utils::SleepMillis(10); + + DeviceLayer::SystemLayer().ScheduleLambda([&]() { + counterRun++; + counterSync--; + }); + + // Wait for the event loop to process the scheduled events. + // Note, that we can not use any synchronization primitives like + // condition variables or barriers, because the test has to compile + // on all platforms. Instead we use a busy loop with a timeout. + for (size_t t = 0; counterSync != 0 && t < 1000; t++) + chip::test_utils::SleepMillis(1); + + err = PlatformMgr().StopEventLoopTask(); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + } - err = PlatformMgr().StopEventLoopTask(); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, counterRun == (3 * 2)); PlatformMgr().Shutdown(); } From bab40deb8fa7ecdd1b0f27bce5b58de01e186b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Ba=C5=82ys?= Date: Tue, 25 Apr 2023 17:25:52 +0200 Subject: [PATCH 025/200] [nrfconnect] Repair Rotating Device ID UID parsing (#26179) Rotating Device Id Unique Id was parsing wrongly in nrfconnect's factory data provider implementation. There was also a problem, that testing Rotating Device Id UID was not being provided by Zephyr's Kconfig. Repaired the factory_data build for nRFconnect devices. --- .../nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + .../nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + .../nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + .../lighting-app/nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + examples/lock-app/nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + examples/pump-app/nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + .../nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + .../window-app/nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + src/platform/nrfconnect/BUILD.gn | 5 ++ .../DeviceInstanceInfoProviderImpl.cpp | 47 +++++++++++++++++++ .../DeviceInstanceInfoProviderImpl.h | 43 +++++++++++++++++ src/platform/nrfconnect/FactoryDataParser.c | 15 +++--- .../nrfconnect/FactoryDataProvider.cpp | 2 +- 21 files changed, 126 insertions(+), 10 deletions(-) create mode 100644 src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.cpp create mode 100644 src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.h diff --git a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp index 0cee0e74ba78c8..05103f4c87f25d 100644 --- a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp +++ b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp @@ -190,6 +190,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/all-clusters-app/nrfconnect/main/include/AppTask.h b/examples/all-clusters-app/nrfconnect/main/include/AppTask.h index a369eeefe55c6b..4b57d1dc3f249c 100644 --- a/examples/all-clusters-app/nrfconnect/main/include/AppTask.h +++ b/examples/all-clusters-app/nrfconnect/main/include/AppTask.h @@ -24,6 +24,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp b/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp index fc565a94d1c12f..19ce36436419b3 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp +++ b/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp @@ -144,6 +144,7 @@ CHIP_ERROR AppTask::Init() SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); SetCommissionableDataProvider(&mFactoryDataProvider); #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h b/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h index 1a6922e9286f0d..9921de58383521 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h +++ b/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h @@ -24,6 +24,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/examples/light-switch-app/nrfconnect/main/AppTask.cpp b/examples/light-switch-app/nrfconnect/main/AppTask.cpp index 4419f8615be960..e77184a6a6c355 100644 --- a/examples/light-switch-app/nrfconnect/main/AppTask.cpp +++ b/examples/light-switch-app/nrfconnect/main/AppTask.cpp @@ -208,6 +208,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/light-switch-app/nrfconnect/main/include/AppTask.h b/examples/light-switch-app/nrfconnect/main/include/AppTask.h index 4e0a264af03667..a40c5e82bfd51f 100644 --- a/examples/light-switch-app/nrfconnect/main/include/AppTask.h +++ b/examples/light-switch-app/nrfconnect/main/include/AppTask.h @@ -25,6 +25,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp index 485d000d5cfb75..3b4d1a020de535 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -232,6 +232,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/lighting-app/nrfconnect/main/include/AppTask.h b/examples/lighting-app/nrfconnect/main/include/AppTask.h index 874be7d759b5a8..51df03f650c530 100644 --- a/examples/lighting-app/nrfconnect/main/include/AppTask.h +++ b/examples/lighting-app/nrfconnect/main/include/AppTask.h @@ -26,6 +26,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_CHIP_PW_RPC diff --git a/examples/lock-app/nrfconnect/main/AppTask.cpp b/examples/lock-app/nrfconnect/main/AppTask.cpp index 61b96e266e6038..9e59b86fcdcc4e 100644 --- a/examples/lock-app/nrfconnect/main/AppTask.cpp +++ b/examples/lock-app/nrfconnect/main/AppTask.cpp @@ -202,6 +202,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/lock-app/nrfconnect/main/include/AppTask.h b/examples/lock-app/nrfconnect/main/include/AppTask.h index 402752d6412738..76738ac9afd331 100644 --- a/examples/lock-app/nrfconnect/main/include/AppTask.h +++ b/examples/lock-app/nrfconnect/main/include/AppTask.h @@ -27,6 +27,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp index 94a7088dbc7644..1a45d22444af03 100644 --- a/examples/pump-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-app/nrfconnect/main/AppTask.cpp @@ -175,6 +175,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/pump-app/nrfconnect/main/include/AppTask.h b/examples/pump-app/nrfconnect/main/include/AppTask.h index a534482c2b7c87..bcf2d1eaf20dad 100644 --- a/examples/pump-app/nrfconnect/main/include/AppTask.h +++ b/examples/pump-app/nrfconnect/main/include/AppTask.h @@ -27,6 +27,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp index b97b11eabc1baf..6a8954c121f0e1 100644 --- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp @@ -173,6 +173,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/pump-controller-app/nrfconnect/main/include/AppTask.h b/examples/pump-controller-app/nrfconnect/main/include/AppTask.h index 742923f106a195..02e7f0a5320d12 100644 --- a/examples/pump-controller-app/nrfconnect/main/include/AppTask.h +++ b/examples/pump-controller-app/nrfconnect/main/include/AppTask.h @@ -27,6 +27,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/examples/window-app/nrfconnect/main/AppTask.cpp b/examples/window-app/nrfconnect/main/AppTask.cpp index b0b3886a0a802f..280f63316a669c 100644 --- a/examples/window-app/nrfconnect/main/AppTask.cpp +++ b/examples/window-app/nrfconnect/main/AppTask.cpp @@ -179,6 +179,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/window-app/nrfconnect/main/include/AppTask.h b/examples/window-app/nrfconnect/main/include/AppTask.h index 4d134a791fa8fd..28a7331d9737ba 100644 --- a/examples/window-app/nrfconnect/main/include/AppTask.h +++ b/examples/window-app/nrfconnect/main/include/AppTask.h @@ -24,6 +24,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/src/platform/nrfconnect/BUILD.gn b/src/platform/nrfconnect/BUILD.gn index 40c6f8cac3d292..1efcadfa9fe82e 100644 --- a/src/platform/nrfconnect/BUILD.gn +++ b/src/platform/nrfconnect/BUILD.gn @@ -69,6 +69,11 @@ static_library("nrfconnect") { "FactoryDataProvider.cpp", "FactoryDataProvider.h", ] + } else { + sources += [ + "DeviceInstanceInfoProviderImpl.cpp", + "DeviceInstanceInfoProviderImpl.h", + ] } if (chip_enable_openthread) { diff --git a/src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.cpp b/src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.cpp new file mode 100644 index 00000000000000..ed4f2124edf754 --- /dev/null +++ b/src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.cpp @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "DeviceInstanceInfoProviderImpl.h" +#include + +namespace chip { +namespace DeviceLayer { + +CHIP_ERROR DeviceInstanceInfoProviderImpl::GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) +{ +#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CONFIG_CHIP_DEVICE_ROTATING_DEVICE_UID) + static_assert(ConfigurationManager::kRotatingDeviceIDUniqueIDLength >= ConfigurationManager::kMinRotatingDeviceIDUniqueIDLength, + "Length of unique ID for rotating device ID is smaller than minimum."); + + ReturnErrorCodeIf(ConfigurationManager::kRotatingDeviceIDUniqueIDLength > uniqueIdSpan.size(), CHIP_ERROR_BUFFER_TOO_SMALL); + + size_t bytesLen = chip::Encoding::HexToBytes(CONFIG_CHIP_DEVICE_ROTATING_DEVICE_UID, + ConfigurationManager::kRotatingDeviceIDUniqueIDLength * 2, uniqueIdSpan.data(), + uniqueIdSpan.size()); + + ReturnErrorCodeIf(bytesLen != ConfigurationManager::kRotatingDeviceIDUniqueIDLength, CHIP_ERROR_INVALID_STRING_LENGTH); + uniqueIdSpan.reduce_size(bytesLen); + + return CHIP_NO_ERROR; +#endif // CHIP_ENABLE_ROTATING_DEVICE_ID + + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.h b/src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.h new file mode 100644 index 00000000000000..1489f2810b4170 --- /dev/null +++ b/src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.h @@ -0,0 +1,43 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +namespace chip { +namespace DeviceLayer { + +class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInfoProvider +{ +public: + CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) override; + + DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) : + Internal::GenericDeviceInstanceInfoProvider(configManager) + {} +}; + +inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl() +{ + static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance()); + return sInstance; +} +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/FactoryDataParser.c b/src/platform/nrfconnect/FactoryDataParser.c index 85caee5f9ac6b2..56da5343d973dc 100644 --- a/src/platform/nrfconnect/FactoryDataParser.c +++ b/src/platform/nrfconnect/FactoryDataParser.c @@ -18,15 +18,12 @@ #include "FactoryDataParser.h" #include -#include #include #include #define MAX_FACTORY_DATA_NESTING_LEVEL 3 -LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL); - static inline bool uint16_decode(zcbor_state_t * states, uint16_t * value) { uint32_t u32; @@ -174,14 +171,14 @@ bool ParseFactoryData(uint8_t * buffer, uint16_t bufferSize, struct FactoryData isdigit(date.value[3]) && date.value[4] == '-' && isdigit(date.value[5]) && isdigit(date.value[6]) && date.value[7] == '-' && isdigit(date.value[8]) && isdigit(date.value[9])) { - factoryData->date_year = - 1000 * (date.value[0] - '0') + 100 * (date.value[1] - '0') + 10 * (date.value[2] - '0') + date.value[3] - '0'; - factoryData->date_month = 10 * (date.value[5] - '0') + date.value[6] - '0'; - factoryData->date_day = 10 * (date.value[8] - '0') + date.value[9] - '0'; + factoryData->date_year = (uint16_t)(1000 * (uint16_t)(date.value[0] - '0') + 100 * (uint16_t)(date.value[1] - '0') + + 10 * (uint16_t)(date.value[2] - '0') + (uint16_t)(date.value[3] - '0')); + factoryData->date_month = (uint8_t)(10 * (uint16_t)(date.value[5] - '0') + (uint16_t)(date.value[6] - '0')); + factoryData->date_day = (uint8_t)(10 * (uint16_t)(date.value[8] - '0') + (uint16_t)(date.value[9] - '0')); } else { - LOG_ERR("Parsing error - wrong date format"); + res = false; } } else if (strncmp("hw_ver_str", (const char *) currentString.value, currentString.len) == 0) @@ -240,7 +237,7 @@ bool ParseFactoryData(uint8_t * buffer, uint16_t bufferSize, struct FactoryData { factoryData->user.data = (void *) states->payload; res = res && zcbor_any_skip(states, NULL); - factoryData->user.len = (void *) states->payload - factoryData->user.data; + factoryData->user.len = (size_t)((void *) states->payload - factoryData->user.data); } else { diff --git a/src/platform/nrfconnect/FactoryDataProvider.cpp b/src/platform/nrfconnect/FactoryDataProvider.cpp index 200b8fac0f33e8..229eb2745d6c91 100644 --- a/src/platform/nrfconnect/FactoryDataProvider.cpp +++ b/src/platform/nrfconnect/FactoryDataProvider.cpp @@ -81,7 +81,7 @@ CHIP_ERROR FactoryDataProvider::Init() return error; } - if (!ParseFactoryData(factoryData, factoryDataSize, &mFactoryData)) + if (!ParseFactoryData(factoryData, static_cast(factoryDataSize), &mFactoryData)) { ChipLogError(DeviceLayer, "Failed to parse factory data"); return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; From 798c2663911021e624ef74c89e45ca624b206ff3 Mon Sep 17 00:00:00 2001 From: Jeonghwan Kim Date: Wed, 26 Apr 2023 00:29:12 +0900 Subject: [PATCH 026/200] [Android] Support Android MDNS subtype (#26136) * [Android] Support Android MDNS subtype (#25235) * Restyled by whitespace * Restyled by clang-format --------- Co-authored-by: Restyled.io --- src/platform/android/DnssdImpl.cpp | 56 ++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/src/platform/android/DnssdImpl.cpp b/src/platform/android/DnssdImpl.cpp index d0caa2ba3d741d..66e43dab29e84b 100644 --- a/src/platform/android/DnssdImpl.cpp +++ b/src/platform/android/DnssdImpl.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace chip { @@ -52,6 +53,9 @@ jmethodID sRemoveServicesMethod = nullptr; // Implementation of functions declared in lib/dnssd/platform/Dnssd.h +constexpr const char * kProtocolTcp = "._tcp"; +constexpr const char * kProtocolUdp = "._udp"; + CHIP_ERROR ChipDnssdInit(DnssdAsyncReturnCallback initCallback, DnssdAsyncReturnCallback errorCallback, void * context) { VerifyOrReturnError(initCallback != nullptr, CHIP_ERROR_INVALID_ARGUMENT); @@ -149,6 +153,33 @@ CHIP_ERROR ChipDnssdFinalizeServiceUpdate() return CHIP_NO_ERROR; } +std::string GetFullType(const char * type, DnssdServiceProtocol protocol) +{ + std::ostringstream typeBuilder; + typeBuilder << type; + typeBuilder << (protocol == DnssdServiceProtocol::kDnssdProtocolUdp ? kProtocolUdp : kProtocolTcp); + return typeBuilder.str(); +} + +std::string GetFullTypeWithSubTypes(const char * type, DnssdServiceProtocol protocol) +{ + auto fullType = GetFullType(type, protocol); + + std::string subtypeDelimiter = "._sub."; + size_t position = fullType.find(subtypeDelimiter); + if (position != std::string::npos) + { + fullType = fullType.substr(position + subtypeDelimiter.size()) + "," + fullType.substr(0, position); + } + + return fullType; +} + +std::string GetFullType(const DnssdService * service) +{ + return GetFullType(service->mType, service->mProtocol); +} + CHIP_ERROR ChipDnssdBrowse(const char * type, DnssdServiceProtocol protocol, Inet::IPAddressType addressType, Inet::InterfaceId interface, DnssdBrowseCallback callback, void * context, intptr_t * browseIdentifier) { @@ -156,11 +187,8 @@ CHIP_ERROR ChipDnssdBrowse(const char * type, DnssdServiceProtocol protocol, Ine VerifyOrReturnError(sBrowserObject != nullptr && sBrowseMethod != nullptr, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(sMdnsCallbackObject != nullptr, CHIP_ERROR_INCORRECT_STATE); - std::string serviceType = type; - serviceType += '.'; - serviceType += (protocol == DnssdServiceProtocol::kDnssdProtocolUdp ? "_udp" : "_tcp"); - - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + std::string serviceType = GetFullTypeWithSubTypes(type, protocol); + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); UtfString jniServiceType(env, serviceType.c_str()); env->CallVoidMethod(sBrowserObject, sBrowseMethod, jniServiceType.jniValue(), reinterpret_cast(callback), @@ -196,14 +224,19 @@ CHIP_ERROR extractProtocol(const char * serviceType, char (&outServiceName)[N], outServiceName[lengthWithoutProtocol] = '\0'; // Set a null terminator outProtocol = DnssdServiceProtocol::kDnssdProtocolUnknown; - if (strcmp("._tcp", dotPos) == 0) + if (strstr(dotPos, "._tcp") != 0) { outProtocol = DnssdServiceProtocol::kDnssdProtocolTcp; } - else if (strcmp("._udp", dotPos) == 0) + else if (strstr(dotPos, "._udp") != 0) { outProtocol = DnssdServiceProtocol::kDnssdProtocolUdp; } + else + { + ChipLogError(Discovery, "protocol type don't include neithor TCP nor UDP!"); + return CHIP_ERROR_INVALID_ARGUMENT; + } ReturnErrorCodeIf(outProtocol == DnssdServiceProtocol::kDnssdProtocolUnknown, CHIP_ERROR_INVALID_ARGUMENT); @@ -216,11 +249,8 @@ CHIP_ERROR ChipDnssdResolve(DnssdService * service, Inet::InterfaceId interface, VerifyOrReturnError(sResolverObject != nullptr && sResolveMethod != nullptr, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(sMdnsCallbackObject != nullptr, CHIP_ERROR_INCORRECT_STATE); - std::string serviceType = service->mType; - serviceType += '.'; - serviceType += (service->mProtocol == DnssdServiceProtocol::kDnssdProtocolUdp ? "_udp" : "_tcp"); - - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + std::string serviceType = GetFullType(service); + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); UtfString jniInstanceName(env, service->mName); UtfString jniServiceType(env, serviceType.c_str()); @@ -433,8 +463,6 @@ void HandleBrowse(jobjectArray instanceName, jstring serviceType, jlong callback JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); JniUtfString jniServiceType(env, serviceType); - VerifyOrReturn(strlen(jniServiceType.c_str()) <= kDnssdTypeAndProtocolMaxSize, dispatch(CHIP_ERROR_INVALID_ARGUMENT)); - auto size = env->GetArrayLength(instanceName); DnssdService * service = new DnssdService[size]; for (decltype(size) i = 0; i < size; i++) From 85fd5cecff99c28016b28e22e4ecde28d1a1b7be Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 25 Apr 2023 13:00:26 -0400 Subject: [PATCH 027/200] Improve documentation for MTRDeviceControllerStartupParams init methods. (#26251) --- .../CHIP/MTRDeviceControllerStartupParams.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.h b/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.h index 49970304ad517e..9df0257445374e 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.h +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.h @@ -32,6 +32,10 @@ NS_ASSUME_NONNULL_BEGIN * Prepare to initialize a controller given a keypair to use for signing * operational certificates. * + * A controller created from MTRDeviceControllerStartupParams initialized with + * this method will be able to issue operational certificates to devices it + * commissions, using nocSigner to sign them. + * @param ipk The Identity Protection Key, must be 16 bytes in length * @param fabricID The fabric identifier, must be non-zero. */ @@ -40,17 +44,20 @@ NS_ASSUME_NONNULL_BEGIN nocSigner:(id)nocSigner API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); /** - * Prepare to initialize a controller with a complete operational certificate - * chain. This initialization method should be used when none of the - * certificate-signing private keys are available locally. + * Prepare to initialize a controller that is not able to sign operational + * certificates itself, and therefore needs to be provided with a complete + * operational certificate chain. This initialization method should be used + * when none of the certificate-signing private keys are available locally. + * + * A controller created from MTRDeviceControllerStartupParams initialized with + * this method will not be able to commission devices unless + * operationalCertificateIssuer and operationalCertificateIssuerQueue are set. * - * The fabric id and node id to use will be derived from the provided + * The fabric id and node id to use for the controller will be derived from the provided * operationalCertificate. * * @param ipk The Identity Protection Key, must be 16 bytes in length * @param intermediateCertificate may be nil if operationalCertificate is directly signed by rootCertificate. - * - * ipk must be 16 bytes in length. */ - (instancetype)initWithIPK:(NSData *)ipk operationalKeypair:(id)operationalKeypair From c2a28c8183c62cb8508266a451250e3447d218eb Mon Sep 17 00:00:00 2001 From: Hrishikesh Dhayagude Date: Wed, 26 Apr 2023 00:43:23 +0530 Subject: [PATCH 028/200] ESP32: Move the BLE deinit after BLE connection is closed, post commissioning (#26183) --- .../esp32/common/CommonDeviceCallbacks.cpp | 66 +++++++++++-------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/examples/platform/esp32/common/CommonDeviceCallbacks.cpp b/examples/platform/esp32/common/CommonDeviceCallbacks.cpp index 4a112aef9ed7f0..c4409a59cc20f2 100644 --- a/examples/platform/esp32/common/CommonDeviceCallbacks.cpp +++ b/examples/platform/esp32/common/CommonDeviceCallbacks.cpp @@ -33,6 +33,7 @@ #include "esp_heap_caps.h" #include "esp_log.h" #include +#include #include #include #if CONFIG_ENABLE_OTA_REQUESTOR @@ -61,6 +62,43 @@ void CommonDeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, i case DeviceEventType::kCHIPoBLEConnectionClosed: ESP_LOGI(TAG, "CHIPoBLE disconnected"); +#if CONFIG_BT_ENABLED +#if CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING + + if (chip::Server::GetInstance().GetFabricTable().FabricCount() > 0) + { + esp_err_t err = ESP_OK; +#if CONFIG_BT_NIMBLE_ENABLED + if (ble_hs_is_enabled()) + { + int ret = nimble_port_stop(); + if (ret == 0) + { + nimble_port_deinit(); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) + err = esp_nimble_hci_and_controller_deinit(); +#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) +#endif // CONFIG_BT_NIMBLE_ENABLED + +#if CONFIG_IDF_TARGET_ESP32 + err += esp_bt_mem_release(ESP_BT_MODE_BTDM); +#elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32H2 + err += esp_bt_mem_release(ESP_BT_MODE_BLE); +#endif + if (err == ESP_OK) + { + ESP_LOGI(TAG, "BLE deinit successful and memory reclaimed"); + } + } + else + { + ESP_LOGW(TAG, "nimble_port_stop() failed"); + } + } + else { ESP_LOGI(TAG, "BLE already deinited"); } + } +#endif // CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING +#endif // CONFIG_BT_ENABLED break; case DeviceEventType::kDnssdInitialized: @@ -76,34 +114,6 @@ void CommonDeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, i case DeviceEventType::kCommissioningComplete: { ESP_LOGI(TAG, "Commissioning complete"); -#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CONFIG_BT_NIMBLE_ENABLED && CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING - - if (ble_hs_is_enabled()) - { - int ret = nimble_port_stop(); - esp_err_t err = ESP_OK; - if (ret == 0) - { - nimble_port_deinit(); -#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) - err = esp_nimble_hci_and_controller_deinit(); -#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) - err += esp_bt_mem_release(ESP_BT_MODE_BTDM); - if (err == ESP_OK) - { - ESP_LOGI(TAG, "BLE deinit successful and memory reclaimed"); - } - } - else - { - ESP_LOGW(TAG, "nimble_port_stop() failed"); - } - } - else - { - ESP_LOGI(TAG, "BLE already deinited"); - } -#endif } break; From 23a8e5ae65520741698ac6aa5af52912d3ad996c Mon Sep 17 00:00:00 2001 From: AlvinHsiao Date: Wed, 26 Apr 2023 21:06:20 +0800 Subject: [PATCH 029/200] [Infineon] Implement button wake up handler (#26178) * Add API to re-send the pending event if wake up from button. --- .../include/wiced_button_manager.h | 7 ++++++ .../cyw30739_sdk/src/wiced_button_manager.c | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/third_party/infineon/cyw30739_sdk/include/wiced_button_manager.h b/third_party/infineon/cyw30739_sdk/include/wiced_button_manager.h index 6162dc95b830c8..65091250a0d809 100644 --- a/third_party/infineon/cyw30739_sdk/include/wiced_button_manager.h +++ b/third_party/infineon/cyw30739_sdk/include/wiced_button_manager.h @@ -229,6 +229,13 @@ extern wiced_result_t wiced_button_manager_init(button_manager_t * manager, */ extern wiced_result_t wiced_button_manager_deinit(button_manager_t * manager); +/** + * Checks if there is pending event and then re-send the event. + * + * @return void : no return value is expected. + */ +extern void wiced_button_manager_pending_event_handle(void); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/third_party/infineon/cyw30739_sdk/src/wiced_button_manager.c b/third_party/infineon/cyw30739_sdk/src/wiced_button_manager.c index 9309b5a78aaa9c..c8761c6e354023 100644 --- a/third_party/infineon/cyw30739_sdk/src/wiced_button_manager.c +++ b/third_party/infineon/cyw30739_sdk/src/wiced_button_manager.c @@ -44,6 +44,7 @@ #include "wiced_memory.h" #include "wiced_misc_rtos_utils.h" #endif +#include /****************************************************** * Macros @@ -675,6 +676,28 @@ static button_manager_button_t * get_button(platform_button_t id) return NULL; } +/** + * Checks if there is pending event and then re-send the event. + * + * @return void : no return value is expected. + */ +void wiced_button_manager_pending_event_handle(void) +{ + uint32_t a; + if (wiced_sleep_get_boot_mode() == WICED_SLEEP_FAST_BOOT) + { + for (a = 0; a < button_manager->number_of_buttons; a++) + { + if (platform_button_pending_event_get_and_clear(button_manager->buttons[a].configuration->button)) + { + button_manager->configuration->event_handler(&button_manager->buttons[a], BUTTON_CLICK_EVENT, + BUTTON_STATE_RELEASED); + break; + } + } + } +} + #ifdef CYW55572 static void button_event_defer_to_mpaf(void * arg) { From 980a1a1e677bf3194e55eda0910b5d4ee2798415 Mon Sep 17 00:00:00 2001 From: "Robin.Gao" Date: Thu, 27 Apr 2023 00:08:35 +0800 Subject: [PATCH 030/200] [Darwin]Fix: enable controller to skip complete step (#26248) * [Darwin]Fix: enable controller to skip complete step; * [Darwin]set skipCommissioningComplete to boolean value and append MTR_NEWLY_AVAILABLE annotation * Update src/darwin/Framework/CHIP/MTRCommissioningParameters.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceController.mm Co-authored-by: Boris Zbarsky --------- Co-authored-by: Boris Zbarsky --- src/darwin/Framework/CHIP/MTRCommissioningParameters.h | 8 ++++++++ src/darwin/Framework/CHIP/MTRDeviceController.mm | 1 + 2 files changed, 9 insertions(+) diff --git a/src/darwin/Framework/CHIP/MTRCommissioningParameters.h b/src/darwin/Framework/CHIP/MTRCommissioningParameters.h index 722bc1ee8ca4ec..c16aaf692de1bb 100644 --- a/src/darwin/Framework/CHIP/MTRCommissioningParameters.h +++ b/src/darwin/Framework/CHIP/MTRCommissioningParameters.h @@ -80,6 +80,14 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, copy, nullable) NSNumber * failSafeTimeout API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +/** + * Only perform the PASE steps of commissioning. + * If set to YES, commissioning will be completed by another admin on the network. + * + * Defaults to NO. + */ +@property (nonatomic, assign) BOOL skipCommissioningComplete MTR_NEWLY_AVAILABLE; + @end @interface MTRCommissioningParameters (Deprecated) diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index f0ecc5441bddca..e6388e083cd3fa 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -463,6 +463,7 @@ - (BOOL)commissionNodeWithID:(NSNumber *)nodeID if (commissioningParams.threadOperationalDataset) { params.SetThreadOperationalDataset(AsByteSpan(commissioningParams.threadOperationalDataset)); } + params.SetSkipCommissioningComplete(commissioningParams.skipCommissioningComplete); if (commissioningParams.wifiSSID) { chip::ByteSpan ssid = AsByteSpan(commissioningParams.wifiSSID); chip::ByteSpan credentials; From 7bbb240b9b445d56cede49c24230319eed6e9efd Mon Sep 17 00:00:00 2001 From: joonhaengHeo <85541460+joonhaengHeo@users.noreply.github.com> Date: Thu, 27 Apr 2023 01:50:36 +0900 Subject: [PATCH 031/200] [Darwin] add commissioning callback (read Commissioning Info, commissioningComplete add deviceId) (#25832) * Implement commissioning event callback api * restyle * Add comment, fix typo * Modify from comment * Update after review * restyle * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Change Variable name(nodeID) remove ununsed code * Modify readCommissioningInfo to interface * restyle * restyle-2 * Modify nodeID error check * restyle * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * modify for changing variable name * restyle * restyle-2 * Apply suggestions from code review * Fix deprecation message. * Remove redundant availability annotations. --------- Co-authored-by: Boris Zbarsky --- .../QRCode/QRCodeViewController.h | 2 +- .../QRCode/QRCodeViewController.m | 22 +++++++--- .../CHIP/MTRDeviceControllerDelegate.h | 35 ++++++++++++++- .../CHIP/MTRDeviceControllerDelegateBridge.h | 3 ++ .../CHIP/MTRDeviceControllerDelegateBridge.mm | 44 +++++++++++++++++++ 5 files changed, 97 insertions(+), 9 deletions(-) diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.h b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.h index 77d143c2c5a2bb..85a2f1f133f2f5 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.h +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.h @@ -21,6 +21,6 @@ #import @interface QRCodeViewController - : UIViewController + : UIViewController @end diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m index 2105bec3b20545..66c2883964932d 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m @@ -408,7 +408,7 @@ - (void)viewDidLoad dispatch_queue_t callbackQueue = dispatch_queue_create("com.csa.matter.qrcodevc.callback", DISPATCH_QUEUE_SERIAL); self.chipController = InitializeMTR(); - [self.chipController setPairingDelegate:self queue:callbackQueue]; + [self.chipController setDeviceControllerDelegate:self queue:callbackQueue]; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)]; [self.view addGestureRecognizer:tap]; @@ -478,8 +478,8 @@ - (void)setVendorIDOnAccessory } } -// MARK: MTRDevicePairingDelegate -- (void)onPairingComplete:(NSError * _Nullable)error +// MARK: MTRDeviceControllerDelegate +- (void)controller:(MTRDeviceController *)controller commissioningSessionEstablishmentDone:(NSError * _Nullable)error { if (error != nil) { NSLog(@"Got pairing error back %@", error); @@ -672,18 +672,26 @@ - (void)commissionWithSSID:(NSString *)ssid password:(NSString *)password } } -- (void)onCommissioningComplete:(NSError * _Nullable)error +// MARK: MTRDeviceControllerDelegate +- (void)controller:(MTRDeviceController *)controller + commissioningComplete:(NSError * _Nullable)error + nodeID:(NSNumber * _Nullable)nodeID { if (error != nil) { NSLog(@"Error retrieving device informations over Mdns: %@", error); return; } // track this device - uint64_t deviceId = MTRGetNextAvailableDeviceID() - 1; - MTRSetDevicePaired(deviceId, YES); + MTRSetDevicePaired([nodeID unsignedLongLongValue], YES); [self setVendorIDOnAccessory]; } +// MARK: MTRDeviceControllerDelegate +- (void)controller:(MTRDeviceController *)controller readCommissioningInfo:(MTRProductIdentity *)info +{ + NSLog(@"readCommissioningInfo, vendorID:%@, productID:%@", info.vendorID, info.productID); +} + - (void)updateUIFields:(MTRSetupPayload *)payload rawPayload:(nullable NSString *)rawPayload isManualCode:(BOOL)isManualCode { if (isManualCode) { @@ -789,7 +797,7 @@ - (void)_restartMatterStack { self.chipController = MTRRestartController(self.chipController); dispatch_queue_t callbackQueue = dispatch_queue_create("com.csa.matter.qrcodevc.callback", DISPATCH_QUEUE_SERIAL); - [self.chipController setPairingDelegate:self queue:callbackQueue]; + [self.chipController setDeviceControllerDelegate:self queue:callbackQueue]; } - (void)handleRendezVousDefault:(NSString *)payload diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h index 5245b980de5fbf..37c2f691307d02 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h @@ -28,6 +28,19 @@ typedef NS_ENUM(NSInteger, MTRCommissioningStatus) { = 3, } API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +/** + * A representation of a (vendor, product) pair that identifies a specific product. + */ +MTR_NEWLY_AVAILABLE +@interface MTRProductIdentity : NSObject + +@property (nonatomic, copy, readonly) NSNumber * vendorID; + +@property (nonatomic, copy, readonly) NSNumber * productID; + +- (instancetype)initWithVendorID:(NSNumber *)vendorID productID:(NSNumber *)productID; +@end + @class MTRDeviceController; /** @@ -52,8 +65,28 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) /** * Notify the delegate when commissioning is completed. */ -- (void)controller:(MTRDeviceController *)controller commissioningComplete:(NSError * _Nullable)error; +- (void)controller:(MTRDeviceController *)controller + commissioningComplete:(NSError * _Nullable)error MTR_NEWLY_DEPRECATED("Please use controller:commissioningComplete:nodeID:"); + +/** + * Notify the delegate when commissioning is completed. + * + * Exactly one of error and nodeID will be nil. + * + * If nodeID is not nil, then it represents the node id the node was assigned, as encoded in its operational certificate. + */ +- (void)controller:(MTRDeviceController *)controller + commissioningComplete:(NSError * _Nullable)error + nodeID:(NSNumber * _Nullable)nodeID MTR_NEWLY_AVAILABLE; +/** + * Notify the delegate when commissioning infomation has been read from the Basic + * Information cluster of the commissionee. + * + * At the point when this notification happens, device attestation has not been performed yet, + * so the information delivered by this notification should not be trusted. + */ +- (void)controller:(MTRDeviceController *)controller readCommissioningInfo:(MTRProductIdentity *)info MTR_NEWLY_AVAILABLE; @end typedef NS_ENUM(NSUInteger, MTRPairingStatus) { diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.h b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.h index 464f0c91093d8d..d13331f46bd2ac 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.h +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.h @@ -18,6 +18,7 @@ #import "MTRDeviceControllerDelegate.h" #include +#include #include NS_ASSUME_NONNULL_BEGIN @@ -37,6 +38,8 @@ class MTRDeviceControllerDelegateBridge : public chip::Controller::DevicePairing void OnPairingDeleted(CHIP_ERROR error) override; + void OnReadCommissioningInfo(const chip::Controller::ReadCommissioningInfo & info) override; + void OnCommissioningComplete(chip::NodeId deviceId, CHIP_ERROR error) override; private: diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm index 59d18882e536c4..71ca534e67ddff 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm @@ -94,6 +94,25 @@ // This is never actually called; just do nothing. } +void MTRDeviceControllerDelegateBridge::OnReadCommissioningInfo(const chip::Controller::ReadCommissioningInfo & info) +{ + chip::VendorId vendorId = info.basic.vendorId; + uint16_t productId = info.basic.productId; + + MTR_LOG_DEFAULT("DeviceControllerDelegate Read Commissioning Info. VendorId %u ProductId %u", vendorId, productId); + + id strongDelegate = mDelegate; + MTRDeviceController * strongController = mController; + if (strongDelegate && mQueue && strongController) { + if ([strongDelegate respondsToSelector:@selector(controller:readCommissioningInfo:)]) { + dispatch_async(mQueue, ^{ + auto * info = [[MTRProductIdentity alloc] initWithVendorID:@(vendorId) productID:@(productId)]; + [strongDelegate controller:strongController readCommissioningInfo:info]; + }); + } + } +} + void MTRDeviceControllerDelegateBridge::OnCommissioningComplete(chip::NodeId nodeId, CHIP_ERROR error) { MTR_LOG_DEFAULT("DeviceControllerDelegate Commissioning complete. NodeId %llu Status %s", nodeId, chip::ErrorStr(error)); @@ -101,6 +120,18 @@ id strongDelegate = mDelegate; MTRDeviceController * strongController = mController; if (strongDelegate && mQueue && strongController) { + if ([strongDelegate respondsToSelector:@selector(controller:commissioningComplete:nodeID:)]) { + dispatch_async(mQueue, ^{ + NSError * nsError = [MTRError errorForCHIPErrorCode:error]; + NSNumber * nodeID = nil; + if (error == CHIP_NO_ERROR) { + nodeID = @(nodeId); + } + [strongDelegate controller:strongController commissioningComplete:nsError nodeID:nodeID]; + }); + return; + } + // If only the DEPRECATED function is defined if ([strongDelegate respondsToSelector:@selector(controller:commissioningComplete:)]) { dispatch_async(mQueue, ^{ NSError * nsError = [MTRError errorForCHIPErrorCode:error]; @@ -109,3 +140,16 @@ } } } + +@implementation MTRProductIdentity + +- (instancetype)initWithVendorID:(NSNumber *)vendorID productID:(NSNumber *)productID +{ + if (self = [super init]) { + _vendorID = vendorID; + _productID = productID; + } + return self; +} + +@end From cc6c41447349554a971ab7f6dcd1157cdccebe3a Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 26 Apr 2023 14:22:01 -0400 Subject: [PATCH 032/200] Fix chip-tool handling of same-named structs in different clusters. (#26253) The chip-tool code was assuming that the only way a struct with the same name could occur in multiple clusters was if it was the same struct, shared by the two clusters. But that's just not true in the spec. For example, there are totally different TargetStruct structs in different clusters. This fixes chip-tool to do the same thing as cluster-objects in terms of deciding what the set of structs we have to deal with is. --- .../templates/ComplexArgumentParser-src.zapt | 62 +- .../templates/ComplexArgumentParser.zapt | 16 +- .../logging/DataModelLogger-src.zapt | 30 +- .../templates/logging/DataModelLogger.zapt | 16 +- .../templates/partials/StructLoggerDecl.zapt | 2 + .../templates/partials/StructLoggerImpl.zapt | 18 + .../templates/partials/StructParserDecl.zapt | 4 + .../templates/partials/StructParserImpl.zapt | 47 + examples/chip-tool/templates/templates.json | 16 + .../cluster/ComplexArgumentParser.cpp | 3105 +++++++++-------- .../cluster/ComplexArgumentParser.h | 269 +- .../cluster/logging/DataModelLogger.cpp | 1591 +++++---- .../cluster/logging/DataModelLogger.h | 177 +- 13 files changed, 2822 insertions(+), 2531 deletions(-) create mode 100644 examples/chip-tool/templates/partials/StructLoggerDecl.zapt create mode 100644 examples/chip-tool/templates/partials/StructLoggerImpl.zapt create mode 100644 examples/chip-tool/templates/partials/StructParserDecl.zapt create mode 100644 examples/chip-tool/templates/partials/StructParserImpl.zapt diff --git a/examples/chip-tool/templates/ComplexArgumentParser-src.zapt b/examples/chip-tool/templates/ComplexArgumentParser-src.zapt index b2c9d172fec555..f9b0f4bef764c5 100644 --- a/examples/chip-tool/templates/ComplexArgumentParser-src.zapt +++ b/examples/chip-tool/templates/ComplexArgumentParser-src.zapt @@ -2,52 +2,16 @@ #include -{{#structs_with_clusters groupByStructName=1}} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::Type & request, Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - {{#zcl_struct_items}} - {{#unless isOptional}} - {{~! Fabric index fields are not sent on writes, so don't force people to - provide them. ~}} - {{#unless (is_num_equal fieldIdentifier 254)}} - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("{{parent.name}}.{{asLowerCamelCase label}}", "{{asLowerCamelCase label}}", value.isMember("{{asLowerCamelCase label}}"))); - {{/unless}} - {{/unless}} - {{/zcl_struct_items}} - - char labelWithMember[kMaxLabelLength]; - {{#zcl_struct_items}} - {{#if isOptional}} - if (value.isMember("{{asLowerCamelCase label}}")) - { - {{else if (is_num_equal fieldIdentifier 254)}} - if (value.isMember("{{asLowerCamelCase label}}")) - { - {{/if}} - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "{{asLowerCamelCase label}}"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.{{asLowerCamelCase label}}, value["{{asLowerCamelCase label}}"])); - {{#if isOptional}} - } - {{else if (is_num_equal fieldIdentifier 254)}} - } - {{/if}} - valueCopy.removeMember("{{asLowerCamelCase label}}"); - - {{/zcl_struct_items}} - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::Type & request) -{ - {{#zcl_struct_items}} - ComplexArgumentParser::Finalize(request.{{asLowerCamelCase label}}); - {{/zcl_struct_items}} -} -{{/structs_with_clusters}} - +{{#zcl_structs}} +{{#if has_more_than_one_cluster}} +{{> struct_parser_impl namespace="detail"}} +{{/if}} +{{/zcl_structs}} + +{{#zcl_clusters}} +{{#zcl_structs}} +{{#unless has_more_than_one_cluster}} +{{> struct_parser_impl namespace=(as_camel_cased ../name false)}} +{{/unless}} +{{/zcl_structs}} +{{/zcl_clusters}} diff --git a/examples/chip-tool/templates/ComplexArgumentParser.zapt b/examples/chip-tool/templates/ComplexArgumentParser.zapt index e057f0462df0a4..7364b243188333 100644 --- a/examples/chip-tool/templates/ComplexArgumentParser.zapt +++ b/examples/chip-tool/templates/ComplexArgumentParser.zapt @@ -5,8 +5,16 @@ #include #include -{{#structs_with_clusters groupByStructName=1}} -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::Type & request, Json::Value & value); +{{#zcl_structs}} +{{#if has_more_than_one_cluster}} +{{> struct_parser_decl namespace="detail"}} +{{/if}} +{{/zcl_structs}} -static void Finalize(chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::Type & request); -{{/structs_with_clusters}} +{{#zcl_clusters}} +{{#zcl_structs}} +{{#unless has_more_than_one_cluster}} +{{> struct_parser_decl namespace=(as_camel_cased ../name false)}} +{{/unless}} +{{/zcl_structs}} +{{/zcl_clusters}} diff --git a/examples/chip-tool/templates/logging/DataModelLogger-src.zapt b/examples/chip-tool/templates/logging/DataModelLogger-src.zapt index d710ff53735f6c..d400874cf67ffb 100644 --- a/examples/chip-tool/templates/logging/DataModelLogger-src.zapt +++ b/examples/chip-tool/templates/logging/DataModelLogger-src.zapt @@ -4,25 +4,19 @@ using namespace chip::app::Clusters; -{{#structs_with_clusters groupByStructName=1}} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); -{{#zcl_struct_items}} - { - CHIP_ERROR err = LogValue("{{asUpperCamelCase label}}", indent + 1, value.{{asLowerCamelCase label}}); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for '{{asUpperCamelCase label}}'"); - return err; - } - } -{{/zcl_struct_items}} - DataModelLogger::LogString(indent, "}"); +{{#zcl_structs}} +{{#if has_more_than_one_cluster}} +{{> struct_logger_impl namespace="detail"}} +{{/if}} +{{/zcl_structs}} - return CHIP_NO_ERROR; -} -{{/structs_with_clusters}} +{{#zcl_clusters}} +{{#zcl_structs}} +{{#unless has_more_than_one_cluster}} +{{> struct_logger_impl namespace=(as_camel_cased ../name false)}} +{{/unless}} +{{/zcl_structs}} +{{/zcl_clusters}} {{#zcl_clusters}} {{#zcl_events}} diff --git a/examples/chip-tool/templates/logging/DataModelLogger.zapt b/examples/chip-tool/templates/logging/DataModelLogger.zapt index c0ea82e116e1ba..222ab67dee0364 100644 --- a/examples/chip-tool/templates/logging/DataModelLogger.zapt +++ b/examples/chip-tool/templates/logging/DataModelLogger.zapt @@ -3,9 +3,19 @@ #include #include -{{#structs_with_clusters groupByStructName=1}} -static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::DecodableType & value); -{{/structs_with_clusters}} +{{#zcl_structs}} +{{#if has_more_than_one_cluster}} +{{> struct_logger_decl namespace="detail"}} +{{/if}} +{{/zcl_structs}} + +{{#zcl_clusters}} +{{#zcl_structs}} +{{#unless has_more_than_one_cluster}} +{{> struct_logger_decl namespace=(as_camel_cased ../name false)}} +{{/unless}} +{{/zcl_structs}} +{{/zcl_clusters}} {{#zcl_clusters}} {{#zcl_events}} diff --git a/examples/chip-tool/templates/partials/StructLoggerDecl.zapt b/examples/chip-tool/templates/partials/StructLoggerDecl.zapt new file mode 100644 index 00000000000000..0f7e47ddc8ecca --- /dev/null +++ b/examples/chip-tool/templates/partials/StructLoggerDecl.zapt @@ -0,0 +1,2 @@ +static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::{{namespace}}::Structs::{{name}}::DecodableType & value); + diff --git a/examples/chip-tool/templates/partials/StructLoggerImpl.zapt b/examples/chip-tool/templates/partials/StructLoggerImpl.zapt new file mode 100644 index 00000000000000..3dbd99e7400ef4 --- /dev/null +++ b/examples/chip-tool/templates/partials/StructLoggerImpl.zapt @@ -0,0 +1,18 @@ +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::{{namespace}}::Structs::{{name}}::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); +{{#zcl_struct_items}} + { + CHIP_ERROR err = LogValue("{{asUpperCamelCase label}}", indent + 1, value.{{asLowerCamelCase label}}); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for '{{asUpperCamelCase label}}'"); + return err; + } + } +{{/zcl_struct_items}} + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + diff --git a/examples/chip-tool/templates/partials/StructParserDecl.zapt b/examples/chip-tool/templates/partials/StructParserDecl.zapt new file mode 100644 index 00000000000000..7fd3364d034c89 --- /dev/null +++ b/examples/chip-tool/templates/partials/StructParserDecl.zapt @@ -0,0 +1,4 @@ +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request, Json::Value & value); + +static void Finalize(chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request); + diff --git a/examples/chip-tool/templates/partials/StructParserImpl.zapt b/examples/chip-tool/templates/partials/StructParserImpl.zapt new file mode 100644 index 00000000000000..268b09451c6036 --- /dev/null +++ b/examples/chip-tool/templates/partials/StructParserImpl.zapt @@ -0,0 +1,47 @@ +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request, Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + {{#zcl_struct_items}} + {{#unless isOptional}} + {{~! Fabric index fields are not sent on writes, so don't force people to + provide them. ~}} + {{#unless (is_num_equal fieldIdentifier 254)}} + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("{{parent.name}}.{{asLowerCamelCase label}}", "{{asLowerCamelCase label}}", value.isMember("{{asLowerCamelCase label}}"))); + {{/unless}} + {{/unless}} + {{/zcl_struct_items}} + + char labelWithMember[kMaxLabelLength]; + {{#zcl_struct_items}} + {{#if isOptional}} + if (value.isMember("{{asLowerCamelCase label}}")) + { + {{else if (is_num_equal fieldIdentifier 254)}} + if (value.isMember("{{asLowerCamelCase label}}")) + { + {{/if}} + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "{{asLowerCamelCase label}}"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.{{asLowerCamelCase label}}, value["{{asLowerCamelCase label}}"])); + {{#if isOptional}} + } + {{else if (is_num_equal fieldIdentifier 254)}} + } + {{/if}} + valueCopy.removeMember("{{asLowerCamelCase label}}"); + + {{/zcl_struct_items}} + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request) +{ + {{#zcl_struct_items}} + ComplexArgumentParser::Finalize(request.{{asLowerCamelCase label}}); + {{/zcl_struct_items}} +} + diff --git a/examples/chip-tool/templates/templates.json b/examples/chip-tool/templates/templates.json index 1552ab8566bfa6..528c7d266dcb97 100644 --- a/examples/chip-tool/templates/templates.json +++ b/examples/chip-tool/templates/templates.json @@ -21,6 +21,22 @@ { "name": "cluster_header", "path": "../../../src/app/zap-templates/partials/cluster_header.zapt" + }, + { + "name": "struct_parser_decl", + "path": "partials/StructParserDecl.zapt" + }, + { + "name": "struct_parser_impl", + "path": "partials/StructParserImpl.zapt" + }, + { + "name": "struct_logger_decl", + "path": "partials/StructLoggerDecl.zapt" + }, + { + "name": "struct_logger_impl", + "path": "partials/StructLoggerImpl.zapt" } ], "templates": [ diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp index 859fd542e6cc77..3d128bfb24f2e8 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp @@ -19,6 +19,253 @@ #include +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ApplicationStruct.catalogVendorID", "catalogVendorID", + value.isMember("catalogVendorID"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ApplicationStruct.applicationID", "applicationID", + value.isMember("applicationID"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "catalogVendorID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.catalogVendorID, value["catalogVendorID"])); + valueCopy.removeMember("catalogVendorID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "applicationID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.applicationID, value["applicationID"])); + valueCopy.removeMember("applicationID"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.catalogVendorID); + ComplexArgumentParser::Finalize(request.applicationID); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::detail::Structs::LabelStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("LabelStruct.label", "label", value.isMember("label"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("LabelStruct.value", "value", value.isMember("value"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "label"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.label, value["label"])); + valueCopy.removeMember("label"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); + valueCopy.removeMember("value"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::detail::Structs::LabelStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.label); + ComplexArgumentParser::Finalize(request.value); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AttributeValuePair.attributeValue", "attributeValue", + value.isMember("attributeValue"))); + + char labelWithMember[kMaxLabelLength]; + if (value.isMember("attributeID")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeID, value["attributeID"])); + } + valueCopy.removeMember("attributeID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeValue"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeValue, value["attributeValue"])); + valueCopy.removeMember("attributeValue"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request) +{ + ComplexArgumentParser::Finalize(request.attributeID); + ComplexArgumentParser::Finalize(request.attributeValue); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ExtensionFieldSet.clusterID", "clusterID", value.isMember("clusterID"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ExtensionFieldSet.attributeValueList", "attributeValueList", + value.isMember("attributeValueList"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "clusterID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.clusterID, value["clusterID"])); + valueCopy.removeMember("clusterID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeValueList"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeValueList, value["attributeValueList"])); + valueCopy.removeMember("attributeValueList"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request) +{ + ComplexArgumentParser::Finalize(request.clusterID); + ComplexArgumentParser::Finalize(request.attributeValueList); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("DeviceTypeStruct.deviceType", "deviceType", value.isMember("deviceType"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("DeviceTypeStruct.revision", "revision", value.isMember("revision"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "deviceType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.deviceType, value["deviceType"])); + valueCopy.removeMember("deviceType"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "revision"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.revision, value["revision"])); + valueCopy.removeMember("revision"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.deviceType); + ComplexArgumentParser::Finalize(request.revision); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Binding::Structs::TargetStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + char labelWithMember[kMaxLabelLength]; + if (value.isMember("node")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "node"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.node, value["node"])); + } + valueCopy.removeMember("node"); + + if (value.isMember("group")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "group"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.group, value["group"])); + } + valueCopy.removeMember("group"); + + if (value.isMember("endpoint")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); + } + valueCopy.removeMember("endpoint"); + + if (value.isMember("cluster")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "cluster"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.cluster, value["cluster"])); + } + valueCopy.removeMember("cluster"); + + if (value.isMember("fabricIndex")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); + } + valueCopy.removeMember("fabricIndex"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::Binding::Structs::TargetStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.node); + ComplexArgumentParser::Finalize(request.group); + ComplexArgumentParser::Finalize(request.endpoint); + ComplexArgumentParser::Finalize(request.cluster); + ComplexArgumentParser::Finalize(request.fabricIndex); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::AccessControl::Structs::Target::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Target.cluster", "cluster", value.isMember("cluster"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Target.endpoint", "endpoint", value.isMember("endpoint"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Target.deviceType", "deviceType", value.isMember("deviceType"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "cluster"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.cluster, value["cluster"])); + valueCopy.removeMember("cluster"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); + valueCopy.removeMember("endpoint"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "deviceType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.deviceType, value["deviceType"])); + valueCopy.removeMember("deviceType"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::AccessControl::Structs::Target::Type & request) +{ + ComplexArgumentParser::Finalize(request.cluster); + ComplexArgumentParser::Finalize(request.endpoint); + ComplexArgumentParser::Finalize(request.deviceType); +} + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::AccessControl::Structs::AccessControlEntryStruct::Type & request, Json::Value & value) @@ -72,6 +319,7 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::AccessControl::Structs ComplexArgumentParser::Finalize(request.targets); ComplexArgumentParser::Finalize(request.fabricIndex); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::AccessControl::Structs::AccessControlExtensionStruct::Type & request, Json::Value & value) @@ -104,6 +352,7 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::AccessControl::Structs ComplexArgumentParser::Finalize(request.data); ComplexArgumentParser::Finalize(request.fabricIndex); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Actions::Structs::ActionStruct::Type & request, Json::Value & value) { @@ -158,8 +407,9 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::Actions::Structs::Acti ComplexArgumentParser::Finalize(request.supportedCommands); ComplexArgumentParser::Finalize(request.state); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request, + chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -167,28 +417,43 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AdditionalInfoStruct.name", "name", value.isMember("name"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AdditionalInfoStruct.value", "value", value.isMember("value"))); - - char labelWithMember[kMaxLabelLength]; + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.endpointListID", "endpointListID", + value.isMember("endpointListID"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.name", "name", value.isMember("name"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.type", "type", value.isMember("type"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.endpoints", "endpoints", value.isMember("endpoints"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpointListID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpointListID, value["endpointListID"])); + valueCopy.removeMember("endpointListID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); valueCopy.removeMember("name"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); - valueCopy.removeMember("value"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "type"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.type, value["type"])); + valueCopy.removeMember("type"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoints"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoints, value["endpoints"])); + valueCopy.removeMember("endpoints"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request) { + ComplexArgumentParser::Finalize(request.endpointListID); ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.value); + ComplexArgumentParser::Finalize(request.type); + ComplexArgumentParser::Finalize(request.endpoints); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request, + chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -196,61 +461,33 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ApplicationEPStruct.application", "application", value.isMember("application"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( + "CapabilityMinimaStruct.caseSessionsPerFabric", "caseSessionsPerFabric", value.isMember("caseSessionsPerFabric"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( + "CapabilityMinimaStruct.subscriptionsPerFabric", "subscriptionsPerFabric", value.isMember("subscriptionsPerFabric"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "application"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.application, value["application"])); - valueCopy.removeMember("application"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "caseSessionsPerFabric"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.caseSessionsPerFabric, value["caseSessionsPerFabric"])); + valueCopy.removeMember("caseSessionsPerFabric"); - if (value.isMember("endpoint")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); - } - valueCopy.removeMember("endpoint"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "subscriptionsPerFabric"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.subscriptionsPerFabric, value["subscriptionsPerFabric"])); + valueCopy.removeMember("subscriptionsPerFabric"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.application); - ComplexArgumentParser::Finalize(request.endpoint); -} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request, - Json::Value & value) +void ComplexArgumentParser::Finalize(chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request) { - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ApplicationStruct.catalogVendorID", "catalogVendorID", - value.isMember("catalogVendorID"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ApplicationStruct.applicationID", "applicationID", - value.isMember("applicationID"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "catalogVendorID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.catalogVendorID, value["catalogVendorID"])); - valueCopy.removeMember("catalogVendorID"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "applicationID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.applicationID, value["applicationID"])); - valueCopy.removeMember("applicationID"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); + ComplexArgumentParser::Finalize(request.caseSessionsPerFabric); + ComplexArgumentParser::Finalize(request.subscriptionsPerFabric); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.catalogVendorID); - ComplexArgumentParser::Finalize(request.applicationID); -} CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request, + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -258,64 +495,37 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AttributeValuePair.attributeValue", "attributeValue", - value.isMember("attributeValue"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ProviderLocation.providerNodeID", "providerNodeID", + value.isMember("providerNodeID"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ProviderLocation.endpoint", "endpoint", value.isMember("endpoint"))); char labelWithMember[kMaxLabelLength]; - if (value.isMember("attributeID")) + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "providerNodeID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.providerNodeID, value["providerNodeID"])); + valueCopy.removeMember("providerNodeID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); + valueCopy.removeMember("endpoint"); + + if (value.isMember("fabricIndex")) { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeID, value["attributeID"])); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); } - valueCopy.removeMember("attributeID"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeValue"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeValue, value["attributeValue"])); - valueCopy.removeMember("attributeValue"); + valueCopy.removeMember("fabricIndex"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request) -{ - ComplexArgumentParser::Finalize(request.attributeID); - ComplexArgumentParser::Finalize(request.attributeValue); -} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request, - Json::Value & value) +void ComplexArgumentParser::Finalize(chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request) { - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("BasicCommissioningInfo.failSafeExpiryLengthSeconds", - "failSafeExpiryLengthSeconds", - value.isMember("failSafeExpiryLengthSeconds"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("BasicCommissioningInfo.maxCumulativeFailsafeSeconds", - "maxCumulativeFailsafeSeconds", - value.isMember("maxCumulativeFailsafeSeconds"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "failSafeExpiryLengthSeconds"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.failSafeExpiryLengthSeconds, value["failSafeExpiryLengthSeconds"])); - valueCopy.removeMember("failSafeExpiryLengthSeconds"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "maxCumulativeFailsafeSeconds"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.maxCumulativeFailsafeSeconds, value["maxCumulativeFailsafeSeconds"])); - valueCopy.removeMember("maxCumulativeFailsafeSeconds"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); + ComplexArgumentParser::Finalize(request.providerNodeID); + ComplexArgumentParser::Finalize(request.endpoint); + ComplexArgumentParser::Finalize(request.fabricIndex); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request) -{ - ComplexArgumentParser::Finalize(request.failSafeExpiryLengthSeconds); - ComplexArgumentParser::Finalize(request.maxCumulativeFailsafeSeconds); -} CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::PowerSource::Structs::BatChargeFaultChangeType::Type & request, Json::Value & value) @@ -347,6 +557,7 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::PowerSource::Structs:: ComplexArgumentParser::Finalize(request.current); ComplexArgumentParser::Finalize(request.previous); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::PowerSource::Structs::BatFaultChangeType::Type & request, Json::Value & value) @@ -378,8 +589,9 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::PowerSource::Structs:: ComplexArgumentParser::Finalize(request.current); ComplexArgumentParser::Finalize(request.previous); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request, + chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -387,63 +599,31 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("BrandingInformationStruct.providerName", "providerName", - value.isMember("providerName"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("WiredFaultChangeType.current", "current", value.isMember("current"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("WiredFaultChangeType.previous", "previous", value.isMember("previous"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "providerName"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.providerName, value["providerName"])); - valueCopy.removeMember("providerName"); - - if (value.isMember("background")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "background"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.background, value["background"])); - } - valueCopy.removeMember("background"); - - if (value.isMember("logo")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "logo"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.logo, value["logo"])); - } - valueCopy.removeMember("logo"); - - if (value.isMember("progressBar")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "progressBar"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.progressBar, value["progressBar"])); - } - valueCopy.removeMember("progressBar"); - - if (value.isMember("splash")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "splash"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.splash, value["splash"])); - } - valueCopy.removeMember("splash"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "current"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.current, value["current"])); + valueCopy.removeMember("current"); - if (value.isMember("waterMark")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "waterMark"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.waterMark, value["waterMark"])); - } - valueCopy.removeMember("waterMark"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "previous"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.previous, value["previous"])); + valueCopy.removeMember("previous"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request) { - ComplexArgumentParser::Finalize(request.providerName); - ComplexArgumentParser::Finalize(request.background); - ComplexArgumentParser::Finalize(request.logo); - ComplexArgumentParser::Finalize(request.progressBar); - ComplexArgumentParser::Finalize(request.splash); - ComplexArgumentParser::Finalize(request.waterMark); + ComplexArgumentParser::Finalize(request.current); + ComplexArgumentParser::Finalize(request.previous); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request, + chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -451,32 +631,35 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( - "CapabilityMinimaStruct.caseSessionsPerFabric", "caseSessionsPerFabric", value.isMember("caseSessionsPerFabric"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( - "CapabilityMinimaStruct.subscriptionsPerFabric", "subscriptionsPerFabric", value.isMember("subscriptionsPerFabric"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("BasicCommissioningInfo.failSafeExpiryLengthSeconds", + "failSafeExpiryLengthSeconds", + value.isMember("failSafeExpiryLengthSeconds"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("BasicCommissioningInfo.maxCumulativeFailsafeSeconds", + "maxCumulativeFailsafeSeconds", + value.isMember("maxCumulativeFailsafeSeconds"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "caseSessionsPerFabric"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "failSafeExpiryLengthSeconds"); ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.caseSessionsPerFabric, value["caseSessionsPerFabric"])); - valueCopy.removeMember("caseSessionsPerFabric"); + ComplexArgumentParser::Setup(labelWithMember, request.failSafeExpiryLengthSeconds, value["failSafeExpiryLengthSeconds"])); + valueCopy.removeMember("failSafeExpiryLengthSeconds"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "subscriptionsPerFabric"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "maxCumulativeFailsafeSeconds"); ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.subscriptionsPerFabric, value["subscriptionsPerFabric"])); - valueCopy.removeMember("subscriptionsPerFabric"); + ComplexArgumentParser::Setup(labelWithMember, request.maxCumulativeFailsafeSeconds, value["maxCumulativeFailsafeSeconds"])); + valueCopy.removeMember("maxCumulativeFailsafeSeconds"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request) { - ComplexArgumentParser::Finalize(request.caseSessionsPerFabric); - ComplexArgumentParser::Finalize(request.subscriptionsPerFabric); + ComplexArgumentParser::Finalize(request.failSafeExpiryLengthSeconds); + ComplexArgumentParser::Finalize(request.maxCumulativeFailsafeSeconds); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request, + chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -485,77 +668,104 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, Json::Value valueCopy(value); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ChannelInfoStruct.majorNumber", "majorNumber", value.isMember("majorNumber"))); + ComplexArgumentParser::EnsureMemberExist("NetworkInfo.networkID", "networkID", value.isMember("networkID"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ChannelInfoStruct.minorNumber", "minorNumber", value.isMember("minorNumber"))); + ComplexArgumentParser::EnsureMemberExist("NetworkInfo.connected", "connected", value.isMember("connected"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "majorNumber"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.majorNumber, value["majorNumber"])); - valueCopy.removeMember("majorNumber"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "minorNumber"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.minorNumber, value["minorNumber"])); - valueCopy.removeMember("minorNumber"); - - if (value.isMember("name")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - } - valueCopy.removeMember("name"); - - if (value.isMember("callSign")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "callSign"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.callSign, value["callSign"])); - } - valueCopy.removeMember("callSign"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "networkID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.networkID, value["networkID"])); + valueCopy.removeMember("networkID"); - if (value.isMember("affiliateCallSign")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "affiliateCallSign"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.affiliateCallSign, value["affiliateCallSign"])); - } - valueCopy.removeMember("affiliateCallSign"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "connected"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.connected, value["connected"])); + valueCopy.removeMember("connected"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request) { - ComplexArgumentParser::Finalize(request.majorNumber); - ComplexArgumentParser::Finalize(request.minorNumber); - ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.callSign); - ComplexArgumentParser::Finalize(request.affiliateCallSign); + ComplexArgumentParser::Finalize(request.networkID); + ComplexArgumentParser::Finalize(request.connected); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request, - Json::Value & value) + +CHIP_ERROR +ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request, + Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ContentSearchStruct.parameterList", "parameterList", - value.isMember("parameterList"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.panId", "panId", value.isMember("panId"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.extendedPanId", "extendedPanId", + value.isMember("extendedPanId"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.networkName", "networkName", + value.isMember("networkName"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.channel", "channel", value.isMember("channel"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.version", "version", value.isMember("version"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.extendedAddress", "extendedAddress", + value.isMember("extendedAddress"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.rssi", "rssi", value.isMember("rssi"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.lqi", "lqi", value.isMember("lqi"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "parameterList"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.parameterList, value["parameterList"])); - valueCopy.removeMember("parameterList"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "panId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.panId, value["panId"])); + valueCopy.removeMember("panId"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extendedPanId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extendedPanId, value["extendedPanId"])); + valueCopy.removeMember("extendedPanId"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "networkName"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.networkName, value["networkName"])); + valueCopy.removeMember("networkName"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channel"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channel, value["channel"])); + valueCopy.removeMember("channel"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "version"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.version, value["version"])); + valueCopy.removeMember("version"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extendedAddress"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extendedAddress, value["extendedAddress"])); + valueCopy.removeMember("extendedAddress"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rssi"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rssi, value["rssi"])); + valueCopy.removeMember("rssi"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lqi"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lqi, value["lqi"])); + valueCopy.removeMember("lqi"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request) { - ComplexArgumentParser::Finalize(request.parameterList); + ComplexArgumentParser::Finalize(request.panId); + ComplexArgumentParser::Finalize(request.extendedPanId); + ComplexArgumentParser::Finalize(request.networkName); + ComplexArgumentParser::Finalize(request.channel); + ComplexArgumentParser::Finalize(request.version); + ComplexArgumentParser::Finalize(request.extendedAddress); + ComplexArgumentParser::Finalize(request.rssi); + ComplexArgumentParser::Finalize(request.lqi); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request, + chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -563,30 +773,57 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("CredentialStruct.credentialType", "credentialType", - value.isMember("credentialType"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("CredentialStruct.credentialIndex", "credentialIndex", - value.isMember("credentialIndex"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.security", "security", value.isMember("security"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.ssid", "ssid", value.isMember("ssid"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.bssid", "bssid", value.isMember("bssid"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.channel", "channel", value.isMember("channel"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.wiFiBand", "wiFiBand", value.isMember("wiFiBand"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.rssi", "rssi", value.isMember("rssi"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "credentialType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.credentialType, value["credentialType"])); - valueCopy.removeMember("credentialType"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "security"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.security, value["security"])); + valueCopy.removeMember("security"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "credentialIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.credentialIndex, value["credentialIndex"])); - valueCopy.removeMember("credentialIndex"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "ssid"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.ssid, value["ssid"])); + valueCopy.removeMember("ssid"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "bssid"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.bssid, value["bssid"])); + valueCopy.removeMember("bssid"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channel"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channel, value["channel"])); + valueCopy.removeMember("channel"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "wiFiBand"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.wiFiBand, value["wiFiBand"])); + valueCopy.removeMember("wiFiBand"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rssi"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rssi, value["rssi"])); + valueCopy.removeMember("rssi"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request) { - ComplexArgumentParser::Finalize(request.credentialType); - ComplexArgumentParser::Finalize(request.credentialIndex); + ComplexArgumentParser::Finalize(request.security); + ComplexArgumentParser::Finalize(request.ssid); + ComplexArgumentParser::Finalize(request.bssid); + ComplexArgumentParser::Finalize(request.channel); + ComplexArgumentParser::Finalize(request.wiFiBand); + ComplexArgumentParser::Finalize(request.rssi); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request, + chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -594,36 +831,75 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DSTOffsetStruct.offset", "offset", value.isMember("offset"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DSTOffsetStruct.validStarting", "validStarting", - value.isMember("validStarting"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("DSTOffsetStruct.validUntil", "validUntil", value.isMember("validUntil"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.name", "name", value.isMember("name"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.isOperational", "isOperational", + value.isMember("isOperational"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.offPremiseServicesReachableIPv4", + "offPremiseServicesReachableIPv4", + value.isMember("offPremiseServicesReachableIPv4"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.offPremiseServicesReachableIPv6", + "offPremiseServicesReachableIPv6", + value.isMember("offPremiseServicesReachableIPv6"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.hardwareAddress", "hardwareAddress", + value.isMember("hardwareAddress"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.IPv4Addresses", "IPv4Addresses", + value.isMember("IPv4Addresses"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.IPv6Addresses", "IPv6Addresses", + value.isMember("IPv6Addresses"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.type", "type", value.isMember("type"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offset"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offset, value["offset"])); - valueCopy.removeMember("offset"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + valueCopy.removeMember("name"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "validStarting"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.validStarting, value["validStarting"])); - valueCopy.removeMember("validStarting"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "isOperational"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.isOperational, value["isOperational"])); + valueCopy.removeMember("isOperational"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "validUntil"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.validUntil, value["validUntil"])); - valueCopy.removeMember("validUntil"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offPremiseServicesReachableIPv4"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offPremiseServicesReachableIPv4, + value["offPremiseServicesReachableIPv4"])); + valueCopy.removeMember("offPremiseServicesReachableIPv4"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offPremiseServicesReachableIPv6"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offPremiseServicesReachableIPv6, + value["offPremiseServicesReachableIPv6"])); + valueCopy.removeMember("offPremiseServicesReachableIPv6"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "hardwareAddress"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.hardwareAddress, value["hardwareAddress"])); + valueCopy.removeMember("hardwareAddress"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "IPv4Addresses"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.IPv4Addresses, value["IPv4Addresses"])); + valueCopy.removeMember("IPv4Addresses"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "IPv6Addresses"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.IPv6Addresses, value["IPv6Addresses"])); + valueCopy.removeMember("IPv6Addresses"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "type"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.type, value["type"])); + valueCopy.removeMember("type"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request) { - ComplexArgumentParser::Finalize(request.offset); - ComplexArgumentParser::Finalize(request.validStarting); - ComplexArgumentParser::Finalize(request.validUntil); + ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.isOperational); + ComplexArgumentParser::Finalize(request.offPremiseServicesReachableIPv4); + ComplexArgumentParser::Finalize(request.offPremiseServicesReachableIPv6); + ComplexArgumentParser::Finalize(request.hardwareAddress); + ComplexArgumentParser::Finalize(request.IPv4Addresses); + ComplexArgumentParser::Finalize(request.IPv6Addresses); + ComplexArgumentParser::Finalize(request.type); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request, + chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -631,65 +907,55 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("DeviceTypeStruct.deviceType", "deviceType", value.isMember("deviceType"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("DeviceTypeStruct.revision", "revision", value.isMember("revision"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadMetricsStruct.id", "id", value.isMember("id"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "deviceType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.deviceType, value["deviceType"])); - valueCopy.removeMember("deviceType"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "revision"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.revision, value["revision"])); - valueCopy.removeMember("revision"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.deviceType); - ComplexArgumentParser::Finalize(request.revision); -} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "id"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.id, value["id"])); + valueCopy.removeMember("id"); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DimensionStruct.width", "width", value.isMember("width"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DimensionStruct.height", "height", value.isMember("height"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DimensionStruct.metric", "metric", value.isMember("metric"))); + if (value.isMember("name")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + } + valueCopy.removeMember("name"); - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "width"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.width, value["width"])); - valueCopy.removeMember("width"); + if (value.isMember("stackFreeCurrent")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "stackFreeCurrent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.stackFreeCurrent, value["stackFreeCurrent"])); + } + valueCopy.removeMember("stackFreeCurrent"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "height"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.height, value["height"])); - valueCopy.removeMember("height"); + if (value.isMember("stackFreeMinimum")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "stackFreeMinimum"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.stackFreeMinimum, value["stackFreeMinimum"])); + } + valueCopy.removeMember("stackFreeMinimum"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "metric"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.metric, value["metric"])); - valueCopy.removeMember("metric"); + if (value.isMember("stackSize")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "stackSize"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.stackSize, value["stackSize"])); + } + valueCopy.removeMember("stackSize"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request) { - ComplexArgumentParser::Finalize(request.width); - ComplexArgumentParser::Finalize(request.height); - ComplexArgumentParser::Finalize(request.metric); + ComplexArgumentParser::Finalize(request.id); + ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.stackFreeCurrent); + ComplexArgumentParser::Finalize(request.stackFreeMinimum); + ComplexArgumentParser::Finalize(request.stackSize); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request, + chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -697,96 +963,112 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DoubleNestedStructList.a", "a", value.isMember("a"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("NeighborTable.extAddress", "extAddress", value.isMember("extAddress"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.age", "age", value.isMember("age"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.rloc16", "rloc16", value.isMember("rloc16"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.linkFrameCounter", "linkFrameCounter", + value.isMember("linkFrameCounter"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.mleFrameCounter", "mleFrameCounter", + value.isMember("mleFrameCounter"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.lqi", "lqi", value.isMember("lqi"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("NeighborTable.averageRssi", "averageRssi", value.isMember("averageRssi"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("NeighborTable.lastRssi", "lastRssi", value.isMember("lastRssi"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.frameErrorRate", "frameErrorRate", + value.isMember("frameErrorRate"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.messageErrorRate", "messageErrorRate", + value.isMember("messageErrorRate"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("NeighborTable.rxOnWhenIdle", "rxOnWhenIdle", value.isMember("rxOnWhenIdle"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.fullThreadDevice", "fullThreadDevice", + value.isMember("fullThreadDevice"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.fullNetworkData", "fullNetworkData", + value.isMember("fullNetworkData"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.isChild", "isChild", value.isMember("isChild"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); - valueCopy.removeMember("a"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extAddress"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extAddress, value["extAddress"])); + valueCopy.removeMember("extAddress"); -void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request) -{ - ComplexArgumentParser::Finalize(request.a); -} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "age"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.age, value["age"])); + valueCopy.removeMember("age"); - // Copy to track which members we already processed. - Json::Value valueCopy(value); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rloc16"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rloc16, value["rloc16"])); + valueCopy.removeMember("rloc16"); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.endpointListID", "endpointListID", - value.isMember("endpointListID"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.name", "name", value.isMember("name"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.type", "type", value.isMember("type"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.endpoints", "endpoints", value.isMember("endpoints"))); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "linkFrameCounter"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.linkFrameCounter, value["linkFrameCounter"])); + valueCopy.removeMember("linkFrameCounter"); - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpointListID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpointListID, value["endpointListID"])); - valueCopy.removeMember("endpointListID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "mleFrameCounter"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.mleFrameCounter, value["mleFrameCounter"])); + valueCopy.removeMember("mleFrameCounter"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - valueCopy.removeMember("name"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lqi"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lqi, value["lqi"])); + valueCopy.removeMember("lqi"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "type"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.type, value["type"])); - valueCopy.removeMember("type"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "averageRssi"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.averageRssi, value["averageRssi"])); + valueCopy.removeMember("averageRssi"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoints"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoints, value["endpoints"])); - valueCopy.removeMember("endpoints"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lastRssi"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lastRssi, value["lastRssi"])); + valueCopy.removeMember("lastRssi"); - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "frameErrorRate"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.frameErrorRate, value["frameErrorRate"])); + valueCopy.removeMember("frameErrorRate"); -void ComplexArgumentParser::Finalize(chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.endpointListID); - ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.type); - ComplexArgumentParser::Finalize(request.endpoints); -} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "messageErrorRate"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.messageErrorRate, value["messageErrorRate"])); + valueCopy.removeMember("messageErrorRate"); - // Copy to track which members we already processed. - Json::Value valueCopy(value); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rxOnWhenIdle"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rxOnWhenIdle, value["rxOnWhenIdle"])); + valueCopy.removeMember("rxOnWhenIdle"); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ExtensionFieldSet.clusterID", "clusterID", value.isMember("clusterID"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ExtensionFieldSet.attributeValueList", "attributeValueList", - value.isMember("attributeValueList"))); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fullThreadDevice"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fullThreadDevice, value["fullThreadDevice"])); + valueCopy.removeMember("fullThreadDevice"); - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "clusterID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.clusterID, value["clusterID"])); - valueCopy.removeMember("clusterID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fullNetworkData"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fullNetworkData, value["fullNetworkData"])); + valueCopy.removeMember("fullNetworkData"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeValueList"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeValueList, value["attributeValueList"])); - valueCopy.removeMember("attributeValueList"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "isChild"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.isChild, value["isChild"])); + valueCopy.removeMember("isChild"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request) { - ComplexArgumentParser::Finalize(request.clusterID); - ComplexArgumentParser::Finalize(request.attributeValueList); + ComplexArgumentParser::Finalize(request.extAddress); + ComplexArgumentParser::Finalize(request.age); + ComplexArgumentParser::Finalize(request.rloc16); + ComplexArgumentParser::Finalize(request.linkFrameCounter); + ComplexArgumentParser::Finalize(request.mleFrameCounter); + ComplexArgumentParser::Finalize(request.lqi); + ComplexArgumentParser::Finalize(request.averageRssi); + ComplexArgumentParser::Finalize(request.lastRssi); + ComplexArgumentParser::Finalize(request.frameErrorRate); + ComplexArgumentParser::Finalize(request.messageErrorRate); + ComplexArgumentParser::Finalize(request.rxOnWhenIdle); + ComplexArgumentParser::Finalize(request.fullThreadDevice); + ComplexArgumentParser::Finalize(request.fullNetworkData); + ComplexArgumentParser::Finalize(request.isChild); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request, + chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -794,59 +1076,108 @@ ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.rootPublicKey", "rootPublicKey", - value.isMember("rootPublicKey"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( + "OperationalDatasetComponents.activeTimestampPresent", "activeTimestampPresent", value.isMember("activeTimestampPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.pendingTimestampPresent", + "pendingTimestampPresent", + value.isMember("pendingTimestampPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.masterKeyPresent", + "masterKeyPresent", value.isMember("masterKeyPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.networkNamePresent", + "networkNamePresent", value.isMember("networkNamePresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.extendedPanIdPresent", + "extendedPanIdPresent", value.isMember("extendedPanIdPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( + "OperationalDatasetComponents.meshLocalPrefixPresent", "meshLocalPrefixPresent", value.isMember("meshLocalPrefixPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.delayPresent", "delayPresent", + value.isMember("delayPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.panIdPresent", "panIdPresent", + value.isMember("panIdPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.channelPresent", "channelPresent", + value.isMember("channelPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.pskcPresent", "pskcPresent", + value.isMember("pskcPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( + "OperationalDatasetComponents.securityPolicyPresent", "securityPolicyPresent", value.isMember("securityPolicyPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.channelMaskPresent", + "channelMaskPresent", value.isMember("channelMaskPresent"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "activeTimestampPresent"); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.vendorID", "vendorID", value.isMember("vendorID"))); + ComplexArgumentParser::Setup(labelWithMember, request.activeTimestampPresent, value["activeTimestampPresent"])); + valueCopy.removeMember("activeTimestampPresent"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "pendingTimestampPresent"); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.fabricID", "fabricID", value.isMember("fabricID"))); + ComplexArgumentParser::Setup(labelWithMember, request.pendingTimestampPresent, value["pendingTimestampPresent"])); + valueCopy.removeMember("pendingTimestampPresent"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "masterKeyPresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.masterKeyPresent, value["masterKeyPresent"])); + valueCopy.removeMember("masterKeyPresent"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "networkNamePresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.networkNamePresent, value["networkNamePresent"])); + valueCopy.removeMember("networkNamePresent"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extendedPanIdPresent"); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.nodeID", "nodeID", value.isMember("nodeID"))); + ComplexArgumentParser::Setup(labelWithMember, request.extendedPanIdPresent, value["extendedPanIdPresent"])); + valueCopy.removeMember("extendedPanIdPresent"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "meshLocalPrefixPresent"); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.label", "label", value.isMember("label"))); + ComplexArgumentParser::Setup(labelWithMember, request.meshLocalPrefixPresent, value["meshLocalPrefixPresent"])); + valueCopy.removeMember("meshLocalPrefixPresent"); - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rootPublicKey"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rootPublicKey, value["rootPublicKey"])); - valueCopy.removeMember("rootPublicKey"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "delayPresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.delayPresent, value["delayPresent"])); + valueCopy.removeMember("delayPresent"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "vendorID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.vendorID, value["vendorID"])); - valueCopy.removeMember("vendorID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "panIdPresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.panIdPresent, value["panIdPresent"])); + valueCopy.removeMember("panIdPresent"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricID, value["fabricID"])); - valueCopy.removeMember("fabricID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channelPresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channelPresent, value["channelPresent"])); + valueCopy.removeMember("channelPresent"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nodeID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nodeID, value["nodeID"])); - valueCopy.removeMember("nodeID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "pskcPresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.pskcPresent, value["pskcPresent"])); + valueCopy.removeMember("pskcPresent"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "label"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.label, value["label"])); - valueCopy.removeMember("label"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "securityPolicyPresent"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.securityPolicyPresent, value["securityPolicyPresent"])); + valueCopy.removeMember("securityPolicyPresent"); - if (value.isMember("fabricIndex")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); - } - valueCopy.removeMember("fabricIndex"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channelMaskPresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channelMaskPresent, value["channelMaskPresent"])); + valueCopy.removeMember("channelMaskPresent"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request) +void ComplexArgumentParser::Finalize( + chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request) { - ComplexArgumentParser::Finalize(request.rootPublicKey); - ComplexArgumentParser::Finalize(request.vendorID); - ComplexArgumentParser::Finalize(request.fabricID); - ComplexArgumentParser::Finalize(request.nodeID); - ComplexArgumentParser::Finalize(request.label); - ComplexArgumentParser::Finalize(request.fabricIndex); + ComplexArgumentParser::Finalize(request.activeTimestampPresent); + ComplexArgumentParser::Finalize(request.pendingTimestampPresent); + ComplexArgumentParser::Finalize(request.masterKeyPresent); + ComplexArgumentParser::Finalize(request.networkNamePresent); + ComplexArgumentParser::Finalize(request.extendedPanIdPresent); + ComplexArgumentParser::Finalize(request.meshLocalPrefixPresent); + ComplexArgumentParser::Finalize(request.delayPresent); + ComplexArgumentParser::Finalize(request.panIdPresent); + ComplexArgumentParser::Finalize(request.channelPresent); + ComplexArgumentParser::Finalize(request.pskcPresent); + ComplexArgumentParser::Finalize(request.securityPolicyPresent); + ComplexArgumentParser::Finalize(request.channelMaskPresent); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request, + chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -855,45 +1186,79 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, Json::Value valueCopy(value); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("GroupInfoMapStruct.groupId", "groupId", value.isMember("groupId"))); + ComplexArgumentParser::EnsureMemberExist("RouteTable.extAddress", "extAddress", value.isMember("extAddress"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.rloc16", "rloc16", value.isMember("rloc16"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.routerId", "routerId", value.isMember("routerId"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.nextHop", "nextHop", value.isMember("nextHop"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.pathCost", "pathCost", value.isMember("pathCost"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.LQIIn", "LQIIn", value.isMember("LQIIn"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.LQIOut", "LQIOut", value.isMember("LQIOut"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.age", "age", value.isMember("age"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("GroupInfoMapStruct.endpoints", "endpoints", value.isMember("endpoints"))); + ComplexArgumentParser::EnsureMemberExist("RouteTable.allocated", "allocated", value.isMember("allocated"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.linkEstablished", "linkEstablished", + value.isMember("linkEstablished"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupId, value["groupId"])); - valueCopy.removeMember("groupId"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extAddress"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extAddress, value["extAddress"])); + valueCopy.removeMember("extAddress"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoints"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoints, value["endpoints"])); - valueCopy.removeMember("endpoints"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rloc16"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rloc16, value["rloc16"])); + valueCopy.removeMember("rloc16"); - if (value.isMember("groupName")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupName"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupName, value["groupName"])); - } - valueCopy.removeMember("groupName"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "routerId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.routerId, value["routerId"])); + valueCopy.removeMember("routerId"); - if (value.isMember("fabricIndex")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); - } - valueCopy.removeMember("fabricIndex"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nextHop"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nextHop, value["nextHop"])); + valueCopy.removeMember("nextHop"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "pathCost"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.pathCost, value["pathCost"])); + valueCopy.removeMember("pathCost"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "LQIIn"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.LQIIn, value["LQIIn"])); + valueCopy.removeMember("LQIIn"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "LQIOut"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.LQIOut, value["LQIOut"])); + valueCopy.removeMember("LQIOut"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "age"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.age, value["age"])); + valueCopy.removeMember("age"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "allocated"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.allocated, value["allocated"])); + valueCopy.removeMember("allocated"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "linkEstablished"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.linkEstablished, value["linkEstablished"])); + valueCopy.removeMember("linkEstablished"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request) { - ComplexArgumentParser::Finalize(request.groupId); - ComplexArgumentParser::Finalize(request.endpoints); - ComplexArgumentParser::Finalize(request.groupName); - ComplexArgumentParser::Finalize(request.fabricIndex); + ComplexArgumentParser::Finalize(request.extAddress); + ComplexArgumentParser::Finalize(request.rloc16); + ComplexArgumentParser::Finalize(request.routerId); + ComplexArgumentParser::Finalize(request.nextHop); + ComplexArgumentParser::Finalize(request.pathCost); + ComplexArgumentParser::Finalize(request.LQIIn); + ComplexArgumentParser::Finalize(request.LQIOut); + ComplexArgumentParser::Finalize(request.age); + ComplexArgumentParser::Finalize(request.allocated); + ComplexArgumentParser::Finalize(request.linkEstablished); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type & request, + chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -902,37 +1267,29 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, Json::Value valueCopy(value); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("GroupKeyMapStruct.groupId", "groupId", value.isMember("groupId"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeyMapStruct.groupKeySetID", "groupKeySetID", - value.isMember("groupKeySetID"))); + ComplexArgumentParser::EnsureMemberExist("SecurityPolicy.rotationTime", "rotationTime", value.isMember("rotationTime"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SecurityPolicy.flags", "flags", value.isMember("flags"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupId, value["groupId"])); - valueCopy.removeMember("groupId"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupKeySetID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupKeySetID, value["groupKeySetID"])); - valueCopy.removeMember("groupKeySetID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rotationTime"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rotationTime, value["rotationTime"])); + valueCopy.removeMember("rotationTime"); - if (value.isMember("fabricIndex")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); - } - valueCopy.removeMember("fabricIndex"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "flags"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.flags, value["flags"])); + valueCopy.removeMember("flags"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request) { - ComplexArgumentParser::Finalize(request.groupId); - ComplexArgumentParser::Finalize(request.groupKeySetID); - ComplexArgumentParser::Finalize(request.fabricIndex); + ComplexArgumentParser::Finalize(request.rotationTime); + ComplexArgumentParser::Finalize(request.flags); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::Type & request, + chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -940,73 +1297,37 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.groupKeySetID", "groupKeySetID", - value.isMember("groupKeySetID"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( - "GroupKeySetStruct.groupKeySecurityPolicy", "groupKeySecurityPolicy", value.isMember("groupKeySecurityPolicy"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochKey0", "epochKey0", value.isMember("epochKey0"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochStartTime0", "epochStartTime0", - value.isMember("epochStartTime0"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochKey1", "epochKey1", value.isMember("epochKey1"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochStartTime1", "epochStartTime1", - value.isMember("epochStartTime1"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DSTOffsetStruct.offset", "offset", value.isMember("offset"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DSTOffsetStruct.validStarting", "validStarting", + value.isMember("validStarting"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochKey2", "epochKey2", value.isMember("epochKey2"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochStartTime2", "epochStartTime2", - value.isMember("epochStartTime2"))); + ComplexArgumentParser::EnsureMemberExist("DSTOffsetStruct.validUntil", "validUntil", value.isMember("validUntil"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupKeySetID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupKeySetID, value["groupKeySetID"])); - valueCopy.removeMember("groupKeySetID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offset"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offset, value["offset"])); + valueCopy.removeMember("offset"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupKeySecurityPolicy"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.groupKeySecurityPolicy, value["groupKeySecurityPolicy"])); - valueCopy.removeMember("groupKeySecurityPolicy"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "validStarting"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.validStarting, value["validStarting"])); + valueCopy.removeMember("validStarting"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochKey0"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochKey0, value["epochKey0"])); - valueCopy.removeMember("epochKey0"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "validUntil"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.validUntil, value["validUntil"])); + valueCopy.removeMember("validUntil"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochStartTime0"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochStartTime0, value["epochStartTime0"])); - valueCopy.removeMember("epochStartTime0"); + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochKey1"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochKey1, value["epochKey1"])); - valueCopy.removeMember("epochKey1"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochStartTime1"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochStartTime1, value["epochStartTime1"])); - valueCopy.removeMember("epochStartTime1"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochKey2"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochKey2, value["epochKey2"])); - valueCopy.removeMember("epochKey2"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochStartTime2"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochStartTime2, value["epochStartTime2"])); - valueCopy.removeMember("epochStartTime2"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request) { - ComplexArgumentParser::Finalize(request.groupKeySetID); - ComplexArgumentParser::Finalize(request.groupKeySecurityPolicy); - ComplexArgumentParser::Finalize(request.epochKey0); - ComplexArgumentParser::Finalize(request.epochStartTime0); - ComplexArgumentParser::Finalize(request.epochKey1); - ComplexArgumentParser::Finalize(request.epochStartTime1); - ComplexArgumentParser::Finalize(request.epochKey2); - ComplexArgumentParser::Finalize(request.epochStartTime2); + ComplexArgumentParser::Finalize(request.offset); + ComplexArgumentParser::Finalize(request.validStarting); + ComplexArgumentParser::Finalize(request.validUntil); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request, + chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1014,69 +1335,99 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.index", "index", value.isMember("index"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.inputType", "inputType", value.isMember("inputType"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.name", "name", value.isMember("name"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.description", "description", value.isMember("description"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TimeZoneStruct.offset", "offset", value.isMember("offset"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TimeZoneStruct.validAt", "validAt", value.isMember("validAt"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "index"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.index, value["index"])); - valueCopy.removeMember("index"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offset"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offset, value["offset"])); + valueCopy.removeMember("offset"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "inputType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.inputType, value["inputType"])); - valueCopy.removeMember("inputType"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "validAt"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.validAt, value["validAt"])); + valueCopy.removeMember("validAt"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + if (value.isMember("name")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + } valueCopy.removeMember("name"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "description"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.description, value["description"])); - valueCopy.removeMember("description"); - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request) { - ComplexArgumentParser::Finalize(request.index); - ComplexArgumentParser::Finalize(request.inputType); + ComplexArgumentParser::Finalize(request.offset); + ComplexArgumentParser::Finalize(request.validAt); ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.description); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::detail::Structs::LabelStruct::Type & request, - Json::Value & value) + +CHIP_ERROR +ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request, + Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("LabelStruct.label", "label", value.isMember("label"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("LabelStruct.value", "value", value.isMember("value"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.rootPublicKey", "rootPublicKey", + value.isMember("rootPublicKey"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.vendorID", "vendorID", value.isMember("vendorID"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.fabricID", "fabricID", value.isMember("fabricID"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.nodeID", "nodeID", value.isMember("nodeID"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.label", "label", value.isMember("label"))); char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rootPublicKey"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rootPublicKey, value["rootPublicKey"])); + valueCopy.removeMember("rootPublicKey"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "vendorID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.vendorID, value["vendorID"])); + valueCopy.removeMember("vendorID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricID, value["fabricID"])); + valueCopy.removeMember("fabricID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nodeID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nodeID, value["nodeID"])); + valueCopy.removeMember("nodeID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "label"); ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.label, value["label"])); valueCopy.removeMember("label"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); - valueCopy.removeMember("value"); + if (value.isMember("fabricIndex")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); + } + valueCopy.removeMember("fabricIndex"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::detail::Structs::LabelStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request) { + ComplexArgumentParser::Finalize(request.rootPublicKey); + ComplexArgumentParser::Finalize(request.vendorID); + ComplexArgumentParser::Finalize(request.fabricID); + ComplexArgumentParser::Finalize(request.nodeID); ComplexArgumentParser::Finalize(request.label); - ComplexArgumentParser::Finalize(request.value); + ComplexArgumentParser::Finalize(request.fabricIndex); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1084,46 +1435,37 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters: // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("LineupInfoStruct.operatorName", "operatorName", value.isMember("operatorName"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("LineupInfoStruct.lineupInfoType", "lineupInfoType", - value.isMember("lineupInfoType"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NOCStruct.noc", "noc", value.isMember("noc"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NOCStruct.icac", "icac", value.isMember("icac"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "operatorName"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.operatorName, value["operatorName"])); - valueCopy.removeMember("operatorName"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "noc"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.noc, value["noc"])); + valueCopy.removeMember("noc"); - if (value.isMember("lineupName")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lineupName"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lineupName, value["lineupName"])); - } - valueCopy.removeMember("lineupName"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "icac"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.icac, value["icac"])); + valueCopy.removeMember("icac"); - if (value.isMember("postalCode")) + if (value.isMember("fabricIndex")) { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "postalCode"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.postalCode, value["postalCode"])); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); } - valueCopy.removeMember("postalCode"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lineupInfoType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lineupInfoType, value["lineupInfoType"])); - valueCopy.removeMember("lineupInfoType"); + valueCopy.removeMember("fabricIndex"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request) { - ComplexArgumentParser::Finalize(request.operatorName); - ComplexArgumentParser::Finalize(request.lineupName); - ComplexArgumentParser::Finalize(request.postalCode); - ComplexArgumentParser::Finalize(request.lineupInfoType); + ComplexArgumentParser::Finalize(request.noc); + ComplexArgumentParser::Finalize(request.icac); + ComplexArgumentParser::Finalize(request.fabricIndex); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type & request, + chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1131,35 +1473,47 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ModeOptionStruct.label", "label", value.isMember("label"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ModeOptionStruct.mode", "mode", value.isMember("mode"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ModeOptionStruct.semanticTags", "semanticTags", value.isMember("semanticTags"))); + ComplexArgumentParser::EnsureMemberExist("GroupInfoMapStruct.groupId", "groupId", value.isMember("groupId"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("GroupInfoMapStruct.endpoints", "endpoints", value.isMember("endpoints"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "label"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.label, value["label"])); - valueCopy.removeMember("label"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupId, value["groupId"])); + valueCopy.removeMember("groupId"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "mode"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.mode, value["mode"])); - valueCopy.removeMember("mode"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoints"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoints, value["endpoints"])); + valueCopy.removeMember("endpoints"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "semanticTags"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.semanticTags, value["semanticTags"])); - valueCopy.removeMember("semanticTags"); + if (value.isMember("groupName")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupName"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupName, value["groupName"])); + } + valueCopy.removeMember("groupName"); + + if (value.isMember("fabricIndex")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); + } + valueCopy.removeMember("fabricIndex"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request) { - ComplexArgumentParser::Finalize(request.label); - ComplexArgumentParser::Finalize(request.mode); - ComplexArgumentParser::Finalize(request.semanticTags); + ComplexArgumentParser::Finalize(request.groupId); + ComplexArgumentParser::Finalize(request.endpoints); + ComplexArgumentParser::Finalize(request.groupName); + ComplexArgumentParser::Finalize(request.fabricIndex); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request, + chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1167,18 +1521,19 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MonitoringRegistration.clientNodeId", "clientNodeId", - value.isMember("clientNodeId"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MonitoringRegistration.ICid", "ICid", value.isMember("ICid"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("GroupKeyMapStruct.groupId", "groupId", value.isMember("groupId"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeyMapStruct.groupKeySetID", "groupKeySetID", + value.isMember("groupKeySetID"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "clientNodeId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.clientNodeId, value["clientNodeId"])); - valueCopy.removeMember("clientNodeId"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupId, value["groupId"])); + valueCopy.removeMember("groupId"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "ICid"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.ICid, value["ICid"])); - valueCopy.removeMember("ICid"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupKeySetID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupKeySetID, value["groupKeySetID"])); + valueCopy.removeMember("groupKeySetID"); if (value.isMember("fabricIndex")) { @@ -1190,14 +1545,15 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type & request) { - ComplexArgumentParser::Finalize(request.clientNodeId); - ComplexArgumentParser::Finalize(request.ICid); + ComplexArgumentParser::Finalize(request.groupId); + ComplexArgumentParser::Finalize(request.groupKeySetID); ComplexArgumentParser::Finalize(request.fabricIndex); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request, + chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1205,146 +1561,74 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NOCStruct.noc", "noc", value.isMember("noc"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NOCStruct.icac", "icac", value.isMember("icac"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "noc"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.noc, value["noc"])); - valueCopy.removeMember("noc"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "icac"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.icac, value["icac"])); - valueCopy.removeMember("icac"); - - if (value.isMember("fabricIndex")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); - } - valueCopy.removeMember("fabricIndex"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.noc); - ComplexArgumentParser::Finalize(request.icac); - ComplexArgumentParser::Finalize(request.fabricIndex); -} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("NeighborTable.extAddress", "extAddress", value.isMember("extAddress"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.age", "age", value.isMember("age"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.rloc16", "rloc16", value.isMember("rloc16"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.linkFrameCounter", "linkFrameCounter", - value.isMember("linkFrameCounter"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.mleFrameCounter", "mleFrameCounter", - value.isMember("mleFrameCounter"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.lqi", "lqi", value.isMember("lqi"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.groupKeySetID", "groupKeySetID", + value.isMember("groupKeySetID"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( + "GroupKeySetStruct.groupKeySecurityPolicy", "groupKeySecurityPolicy", value.isMember("groupKeySecurityPolicy"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("NeighborTable.averageRssi", "averageRssi", value.isMember("averageRssi"))); + ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochKey0", "epochKey0", value.isMember("epochKey0"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochStartTime0", "epochStartTime0", + value.isMember("epochStartTime0"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("NeighborTable.lastRssi", "lastRssi", value.isMember("lastRssi"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.frameErrorRate", "frameErrorRate", - value.isMember("frameErrorRate"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.messageErrorRate", "messageErrorRate", - value.isMember("messageErrorRate"))); + ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochKey1", "epochKey1", value.isMember("epochKey1"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochStartTime1", "epochStartTime1", + value.isMember("epochStartTime1"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("NeighborTable.rxOnWhenIdle", "rxOnWhenIdle", value.isMember("rxOnWhenIdle"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.fullThreadDevice", "fullThreadDevice", - value.isMember("fullThreadDevice"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.fullNetworkData", "fullNetworkData", - value.isMember("fullNetworkData"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.isChild", "isChild", value.isMember("isChild"))); + ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochKey2", "epochKey2", value.isMember("epochKey2"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochStartTime2", "epochStartTime2", + value.isMember("epochStartTime2"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extAddress"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extAddress, value["extAddress"])); - valueCopy.removeMember("extAddress"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "age"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.age, value["age"])); - valueCopy.removeMember("age"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rloc16"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rloc16, value["rloc16"])); - valueCopy.removeMember("rloc16"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "linkFrameCounter"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.linkFrameCounter, value["linkFrameCounter"])); - valueCopy.removeMember("linkFrameCounter"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "mleFrameCounter"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.mleFrameCounter, value["mleFrameCounter"])); - valueCopy.removeMember("mleFrameCounter"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lqi"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lqi, value["lqi"])); - valueCopy.removeMember("lqi"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "averageRssi"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.averageRssi, value["averageRssi"])); - valueCopy.removeMember("averageRssi"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupKeySetID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupKeySetID, value["groupKeySetID"])); + valueCopy.removeMember("groupKeySetID"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lastRssi"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lastRssi, value["lastRssi"])); - valueCopy.removeMember("lastRssi"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupKeySecurityPolicy"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.groupKeySecurityPolicy, value["groupKeySecurityPolicy"])); + valueCopy.removeMember("groupKeySecurityPolicy"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "frameErrorRate"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.frameErrorRate, value["frameErrorRate"])); - valueCopy.removeMember("frameErrorRate"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochKey0"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochKey0, value["epochKey0"])); + valueCopy.removeMember("epochKey0"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "messageErrorRate"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.messageErrorRate, value["messageErrorRate"])); - valueCopy.removeMember("messageErrorRate"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochStartTime0"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochStartTime0, value["epochStartTime0"])); + valueCopy.removeMember("epochStartTime0"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rxOnWhenIdle"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rxOnWhenIdle, value["rxOnWhenIdle"])); - valueCopy.removeMember("rxOnWhenIdle"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochKey1"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochKey1, value["epochKey1"])); + valueCopy.removeMember("epochKey1"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fullThreadDevice"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fullThreadDevice, value["fullThreadDevice"])); - valueCopy.removeMember("fullThreadDevice"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochStartTime1"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochStartTime1, value["epochStartTime1"])); + valueCopy.removeMember("epochStartTime1"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fullNetworkData"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fullNetworkData, value["fullNetworkData"])); - valueCopy.removeMember("fullNetworkData"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochKey2"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochKey2, value["epochKey2"])); + valueCopy.removeMember("epochKey2"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "isChild"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.isChild, value["isChild"])); - valueCopy.removeMember("isChild"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochStartTime2"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochStartTime2, value["epochStartTime2"])); + valueCopy.removeMember("epochStartTime2"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::Type & request) { - ComplexArgumentParser::Finalize(request.extAddress); - ComplexArgumentParser::Finalize(request.age); - ComplexArgumentParser::Finalize(request.rloc16); - ComplexArgumentParser::Finalize(request.linkFrameCounter); - ComplexArgumentParser::Finalize(request.mleFrameCounter); - ComplexArgumentParser::Finalize(request.lqi); - ComplexArgumentParser::Finalize(request.averageRssi); - ComplexArgumentParser::Finalize(request.lastRssi); - ComplexArgumentParser::Finalize(request.frameErrorRate); - ComplexArgumentParser::Finalize(request.messageErrorRate); - ComplexArgumentParser::Finalize(request.rxOnWhenIdle); - ComplexArgumentParser::Finalize(request.fullThreadDevice); - ComplexArgumentParser::Finalize(request.fullNetworkData); - ComplexArgumentParser::Finalize(request.isChild); + ComplexArgumentParser::Finalize(request.groupKeySetID); + ComplexArgumentParser::Finalize(request.groupKeySecurityPolicy); + ComplexArgumentParser::Finalize(request.epochKey0); + ComplexArgumentParser::Finalize(request.epochStartTime0); + ComplexArgumentParser::Finalize(request.epochKey1); + ComplexArgumentParser::Finalize(request.epochStartTime1); + ComplexArgumentParser::Finalize(request.epochKey2); + ComplexArgumentParser::Finalize(request.epochStartTime2); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1352,34 +1636,30 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters: // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStruct.a", "a", value.isMember("a"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStruct.b", "b", value.isMember("b"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStruct.c", "c", value.isMember("c"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("SemanticTagStruct.mfgCode", "mfgCode", value.isMember("mfgCode"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SemanticTagStruct.value", "value", value.isMember("value"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); - valueCopy.removeMember("a"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "b"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.b, value["b"])); - valueCopy.removeMember("b"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "mfgCode"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.mfgCode, value["mfgCode"])); + valueCopy.removeMember("mfgCode"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "c"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); - valueCopy.removeMember("c"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); + valueCopy.removeMember("value"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request) { - ComplexArgumentParser::Finalize(request.a); - ComplexArgumentParser::Finalize(request.b); - ComplexArgumentParser::Finalize(request.c); + ComplexArgumentParser::Finalize(request.mfgCode); + ComplexArgumentParser::Finalize(request.value); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request, + chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1387,58 +1667,36 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.a", "a", value.isMember("a"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.b", "b", value.isMember("b"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.c", "c", value.isMember("c"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.d", "d", value.isMember("d"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.e", "e", value.isMember("e"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.f", "f", value.isMember("f"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.g", "g", value.isMember("g"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ModeOptionStruct.label", "label", value.isMember("label"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ModeOptionStruct.mode", "mode", value.isMember("mode"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ModeOptionStruct.semanticTags", "semanticTags", value.isMember("semanticTags"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); - valueCopy.removeMember("a"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "b"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.b, value["b"])); - valueCopy.removeMember("b"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "c"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); - valueCopy.removeMember("c"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "d"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.d, value["d"])); - valueCopy.removeMember("d"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "e"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.e, value["e"])); - valueCopy.removeMember("e"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "label"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.label, value["label"])); + valueCopy.removeMember("label"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "f"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.f, value["f"])); - valueCopy.removeMember("f"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "mode"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.mode, value["mode"])); + valueCopy.removeMember("mode"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "g"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.g, value["g"])); - valueCopy.removeMember("g"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "semanticTags"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.semanticTags, value["semanticTags"])); + valueCopy.removeMember("semanticTags"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type & request) { - ComplexArgumentParser::Finalize(request.a); - ComplexArgumentParser::Finalize(request.b); - ComplexArgumentParser::Finalize(request.c); - ComplexArgumentParser::Finalize(request.d); - ComplexArgumentParser::Finalize(request.e); - ComplexArgumentParser::Finalize(request.f); - ComplexArgumentParser::Finalize(request.g); + ComplexArgumentParser::Finalize(request.label); + ComplexArgumentParser::Finalize(request.mode); + ComplexArgumentParser::Finalize(request.semanticTags); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request, + chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1446,30 +1704,31 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("NetworkInfo.networkID", "networkID", value.isMember("networkID"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("NetworkInfo.connected", "connected", value.isMember("connected"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("CredentialStruct.credentialType", "credentialType", + value.isMember("credentialType"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("CredentialStruct.credentialIndex", "credentialIndex", + value.isMember("credentialIndex"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "networkID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.networkID, value["networkID"])); - valueCopy.removeMember("networkID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "credentialType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.credentialType, value["credentialType"])); + valueCopy.removeMember("credentialType"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "connected"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.connected, value["connected"])); - valueCopy.removeMember("connected"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "credentialIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.credentialIndex, value["credentialIndex"])); + valueCopy.removeMember("credentialIndex"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request) { - ComplexArgumentParser::Finalize(request.networkID); - ComplexArgumentParser::Finalize(request.connected); + ComplexArgumentParser::Finalize(request.credentialType); + ComplexArgumentParser::Finalize(request.credentialIndex); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request, + chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1477,74 +1736,38 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.name", "name", value.isMember("name"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.isOperational", "isOperational", - value.isMember("isOperational"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.offPremiseServicesReachableIPv4", - "offPremiseServicesReachableIPv4", - value.isMember("offPremiseServicesReachableIPv4"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.offPremiseServicesReachableIPv6", - "offPremiseServicesReachableIPv6", - value.isMember("offPremiseServicesReachableIPv6"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.hardwareAddress", "hardwareAddress", - value.isMember("hardwareAddress"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.IPv4Addresses", "IPv4Addresses", - value.isMember("IPv4Addresses"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.IPv6Addresses", "IPv6Addresses", - value.isMember("IPv6Addresses"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.type", "type", value.isMember("type"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThermostatScheduleTransition.transitionTime", "transitionTime", + value.isMember("transitionTime"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThermostatScheduleTransition.heatSetpoint", "heatSetpoint", + value.isMember("heatSetpoint"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThermostatScheduleTransition.coolSetpoint", "coolSetpoint", + value.isMember("coolSetpoint"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - valueCopy.removeMember("name"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "isOperational"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.isOperational, value["isOperational"])); - valueCopy.removeMember("isOperational"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offPremiseServicesReachableIPv4"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offPremiseServicesReachableIPv4, - value["offPremiseServicesReachableIPv4"])); - valueCopy.removeMember("offPremiseServicesReachableIPv4"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offPremiseServicesReachableIPv6"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offPremiseServicesReachableIPv6, - value["offPremiseServicesReachableIPv6"])); - valueCopy.removeMember("offPremiseServicesReachableIPv6"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "hardwareAddress"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.hardwareAddress, value["hardwareAddress"])); - valueCopy.removeMember("hardwareAddress"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "IPv4Addresses"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.IPv4Addresses, value["IPv4Addresses"])); - valueCopy.removeMember("IPv4Addresses"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "transitionTime"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.transitionTime, value["transitionTime"])); + valueCopy.removeMember("transitionTime"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "IPv6Addresses"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.IPv6Addresses, value["IPv6Addresses"])); - valueCopy.removeMember("IPv6Addresses"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "heatSetpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.heatSetpoint, value["heatSetpoint"])); + valueCopy.removeMember("heatSetpoint"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "type"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.type, value["type"])); - valueCopy.removeMember("type"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "coolSetpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.coolSetpoint, value["coolSetpoint"])); + valueCopy.removeMember("coolSetpoint"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request) { - ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.isOperational); - ComplexArgumentParser::Finalize(request.offPremiseServicesReachableIPv4); - ComplexArgumentParser::Finalize(request.offPremiseServicesReachableIPv6); - ComplexArgumentParser::Finalize(request.hardwareAddress); - ComplexArgumentParser::Finalize(request.IPv4Addresses); - ComplexArgumentParser::Finalize(request.IPv6Addresses); - ComplexArgumentParser::Finalize(request.type); + ComplexArgumentParser::Finalize(request.transitionTime); + ComplexArgumentParser::Finalize(request.heatSetpoint); + ComplexArgumentParser::Finalize(request.coolSetpoint); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request, + chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1552,221 +1775,54 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableInt", "nullableInt", - value.isMember("nullableInt"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableString", "nullableString", - value.isMember("nullableString"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableStruct", "nullableStruct", - value.isMember("nullableStruct"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableList", "nullableList", - value.isMember("nullableList"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableInt"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableInt, value["nullableInt"])); - valueCopy.removeMember("nullableInt"); - - if (value.isMember("optionalInt")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalInt"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalInt, value["optionalInt"])); - } - valueCopy.removeMember("optionalInt"); - - if (value.isMember("nullableOptionalInt")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalInt"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalInt, value["nullableOptionalInt"])); - } - valueCopy.removeMember("nullableOptionalInt"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableString"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableString, value["nullableString"])); - valueCopy.removeMember("nullableString"); - - if (value.isMember("optionalString")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalString"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalString, value["optionalString"])); - } - valueCopy.removeMember("optionalString"); - - if (value.isMember("nullableOptionalString")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalString"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalString, value["nullableOptionalString"])); - } - valueCopy.removeMember("nullableOptionalString"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableStruct"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableStruct, value["nullableStruct"])); - valueCopy.removeMember("nullableStruct"); - - if (value.isMember("optionalStruct")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalStruct"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalStruct, value["optionalStruct"])); - } - valueCopy.removeMember("optionalStruct"); - - if (value.isMember("nullableOptionalStruct")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalStruct"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalStruct, value["nullableOptionalStruct"])); - } - valueCopy.removeMember("nullableOptionalStruct"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableList"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableList, value["nullableList"])); - valueCopy.removeMember("nullableList"); - - if (value.isMember("optionalList")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalList"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalList, value["optionalList"])); - } - valueCopy.removeMember("optionalList"); - - if (value.isMember("nullableOptionalList")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalList"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalList, value["nullableOptionalList"])); - } - valueCopy.removeMember("nullableOptionalList"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.nullableInt); - ComplexArgumentParser::Finalize(request.optionalInt); - ComplexArgumentParser::Finalize(request.nullableOptionalInt); - ComplexArgumentParser::Finalize(request.nullableString); - ComplexArgumentParser::Finalize(request.optionalString); - ComplexArgumentParser::Finalize(request.nullableOptionalString); - ComplexArgumentParser::Finalize(request.nullableStruct); - ComplexArgumentParser::Finalize(request.optionalStruct); - ComplexArgumentParser::Finalize(request.nullableOptionalStruct); - ComplexArgumentParser::Finalize(request.nullableList); - ComplexArgumentParser::Finalize(request.optionalList); - ComplexArgumentParser::Finalize(request.nullableOptionalList); -} -CHIP_ERROR -ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( - "OperationalDatasetComponents.activeTimestampPresent", "activeTimestampPresent", value.isMember("activeTimestampPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.pendingTimestampPresent", - "pendingTimestampPresent", - value.isMember("pendingTimestampPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.masterKeyPresent", - "masterKeyPresent", value.isMember("masterKeyPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.networkNamePresent", - "networkNamePresent", value.isMember("networkNamePresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.extendedPanIdPresent", - "extendedPanIdPresent", value.isMember("extendedPanIdPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( - "OperationalDatasetComponents.meshLocalPrefixPresent", "meshLocalPrefixPresent", value.isMember("meshLocalPrefixPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.delayPresent", "delayPresent", - value.isMember("delayPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.panIdPresent", "panIdPresent", - value.isMember("panIdPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.channelPresent", "channelPresent", - value.isMember("channelPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.pskcPresent", "pskcPresent", - value.isMember("pskcPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( - "OperationalDatasetComponents.securityPolicyPresent", "securityPolicyPresent", value.isMember("securityPolicyPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.channelMaskPresent", - "channelMaskPresent", value.isMember("channelMaskPresent"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "activeTimestampPresent"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.activeTimestampPresent, value["activeTimestampPresent"])); - valueCopy.removeMember("activeTimestampPresent"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "pendingTimestampPresent"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.pendingTimestampPresent, value["pendingTimestampPresent"])); - valueCopy.removeMember("pendingTimestampPresent"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "masterKeyPresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.masterKeyPresent, value["masterKeyPresent"])); - valueCopy.removeMember("masterKeyPresent"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "networkNamePresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.networkNamePresent, value["networkNamePresent"])); - valueCopy.removeMember("networkNamePresent"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extendedPanIdPresent"); ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.extendedPanIdPresent, value["extendedPanIdPresent"])); - valueCopy.removeMember("extendedPanIdPresent"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "meshLocalPrefixPresent"); + ComplexArgumentParser::EnsureMemberExist("ChannelInfoStruct.majorNumber", "majorNumber", value.isMember("majorNumber"))); ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.meshLocalPrefixPresent, value["meshLocalPrefixPresent"])); - valueCopy.removeMember("meshLocalPrefixPresent"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "delayPresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.delayPresent, value["delayPresent"])); - valueCopy.removeMember("delayPresent"); + ComplexArgumentParser::EnsureMemberExist("ChannelInfoStruct.minorNumber", "minorNumber", value.isMember("minorNumber"))); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "panIdPresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.panIdPresent, value["panIdPresent"])); - valueCopy.removeMember("panIdPresent"); + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "majorNumber"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.majorNumber, value["majorNumber"])); + valueCopy.removeMember("majorNumber"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channelPresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channelPresent, value["channelPresent"])); - valueCopy.removeMember("channelPresent"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "minorNumber"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.minorNumber, value["minorNumber"])); + valueCopy.removeMember("minorNumber"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "pskcPresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.pskcPresent, value["pskcPresent"])); - valueCopy.removeMember("pskcPresent"); + if (value.isMember("name")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + } + valueCopy.removeMember("name"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "securityPolicyPresent"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.securityPolicyPresent, value["securityPolicyPresent"])); - valueCopy.removeMember("securityPolicyPresent"); + if (value.isMember("callSign")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "callSign"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.callSign, value["callSign"])); + } + valueCopy.removeMember("callSign"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channelMaskPresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channelMaskPresent, value["channelMaskPresent"])); - valueCopy.removeMember("channelMaskPresent"); + if (value.isMember("affiliateCallSign")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "affiliateCallSign"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.affiliateCallSign, value["affiliateCallSign"])); + } + valueCopy.removeMember("affiliateCallSign"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize( - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request) { - ComplexArgumentParser::Finalize(request.activeTimestampPresent); - ComplexArgumentParser::Finalize(request.pendingTimestampPresent); - ComplexArgumentParser::Finalize(request.masterKeyPresent); - ComplexArgumentParser::Finalize(request.networkNamePresent); - ComplexArgumentParser::Finalize(request.extendedPanIdPresent); - ComplexArgumentParser::Finalize(request.meshLocalPrefixPresent); - ComplexArgumentParser::Finalize(request.delayPresent); - ComplexArgumentParser::Finalize(request.panIdPresent); - ComplexArgumentParser::Finalize(request.channelPresent); - ComplexArgumentParser::Finalize(request.pskcPresent); - ComplexArgumentParser::Finalize(request.securityPolicyPresent); - ComplexArgumentParser::Finalize(request.channelMaskPresent); + ComplexArgumentParser::Finalize(request.majorNumber); + ComplexArgumentParser::Finalize(request.minorNumber); + ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.callSign); + ComplexArgumentParser::Finalize(request.affiliateCallSign); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1774,35 +1830,47 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OutputInfoStruct.index", "index", value.isMember("index"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("OutputInfoStruct.outputType", "outputType", value.isMember("outputType"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OutputInfoStruct.name", "name", value.isMember("name"))); + ComplexArgumentParser::EnsureMemberExist("LineupInfoStruct.operatorName", "operatorName", value.isMember("operatorName"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("LineupInfoStruct.lineupInfoType", "lineupInfoType", + value.isMember("lineupInfoType"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "index"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.index, value["index"])); - valueCopy.removeMember("index"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "operatorName"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.operatorName, value["operatorName"])); + valueCopy.removeMember("operatorName"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "outputType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.outputType, value["outputType"])); - valueCopy.removeMember("outputType"); + if (value.isMember("lineupName")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lineupName"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lineupName, value["lineupName"])); + } + valueCopy.removeMember("lineupName"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - valueCopy.removeMember("name"); + if (value.isMember("postalCode")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "postalCode"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.postalCode, value["postalCode"])); + } + valueCopy.removeMember("postalCode"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lineupInfoType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lineupInfoType, value["lineupInfoType"])); + valueCopy.removeMember("lineupInfoType"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request) { - ComplexArgumentParser::Finalize(request.index); - ComplexArgumentParser::Finalize(request.outputType); - ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.operatorName); + ComplexArgumentParser::Finalize(request.lineupName); + ComplexArgumentParser::Finalize(request.postalCode); + ComplexArgumentParser::Finalize(request.lineupInfoType); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request, + chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1810,34 +1878,28 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ParameterStruct.type", "type", value.isMember("type"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ParameterStruct.value", "value", value.isMember("value"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("TargetInfoStruct.identifier", "identifier", value.isMember("identifier"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TargetInfoStruct.name", "name", value.isMember("name"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "type"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.type, value["type"])); - valueCopy.removeMember("type"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); - valueCopy.removeMember("value"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "identifier"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.identifier, value["identifier"])); + valueCopy.removeMember("identifier"); - if (value.isMember("externalIDList")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "externalIDList"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.externalIDList, value["externalIDList"])); - } - valueCopy.removeMember("externalIDList"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + valueCopy.removeMember("name"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request) { - ComplexArgumentParser::Finalize(request.type); - ComplexArgumentParser::Finalize(request.value); - ComplexArgumentParser::Finalize(request.externalIDList); + ComplexArgumentParser::Finalize(request.identifier); + ComplexArgumentParser::Finalize(request.name); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Type & request, Json::Value & value) @@ -1869,8 +1931,9 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::MediaPlayback::Structs ComplexArgumentParser::Finalize(request.updatedAt); ComplexArgumentParser::Finalize(request.position); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request, + chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1878,38 +1941,43 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ProviderLocation.providerNodeID", "providerNodeID", - value.isMember("providerNodeID"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.index", "index", value.isMember("index"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ProviderLocation.endpoint", "endpoint", value.isMember("endpoint"))); + ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.inputType", "inputType", value.isMember("inputType"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.name", "name", value.isMember("name"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.description", "description", value.isMember("description"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "providerNodeID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.providerNodeID, value["providerNodeID"])); - valueCopy.removeMember("providerNodeID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "index"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.index, value["index"])); + valueCopy.removeMember("index"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); - valueCopy.removeMember("endpoint"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "inputType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.inputType, value["inputType"])); + valueCopy.removeMember("inputType"); - if (value.isMember("fabricIndex")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); - } - valueCopy.removeMember("fabricIndex"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + valueCopy.removeMember("name"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "description"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.description, value["description"])); + valueCopy.removeMember("description"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request) { - ComplexArgumentParser::Finalize(request.providerNodeID); - ComplexArgumentParser::Finalize(request.endpoint); - ComplexArgumentParser::Finalize(request.fabricIndex); + ComplexArgumentParser::Finalize(request.index); + ComplexArgumentParser::Finalize(request.inputType); + ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.description); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request, + chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1917,79 +1985,35 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("RouteTable.extAddress", "extAddress", value.isMember("extAddress"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.rloc16", "rloc16", value.isMember("rloc16"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.routerId", "routerId", value.isMember("routerId"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.nextHop", "nextHop", value.isMember("nextHop"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.pathCost", "pathCost", value.isMember("pathCost"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.LQIIn", "LQIIn", value.isMember("LQIIn"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.LQIOut", "LQIOut", value.isMember("LQIOut"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.age", "age", value.isMember("age"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("RouteTable.allocated", "allocated", value.isMember("allocated"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.linkEstablished", "linkEstablished", - value.isMember("linkEstablished"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DimensionStruct.width", "width", value.isMember("width"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DimensionStruct.height", "height", value.isMember("height"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DimensionStruct.metric", "metric", value.isMember("metric"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extAddress"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extAddress, value["extAddress"])); - valueCopy.removeMember("extAddress"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rloc16"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rloc16, value["rloc16"])); - valueCopy.removeMember("rloc16"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "routerId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.routerId, value["routerId"])); - valueCopy.removeMember("routerId"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nextHop"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nextHop, value["nextHop"])); - valueCopy.removeMember("nextHop"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "pathCost"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.pathCost, value["pathCost"])); - valueCopy.removeMember("pathCost"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "LQIIn"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.LQIIn, value["LQIIn"])); - valueCopy.removeMember("LQIIn"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "LQIOut"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.LQIOut, value["LQIOut"])); - valueCopy.removeMember("LQIOut"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "age"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.age, value["age"])); - valueCopy.removeMember("age"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "allocated"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.allocated, value["allocated"])); - valueCopy.removeMember("allocated"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "linkEstablished"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.linkEstablished, value["linkEstablished"])); - valueCopy.removeMember("linkEstablished"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "width"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.width, value["width"])); + valueCopy.removeMember("width"); - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "height"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.height, value["height"])); + valueCopy.removeMember("height"); -void ComplexArgumentParser::Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request) -{ - ComplexArgumentParser::Finalize(request.extAddress); - ComplexArgumentParser::Finalize(request.rloc16); - ComplexArgumentParser::Finalize(request.routerId); - ComplexArgumentParser::Finalize(request.nextHop); - ComplexArgumentParser::Finalize(request.pathCost); - ComplexArgumentParser::Finalize(request.LQIIn); - ComplexArgumentParser::Finalize(request.LQIOut); - ComplexArgumentParser::Finalize(request.age); - ComplexArgumentParser::Finalize(request.allocated); - ComplexArgumentParser::Finalize(request.linkEstablished); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "metric"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.metric, value["metric"])); + valueCopy.removeMember("metric"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.width); + ComplexArgumentParser::Finalize(request.height); + ComplexArgumentParser::Finalize(request.metric); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request, + chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1997,29 +2021,29 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("SecurityPolicy.rotationTime", "rotationTime", value.isMember("rotationTime"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SecurityPolicy.flags", "flags", value.isMember("flags"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AdditionalInfoStruct.name", "name", value.isMember("name"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AdditionalInfoStruct.value", "value", value.isMember("value"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rotationTime"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rotationTime, value["rotationTime"])); - valueCopy.removeMember("rotationTime"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + valueCopy.removeMember("name"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "flags"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.flags, value["flags"])); - valueCopy.removeMember("flags"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); + valueCopy.removeMember("value"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request) { - ComplexArgumentParser::Finalize(request.rotationTime); - ComplexArgumentParser::Finalize(request.flags); + ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.value); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request, + chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2027,28 +2051,37 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("SemanticTagStruct.mfgCode", "mfgCode", value.isMember("mfgCode"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SemanticTagStruct.value", "value", value.isMember("value"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ParameterStruct.type", "type", value.isMember("type"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ParameterStruct.value", "value", value.isMember("value"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "mfgCode"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.mfgCode, value["mfgCode"])); - valueCopy.removeMember("mfgCode"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "type"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.type, value["type"])); + valueCopy.removeMember("type"); snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); valueCopy.removeMember("value"); + if (value.isMember("externalIDList")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "externalIDList"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.externalIDList, value["externalIDList"])); + } + valueCopy.removeMember("externalIDList"); + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request) { - ComplexArgumentParser::Finalize(request.mfgCode); + ComplexArgumentParser::Finalize(request.type); ComplexArgumentParser::Finalize(request.value); + ComplexArgumentParser::Finalize(request.externalIDList); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2056,62 +2089,22 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters: // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.a", "a", value.isMember("a"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.b", "b", value.isMember("b"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.c", "c", value.isMember("c"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.d", "d", value.isMember("d"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.e", "e", value.isMember("e"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.f", "f", value.isMember("f"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.g", "g", value.isMember("g"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.h", "h", value.isMember("h"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ContentSearchStruct.parameterList", "parameterList", + value.isMember("parameterList"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); - valueCopy.removeMember("a"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "b"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.b, value["b"])); - valueCopy.removeMember("b"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "c"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); - valueCopy.removeMember("c"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "d"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.d, value["d"])); - valueCopy.removeMember("d"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "e"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.e, value["e"])); - valueCopy.removeMember("e"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "f"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.f, value["f"])); - valueCopy.removeMember("f"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "g"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.g, value["g"])); - valueCopy.removeMember("g"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "h"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.h, value["h"])); - valueCopy.removeMember("h"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "parameterList"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.parameterList, value["parameterList"])); + valueCopy.removeMember("parameterList"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request) { - ComplexArgumentParser::Finalize(request.a); - ComplexArgumentParser::Finalize(request.b); - ComplexArgumentParser::Finalize(request.c); - ComplexArgumentParser::Finalize(request.d); - ComplexArgumentParser::Finalize(request.e); - ComplexArgumentParser::Finalize(request.f); - ComplexArgumentParser::Finalize(request.g); - ComplexArgumentParser::Finalize(request.h); + ComplexArgumentParser::Finalize(request.parameterList); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::Type & request, Json::Value & value) @@ -2152,7 +2145,9 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Struc ComplexArgumentParser::Finalize(request.color); ComplexArgumentParser::Finalize(request.size); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::AccessControl::Structs::Target::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2160,34 +2155,134 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters: // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Target.cluster", "cluster", value.isMember("cluster"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Target.endpoint", "endpoint", value.isMember("endpoint"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Target.deviceType", "deviceType", value.isMember("deviceType"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("BrandingInformationStruct.providerName", "providerName", + value.isMember("providerName"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "cluster"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.cluster, value["cluster"])); - valueCopy.removeMember("cluster"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "providerName"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.providerName, value["providerName"])); + valueCopy.removeMember("providerName"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); - valueCopy.removeMember("endpoint"); + if (value.isMember("background")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "background"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.background, value["background"])); + } + valueCopy.removeMember("background"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "deviceType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.deviceType, value["deviceType"])); - valueCopy.removeMember("deviceType"); + if (value.isMember("logo")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "logo"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.logo, value["logo"])); + } + valueCopy.removeMember("logo"); + + if (value.isMember("progressBar")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "progressBar"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.progressBar, value["progressBar"])); + } + valueCopy.removeMember("progressBar"); + + if (value.isMember("splash")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "splash"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.splash, value["splash"])); + } + valueCopy.removeMember("splash"); + + if (value.isMember("waterMark")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "waterMark"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.waterMark, value["waterMark"])); + } + valueCopy.removeMember("waterMark"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::AccessControl::Structs::Target::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request) { - ComplexArgumentParser::Finalize(request.cluster); + ComplexArgumentParser::Finalize(request.providerName); + ComplexArgumentParser::Finalize(request.background); + ComplexArgumentParser::Finalize(request.logo); + ComplexArgumentParser::Finalize(request.progressBar); + ComplexArgumentParser::Finalize(request.splash); + ComplexArgumentParser::Finalize(request.waterMark); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OutputInfoStruct.index", "index", value.isMember("index"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("OutputInfoStruct.outputType", "outputType", value.isMember("outputType"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OutputInfoStruct.name", "name", value.isMember("name"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "index"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.index, value["index"])); + valueCopy.removeMember("index"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "outputType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.outputType, value["outputType"])); + valueCopy.removeMember("outputType"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + valueCopy.removeMember("name"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.index); + ComplexArgumentParser::Finalize(request.outputType); + ComplexArgumentParser::Finalize(request.name); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ApplicationEPStruct.application", "application", value.isMember("application"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "application"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.application, value["application"])); + valueCopy.removeMember("application"); + + if (value.isMember("endpoint")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); + } + valueCopy.removeMember("endpoint"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.application); ComplexArgumentParser::Finalize(request.endpoint); - ComplexArgumentParser::Finalize(request.deviceType); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request, + chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2195,28 +2290,37 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("TargetInfoStruct.identifier", "identifier", value.isMember("identifier"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TargetInfoStruct.name", "name", value.isMember("name"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MonitoringRegistration.clientNodeId", "clientNodeId", + value.isMember("clientNodeId"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MonitoringRegistration.ICid", "ICid", value.isMember("ICid"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "identifier"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.identifier, value["identifier"])); - valueCopy.removeMember("identifier"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "clientNodeId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.clientNodeId, value["clientNodeId"])); + valueCopy.removeMember("clientNodeId"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - valueCopy.removeMember("name"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "ICid"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.ICid, value["ICid"])); + valueCopy.removeMember("ICid"); + + if (value.isMember("fabricIndex")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); + } + valueCopy.removeMember("fabricIndex"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request) { - ComplexArgumentParser::Finalize(request.identifier); - ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.clientNodeId); + ComplexArgumentParser::Finalize(request.ICid); + ComplexArgumentParser::Finalize(request.fabricIndex); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Binding::Structs::TargetStruct::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2224,53 +2328,63 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters: // Copy to track which members we already processed. Json::Value valueCopy(value); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.a", "a", value.isMember("a"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.b", "b", value.isMember("b"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.c", "c", value.isMember("c"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.d", "d", value.isMember("d"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.e", "e", value.isMember("e"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.f", "f", value.isMember("f"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.g", "g", value.isMember("g"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.h", "h", value.isMember("h"))); + char labelWithMember[kMaxLabelLength]; - if (value.isMember("node")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "node"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.node, value["node"])); - } - valueCopy.removeMember("node"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); + valueCopy.removeMember("a"); - if (value.isMember("group")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "group"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.group, value["group"])); - } - valueCopy.removeMember("group"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "b"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.b, value["b"])); + valueCopy.removeMember("b"); - if (value.isMember("endpoint")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); - } - valueCopy.removeMember("endpoint"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "c"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); + valueCopy.removeMember("c"); - if (value.isMember("cluster")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "cluster"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.cluster, value["cluster"])); - } - valueCopy.removeMember("cluster"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "d"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.d, value["d"])); + valueCopy.removeMember("d"); - if (value.isMember("fabricIndex")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); - } - valueCopy.removeMember("fabricIndex"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "e"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.e, value["e"])); + valueCopy.removeMember("e"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "f"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.f, value["f"])); + valueCopy.removeMember("f"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "g"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.g, value["g"])); + valueCopy.removeMember("g"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "h"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.h, value["h"])); + valueCopy.removeMember("h"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::Binding::Structs::TargetStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request) { - ComplexArgumentParser::Finalize(request.node); - ComplexArgumentParser::Finalize(request.group); - ComplexArgumentParser::Finalize(request.endpoint); - ComplexArgumentParser::Finalize(request.cluster); - ComplexArgumentParser::Finalize(request.fabricIndex); + ComplexArgumentParser::Finalize(request.a); + ComplexArgumentParser::Finalize(request.b); + ComplexArgumentParser::Finalize(request.c); + ComplexArgumentParser::Finalize(request.d); + ComplexArgumentParser::Finalize(request.e); + ComplexArgumentParser::Finalize(request.f); + ComplexArgumentParser::Finalize(request.g); + ComplexArgumentParser::Finalize(request.h); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::Type & request, Json::Value & value) @@ -2355,39 +2469,9 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs:: ComplexArgumentParser::Finalize(request.fabricSensitiveInt8uList); ComplexArgumentParser::Finalize(request.fabricIndex); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("TestListStructOctet.member1", "member1", value.isMember("member1"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("TestListStructOctet.member2", "member2", value.isMember("member2"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "member1"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.member1, value["member1"])); - valueCopy.removeMember("member1"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "member2"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.member2, value["member2"])); - valueCopy.removeMember("member2"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} -void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request) -{ - ComplexArgumentParser::Finalize(request.member1); - ComplexArgumentParser::Finalize(request.member2); -} CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request, + chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2395,110 +2479,112 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThermostatScheduleTransition.transitionTime", "transitionTime", - value.isMember("transitionTime"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThermostatScheduleTransition.heatSetpoint", "heatSetpoint", - value.isMember("heatSetpoint"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThermostatScheduleTransition.coolSetpoint", "coolSetpoint", - value.isMember("coolSetpoint"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableInt", "nullableInt", + value.isMember("nullableInt"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableString", "nullableString", + value.isMember("nullableString"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableStruct", "nullableStruct", + value.isMember("nullableStruct"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableList", "nullableList", + value.isMember("nullableList"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "transitionTime"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.transitionTime, value["transitionTime"])); - valueCopy.removeMember("transitionTime"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "heatSetpoint"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.heatSetpoint, value["heatSetpoint"])); - valueCopy.removeMember("heatSetpoint"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "coolSetpoint"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.coolSetpoint, value["coolSetpoint"])); - valueCopy.removeMember("coolSetpoint"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request) -{ - ComplexArgumentParser::Finalize(request.transitionTime); - ComplexArgumentParser::Finalize(request.heatSetpoint); - ComplexArgumentParser::Finalize(request.coolSetpoint); -} -CHIP_ERROR -ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableInt"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableInt, value["nullableInt"])); + valueCopy.removeMember("nullableInt"); - // Copy to track which members we already processed. - Json::Value valueCopy(value); + if (value.isMember("optionalInt")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalInt"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalInt, value["optionalInt"])); + } + valueCopy.removeMember("optionalInt"); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.panId", "panId", value.isMember("panId"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.extendedPanId", "extendedPanId", - value.isMember("extendedPanId"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.networkName", "networkName", - value.isMember("networkName"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.channel", "channel", value.isMember("channel"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.version", "version", value.isMember("version"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.extendedAddress", "extendedAddress", - value.isMember("extendedAddress"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.rssi", "rssi", value.isMember("rssi"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.lqi", "lqi", value.isMember("lqi"))); + if (value.isMember("nullableOptionalInt")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalInt"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalInt, value["nullableOptionalInt"])); + } + valueCopy.removeMember("nullableOptionalInt"); - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "panId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.panId, value["panId"])); - valueCopy.removeMember("panId"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableString"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableString, value["nullableString"])); + valueCopy.removeMember("nullableString"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extendedPanId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extendedPanId, value["extendedPanId"])); - valueCopy.removeMember("extendedPanId"); + if (value.isMember("optionalString")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalString"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalString, value["optionalString"])); + } + valueCopy.removeMember("optionalString"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "networkName"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.networkName, value["networkName"])); - valueCopy.removeMember("networkName"); + if (value.isMember("nullableOptionalString")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalString"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalString, value["nullableOptionalString"])); + } + valueCopy.removeMember("nullableOptionalString"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channel"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channel, value["channel"])); - valueCopy.removeMember("channel"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableStruct"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableStruct, value["nullableStruct"])); + valueCopy.removeMember("nullableStruct"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "version"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.version, value["version"])); - valueCopy.removeMember("version"); + if (value.isMember("optionalStruct")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalStruct"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalStruct, value["optionalStruct"])); + } + valueCopy.removeMember("optionalStruct"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extendedAddress"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extendedAddress, value["extendedAddress"])); - valueCopy.removeMember("extendedAddress"); + if (value.isMember("nullableOptionalStruct")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalStruct"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalStruct, value["nullableOptionalStruct"])); + } + valueCopy.removeMember("nullableOptionalStruct"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rssi"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rssi, value["rssi"])); - valueCopy.removeMember("rssi"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableList"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableList, value["nullableList"])); + valueCopy.removeMember("nullableList"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lqi"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lqi, value["lqi"])); - valueCopy.removeMember("lqi"); + if (value.isMember("optionalList")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalList"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalList, value["optionalList"])); + } + valueCopy.removeMember("optionalList"); + + if (value.isMember("nullableOptionalList")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalList"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalList, value["nullableOptionalList"])); + } + valueCopy.removeMember("nullableOptionalList"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request) { - ComplexArgumentParser::Finalize(request.panId); - ComplexArgumentParser::Finalize(request.extendedPanId); - ComplexArgumentParser::Finalize(request.networkName); - ComplexArgumentParser::Finalize(request.channel); - ComplexArgumentParser::Finalize(request.version); - ComplexArgumentParser::Finalize(request.extendedAddress); - ComplexArgumentParser::Finalize(request.rssi); - ComplexArgumentParser::Finalize(request.lqi); + ComplexArgumentParser::Finalize(request.nullableInt); + ComplexArgumentParser::Finalize(request.optionalInt); + ComplexArgumentParser::Finalize(request.nullableOptionalInt); + ComplexArgumentParser::Finalize(request.nullableString); + ComplexArgumentParser::Finalize(request.optionalString); + ComplexArgumentParser::Finalize(request.nullableOptionalString); + ComplexArgumentParser::Finalize(request.nullableStruct); + ComplexArgumentParser::Finalize(request.optionalStruct); + ComplexArgumentParser::Finalize(request.nullableOptionalStruct); + ComplexArgumentParser::Finalize(request.nullableList); + ComplexArgumentParser::Finalize(request.optionalList); + ComplexArgumentParser::Finalize(request.nullableOptionalList); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2506,54 +2592,35 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadMetricsStruct.id", "id", value.isMember("id"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStruct.a", "a", value.isMember("a"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStruct.b", "b", value.isMember("b"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStruct.c", "c", value.isMember("c"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "id"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.id, value["id"])); - valueCopy.removeMember("id"); - - if (value.isMember("name")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - } - valueCopy.removeMember("name"); - - if (value.isMember("stackFreeCurrent")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "stackFreeCurrent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.stackFreeCurrent, value["stackFreeCurrent"])); - } - valueCopy.removeMember("stackFreeCurrent"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); + valueCopy.removeMember("a"); - if (value.isMember("stackFreeMinimum")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "stackFreeMinimum"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.stackFreeMinimum, value["stackFreeMinimum"])); - } - valueCopy.removeMember("stackFreeMinimum"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "b"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.b, value["b"])); + valueCopy.removeMember("b"); - if (value.isMember("stackSize")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "stackSize"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.stackSize, value["stackSize"])); - } - valueCopy.removeMember("stackSize"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "c"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); + valueCopy.removeMember("c"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request) { - ComplexArgumentParser::Finalize(request.id); - ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.stackFreeCurrent); - ComplexArgumentParser::Finalize(request.stackFreeMinimum); - ComplexArgumentParser::Finalize(request.stackSize); + ComplexArgumentParser::Finalize(request.a); + ComplexArgumentParser::Finalize(request.b); + ComplexArgumentParser::Finalize(request.c); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request, + chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2561,36 +2628,59 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TimeZoneStruct.offset", "offset", value.isMember("offset"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TimeZoneStruct.validAt", "validAt", value.isMember("validAt"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.a", "a", value.isMember("a"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.b", "b", value.isMember("b"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.c", "c", value.isMember("c"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.d", "d", value.isMember("d"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.e", "e", value.isMember("e"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.f", "f", value.isMember("f"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.g", "g", value.isMember("g"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offset"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offset, value["offset"])); - valueCopy.removeMember("offset"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); + valueCopy.removeMember("a"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "validAt"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.validAt, value["validAt"])); - valueCopy.removeMember("validAt"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "b"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.b, value["b"])); + valueCopy.removeMember("b"); - if (value.isMember("name")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - } - valueCopy.removeMember("name"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "c"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); + valueCopy.removeMember("c"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "d"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.d, value["d"])); + valueCopy.removeMember("d"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "e"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.e, value["e"])); + valueCopy.removeMember("e"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "f"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.f, value["f"])); + valueCopy.removeMember("f"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "g"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.g, value["g"])); + valueCopy.removeMember("g"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request) { - ComplexArgumentParser::Finalize(request.offset); - ComplexArgumentParser::Finalize(request.validAt); - ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.a); + ComplexArgumentParser::Finalize(request.b); + ComplexArgumentParser::Finalize(request.c); + ComplexArgumentParser::Finalize(request.d); + ComplexArgumentParser::Finalize(request.e); + ComplexArgumentParser::Finalize(request.f); + ComplexArgumentParser::Finalize(request.g); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request, + chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2598,56 +2688,23 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.security", "security", value.isMember("security"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.ssid", "ssid", value.isMember("ssid"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.bssid", "bssid", value.isMember("bssid"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.channel", "channel", value.isMember("channel"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.wiFiBand", "wiFiBand", value.isMember("wiFiBand"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.rssi", "rssi", value.isMember("rssi"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DoubleNestedStructList.a", "a", value.isMember("a"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "security"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.security, value["security"])); - valueCopy.removeMember("security"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "ssid"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.ssid, value["ssid"])); - valueCopy.removeMember("ssid"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "bssid"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.bssid, value["bssid"])); - valueCopy.removeMember("bssid"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channel"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channel, value["channel"])); - valueCopy.removeMember("channel"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "wiFiBand"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.wiFiBand, value["wiFiBand"])); - valueCopy.removeMember("wiFiBand"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rssi"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rssi, value["rssi"])); - valueCopy.removeMember("rssi"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); + valueCopy.removeMember("a"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request) { - ComplexArgumentParser::Finalize(request.security); - ComplexArgumentParser::Finalize(request.ssid); - ComplexArgumentParser::Finalize(request.bssid); - ComplexArgumentParser::Finalize(request.channel); - ComplexArgumentParser::Finalize(request.wiFiBand); - ComplexArgumentParser::Finalize(request.rssi); + ComplexArgumentParser::Finalize(request.a); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request, + chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2656,24 +2713,24 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, Json::Value valueCopy(value); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("WiredFaultChangeType.current", "current", value.isMember("current"))); + ComplexArgumentParser::EnsureMemberExist("TestListStructOctet.member1", "member1", value.isMember("member1"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("WiredFaultChangeType.previous", "previous", value.isMember("previous"))); + ComplexArgumentParser::EnsureMemberExist("TestListStructOctet.member2", "member2", value.isMember("member2"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "current"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.current, value["current"])); - valueCopy.removeMember("current"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "member1"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.member1, value["member1"])); + valueCopy.removeMember("member1"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "previous"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.previous, value["previous"])); - valueCopy.removeMember("previous"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "member2"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.member2, value["member2"])); + valueCopy.removeMember("member2"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request) { - ComplexArgumentParser::Finalize(request.current); - ComplexArgumentParser::Finalize(request.previous); + ComplexArgumentParser::Finalize(request.member1); + ComplexArgumentParser::Finalize(request.member2); } diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h index 8c0036f996e70c..990126cbc87187 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h @@ -22,242 +22,299 @@ #include #include +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs::LabelStruct::Type & request, Json::Value & value); + +static void Finalize(chip::app::Clusters::detail::Structs::LabelStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Binding::Structs::TargetStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::Binding::Structs::TargetStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AccessControl::Structs::Target::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::AccessControl::Structs::Target::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AccessControl::Structs::AccessControlEntryStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::AccessControl::Structs::AccessControlEntryStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AccessControl::Structs::AccessControlExtensionStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::AccessControl::Structs::AccessControlExtensionStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Actions::Structs::ActionStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::Actions::Structs::ActionStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request, - Json::Value & value); -static void Finalize(chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request, - Json::Value & value); +static void Finalize(chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request); -static void Finalize(chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request); +static void Finalize(chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request); + static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request, + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request); +static void Finalize(chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::PowerSource::Structs::BatChargeFaultChangeType::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::PowerSource::Structs::BatChargeFaultChangeType::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::PowerSource::Structs::BatFaultChangeType::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::PowerSource::Structs::BatFaultChangeType::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request); + static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request, + chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request, +static void Finalize(chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request, +static void Finalize(chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request); + +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request, +static void Finalize(chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request); + +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request, +static void Finalize(chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request, +static void Finalize(chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request, +static void Finalize(chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request, +static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request); + +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request, +static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request, +static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request, +static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request); +static void Finalize(chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request, - Json::Value & value); -static void Finalize(chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs::LabelStruct::Type & request, Json::Value & value); - -static void Finalize(chip::app::Clusters::detail::Structs::LabelStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request); +static void Finalize(chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request, - Json::Value & value); -static void Finalize(chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request, - Json::Value & value); +static void Finalize(chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request); -static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request, - Json::Value & value); +static void Finalize(chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request, - Json::Value & value); +static void Finalize(chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request); -static void Finalize(chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request); -static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request, - Json::Value & value); +static void Finalize(chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request); -static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request, - Json::Value & value); +static void Finalize(chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request); -static void Finalize(chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request); static CHIP_ERROR Setup(const char * label, chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Type & request); -static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request, + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request, +static void Finalize(chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request, +static void Finalize(chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request, +static void Finalize(chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request, +static void Finalize(chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request); +static void Finalize(chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AccessControl::Structs::Target::Type & request, + +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::AccessControl::Structs::Target::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request, +static void Finalize(chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Binding::Structs::TargetStruct::Type & request, +static void Finalize(chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Binding::Structs::TargetStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::Type & request, +static void Finalize(chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request, +static void Finalize(chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request, +static void Finalize(chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request); -static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request, +static void Finalize(chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request, +static void Finalize(chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request, +static void Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request); -static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request, +static void Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request, +static void Finalize(chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request); +static void Finalize(chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index 578944136f8fdd..e85d4920b846c2 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -21,48 +21,73 @@ using namespace chip::app::Clusters; -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::AccessControl::Structs::AccessControlEntryStruct::DecodableType & value) +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::detail::Structs::ApplicationStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Privilege", indent + 1, value.privilege); + CHIP_ERROR err = LogValue("CatalogVendorID", indent + 1, value.catalogVendorID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Privilege'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CatalogVendorID'"); return err; } } { - CHIP_ERROR err = LogValue("AuthMode", indent + 1, value.authMode); + CHIP_ERROR err = LogValue("ApplicationID", indent + 1, value.applicationID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AuthMode'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ApplicationID'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::detail::Structs::LabelStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Subjects", indent + 1, value.subjects); + CHIP_ERROR err = LogValue("Label", indent + 1, value.label); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Subjects'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Label'"); return err; } } { - CHIP_ERROR err = LogValue("Targets", indent + 1, value.targets); + CHIP_ERROR err = LogValue("Value", indent + 1, value.value); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Targets'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Scenes::Structs::AttributeValuePair::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("AttributeID", indent + 1, value.attributeID); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AttributeID'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("AttributeValue", indent + 1, value.attributeValue); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AttributeValue'"); return err; } } @@ -70,24 +95,24 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::AccessControl::Structs::AccessControlExtensionStruct::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Data", indent + 1, value.data); + CHIP_ERROR err = LogValue("ClusterID", indent + 1, value.clusterID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Data'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ClusterID'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("AttributeValueList", indent + 1, value.attributeValueList); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AttributeValueList'"); return err; } } @@ -95,55 +120,73 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Actions::Structs::ActionStruct::DecodableType & value) + const chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ActionID", indent + 1, value.actionID); + CHIP_ERROR err = LogValue("DeviceType", indent + 1, value.deviceType); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ActionID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'DeviceType'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("Revision", indent + 1, value.revision); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Revision'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Binding::Structs::TargetStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("Node", indent + 1, value.node); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Node'"); return err; } } { - CHIP_ERROR err = LogValue("Type", indent + 1, value.type); + CHIP_ERROR err = LogValue("Group", indent + 1, value.group); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Group'"); return err; } } { - CHIP_ERROR err = LogValue("EndpointListID", indent + 1, value.endpointListID); + CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EndpointListID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); return err; } } { - CHIP_ERROR err = LogValue("SupportedCommands", indent + 1, value.supportedCommands); + CHIP_ERROR err = LogValue("Cluster", indent + 1, value.cluster); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SupportedCommands'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Cluster'"); return err; } } { - CHIP_ERROR err = LogValue("State", indent + 1, value.state); + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'State'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -151,24 +194,32 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::AccessControl::Structs::Target::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("Cluster", indent + 1, value.cluster); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Cluster'"); return err; } } { - CHIP_ERROR err = LogValue("Value", indent + 1, value.value); + CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("DeviceType", indent + 1, value.deviceType); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'DeviceType'"); return err; } } @@ -176,48 +227,49 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::DecodableType & value) + const chip::app::Clusters::AccessControl::Structs::AccessControlEntryStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Application", indent + 1, value.application); + CHIP_ERROR err = LogValue("Privilege", indent + 1, value.privilege); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Application'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Privilege'"); return err; } } { - CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); + CHIP_ERROR err = LogValue("AuthMode", indent + 1, value.authMode); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AuthMode'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::detail::Structs::ApplicationStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("CatalogVendorID", indent + 1, value.catalogVendorID); + CHIP_ERROR err = LogValue("Subjects", indent + 1, value.subjects); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CatalogVendorID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Subjects'"); return err; } } { - CHIP_ERROR err = LogValue("ApplicationID", indent + 1, value.applicationID); + CHIP_ERROR err = LogValue("Targets", indent + 1, value.targets); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ApplicationID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Targets'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -225,23 +277,25 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Scenes::Structs::AttributeValuePair::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::AccessControl::Structs::AccessControlExtensionStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("AttributeID", indent + 1, value.attributeID); + CHIP_ERROR err = LogValue("Data", indent + 1, value.data); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AttributeID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Data'"); return err; } } { - CHIP_ERROR err = LogValue("AttributeValue", indent + 1, value.attributeValue); + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AttributeValue'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -249,73 +303,56 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Actions::Structs::ActionStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("FailSafeExpiryLengthSeconds", indent + 1, value.failSafeExpiryLengthSeconds); + CHIP_ERROR err = LogValue("ActionID", indent + 1, value.actionID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FailSafeExpiryLengthSeconds'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ActionID'"); return err; } } { - CHIP_ERROR err = LogValue("MaxCumulativeFailsafeSeconds", indent + 1, value.maxCumulativeFailsafeSeconds); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MaxCumulativeFailsafeSeconds'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::PowerSource::Structs::BatChargeFaultChangeType::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Current", indent + 1, value.current); + CHIP_ERROR err = LogValue("Type", indent + 1, value.type); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Current'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); return err; } } { - CHIP_ERROR err = LogValue("Previous", indent + 1, value.previous); + CHIP_ERROR err = LogValue("EndpointListID", indent + 1, value.endpointListID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Previous'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EndpointListID'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::PowerSource::Structs::BatFaultChangeType::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Current", indent + 1, value.current); + CHIP_ERROR err = LogValue("SupportedCommands", indent + 1, value.supportedCommands); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Current'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SupportedCommands'"); return err; } } { - CHIP_ERROR err = LogValue("Previous", indent + 1, value.previous); + CHIP_ERROR err = LogValue("State", indent + 1, value.state); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Previous'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'State'"); return err; } } @@ -323,56 +360,66 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Actions::Structs::EndpointListStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ProviderName", indent + 1, value.providerName); + CHIP_ERROR err = LogValue("EndpointListID", indent + 1, value.endpointListID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ProviderName'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EndpointListID'"); return err; } } { - CHIP_ERROR err = LogValue("Background", indent + 1, value.background); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Background'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } { - CHIP_ERROR err = LogValue("Logo", indent + 1, value.logo); + CHIP_ERROR err = LogValue("Type", indent + 1, value.type); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Logo'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); return err; } } { - CHIP_ERROR err = LogValue("ProgressBar", indent + 1, value.progressBar); + CHIP_ERROR err = LogValue("Endpoints", indent + 1, value.endpoints); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ProgressBar'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoints'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Splash", indent + 1, value.splash); + CHIP_ERROR err = LogValue("CaseSessionsPerFabric", indent + 1, value.caseSessionsPerFabric); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Splash'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CaseSessionsPerFabric'"); return err; } } { - CHIP_ERROR err = LogValue("WaterMark", indent + 1, value.waterMark); + CHIP_ERROR err = LogValue("SubscriptionsPerFabric", indent + 1, value.subscriptionsPerFabric); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'WaterMark'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SubscriptionsPerFabric'"); return err; } } @@ -380,24 +427,33 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::DecodableType & value) + const chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("CaseSessionsPerFabric", indent + 1, value.caseSessionsPerFabric); + CHIP_ERROR err = LogValue("ProviderNodeID", indent + 1, value.providerNodeID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CaseSessionsPerFabric'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ProviderNodeID'"); return err; } } { - CHIP_ERROR err = LogValue("SubscriptionsPerFabric", indent + 1, value.subscriptionsPerFabric); + CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SubscriptionsPerFabric'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -405,47 +461,75 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Channel::Structs::ChannelInfoStruct::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::PowerSource::Structs::BatChargeFaultChangeType::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("MajorNumber", indent + 1, value.majorNumber); + CHIP_ERROR err = LogValue("Current", indent + 1, value.current); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MajorNumber'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Current'"); return err; } } { - CHIP_ERROR err = LogValue("MinorNumber", indent + 1, value.minorNumber); + CHIP_ERROR err = LogValue("Previous", indent + 1, value.previous); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Previous'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::PowerSource::Structs::BatFaultChangeType::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("Current", indent + 1, value.current); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MinorNumber'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Current'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("Previous", indent + 1, value.previous); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Previous'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("CallSign", indent + 1, value.callSign); + CHIP_ERROR err = LogValue("Current", indent + 1, value.current); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CallSign'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Current'"); return err; } } { - CHIP_ERROR err = LogValue("AffiliateCallSign", indent + 1, value.affiliateCallSign); + CHIP_ERROR err = LogValue("Previous", indent + 1, value.previous); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AffiliateCallSign'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Previous'"); return err; } } @@ -453,16 +537,25 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::DecodableType & value) + const chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ParameterList", indent + 1, value.parameterList); + CHIP_ERROR err = LogValue("FailSafeExpiryLengthSeconds", indent + 1, value.failSafeExpiryLengthSeconds); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ParameterList'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FailSafeExpiryLengthSeconds'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("MaxCumulativeFailsafeSeconds", indent + 1, value.maxCumulativeFailsafeSeconds); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MaxCumulativeFailsafeSeconds'"); return err; } } @@ -470,23 +563,24 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::DoorLock::Structs::CredentialStruct::DecodableType & value) + const chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("CredentialType", indent + 1, value.credentialType); + CHIP_ERROR err = LogValue("NetworkID", indent + 1, value.networkID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CredentialType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NetworkID'"); return err; } } { - CHIP_ERROR err = LogValue("CredentialIndex", indent + 1, value.credentialIndex); + CHIP_ERROR err = LogValue("Connected", indent + 1, value.connected); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CredentialIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Connected'"); return err; } } @@ -494,88 +588,73 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue( + const char * label, size_t indent, + const chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Offset", indent + 1, value.offset); + CHIP_ERROR err = LogValue("PanId", indent + 1, value.panId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Offset'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PanId'"); return err; } } { - CHIP_ERROR err = LogValue("ValidStarting", indent + 1, value.validStarting); + CHIP_ERROR err = LogValue("ExtendedPanId", indent + 1, value.extendedPanId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ValidStarting'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtendedPanId'"); return err; } } { - CHIP_ERROR err = LogValue("ValidUntil", indent + 1, value.validUntil); + CHIP_ERROR err = LogValue("NetworkName", indent + 1, value.networkName); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ValidUntil'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NetworkName'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("DeviceType", indent + 1, value.deviceType); + CHIP_ERROR err = LogValue("Channel", indent + 1, value.channel); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'DeviceType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Channel'"); return err; } } { - CHIP_ERROR err = LogValue("Revision", indent + 1, value.revision); + CHIP_ERROR err = LogValue("Version", indent + 1, value.version); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Revision'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Version'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Width", indent + 1, value.width); + CHIP_ERROR err = LogValue("ExtendedAddress", indent + 1, value.extendedAddress); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Width'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtendedAddress'"); return err; } } { - CHIP_ERROR err = LogValue("Height", indent + 1, value.height); + CHIP_ERROR err = LogValue("Rssi", indent + 1, value.rssi); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Height'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Rssi'"); return err; } } { - CHIP_ERROR err = LogValue("Metric", indent + 1, value.metric); + CHIP_ERROR err = LogValue("Lqi", indent + 1, value.lqi); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Metric'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Lqi'"); return err; } } @@ -583,79 +662,57 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); - { - CHIP_ERROR err = LogValue("A", indent + 1, value.a); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); - return err; - } - } - DataModelLogger::LogString(indent, "}"); - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Actions::Structs::EndpointListStruct::DecodableType & value) +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("EndpointListID", indent + 1, value.endpointListID); + CHIP_ERROR err = LogValue("Security", indent + 1, value.security); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EndpointListID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Security'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("Ssid", indent + 1, value.ssid); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Ssid'"); return err; } } { - CHIP_ERROR err = LogValue("Type", indent + 1, value.type); + CHIP_ERROR err = LogValue("Bssid", indent + 1, value.bssid); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Bssid'"); return err; } } { - CHIP_ERROR err = LogValue("Endpoints", indent + 1, value.endpoints); + CHIP_ERROR err = LogValue("Channel", indent + 1, value.channel); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoints'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Channel'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ClusterID", indent + 1, value.clusterID); + CHIP_ERROR err = LogValue("WiFiBand", indent + 1, value.wiFiBand); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ClusterID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'WiFiBand'"); return err; } } { - CHIP_ERROR err = LogValue("AttributeValueList", indent + 1, value.attributeValueList); + CHIP_ERROR err = LogValue("Rssi", indent + 1, value.rssi); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AttributeValueList'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Rssi'"); return err; } } @@ -663,130 +720,123 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::DecodableType & value) + const chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("RootPublicKey", indent + 1, value.rootPublicKey); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RootPublicKey'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } { - CHIP_ERROR err = LogValue("VendorID", indent + 1, value.vendorID); + CHIP_ERROR err = LogValue("IsOperational", indent + 1, value.isOperational); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'VendorID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IsOperational'"); return err; } } { - CHIP_ERROR err = LogValue("FabricID", indent + 1, value.fabricID); + CHIP_ERROR err = LogValue("OffPremiseServicesReachableIPv4", indent + 1, value.offPremiseServicesReachableIPv4); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OffPremiseServicesReachableIPv4'"); return err; } } { - CHIP_ERROR err = LogValue("NodeID", indent + 1, value.nodeID); + CHIP_ERROR err = LogValue("OffPremiseServicesReachableIPv6", indent + 1, value.offPremiseServicesReachableIPv6); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NodeID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OffPremiseServicesReachableIPv6'"); return err; } } { - CHIP_ERROR err = LogValue("Label", indent + 1, value.label); + CHIP_ERROR err = LogValue("HardwareAddress", indent + 1, value.hardwareAddress); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Label'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'HardwareAddress'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("IPv4Addresses", indent + 1, value.IPv4Addresses); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IPv4Addresses'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("GroupId", indent + 1, value.groupId); + CHIP_ERROR err = LogValue("IPv6Addresses", indent + 1, value.IPv6Addresses); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IPv6Addresses'"); return err; } } { - CHIP_ERROR err = LogValue("Endpoints", indent + 1, value.endpoints); + CHIP_ERROR err = LogValue("Type", indent + 1, value.type); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoints'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("GroupName", indent + 1, value.groupName); + CHIP_ERROR err = LogValue("Id", indent + 1, value.id); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupName'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Id'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("GroupId", indent + 1, value.groupId); + CHIP_ERROR err = LogValue("StackFreeCurrent", indent + 1, value.stackFreeCurrent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StackFreeCurrent'"); return err; } } { - CHIP_ERROR err = LogValue("GroupKeySetID", indent + 1, value.groupKeySetID); + CHIP_ERROR err = LogValue("StackFreeMinimum", indent + 1, value.stackFreeMinimum); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupKeySetID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StackFreeMinimum'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("StackSize", indent + 1, value.stackSize); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StackSize'"); return err; } } @@ -794,136 +844,121 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & value) + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("GroupKeySetID", indent + 1, value.groupKeySetID); + CHIP_ERROR err = LogValue("ExtAddress", indent + 1, value.extAddress); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupKeySetID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtAddress'"); return err; } } { - CHIP_ERROR err = LogValue("GroupKeySecurityPolicy", indent + 1, value.groupKeySecurityPolicy); + CHIP_ERROR err = LogValue("Age", indent + 1, value.age); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupKeySecurityPolicy'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Age'"); return err; } } { - CHIP_ERROR err = LogValue("EpochKey0", indent + 1, value.epochKey0); + CHIP_ERROR err = LogValue("Rloc16", indent + 1, value.rloc16); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochKey0'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Rloc16'"); return err; } } { - CHIP_ERROR err = LogValue("EpochStartTime0", indent + 1, value.epochStartTime0); + CHIP_ERROR err = LogValue("LinkFrameCounter", indent + 1, value.linkFrameCounter); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochStartTime0'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LinkFrameCounter'"); return err; } } { - CHIP_ERROR err = LogValue("EpochKey1", indent + 1, value.epochKey1); + CHIP_ERROR err = LogValue("MleFrameCounter", indent + 1, value.mleFrameCounter); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochKey1'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MleFrameCounter'"); return err; } } { - CHIP_ERROR err = LogValue("EpochStartTime1", indent + 1, value.epochStartTime1); + CHIP_ERROR err = LogValue("Lqi", indent + 1, value.lqi); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochStartTime1'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Lqi'"); return err; } } { - CHIP_ERROR err = LogValue("EpochKey2", indent + 1, value.epochKey2); + CHIP_ERROR err = LogValue("AverageRssi", indent + 1, value.averageRssi); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochKey2'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AverageRssi'"); return err; } } { - CHIP_ERROR err = LogValue("EpochStartTime2", indent + 1, value.epochStartTime2); + CHIP_ERROR err = LogValue("LastRssi", indent + 1, value.lastRssi); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochStartTime2'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LastRssi'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::MediaInput::Structs::InputInfoStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Index", indent + 1, value.index); + CHIP_ERROR err = LogValue("FrameErrorRate", indent + 1, value.frameErrorRate); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Index'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FrameErrorRate'"); return err; } } { - CHIP_ERROR err = LogValue("InputType", indent + 1, value.inputType); + CHIP_ERROR err = LogValue("MessageErrorRate", indent + 1, value.messageErrorRate); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'InputType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MessageErrorRate'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("RxOnWhenIdle", indent + 1, value.rxOnWhenIdle); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RxOnWhenIdle'"); return err; } } { - CHIP_ERROR err = LogValue("Description", indent + 1, value.description); + CHIP_ERROR err = LogValue("FullThreadDevice", indent + 1, value.fullThreadDevice); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Description'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FullThreadDevice'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::detail::Structs::LabelStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Label", indent + 1, value.label); + CHIP_ERROR err = LogValue("FullNetworkData", indent + 1, value.fullNetworkData); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Label'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FullNetworkData'"); return err; } } { - CHIP_ERROR err = LogValue("Value", indent + 1, value.value); + CHIP_ERROR err = LogValue("IsChild", indent + 1, value.isChild); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IsChild'"); return err; } } @@ -931,136 +966,105 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Channel::Structs::LineupInfoStruct::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue( + const char * label, size_t indent, + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("OperatorName", indent + 1, value.operatorName); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OperatorName'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("LineupName", indent + 1, value.lineupName); + CHIP_ERROR err = LogValue("ActiveTimestampPresent", indent + 1, value.activeTimestampPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LineupName'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ActiveTimestampPresent'"); return err; } } { - CHIP_ERROR err = LogValue("PostalCode", indent + 1, value.postalCode); + CHIP_ERROR err = LogValue("PendingTimestampPresent", indent + 1, value.pendingTimestampPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PostalCode'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PendingTimestampPresent'"); return err; } } { - CHIP_ERROR err = LogValue("LineupInfoType", indent + 1, value.lineupInfoType); + CHIP_ERROR err = LogValue("MasterKeyPresent", indent + 1, value.masterKeyPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LineupInfoType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MasterKeyPresent'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Label", indent + 1, value.label); + CHIP_ERROR err = LogValue("NetworkNamePresent", indent + 1, value.networkNamePresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Label'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NetworkNamePresent'"); return err; } } { - CHIP_ERROR err = LogValue("Mode", indent + 1, value.mode); + CHIP_ERROR err = LogValue("ExtendedPanIdPresent", indent + 1, value.extendedPanIdPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Mode'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtendedPanIdPresent'"); return err; } } { - CHIP_ERROR err = LogValue("SemanticTags", indent + 1, value.semanticTags); + CHIP_ERROR err = LogValue("MeshLocalPrefixPresent", indent + 1, value.meshLocalPrefixPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SemanticTags'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MeshLocalPrefixPresent'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ClientNodeId", indent + 1, value.clientNodeId); + CHIP_ERROR err = LogValue("DelayPresent", indent + 1, value.delayPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ClientNodeId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'DelayPresent'"); return err; } } { - CHIP_ERROR err = LogValue("ICid", indent + 1, value.ICid); + CHIP_ERROR err = LogValue("PanIdPresent", indent + 1, value.panIdPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ICid'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PanIdPresent'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("ChannelPresent", indent + 1, value.channelPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ChannelPresent'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Noc", indent + 1, value.noc); + CHIP_ERROR err = LogValue("PskcPresent", indent + 1, value.pskcPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Noc'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PskcPresent'"); return err; } } { - CHIP_ERROR err = LogValue("Icac", indent + 1, value.icac); + CHIP_ERROR err = LogValue("SecurityPolicyPresent", indent + 1, value.securityPolicyPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Icac'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SecurityPolicyPresent'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("ChannelMaskPresent", indent + 1, value.channelMaskPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ChannelMaskPresent'"); return err; } } @@ -1068,9 +1072,10 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::DecodableType & value) + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { @@ -1081,14 +1086,6 @@ DataModelLogger::LogValue(const char * label, size_t indent, return err; } } - { - CHIP_ERROR err = LogValue("Age", indent + 1, value.age); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Age'"); - return err; - } - } { CHIP_ERROR err = LogValue("Rloc16", indent + 1, value.rloc16); if (err != CHIP_NO_ERROR) @@ -1098,90 +1095,92 @@ DataModelLogger::LogValue(const char * label, size_t indent, } } { - CHIP_ERROR err = LogValue("LinkFrameCounter", indent + 1, value.linkFrameCounter); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LinkFrameCounter'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("MleFrameCounter", indent + 1, value.mleFrameCounter); + CHIP_ERROR err = LogValue("RouterId", indent + 1, value.routerId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MleFrameCounter'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RouterId'"); return err; } } { - CHIP_ERROR err = LogValue("Lqi", indent + 1, value.lqi); + CHIP_ERROR err = LogValue("NextHop", indent + 1, value.nextHop); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Lqi'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NextHop'"); return err; } } { - CHIP_ERROR err = LogValue("AverageRssi", indent + 1, value.averageRssi); + CHIP_ERROR err = LogValue("PathCost", indent + 1, value.pathCost); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AverageRssi'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PathCost'"); return err; } } { - CHIP_ERROR err = LogValue("LastRssi", indent + 1, value.lastRssi); + CHIP_ERROR err = LogValue("LQIIn", indent + 1, value.LQIIn); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LastRssi'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LQIIn'"); return err; } } { - CHIP_ERROR err = LogValue("FrameErrorRate", indent + 1, value.frameErrorRate); + CHIP_ERROR err = LogValue("LQIOut", indent + 1, value.LQIOut); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FrameErrorRate'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LQIOut'"); return err; } } { - CHIP_ERROR err = LogValue("MessageErrorRate", indent + 1, value.messageErrorRate); + CHIP_ERROR err = LogValue("Age", indent + 1, value.age); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MessageErrorRate'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Age'"); return err; } } { - CHIP_ERROR err = LogValue("RxOnWhenIdle", indent + 1, value.rxOnWhenIdle); + CHIP_ERROR err = LogValue("Allocated", indent + 1, value.allocated); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RxOnWhenIdle'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Allocated'"); return err; } } { - CHIP_ERROR err = LogValue("FullThreadDevice", indent + 1, value.fullThreadDevice); + CHIP_ERROR err = LogValue("LinkEstablished", indent + 1, value.linkEstablished); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FullThreadDevice'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LinkEstablished'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("FullNetworkData", indent + 1, value.fullNetworkData); + CHIP_ERROR err = LogValue("RotationTime", indent + 1, value.rotationTime); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FullNetworkData'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RotationTime'"); return err; } } { - CHIP_ERROR err = LogValue("IsChild", indent + 1, value.isChild); + CHIP_ERROR err = LogValue("Flags", indent + 1, value.flags); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IsChild'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Flags'"); return err; } } @@ -1189,31 +1188,33 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::NestedStruct::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("A", indent + 1, value.a); + CHIP_ERROR err = LogValue("Offset", indent + 1, value.offset); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Offset'"); return err; } } { - CHIP_ERROR err = LogValue("B", indent + 1, value.b); + CHIP_ERROR err = LogValue("ValidStarting", indent + 1, value.validStarting); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'B'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ValidStarting'"); return err; } } { - CHIP_ERROR err = LogValue("C", indent + 1, value.c); + CHIP_ERROR err = LogValue("ValidUntil", indent + 1, value.validUntil); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'C'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ValidUntil'"); return err; } } @@ -1221,63 +1222,90 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::NestedStructList::DecodableType & value) + const chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("A", indent + 1, value.a); + CHIP_ERROR err = LogValue("Offset", indent + 1, value.offset); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Offset'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("ValidAt", indent + 1, value.validAt); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ValidAt'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("B", indent + 1, value.b); + CHIP_ERROR err = LogValue("RootPublicKey", indent + 1, value.rootPublicKey); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'B'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RootPublicKey'"); return err; } } { - CHIP_ERROR err = LogValue("C", indent + 1, value.c); + CHIP_ERROR err = LogValue("VendorID", indent + 1, value.vendorID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'C'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'VendorID'"); return err; } } { - CHIP_ERROR err = LogValue("D", indent + 1, value.d); + CHIP_ERROR err = LogValue("FabricID", indent + 1, value.fabricID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'D'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricID'"); return err; } } { - CHIP_ERROR err = LogValue("E", indent + 1, value.e); + CHIP_ERROR err = LogValue("NodeID", indent + 1, value.nodeID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'E'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NodeID'"); return err; } } { - CHIP_ERROR err = LogValue("F", indent + 1, value.f); + CHIP_ERROR err = LogValue("Label", indent + 1, value.label); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'F'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Label'"); return err; } } { - CHIP_ERROR err = LogValue("G", indent + 1, value.g); + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'G'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -1285,23 +1313,32 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::DecodableType & value) + const chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("NetworkID", indent + 1, value.networkID); + CHIP_ERROR err = LogValue("Noc", indent + 1, value.noc); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NetworkID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Noc'"); return err; } } { - CHIP_ERROR err = LogValue("Connected", indent + 1, value.connected); + CHIP_ERROR err = LogValue("Icac", indent + 1, value.icac); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Connected'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Icac'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -1309,72 +1346,75 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::DecodableType & value) + const chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("IsOperational", indent + 1, value.isOperational); + CHIP_ERROR err = LogValue("GroupId", indent + 1, value.groupId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IsOperational'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupId'"); return err; } } { - CHIP_ERROR err = LogValue("OffPremiseServicesReachableIPv4", indent + 1, value.offPremiseServicesReachableIPv4); + CHIP_ERROR err = LogValue("Endpoints", indent + 1, value.endpoints); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OffPremiseServicesReachableIPv4'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoints'"); return err; } } { - CHIP_ERROR err = LogValue("OffPremiseServicesReachableIPv6", indent + 1, value.offPremiseServicesReachableIPv6); + CHIP_ERROR err = LogValue("GroupName", indent + 1, value.groupName); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OffPremiseServicesReachableIPv6'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupName'"); return err; } } { - CHIP_ERROR err = LogValue("HardwareAddress", indent + 1, value.hardwareAddress); + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'HardwareAddress'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("IPv4Addresses", indent + 1, value.IPv4Addresses); + CHIP_ERROR err = LogValue("GroupId", indent + 1, value.groupId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IPv4Addresses'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupId'"); return err; } } { - CHIP_ERROR err = LogValue("IPv6Addresses", indent + 1, value.IPv6Addresses); + CHIP_ERROR err = LogValue("GroupKeySetID", indent + 1, value.groupKeySetID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IPv6Addresses'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupKeySetID'"); return err; } } { - CHIP_ERROR err = LogValue("Type", indent + 1, value.type); + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -1382,104 +1422,98 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::DecodableType & value) + const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("NullableInt", indent + 1, value.nullableInt); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableInt'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("OptionalInt", indent + 1, value.optionalInt); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalInt'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("NullableOptionalInt", indent + 1, value.nullableOptionalInt); + CHIP_ERROR err = LogValue("GroupKeySetID", indent + 1, value.groupKeySetID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalInt'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupKeySetID'"); return err; } } { - CHIP_ERROR err = LogValue("NullableString", indent + 1, value.nullableString); + CHIP_ERROR err = LogValue("GroupKeySecurityPolicy", indent + 1, value.groupKeySecurityPolicy); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableString'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupKeySecurityPolicy'"); return err; } } { - CHIP_ERROR err = LogValue("OptionalString", indent + 1, value.optionalString); + CHIP_ERROR err = LogValue("EpochKey0", indent + 1, value.epochKey0); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalString'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochKey0'"); return err; } } { - CHIP_ERROR err = LogValue("NullableOptionalString", indent + 1, value.nullableOptionalString); + CHIP_ERROR err = LogValue("EpochStartTime0", indent + 1, value.epochStartTime0); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalString'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochStartTime0'"); return err; } } { - CHIP_ERROR err = LogValue("NullableStruct", indent + 1, value.nullableStruct); + CHIP_ERROR err = LogValue("EpochKey1", indent + 1, value.epochKey1); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableStruct'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochKey1'"); return err; } } { - CHIP_ERROR err = LogValue("OptionalStruct", indent + 1, value.optionalStruct); + CHIP_ERROR err = LogValue("EpochStartTime1", indent + 1, value.epochStartTime1); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalStruct'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochStartTime1'"); return err; } } { - CHIP_ERROR err = LogValue("NullableOptionalStruct", indent + 1, value.nullableOptionalStruct); + CHIP_ERROR err = LogValue("EpochKey2", indent + 1, value.epochKey2); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalStruct'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochKey2'"); return err; } } { - CHIP_ERROR err = LogValue("NullableList", indent + 1, value.nullableList); + CHIP_ERROR err = LogValue("EpochStartTime2", indent + 1, value.epochStartTime2); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableList'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochStartTime2'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("OptionalList", indent + 1, value.optionalList); + CHIP_ERROR err = LogValue("MfgCode", indent + 1, value.mfgCode); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalList'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MfgCode'"); return err; } } { - CHIP_ERROR err = LogValue("NullableOptionalList", indent + 1, value.nullableOptionalList); + CHIP_ERROR err = LogValue("Value", indent + 1, value.value); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalList'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); return err; } } @@ -1487,104 +1521,140 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue( - const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ActiveTimestampPresent", indent + 1, value.activeTimestampPresent); + CHIP_ERROR err = LogValue("Label", indent + 1, value.label); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ActiveTimestampPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Label'"); return err; } } { - CHIP_ERROR err = LogValue("PendingTimestampPresent", indent + 1, value.pendingTimestampPresent); + CHIP_ERROR err = LogValue("Mode", indent + 1, value.mode); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PendingTimestampPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Mode'"); return err; } } { - CHIP_ERROR err = LogValue("MasterKeyPresent", indent + 1, value.masterKeyPresent); + CHIP_ERROR err = LogValue("SemanticTags", indent + 1, value.semanticTags); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MasterKeyPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SemanticTags'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::DoorLock::Structs::CredentialStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("CredentialType", indent + 1, value.credentialType); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CredentialType'"); return err; } } { - CHIP_ERROR err = LogValue("NetworkNamePresent", indent + 1, value.networkNamePresent); + CHIP_ERROR err = LogValue("CredentialIndex", indent + 1, value.credentialIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NetworkNamePresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CredentialIndex'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ExtendedPanIdPresent", indent + 1, value.extendedPanIdPresent); + CHIP_ERROR err = LogValue("TransitionTime", indent + 1, value.transitionTime); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtendedPanIdPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'TransitionTime'"); return err; } } { - CHIP_ERROR err = LogValue("MeshLocalPrefixPresent", indent + 1, value.meshLocalPrefixPresent); + CHIP_ERROR err = LogValue("HeatSetpoint", indent + 1, value.heatSetpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MeshLocalPrefixPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'HeatSetpoint'"); return err; } } { - CHIP_ERROR err = LogValue("DelayPresent", indent + 1, value.delayPresent); + CHIP_ERROR err = LogValue("CoolSetpoint", indent + 1, value.coolSetpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'DelayPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CoolSetpoint'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Channel::Structs::ChannelInfoStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("PanIdPresent", indent + 1, value.panIdPresent); + CHIP_ERROR err = LogValue("MajorNumber", indent + 1, value.majorNumber); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PanIdPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MajorNumber'"); return err; } } { - CHIP_ERROR err = LogValue("ChannelPresent", indent + 1, value.channelPresent); + CHIP_ERROR err = LogValue("MinorNumber", indent + 1, value.minorNumber); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ChannelPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MinorNumber'"); return err; } } { - CHIP_ERROR err = LogValue("PskcPresent", indent + 1, value.pskcPresent); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PskcPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } { - CHIP_ERROR err = LogValue("SecurityPolicyPresent", indent + 1, value.securityPolicyPresent); + CHIP_ERROR err = LogValue("CallSign", indent + 1, value.callSign); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SecurityPolicyPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CallSign'"); return err; } } { - CHIP_ERROR err = LogValue("ChannelMaskPresent", indent + 1, value.channelMaskPresent); + CHIP_ERROR err = LogValue("AffiliateCallSign", indent + 1, value.affiliateCallSign); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ChannelMaskPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AffiliateCallSign'"); return err; } } @@ -1592,31 +1662,40 @@ CHIP_ERROR DataModelLogger::LogValue( return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::DecodableType & value) + const chip::app::Clusters::Channel::Structs::LineupInfoStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Index", indent + 1, value.index); + CHIP_ERROR err = LogValue("OperatorName", indent + 1, value.operatorName); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Index'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OperatorName'"); return err; } } { - CHIP_ERROR err = LogValue("OutputType", indent + 1, value.outputType); + CHIP_ERROR err = LogValue("LineupName", indent + 1, value.lineupName); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OutputType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LineupName'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("PostalCode", indent + 1, value.postalCode); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PostalCode'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("LineupInfoType", indent + 1, value.lineupInfoType); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LineupInfoType'"); return err; } } @@ -1624,31 +1703,24 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::DecodableType & value) + const chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Type", indent + 1, value.type); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("Value", indent + 1, value.value); + CHIP_ERROR err = LogValue("Identifier", indent + 1, value.identifier); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Identifier'"); return err; } } { - CHIP_ERROR err = LogValue("ExternalIDList", indent + 1, value.externalIDList); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExternalIDList'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } @@ -1656,6 +1728,7 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::DecodableType & value) @@ -1681,121 +1754,132 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::MediaInput::Structs::InputInfoStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ProviderNodeID", indent + 1, value.providerNodeID); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ProviderNodeID'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); + CHIP_ERROR err = LogValue("Index", indent + 1, value.index); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Index'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("InputType", indent + 1, value.inputType); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'InputType'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ExtAddress", indent + 1, value.extAddress); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtAddress'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } { - CHIP_ERROR err = LogValue("Rloc16", indent + 1, value.rloc16); + CHIP_ERROR err = LogValue("Description", indent + 1, value.description); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Rloc16'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Description'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("RouterId", indent + 1, value.routerId); + CHIP_ERROR err = LogValue("Width", indent + 1, value.width); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RouterId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Width'"); return err; } } { - CHIP_ERROR err = LogValue("NextHop", indent + 1, value.nextHop); + CHIP_ERROR err = LogValue("Height", indent + 1, value.height); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NextHop'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Height'"); return err; } } { - CHIP_ERROR err = LogValue("PathCost", indent + 1, value.pathCost); + CHIP_ERROR err = LogValue("Metric", indent + 1, value.metric); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PathCost'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Metric'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("LQIIn", indent + 1, value.LQIIn); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LQIIn'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } { - CHIP_ERROR err = LogValue("LQIOut", indent + 1, value.LQIOut); + CHIP_ERROR err = LogValue("Value", indent + 1, value.value); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LQIOut'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Age", indent + 1, value.age); + CHIP_ERROR err = LogValue("Type", indent + 1, value.type); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Age'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); return err; } } { - CHIP_ERROR err = LogValue("Allocated", indent + 1, value.allocated); + CHIP_ERROR err = LogValue("Value", indent + 1, value.value); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Allocated'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); return err; } } { - CHIP_ERROR err = LogValue("LinkEstablished", indent + 1, value.linkEstablished); + CHIP_ERROR err = LogValue("ExternalIDList", indent + 1, value.externalIDList); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LinkEstablished'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExternalIDList'"); return err; } } @@ -1803,24 +1887,17 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::DecodableType & value) + const chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("RotationTime", indent + 1, value.rotationTime); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RotationTime'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("Flags", indent + 1, value.flags); + CHIP_ERROR err = LogValue("ParameterList", indent + 1, value.parameterList); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Flags'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ParameterList'"); return err; } } @@ -1828,23 +1905,33 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("MfgCode", indent + 1, value.mfgCode); + CHIP_ERROR err = LogValue("ImageURL", indent + 1, value.imageURL); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MfgCode'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ImageURL'"); return err; } } { - CHIP_ERROR err = LogValue("Value", indent + 1, value.value); + CHIP_ERROR err = LogValue("Color", indent + 1, value.color); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Color'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("Size", indent + 1, value.size); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Size'"); return err; } } @@ -1852,71 +1939,90 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::SimpleStruct::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("A", indent + 1, value.a); + CHIP_ERROR err = LogValue("ProviderName", indent + 1, value.providerName); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ProviderName'"); return err; } } { - CHIP_ERROR err = LogValue("B", indent + 1, value.b); + CHIP_ERROR err = LogValue("Background", indent + 1, value.background); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'B'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Background'"); return err; } } { - CHIP_ERROR err = LogValue("C", indent + 1, value.c); + CHIP_ERROR err = LogValue("Logo", indent + 1, value.logo); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'C'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Logo'"); return err; } } { - CHIP_ERROR err = LogValue("D", indent + 1, value.d); + CHIP_ERROR err = LogValue("ProgressBar", indent + 1, value.progressBar); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'D'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ProgressBar'"); return err; } } { - CHIP_ERROR err = LogValue("E", indent + 1, value.e); + CHIP_ERROR err = LogValue("Splash", indent + 1, value.splash); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'E'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Splash'"); return err; } } { - CHIP_ERROR err = LogValue("F", indent + 1, value.f); + CHIP_ERROR err = LogValue("WaterMark", indent + 1, value.waterMark); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'F'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'WaterMark'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("Index", indent + 1, value.index); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Index'"); return err; } } { - CHIP_ERROR err = LogValue("G", indent + 1, value.g); + CHIP_ERROR err = LogValue("OutputType", indent + 1, value.outputType); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'G'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OutputType'"); return err; } } { - CHIP_ERROR err = LogValue("H", indent + 1, value.h); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'H'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } @@ -1924,32 +2030,25 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::DecodableType & value) + const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ImageURL", indent + 1, value.imageURL); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ImageURL'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("Color", indent + 1, value.color); + CHIP_ERROR err = LogValue("Application", indent + 1, value.application); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Color'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Application'"); return err; } } { - CHIP_ERROR err = LogValue("Size", indent + 1, value.size); + CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Size'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); return err; } } @@ -1957,31 +2056,33 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::AccessControl::Structs::Target::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Cluster", indent + 1, value.cluster); + CHIP_ERROR err = LogValue("ClientNodeId", indent + 1, value.clientNodeId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Cluster'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ClientNodeId'"); return err; } } { - CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); + CHIP_ERROR err = LogValue("ICid", indent + 1, value.ICid); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ICid'"); return err; } } { - CHIP_ERROR err = LogValue("DeviceType", indent + 1, value.deviceType); + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'DeviceType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -1989,71 +2090,72 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::DecodableType & value) + const chip::app::Clusters::UnitTesting::Structs::SimpleStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Identifier", indent + 1, value.identifier); + CHIP_ERROR err = LogValue("A", indent + 1, value.a); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Identifier'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("B", indent + 1, value.b); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'B'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Binding::Structs::TargetStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Node", indent + 1, value.node); + CHIP_ERROR err = LogValue("C", indent + 1, value.c); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Node'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'C'"); return err; } } { - CHIP_ERROR err = LogValue("Group", indent + 1, value.group); + CHIP_ERROR err = LogValue("D", indent + 1, value.d); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Group'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'D'"); return err; } } { - CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); + CHIP_ERROR err = LogValue("E", indent + 1, value.e); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'E'"); return err; } } { - CHIP_ERROR err = LogValue("Cluster", indent + 1, value.cluster); + CHIP_ERROR err = LogValue("F", indent + 1, value.f); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Cluster'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'F'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("G", indent + 1, value.g); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'G'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("H", indent + 1, value.h); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'H'"); return err; } } @@ -2061,6 +2163,7 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::DecodableType & value) { @@ -2134,129 +2237,105 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Member1", indent + 1, value.member1); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Member1'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("Member2", indent + 1, value.member2); + CHIP_ERROR err = LogValue("NullableInt", indent + 1, value.nullableInt); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Member2'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableInt'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("TransitionTime", indent + 1, value.transitionTime); + CHIP_ERROR err = LogValue("OptionalInt", indent + 1, value.optionalInt); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'TransitionTime'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalInt'"); return err; } } { - CHIP_ERROR err = LogValue("HeatSetpoint", indent + 1, value.heatSetpoint); + CHIP_ERROR err = LogValue("NullableOptionalInt", indent + 1, value.nullableOptionalInt); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'HeatSetpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalInt'"); return err; } } { - CHIP_ERROR err = LogValue("CoolSetpoint", indent + 1, value.coolSetpoint); + CHIP_ERROR err = LogValue("NullableString", indent + 1, value.nullableString); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CoolSetpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableString'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue( - const char * label, size_t indent, - const chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("PanId", indent + 1, value.panId); + CHIP_ERROR err = LogValue("OptionalString", indent + 1, value.optionalString); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PanId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalString'"); return err; } } { - CHIP_ERROR err = LogValue("ExtendedPanId", indent + 1, value.extendedPanId); + CHIP_ERROR err = LogValue("NullableOptionalString", indent + 1, value.nullableOptionalString); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtendedPanId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalString'"); return err; } } { - CHIP_ERROR err = LogValue("NetworkName", indent + 1, value.networkName); + CHIP_ERROR err = LogValue("NullableStruct", indent + 1, value.nullableStruct); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NetworkName'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableStruct'"); return err; } } { - CHIP_ERROR err = LogValue("Channel", indent + 1, value.channel); + CHIP_ERROR err = LogValue("OptionalStruct", indent + 1, value.optionalStruct); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Channel'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalStruct'"); return err; } } { - CHIP_ERROR err = LogValue("Version", indent + 1, value.version); + CHIP_ERROR err = LogValue("NullableOptionalStruct", indent + 1, value.nullableOptionalStruct); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Version'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalStruct'"); return err; } } { - CHIP_ERROR err = LogValue("ExtendedAddress", indent + 1, value.extendedAddress); + CHIP_ERROR err = LogValue("NullableList", indent + 1, value.nullableList); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtendedAddress'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableList'"); return err; } } { - CHIP_ERROR err = LogValue("Rssi", indent + 1, value.rssi); + CHIP_ERROR err = LogValue("OptionalList", indent + 1, value.optionalList); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Rssi'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalList'"); return err; } } { - CHIP_ERROR err = LogValue("Lqi", indent + 1, value.lqi); + CHIP_ERROR err = LogValue("NullableOptionalList", indent + 1, value.nullableOptionalList); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Lqi'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalList'"); return err; } } @@ -2264,48 +2343,32 @@ CHIP_ERROR DataModelLogger::LogValue( return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::UnitTesting::Structs::NestedStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Id", indent + 1, value.id); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Id'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("StackFreeCurrent", indent + 1, value.stackFreeCurrent); + CHIP_ERROR err = LogValue("A", indent + 1, value.a); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StackFreeCurrent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); return err; } } { - CHIP_ERROR err = LogValue("StackFreeMinimum", indent + 1, value.stackFreeMinimum); + CHIP_ERROR err = LogValue("B", indent + 1, value.b); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StackFreeMinimum'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'B'"); return err; } } { - CHIP_ERROR err = LogValue("StackSize", indent + 1, value.stackSize); + CHIP_ERROR err = LogValue("C", indent + 1, value.c); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StackSize'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'C'"); return err; } } @@ -2313,88 +2376,81 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::DecodableType & value) + const chip::app::Clusters::UnitTesting::Structs::NestedStructList::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Offset", indent + 1, value.offset); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Offset'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("ValidAt", indent + 1, value.validAt); + CHIP_ERROR err = LogValue("A", indent + 1, value.a); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ValidAt'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("B", indent + 1, value.b); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'B'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Security", indent + 1, value.security); + CHIP_ERROR err = LogValue("C", indent + 1, value.c); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Security'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'C'"); return err; } } { - CHIP_ERROR err = LogValue("Ssid", indent + 1, value.ssid); + CHIP_ERROR err = LogValue("D", indent + 1, value.d); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Ssid'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'D'"); return err; } } { - CHIP_ERROR err = LogValue("Bssid", indent + 1, value.bssid); + CHIP_ERROR err = LogValue("E", indent + 1, value.e); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Bssid'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'E'"); return err; } } { - CHIP_ERROR err = LogValue("Channel", indent + 1, value.channel); + CHIP_ERROR err = LogValue("F", indent + 1, value.f); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Channel'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'F'"); return err; } } { - CHIP_ERROR err = LogValue("WiFiBand", indent + 1, value.wiFiBand); + CHIP_ERROR err = LogValue("G", indent + 1, value.g); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'WiFiBand'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'G'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Rssi", indent + 1, value.rssi); + CHIP_ERROR err = LogValue("A", indent + 1, value.a); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Rssi'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); return err; } } @@ -2402,23 +2458,24 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::DecodableType & value) + const chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Current", indent + 1, value.current); + CHIP_ERROR err = LogValue("Member1", indent + 1, value.member1); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Current'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Member1'"); return err; } } { - CHIP_ERROR err = LogValue("Previous", indent + 1, value.previous); + CHIP_ERROR err = LogValue("Member2", indent + 1, value.member2); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Previous'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Member2'"); return err; } } diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h index cb1d136ebc92b7..368f75af3cfc10 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -20,126 +20,183 @@ #include #include +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::detail::Structs::ApplicationStruct::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::detail::Structs::LabelStruct::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::Scenes::Structs::AttributeValuePair::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::Binding::Structs::TargetStruct::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::AccessControl::Structs::Target::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::AccessControl::Structs::AccessControlEntryStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::AccessControl::Structs::AccessControlExtensionStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::Actions::Structs::ActionStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::detail::Structs::ApplicationStruct::DecodableType & value); + const chip::app::Clusters::Actions::Structs::EndpointListStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Scenes::Structs::AttributeValuePair::DecodableType & value); + const chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::DecodableType & value); + const chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::PowerSource::Structs::BatChargeFaultChangeType::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::PowerSource::Structs::BatFaultChangeType::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::DecodableType & value); + const chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Channel::Structs::ChannelInfoStruct::DecodableType & value); + const chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::DecodableType & value); + const chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::DecodableType & value); + +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::DecodableType & value); + +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::DoorLock::Structs::CredentialStruct::DecodableType & value); + const chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::DecodableType & value); + const chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::DecodableType & value); + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::DecodableType & value); + +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::DecodableType & value); + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::DecodableType & value); + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Actions::Structs::EndpointListStruct::DecodableType & value); + const chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType & value); + const chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::MediaInput::Structs::InputInfoStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::detail::Structs::LabelStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Channel::Structs::LineupInfoStruct::DecodableType & value); + const chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType & value); + const chip::app::Clusters::DoorLock::Structs::CredentialStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::DecodableType & value); + const chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::DecodableType & value); + const chip::app::Clusters::Channel::Structs::ChannelInfoStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::NestedStruct::DecodableType & value); + const chip::app::Clusters::Channel::Structs::LineupInfoStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::NestedStructList::DecodableType & value); + const chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::DecodableType & value); + const chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::DecodableType & value); + const chip::app::Clusters::MediaInput::Structs::InputInfoStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::DecodableType & value); -static CHIP_ERROR -LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::DecodableType & value); + const chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::DecodableType & value); + const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::DecodableType & value); + const chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::DecodableType & value); + const chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::SimpleStruct::DecodableType & value); + const chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::DecodableType & value); + const chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::AccessControl::Structs::Target::DecodableType & value); + const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::DecodableType & value); + const chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Binding::Structs::TargetStruct::DecodableType & value); + const chip::app::Clusters::UnitTesting::Structs::SimpleStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::DecodableType & value); + const chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::DecodableType & value); -static CHIP_ERROR -LogValue(const char * label, size_t indent, - const chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::DecodableType & value); + const chip::app::Clusters::UnitTesting::Structs::NestedStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::DecodableType & value); + const chip::app::Clusters::UnitTesting::Structs::NestedStructList::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::DecodableType & value); -static CHIP_ERROR -LogValue(const char * label, size_t indent, - const chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::DecodableType & value); + const chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::DecodableType & value); + const chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::AccessControl::Events::AccessControlEntryChanged::DecodableType & value); From fa3563a9ea15f9baa34b3cb4434e4131f5e33643 Mon Sep 17 00:00:00 2001 From: Kamil Kasperczyk <66371704+kkasperczyk-no@users.noreply.github.com> Date: Wed, 26 Apr 2023 20:42:15 +0200 Subject: [PATCH 033/200] [dnssd] Fixed OT DNS API usage for Thread platform (#26199) * [dnssd] Fixed OT DNS API usage for Thread platform Introduced several fixes to the Thread platform DNS implementation: * Added checking if memory allocation for DnsResult was successful and dispatching dedicated methods to inform upper layer in case of memory allocation failure * Added checking if DNS response for DNS resolve includes AAAA record. In case it doesn't the additional DNS query to obtain IPv6 address will be sent. * Added checking if DNS response for DNS browse includes SRV, TXT and AAAA records. In case it doesn't the additional DNS queries to obtain SRV + TXT, and AAAA records will be sent. * Addressed review comments * Fixed error handling and potential memory leaks * Moved handling resolve after browse from Thread platform to Discovery_ImplPlatform. * Addressed second code review * Fixed string copying by adding the exact size of data to copy instead of relying on the max buffer size. --- src/lib/dnssd/Discovery_ImplPlatform.cpp | 4 +- ...nericThreadStackManagerImpl_OpenThread.cpp | 199 ++++++++++++++---- ...GenericThreadStackManagerImpl_OpenThread.h | 11 +- 3 files changed, 168 insertions(+), 46 deletions(-) diff --git a/src/lib/dnssd/Discovery_ImplPlatform.cpp b/src/lib/dnssd/Discovery_ImplPlatform.cpp index bffd7e8bff9872..675e7ac238106b 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.cpp +++ b/src/lib/dnssd/Discovery_ImplPlatform.cpp @@ -172,7 +172,9 @@ static void HandleNodeBrowse(void * context, DnssdService * services, size_t ser { proxy->Retain(); // For some platforms browsed services are already resolved, so verify if resolve is really needed or call resolve callback - if (!services[i].mAddress.HasValue()) + + // Check if SRV, TXT and AAAA records were received in DNS responses + if (strlen(services[i].mHostName) == 0 || services[i].mTextEntrySize == 0 || !services[i].mAddress.HasValue()) { ChipDnssdResolve(&services[i], services[i].mInterface, HandleNodeResolve, context); } diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp index 603924e71bbc34..3142fd102ba670 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp @@ -2498,31 +2498,20 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_SetSrpDnsCallba template CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::FromOtDnsResponseToMdnsData( otDnsServiceInfo & serviceInfo, const char * serviceType, chip::Dnssd::DnssdService & mdnsService, - DnsServiceTxtEntries & serviceTxtEntries) + DnsServiceTxtEntries & serviceTxtEntries, otError error) { char protocol[chip::Dnssd::kDnssdProtocolTextMaxSize + 1]; - if (strchr(serviceInfo.mHostNameBuffer, '.') == nullptr) - return CHIP_ERROR_INVALID_ARGUMENT; - - // Extract from the .. the part. - size_t substringSize = strchr(serviceInfo.mHostNameBuffer, '.') - serviceInfo.mHostNameBuffer; - if (substringSize >= ArraySize(mdnsService.mHostName)) - { - return CHIP_ERROR_INVALID_ARGUMENT; - } - Platform::CopyString(mdnsService.mHostName, serviceInfo.mHostNameBuffer); - if (strchr(serviceType, '.') == nullptr) return CHIP_ERROR_INVALID_ARGUMENT; // Extract from the ... the part. - substringSize = strchr(serviceType, '.') - serviceType; + size_t substringSize = strchr(serviceType, '.') - serviceType; if (substringSize >= ArraySize(mdnsService.mType)) { return CHIP_ERROR_INVALID_ARGUMENT; } - Platform::CopyString(mdnsService.mType, serviceType); + Platform::CopyString(mdnsService.mType, substringSize + 1, serviceType); // Extract from the ... the part. const char * protocolSubstringStart = serviceType + substringSize + 1; @@ -2535,7 +2524,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::FromOtDnsRespons { return CHIP_ERROR_INVALID_ARGUMENT; } - Platform::CopyString(protocol, protocolSubstringStart); + Platform::CopyString(protocol, substringSize + 1, protocolSubstringStart); if (strncmp(protocol, "_udp", chip::Dnssd::kDnssdProtocolTextMaxSize) == 0) { @@ -2549,37 +2538,97 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::FromOtDnsRespons { mdnsService.mProtocol = chip::Dnssd::DnssdServiceProtocol::kDnssdProtocolUnknown; } - mdnsService.mPort = serviceInfo.mPort; - mdnsService.mInterface = Inet::InterfaceId::Null(); - mdnsService.mAddressType = Inet::IPAddressType::kIPv6; - mdnsService.mAddress = chip::Optional(ToIPAddress(serviceInfo.mHostAddress)); - otDnsTxtEntryIterator iterator; - otDnsInitTxtEntryIterator(&iterator, serviceInfo.mTxtData, serviceInfo.mTxtDataSize); + // Check if SRV record was included in DNS response. + if (error != OT_ERROR_NOT_FOUND) + { + if (strchr(serviceInfo.mHostNameBuffer, '.') == nullptr) + return CHIP_ERROR_INVALID_ARGUMENT; - otDnsTxtEntry txtEntry; - FixedBufferAllocator alloc(serviceTxtEntries.mBuffer); + // Extract from the .. the part. + substringSize = strchr(serviceInfo.mHostNameBuffer, '.') - serviceInfo.mHostNameBuffer; + if (substringSize >= ArraySize(mdnsService.mHostName)) + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + Platform::CopyString(mdnsService.mHostName, substringSize + 1, serviceInfo.mHostNameBuffer); - uint8_t entryIndex = 0; - while ((otDnsGetNextTxtEntry(&iterator, &txtEntry) == OT_ERROR_NONE) && entryIndex < kMaxDnsServiceTxtEntriesNumber) - { - if (txtEntry.mKey == nullptr || txtEntry.mValue == nullptr) - continue; + mdnsService.mPort = serviceInfo.mPort; + } - serviceTxtEntries.mTxtEntries[entryIndex].mKey = alloc.Clone(txtEntry.mKey); - serviceTxtEntries.mTxtEntries[entryIndex].mData = alloc.Clone(txtEntry.mValue, txtEntry.mValueLength); - serviceTxtEntries.mTxtEntries[entryIndex].mDataSize = txtEntry.mValueLength; - entryIndex++; + mdnsService.mInterface = Inet::InterfaceId::Null(); + + // Check if AAAA record was included in DNS response. + + if (!otIp6IsAddressUnspecified(&serviceInfo.mHostAddress)) + { + mdnsService.mAddressType = Inet::IPAddressType::kIPv6; + mdnsService.mAddress = MakeOptional(ToIPAddress(serviceInfo.mHostAddress)); } - ReturnErrorCodeIf(alloc.AnyAllocFailed(), CHIP_ERROR_BUFFER_TOO_SMALL); + // Check if TXT record was included in DNS response. + if (serviceInfo.mTxtDataSize != 0) + { + otDnsTxtEntryIterator iterator; + otDnsInitTxtEntryIterator(&iterator, serviceInfo.mTxtData, serviceInfo.mTxtDataSize); + + otDnsTxtEntry txtEntry; + FixedBufferAllocator alloc(serviceTxtEntries.mBuffer); - mdnsService.mTextEntries = serviceTxtEntries.mTxtEntries; - mdnsService.mTextEntrySize = entryIndex; + uint8_t entryIndex = 0; + while ((otDnsGetNextTxtEntry(&iterator, &txtEntry) == OT_ERROR_NONE) && entryIndex < kMaxDnsServiceTxtEntriesNumber) + { + if (txtEntry.mKey == nullptr || txtEntry.mValue == nullptr) + continue; + + serviceTxtEntries.mTxtEntries[entryIndex].mKey = alloc.Clone(txtEntry.mKey); + serviceTxtEntries.mTxtEntries[entryIndex].mData = alloc.Clone(txtEntry.mValue, txtEntry.mValueLength); + serviceTxtEntries.mTxtEntries[entryIndex].mDataSize = txtEntry.mValueLength; + entryIndex++; + } + + ReturnErrorCodeIf(alloc.AnyAllocFailed(), CHIP_ERROR_BUFFER_TOO_SMALL); + + mdnsService.mTextEntries = serviceTxtEntries.mTxtEntries; + mdnsService.mTextEntrySize = entryIndex; + } return CHIP_NO_ERROR; } +template +CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::ResolveAddress(intptr_t context, otDnsAddressCallback callback) +{ + DnsResult * dnsResult = reinterpret_cast(context); + + ThreadStackMgrImpl().LockThreadStack(); + + char fullHostName[chip::Dnssd::kHostNameMaxLength + 1 + SrpClient::kDefaultDomainNameSize + 1]; + snprintf(fullHostName, sizeof(fullHostName), "%s.%s", dnsResult->mMdnsService.mHostName, SrpClient::kDefaultDomainName); + + CHIP_ERROR error = MapOpenThreadError(otDnsClientResolveAddress(ThreadStackMgrImpl().OTInstance(), fullHostName, callback, + reinterpret_cast(dnsResult), NULL)); + + ThreadStackMgrImpl().UnlockThreadStack(); + + return error; +} + +template +void GenericThreadStackManagerImpl_OpenThread::DispatchAddressResolve(intptr_t context) +{ + CHIP_ERROR error = ResolveAddress(context, OnDnsAddressResolveResult); + + // In case of address resolve failure, fill the error code field and dispatch method to end resolve process. + if (error != CHIP_NO_ERROR) + { + DnsResult * dnsResult = reinterpret_cast(context); + dnsResult->error = error; + + DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolve, reinterpret_cast(dnsResult)); + } +} + template void GenericThreadStackManagerImpl_OpenThread::DispatchResolve(intptr_t context) { @@ -2596,6 +2645,13 @@ void GenericThreadStackManagerImpl_OpenThread::DispatchResolve(intptr Platform::Delete(dnsResult); } +template +void GenericThreadStackManagerImpl_OpenThread::DispatchResolveNoMemory(intptr_t context) +{ + Span ipAddrs; + ThreadStackMgrImpl().mDnsResolveCallback(reinterpret_cast(context), nullptr, ipAddrs, CHIP_ERROR_NO_MEMORY); +} + template void GenericThreadStackManagerImpl_OpenThread::DispatchBrowseEmpty(intptr_t context) { @@ -2612,6 +2668,12 @@ void GenericThreadStackManagerImpl_OpenThread::DispatchBrowse(intptr_ Platform::Delete(dnsResult); } +template +void GenericThreadStackManagerImpl_OpenThread::DispatchBrowseNoMemory(intptr_t context) +{ + ThreadStackMgrImpl().mDnsBrowseCallback(reinterpret_cast(context), nullptr, 0, true, CHIP_ERROR_NO_MEMORY); +} + template void GenericThreadStackManagerImpl_OpenThread::OnDnsBrowseResult(otError aError, const otDnsBrowseResponse * aResponse, void * aContext) @@ -2647,12 +2709,16 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsBrowseResult(otEr serviceInfo.mTxtData = txtBuffer; serviceInfo.mTxtDataSize = sizeof(txtBuffer); - error = MapOpenThreadError(otDnsBrowseResponseGetServiceInfo(aResponse, serviceName, &serviceInfo)); + otError err = otDnsBrowseResponseGetServiceInfo(aResponse, serviceName, &serviceInfo); + error = MapOpenThreadError(err); - VerifyOrExit(error == CHIP_NO_ERROR, ); + VerifyOrExit(err == OT_ERROR_NOT_FOUND || err == OT_ERROR_NONE, ); DnsResult * dnsResult = Platform::New(aContext, CHIP_NO_ERROR); - error = FromOtDnsResponseToMdnsData(serviceInfo, type, dnsResult->mMdnsService, dnsResult->mServiceTxtEntry); + + VerifyOrExit(dnsResult != nullptr, error = CHIP_ERROR_NO_MEMORY); + + error = FromOtDnsResponseToMdnsData(serviceInfo, type, dnsResult->mMdnsService, dnsResult->mServiceTxtEntry, err); if (CHIP_NO_ERROR == error) { // Invoke callback for every service one by one instead of for the whole @@ -2672,7 +2738,15 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsBrowseResult(otEr exit: // Invoke callback to notify about end-of-browse or failure DnsResult * dnsResult = Platform::New(aContext, error); - DeviceLayer::PlatformMgr().ScheduleWork(DispatchBrowseEmpty, reinterpret_cast(dnsResult)); + + if (dnsResult == nullptr) + { + DeviceLayer::PlatformMgr().ScheduleWork(DispatchBrowseNoMemory, reinterpret_cast(aContext)); + } + else + { + DeviceLayer::PlatformMgr().ScheduleWork(DispatchBrowseEmpty, reinterpret_cast(dnsResult)); + } } template @@ -2701,12 +2775,36 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_DnsBrowse(const return error; } +template +void GenericThreadStackManagerImpl_OpenThread::OnDnsAddressResolveResult(otError aError, + const otDnsAddressResponse * aResponse, + void * aContext) +{ + CHIP_ERROR error; + DnsResult * dnsResult = reinterpret_cast(aContext); + otIp6Address address; + + error = MapOpenThreadError(otDnsAddressResponseGetAddress(aResponse, 0, &address, nullptr)); + if (error == CHIP_NO_ERROR) + { + dnsResult->mMdnsService.mAddress = MakeOptional(ToIPAddress(address)); + } + + dnsResult->error = error; + + DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolve, reinterpret_cast(dnsResult)); +} + template void GenericThreadStackManagerImpl_OpenThread::OnDnsResolveResult(otError aError, const otDnsServiceResponse * aResponse, void * aContext) { CHIP_ERROR error; + otError otErr; DnsResult * dnsResult = Platform::New(aContext, MapOpenThreadError(aError)); + + VerifyOrExit(dnsResult != nullptr, error = CHIP_ERROR_NO_MEMORY); + // type buffer size is kDnssdTypeAndProtocolMaxSize + . + kMaxDomainNameSize + . + termination character char type[Dnssd::kDnssdTypeAndProtocolMaxSize + SrpClient::kMaxDomainNameSize + 3]; // hostname buffer size is kHostNameMaxLength + . + kMaxDomainNameSize + . + termination character @@ -2718,7 +2816,7 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsResolveResult(otE if (ThreadStackMgrImpl().mDnsResolveCallback == nullptr) { - ChipLogError(DeviceLayer, "Invalid dns browse callback"); + ChipLogError(DeviceLayer, "Invalid dns resolve callback"); return; } @@ -2734,16 +2832,31 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsResolveResult(otE serviceInfo.mTxtData = txtBuffer; serviceInfo.mTxtDataSize = sizeof(txtBuffer); - error = MapOpenThreadError(otDnsServiceResponseGetServiceInfo(aResponse, &serviceInfo)); + otErr = otDnsServiceResponseGetServiceInfo(aResponse, &serviceInfo); + error = MapOpenThreadError(otErr); VerifyOrExit(error == CHIP_NO_ERROR, ); - error = FromOtDnsResponseToMdnsData(serviceInfo, type, dnsResult->mMdnsService, dnsResult->mServiceTxtEntry); + error = FromOtDnsResponseToMdnsData(serviceInfo, type, dnsResult->mMdnsService, dnsResult->mServiceTxtEntry, otErr); exit: + if (dnsResult == nullptr) + { + DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolveNoMemory, reinterpret_cast(aContext)); + return; + } dnsResult->error = error; - DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolve, reinterpret_cast(dnsResult)); + + // If IPv6 address in unspecified (AAAA record not present), send additional DNS query to obtain IPv6 address. + if (otIp6IsAddressUnspecified(&serviceInfo.mHostAddress)) + { + DeviceLayer::PlatformMgr().ScheduleWork(DispatchAddressResolve, reinterpret_cast(dnsResult)); + } + else + { + DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolve, reinterpret_cast(dnsResult)); + } } template diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h index 413f00649ab593..2397b5e143828d 100755 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h @@ -136,8 +136,11 @@ class GenericThreadStackManagerImpl_OpenThread CHIP_ERROR _DnsBrowse(const char * aServiceName, DnsBrowseCallback aCallback, void * aContext); CHIP_ERROR _DnsResolve(const char * aServiceName, const char * aInstanceName, DnsResolveCallback aCallback, void * aContext); static void DispatchResolve(intptr_t context); + static void DispatchResolveNoMemory(intptr_t context); + static void DispatchAddressResolve(intptr_t context); static void DispatchBrowseEmpty(intptr_t context); static void DispatchBrowse(intptr_t context); + static void DispatchBrowseNoMemory(intptr_t context); #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT @@ -261,9 +264,13 @@ class GenericThreadStackManagerImpl_OpenThread static void OnDnsBrowseResult(otError aError, const otDnsBrowseResponse * aResponse, void * aContext); static void OnDnsResolveResult(otError aError, const otDnsServiceResponse * aResponse, void * aContext); + static void OnDnsAddressResolveResult(otError aError, const otDnsAddressResponse * aResponse, void * aContext); + + static CHIP_ERROR ResolveAddress(intptr_t context, otDnsAddressCallback callback); + static CHIP_ERROR FromOtDnsResponseToMdnsData(otDnsServiceInfo & serviceInfo, const char * serviceType, - chip::Dnssd::DnssdService & mdnsService, - DnsServiceTxtEntries & serviceTxtEntries); + chip::Dnssd::DnssdService & mdnsService, DnsServiceTxtEntries & serviceTxtEntries, + otError error); #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT From a4365db5f13a8b75295ca099a8395d50bdf7356d Mon Sep 17 00:00:00 2001 From: sharad-patil24 <100128124+sharad-patil24@users.noreply.github.com> Date: Thu, 27 Apr 2023 00:28:05 +0530 Subject: [PATCH 034/200] [Silabs] : SiWX917- Reduce the task stack and buffer size to reduce the Ram Consumption (#26242) * [Silabs] : SiWX917- Reduce the task stack and buffer size to reduce the RAM consumption * Restyled by clang-format * Review Comment addressed --------- Co-authored-by: Restyled.io --- examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h index 09a44344bafb45..cb1279590926c7 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h +++ b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h @@ -21,10 +21,10 @@ * Interface to RSI Sapis */ -#define WFX_RSI_WLAN_TASK_SZ (1024 + 512 + 256 + 1024 + 512) /* Unknown how big this should be */ -#define WFX_RSI_TASK_SZ (1024 + 1024 + 1024) /* Stack for the WFX/RSI task */ -#define WFX_RSI_BUF_SZ (1024 * 15) /* May need tweak */ -#define WFX_RSI_CONFIG_MAX_JOIN (5) /* Max join retries */ +#define WFX_RSI_WLAN_TASK_SZ (1024 + 512 + 256) /* Stack for the WLAN task */ +#define WFX_RSI_TASK_SZ (1024 + 1024) /* Stack for the WFX/RSI task */ +#define WFX_RSI_BUF_SZ (1024 * 10) /* May need tweak */ +#define WFX_RSI_CONFIG_MAX_JOIN (5) /* Max join retries */ /* * Various events fielded by the wfx_rsi task From b1009b42b46a44edeec1b6f3b60a4cf294f1dc9d Mon Sep 17 00:00:00 2001 From: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com> Date: Thu, 27 Apr 2023 00:29:32 +0530 Subject: [PATCH 035/200] bugfix for the zap file missing reset counts for DGWIFI (#26220) --- .../thermostat-common/thermostat.matter | 2 ++ .../thermostat/thermostat-common/thermostat.zap | 15 +++++++++++++-- examples/window-app/common/window-app.matter | 2 ++ examples/window-app/common/window-app.zap | 15 +++++++++++++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/examples/thermostat/thermostat-common/thermostat.matter b/examples/thermostat/thermostat-common/thermostat.matter index bba43c1a883bca..5711a58d2c24d8 100644 --- a/examples/thermostat/thermostat-common/thermostat.matter +++ b/examples/thermostat/thermostat-common/thermostat.matter @@ -1283,6 +1283,8 @@ server cluster WiFiNetworkDiagnostics = 54 { readonly attribute attrib_id attributeList[] = 65531; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; + + command ResetCounts(): DefaultSuccess = 0; } /** The Ethernet Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ diff --git a/examples/thermostat/thermostat-common/thermostat.zap b/examples/thermostat/thermostat-common/thermostat.zap index a7dbfd6603f3dd..81ca71a259c3be 100644 --- a/examples/thermostat/thermostat-common/thermostat.zap +++ b/examples/thermostat/thermostat-common/thermostat.zap @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 96, "creator": "zap", "keyValuePairs": [ { @@ -4118,6 +4118,16 @@ "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", "side": "client", "enabled": 0, + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], "attributes": [ { "name": "ClusterRevision", @@ -14772,5 +14782,6 @@ "endpointVersion": 1, "deviceIdentifier": 769 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/window-app/common/window-app.matter b/examples/window-app/common/window-app.matter index 0ed782bffccebb..0ac80a3916d20e 100644 --- a/examples/window-app/common/window-app.matter +++ b/examples/window-app/common/window-app.matter @@ -1414,6 +1414,8 @@ server cluster WiFiNetworkDiagnostics = 54 { readonly attribute attrib_id attributeList[] = 65531; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; + + command ResetCounts(): DefaultSuccess = 0; } /** The Ethernet Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ diff --git a/examples/window-app/common/window-app.zap b/examples/window-app/common/window-app.zap index e58cbfacb7c805..72c2db91f20e28 100644 --- a/examples/window-app/common/window-app.zap +++ b/examples/window-app/common/window-app.zap @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 96, "creator": "zap", "keyValuePairs": [ { @@ -4804,6 +4804,16 @@ "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", "side": "client", "enabled": 0, + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], "attributes": [ { "name": "ClusterRevision", @@ -9335,5 +9345,6 @@ "endpointVersion": 2, "deviceIdentifier": 514 } - ] + ], + "log": [] } \ No newline at end of file From 32eef3ecd7c402aed48e0f8f4a1cdc71f4650c3c Mon Sep 17 00:00:00 2001 From: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com> Date: Thu, 27 Apr 2023 01:04:50 +0530 Subject: [PATCH 036/200] [Silabs] [SiWx917] Addressing build failures on 917 SOC due to GCC update (#26266) * addressing build failures on 917 SOC due to GCC update * updating the matter support pointer --- examples/platform/silabs/SiWx917/BUILD.gn | 3 +++ src/platform/silabs/SiWx917/wifi/dhcp_client.h | 1 + src/platform/silabs/SiWx917/wifi/wfx_msgs.h | 2 ++ third_party/silabs/matter_support | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 7404436fbc90d8..ad3775845f3efa 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -186,6 +186,8 @@ config("siwx917-common-config") { if (siwx917_commissionable_data) { defines += [ "SIWX917_USE_COMISSIONABLE_DATA=1" ] } + + ldflags = [ "-Wl,--no-warn-rwx-segment" ] } config("silabs-wifi-config") { @@ -238,6 +240,7 @@ source_set("siwx917-common") { sources = [ "${silabs_common_plat_dir}/LEDWidget.cpp", "${silabs_common_plat_dir}/heap_4_silabs.c", + "${silabs_common_plat_dir}/syscalls_stubs.cpp", "${wifi_sdk_dir}/dhcp_client.cpp", "${wifi_sdk_dir}/ethernetif.cpp", "${wifi_sdk_dir}/lwip_netif.cpp", diff --git a/src/platform/silabs/SiWx917/wifi/dhcp_client.h b/src/platform/silabs/SiWx917/wifi/dhcp_client.h index 4ee9d2f5d0d68d..d5a6bd903104bd 100644 --- a/src/platform/silabs/SiWx917/wifi/dhcp_client.h +++ b/src/platform/silabs/SiWx917/wifi/dhcp_client.h @@ -18,6 +18,7 @@ #if LWIP_IPV4 && LWIP_DHCP #pragma once +#include #ifdef __cplusplus extern "C" { #endif diff --git a/src/platform/silabs/SiWx917/wifi/wfx_msgs.h b/src/platform/silabs/SiWx917/wifi/wfx_msgs.h index 44ff525a56a347..b87a7c070716a2 100644 --- a/src/platform/silabs/SiWx917/wifi/wfx_msgs.h +++ b/src/platform/silabs/SiWx917/wifi/wfx_msgs.h @@ -17,6 +17,8 @@ #ifndef _WFX_MSGS_H_ #define _WFX_MSGS_H_ + +#include /* * Taken from sl_wfx firmware - so I can re-use. * I need to do a better job than to use this stuff diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 53c27ef4ed0cff..4d93227fc8679d 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 53c27ef4ed0cff01ad913b9e25d57ccb58cd49f4 +Subproject commit 4d93227fc8679d66f0dd8d408b114425ca73bc0c From 6678adb30898a9e071610090fd9726297380c6c8 Mon Sep 17 00:00:00 2001 From: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com> Date: Thu, 27 Apr 2023 01:06:30 +0530 Subject: [PATCH 037/200] [Silabs] RS911x not going into power save upon power cycle (#26260) * Calling power save at only position * stopping the ble advertisement after sta was connected * removing the condition for wf200 and keeping it only for rs9116 * addressing review comments * Restyled by clang-format * Restyled by gn * address review comments * Restyled by clang-format --------- Co-authored-by: Restyled.io --- .../platform/silabs/efr32/rs911x/rsi_if.c | 34 ++++++++--------- .../platform/silabs/efr32/rs911x/wfx_rsi.h | 3 ++ .../silabs/efr32/rs911x/wfx_rsi_host.c | 20 ++++++++++ src/platform/silabs/BLEManagerImpl.h | 5 +-- .../silabs/ConnectivityManagerImpl_WIFI.cpp | 13 ++++++- .../silabs/efr32/rs911x/BLEManagerImpl.cpp | 38 +++++-------------- .../silabs/efr32/wifi/wfx_host_events.h | 4 ++ third_party/silabs/efr32_sdk.gni | 11 ++++-- 8 files changed, 75 insertions(+), 53 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index 324f635f3015f0..dae7b0cd4f762e 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -181,6 +181,7 @@ int32_t wfx_rsi_disconnect() return status; } +#if CHIP_DEVICE_CONFIG_ENABLE_SED /****************************************************************** * @fn wfx_rsi_power_save() * @brief @@ -190,16 +191,29 @@ int32_t wfx_rsi_disconnect() * @return * None *********************************************************************/ -void wfx_rsi_power_save() +int32_t wfx_rsi_power_save() { - int32_t status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); + int32_t status; +#ifdef RSI_BLE_ENABLE + status = rsi_bt_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); + if (status != RSI_SUCCESS) + { + SILABS_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status); + return status; + } +#endif /* RSI_BLE_ENABLE */ + + status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); if (status != RSI_SUCCESS) { SILABS_LOG("Powersave Config Failed, Error Code : 0x%lX", status); - return; + return status; } SILABS_LOG("Powersave Config Success"); + return status; } +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ + /****************************************************************** * @fn wfx_rsi_join_cb(uint16_t status, const uint8_t *buf, const uint16_t len) * @brief @@ -596,13 +610,6 @@ void wfx_rsi_task(void * arg) { wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr); hasNotifiedIPV4 = true; -#if CHIP_DEVICE_CONFIG_ENABLE_SED -#ifndef RSI_BLE_ENABLE - // enabling the power save mode for RS9116 if sleepy device is enabled - // if BLE is used on the rs9116 then powersave config is done after ble disconnect event - wfx_rsi_power_save(); -#endif /* RSI_BLE_ENABLE */ -#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ if (!hasNotifiedWifiConnectivity) { wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac); @@ -622,13 +629,6 @@ void wfx_rsi_task(void * arg) { wfx_ipv6_notify(GET_IPV6_SUCCESS); hasNotifiedIPV6 = true; -#if CHIP_DEVICE_CONFIG_ENABLE_SED -#ifndef RSI_BLE_ENABLE - // enabling the power save mode for RS9116 if sleepy device is enabled - // if BLE is used on the rs9116 then powersave config is done after ble disconnect event - wfx_rsi_power_save(); -#endif /* RSI_BLE_ENABLE */ -#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ if (!hasNotifiedWifiConnectivity) { wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac); diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h index 846644f2ba7f55..7292970a11c011 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h @@ -91,6 +91,9 @@ int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap); int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); int32_t wfx_rsi_reset_count(); int32_t wfx_rsi_disconnect(); +#if CHIP_DEVICE_CONFIG_ENABLE_SED +int32_t wfx_rsi_power_save(); +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ #define SILABS_LOG(...) efr32Log(__VA_ARGS__); #ifdef __cplusplus diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c index 9f89a678dfce0a..0691c21670518a 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c @@ -30,6 +30,7 @@ #include "event_groups.h" #include "task.h" +#include "rsi_error.h" #include "wfx_host_events.h" #include "wfx_rsi.h" @@ -195,6 +196,25 @@ sl_status_t wfx_connect_to_ap(void) return SL_STATUS_OK; } +#if CHIP_DEVICE_CONFIG_ENABLE_SED +/********************************************************************* + * @fn sl_status_t wfx_power_save() + * @brief + * Implements the power save in sleepy application + * @param[in] None + * @return SL_STATUS_OK if successful, + * SL_STATUS_FAIL otherwise + ***********************************************************************/ +sl_status_t wfx_power_save() +{ + if (wfx_rsi_power_save() != RSI_ERROR_NONE) + { + return SL_STATUS_FAIL; + } + return SL_STATUS_OK; +} +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ + /********************************************************************* * @fn void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif) * @brief diff --git a/src/platform/silabs/BLEManagerImpl.h b/src/platform/silabs/BLEManagerImpl.h index 330aad5a1c4be6..da6ce3bb4e3002 100644 --- a/src/platform/silabs/BLEManagerImpl.h +++ b/src/platform/silabs/BLEManagerImpl.h @@ -72,7 +72,6 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId); void HandleTXCharCCCDWrite(rsi_ble_event_write_t * evt); void HandleSoftTimerEvent(void); - CHIP_ERROR StartAdvertising(void); #else void HandleConnectEvent(volatile sl_bt_msg_t * evt); void HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt); @@ -81,8 +80,9 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId); void HandleTXCharCCCDWrite(volatile sl_bt_msg_t * evt); void HandleSoftTimerEvent(volatile sl_bt_msg_t * evt); - CHIP_ERROR StartAdvertising(void); #endif // RSI_BLE_ENABLE + CHIP_ERROR StartAdvertising(void); + CHIP_ERROR StopAdvertising(void); #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING #ifdef RSI_BLE_ENABLE @@ -187,7 +187,6 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla CHIP_ERROR MapBLEError(int bleErr); void DriveBLEState(void); CHIP_ERROR ConfigureAdvertisingData(void); - CHIP_ERROR StopAdvertising(void); #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING CHIP_ERROR EncodeAdditionalDataTlv(); #endif diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index edbff853f34e8f..6b10b294b5ad02 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -380,7 +380,18 @@ void ConnectivityManagerImpl::OnStationConnected() event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Established; (void) PlatformMgr().PostEvent(&event); - + // Setting the rs911x in the power save mode +#if (CHIP_DEVICE_CONFIG_ENABLE_SED && RS911X_WIFI) + // TODO: Remove stop advertising after BLEManagerImpl is fixed +#if RSI_BLE_ENABLE + chip::DeviceLayer::Internal::BLEManagerImpl().StopAdvertising(); +#endif /* RSI_BLE_ENABLE */ + sl_status_t err = wfx_power_save(); + if (err != SL_STATUS_OK) + { + ChipLogError(DeviceLayer, "Power save config for Wifi failed"); + } +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED && RS911X_WIFI */ UpdateInternetConnectivityState(); } diff --git a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp index f03e9d1356543c..4a910e0a29aae5 100644 --- a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp +++ b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp @@ -661,23 +661,21 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) return CHIP_NO_ERROR; // err; } -// TODO:: Implementation need to be done. CHIP_ERROR BLEManagerImpl::StopAdvertising(void) { CHIP_ERROR err = CHIP_NO_ERROR; int32_t status = 0; - if (mFlags.Has(Flags::kAdvertising)) + // TODO: add the below code in a condition if (mFlags.Has(Flags::kAdvertising)) + // Since DriveBLEState is not called the device is still advertising + mFlags.Clear(Flags::kAdvertising).Clear(Flags::kRestartAdvertising); + mFlags.Set(Flags::kFastAdvertisingEnabled, true); + status = rsi_ble_stop_advertising(); + if (status != RSI_SUCCESS) { - mFlags.Clear(Flags::kAdvertising).Clear(Flags::kRestartAdvertising); - mFlags.Set(Flags::kFastAdvertisingEnabled, true); - status = rsi_ble_stop_advertising(); - if (status != RSI_SUCCESS) - { - ChipLogProgress(DeviceLayer, "advertising failed to stop, with status = 0x%lx", status); - } - advertising_set_handle = 0xff; - CancelBleAdvTimeoutTimer(); + ChipLogProgress(DeviceLayer, "advertising failed to stop, with status = 0x%lx", status); } + advertising_set_handle = 0xff; + CancelBleAdvTimeoutTimer(); // exit: return err; @@ -723,24 +721,6 @@ void BLEManagerImpl::HandleConnectionCloseEvent(uint16_t reason) ChipLogProgress(DeviceLayer, "Disconnect Event for handle : %d", connHandle); -#if CHIP_DEVICE_CONFIG_ENABLE_SED - int32_t status; - status = rsi_bt_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); - if (status != RSI_SUCCESS) - { - SILABS_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status); - return; - } - - status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); - if (status != RSI_SUCCESS) - { - SILABS_LOG("WLAN Powersave Config Failed, Error Code : 0x%lX", status); - return; - } - SILABS_LOG("Powersave Config Success"); -#endif - if (RemoveConnection(connHandle)) { ChipDeviceEvent event; diff --git a/src/platform/silabs/efr32/wifi/wfx_host_events.h b/src/platform/silabs/efr32/wifi/wfx_host_events.h index 1d41c750517c82..c0724b7237e808 100644 --- a/src/platform/silabs/efr32/wifi/wfx_host_events.h +++ b/src/platform/silabs/efr32/wifi/wfx_host_events.h @@ -352,6 +352,10 @@ void wfx_ip_changed_notify(int got_ip); void wfx_ipv6_notify(int got_ip); #ifdef RS911X_WIFI +/* RSI Power Save */ +#if CHIP_DEVICE_CONFIG_ENABLE_SED +sl_status_t wfx_power_save(); +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ /* RSI for LWIP */ void * wfx_rsi_alloc_pkt(void); void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off); diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 97de1caf125afe..f84e257af916f5 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -338,10 +338,15 @@ template("efr32_sdk") { "SL_CATALOG_POWER_MANAGER_PRESENT", "SL_CATALOG_SLEEPTIMER_PRESENT", "SL_SLEEP_TIME_MS=${sleep_time_ms}", - - # Used for wifi devices to get packet details - "WIFI_DEBUG_ENABLED=1", ] + + if (defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi) { + defines += [ + # Used for wifi devices to get packet details + # TODO: Remove this flag, once the communication is fixed + "WIFI_DEBUG_ENABLED=1", + ] + } } if (chip_build_libshell) { # matter shell From 8cdd0aa0b3a37f6f6abf2458adbb3d274f43337f Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 26 Apr 2023 16:21:38 -0400 Subject: [PATCH 038/200] Add LightSensorType to IlluminanceMeasurement for chef lighting example (#26269) --- .../devices/rootnode_lightsensor_lZQycTFcJK.matter | 2 ++ .../chef/devices/rootnode_lightsensor_lZQycTFcJK.zap | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter index e60751a893b628..6ed3b14735881e 100644 --- a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter +++ b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter @@ -1229,6 +1229,7 @@ server cluster IlluminanceMeasurement = 1024 { readonly attribute nullable int16u measuredValue = 0; readonly attribute nullable int16u minMeasuredValue = 1; readonly attribute nullable int16u maxMeasuredValue = 2; + readonly attribute nullable enum8 lightSensorType = 4; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1440,6 +1441,7 @@ endpoint 1 { ram attribute measuredValue default = 0xC351; ram attribute minMeasuredValue default = 1; ram attribute maxMeasuredValue default = 0xfffe; + ram attribute lightSensorType default = 1; callback attribute generatedCommandList default = 0; callback attribute acceptedCommandList default = 0; callback attribute attributeList default = 0; diff --git a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap index 1ad280a7a693bd..0404fe4a4b3339 100644 --- a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap +++ b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 96, "creator": "zap", "keyValuePairs": [ { @@ -6141,11 +6141,11 @@ "mfgCode": null, "side": "server", "type": "enum8", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0xFF", + "defaultValue": "1", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -6255,5 +6255,6 @@ "endpointVersion": 1, "deviceIdentifier": 262 } - ] -} \ No newline at end of file + ], + "log": [] +} From c837ea3d0b48da9b869e89d5128b3e497376fe60 Mon Sep 17 00:00:00 2001 From: Ezra Hale Date: Thu, 27 Apr 2023 01:14:30 -0400 Subject: [PATCH 039/200] updated board references from BRD4161A to BRD4187C in example commands (#26264) * updated board references from BRD4161A to BRD4187C in example commands * change EFR32_BOARD to SILABS_BOARD * change references to silabs_board to SILABS_BOARD --- examples/light-switch-app/silabs/efr32/README.md | 14 +++++++------- examples/lighting-app/silabs/efr32/README.md | 12 ++++++------ examples/lock-app/silabs/efr32/README.md | 14 +++++++------- examples/thermostat/silabs/efr32/README.md | 14 +++++++------- examples/window-app/silabs/efr32/README.md | 12 ++++++------ 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/examples/light-switch-app/silabs/efr32/README.md b/examples/light-switch-app/silabs/efr32/README.md index 5651486640ee0e..bf18af9f03c0b2 100644 --- a/examples/light-switch-app/silabs/efr32/README.md +++ b/examples/light-switch-app/silabs/efr32/README.md @@ -106,7 +106,7 @@ Silicon Labs platform. * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32/ ./out/light-switch-app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32/ ./out/light-switch-app BRD4187C - To delete generated executable, libraries and object files use: @@ -118,7 +118,7 @@ Silicon Labs platform. $ cd ~/connectedhomeip/examples/light-switch-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug $ ninja -C out/debug @@ -129,26 +129,26 @@ Silicon Labs platform. * Build the example with Matter shell - ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/silabs/efr32/ out/light-switch-app BRD4161A chip_build_libshell=true + ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/silabs/efr32/ out/light-switch-app BRD4187C chip_build_libshell=true * Build the example as Sleepy End Device (SED) - $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32/ ./out/light-switch-app_SED BRD4161A --sed + $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32/ ./out/light-switch-app_SED BRD4187C --sed or use gn as previously mentioned but adding the following arguments: - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false chip_build_libshell=true' + $ gn gen out/debug '--args=SILABS_BOARD="BRD4187C" enable_sleepy_device=true chip_openthread_ftd=false chip_build_libshell=true' * Build the example with pigweed RCP - $ ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/silabs/efr32/ out/light-switch-app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/silabs/efr32/ out/light-switch-app_rpc BRD4187C 'import("//with_pw_rpc.gni")' or use GN/Ninja Directly $ cd ~/connectedhomeip/examples/light-switch-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug --args='import("//with_pw_rpc.gni")' $ ninja -C out/debug diff --git a/examples/lighting-app/silabs/efr32/README.md b/examples/lighting-app/silabs/efr32/README.md index 4dde93ddcb93ca..1cd0ed3df33193 100644 --- a/examples/lighting-app/silabs/efr32/README.md +++ b/examples/lighting-app/silabs/efr32/README.md @@ -100,7 +100,7 @@ Silicon Labs platform. * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/efr32/ ./out/lighting-app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/efr32/ ./out/lighting-app BRD4187C - To delete generated executable, libraries and object files use: @@ -112,7 +112,7 @@ Silicon Labs platform. $ cd ~/connectedhomeip/examples/lighting-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export silabs_board=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug $ ninja -C out/debug @@ -123,22 +123,22 @@ Silicon Labs platform. * Build the example as Sleepy End Device (SED) - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/efr32/ ./out/lighting-app_SED BRD4161A --sed + $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/efr32/ ./out/lighting-app_SED BRD4187C --sed or use gn as previously mentioned but adding the following arguments: - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false' + $ gn gen out/debug '--args=SILABS_BOARD="BRD4187C" enable_sleepy_device=true chip_openthread_ftd=false' * Build the example with pigweed RPC - $ ./scripts/examples/gn_efr32_example.sh examples/lighting-app/silabs/efr32/ out/lighting_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/lighting-app/silabs/efr32/ out/lighting_app_rpc BRD4187C 'import("//with_pw_rpc.gni")' or use GN/Ninja Directly $ cd ~/connectedhomeip/examples/lighting-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export silabs_board=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug --args='import("//with_pw_rpc.gni")' $ ninja -C out/debug diff --git a/examples/lock-app/silabs/efr32/README.md b/examples/lock-app/silabs/efr32/README.md index 8d6ed7776bb565..6c3fe8453ec3ee 100644 --- a/examples/lock-app/silabs/efr32/README.md +++ b/examples/lock-app/silabs/efr32/README.md @@ -102,7 +102,7 @@ Mac OS X ``` cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32/ ./out/lock_app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32/ ./out/lock_app BRD4187C ``` - To delete generated executable, libraries and object files use: @@ -118,8 +118,8 @@ Mac OS X $ cd ~/connectedhomeip/examples/silabs/lock-app/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A - $ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" silabs_board=\"${EFR32_BOARD}\"" + $ export SILABS_BOARD=BRD4187C + $ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" SILABS_BOARD=\"${SILABS_BOARD}\"" $ ninja -C out/debug ``` @@ -133,19 +133,19 @@ Mac OS X * Build the example as Sleepy End Device (SED) ``` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32/ ./out/lock-app_SED BRD4161A --sed + $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32/ ./out/lock-app_SED BRD4187C --sed ``` or use gn as previously mentioned but adding the following arguments: ``` - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false' + $ gn gen out/debug '--args=SILABS_BOARD="BRD4187C" enable_sleepy_device=true chip_openthread_ftd=false' ``` * Build the example with pigweed RCP ``` - $ ./scripts/examples/gn_efr32_example.sh examples/lock-app/silabs/efr32/ out/lock_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/lock-app/silabs/efr32/ out/lock_app_rpc BRD4187C 'import("//with_pw_rpc.gni")' ``` or use GN/Ninja Directly @@ -154,7 +154,7 @@ Mac OS X $ cd ~/connectedhomeip/examples/lock-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug --args='import("//with_pw_rpc.gni")' $ ninja -C out/debug ``` diff --git a/examples/thermostat/silabs/efr32/README.md b/examples/thermostat/silabs/efr32/README.md index 2a6cfb9289bdf0..8fafaa7827ba05 100644 --- a/examples/thermostat/silabs/efr32/README.md +++ b/examples/thermostat/silabs/efr32/README.md @@ -106,7 +106,7 @@ Silicon Labs platform. * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/silabs/efr32/ ./out/thermostat-app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/silabs/efr32/ ./out/thermostat-app BRD4187C - To delete generated executable, libraries and object files use: @@ -118,7 +118,7 @@ Silicon Labs platform. $ cd ~/connectedhomeip/examples/thermostat/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug $ ninja -C out/debug @@ -129,26 +129,26 @@ Silicon Labs platform. * Build the example with Matter shell - ./scripts/examples/gn_efr32_example.sh examples/thermostat/silabs/efr32/ out/thermostat-app BRD4161A chip_build_libshell=true + ./scripts/examples/gn_efr32_example.sh examples/thermostat/silabs/efr32/ out/thermostat-app BRD4187C chip_build_libshell=true * Build the example as Sleepy End Device (SED) - $ ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/silabs/efr32/ ./out/thermostat-app_SED BRD4161A --sed + $ ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/silabs/efr32/ ./out/thermostat-app_SED BRD4187C --sed or use gn as previously mentioned but adding the following arguments: - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false chip_build_libshell=true' + $ gn gen out/debug '--args=SILABS_BOARD="BRD4187C" enable_sleepy_device=true chip_openthread_ftd=false chip_build_libshell=true' * Build the example with pigweed RCP - $ ./scripts/examples/gn_efr32_example.sh examples/thermostat/silabs/efr32/ out/thermostat-app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/thermostat/silabs/efr32/ out/thermostat-app_rpc BRD4187C 'import("//with_pw_rpc.gni")' or use GN/Ninja Directly $ cd ~/connectedhomeip/examples/thermostat/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug --args='import("//with_pw_rpc.gni")' $ ninja -C out/debug diff --git a/examples/window-app/silabs/efr32/README.md b/examples/window-app/silabs/efr32/README.md index 9e531212f85cee..4d5231863c9aae 100644 --- a/examples/window-app/silabs/efr32/README.md +++ b/examples/window-app/silabs/efr32/README.md @@ -99,7 +99,7 @@ Silicon Labs platform. * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/window-app/silabs/efr32/ ./out/window-app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/window-app/silabs/efr32/ ./out/window-app BRD4187C - To delete generated executable, libraries and object files use: @@ -111,7 +111,7 @@ Silicon Labs platform. $ cd ~/connectedhomeip/examples/window-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug $ ninja -C out/debug @@ -122,22 +122,22 @@ Silicon Labs platform. * Build the example as Sleepy End Device (SED) - $ ./scripts/examples/gn_efr32_example.sh ./examples/window-app/silabs/efr32/ ./out/window-app_SED BRD4161A --sed + $ ./scripts/examples/gn_efr32_example.sh ./examples/window-app/silabs/efr32/ ./out/window-app_SED BRD4187C --sed or use gn as previously mentioned but adding the following arguments: - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false' + $ gn gen out/debug '--args=SILABS_BOARD="BRD4187C" enable_sleepy_device=true chip_openthread_ftd=false' * Build the example with pigweed RCP - $ ./scripts/examples/gn_efr32_example.sh examples/window-app/silabs/efr32/ out/window_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/window-app/silabs/efr32/ out/window_app_rpc BRD4187C 'import("//with_pw_rpc.gni")' or use GN/Ninja Directly $ cd ~/connectedhomeip/examples/window-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug --args='import("//with_pw_rpc.gni")' $ ninja -C out/debug From c1108d7f7360e9065c9e3dd5f4d2d9cfabdffbbe Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Thu, 27 Apr 2023 01:30:10 -0400 Subject: [PATCH 040/200] Added build configuration flags (#26273) --- .../silabs/efr32/project_include/OpenThreadConfig.h | 9 ++++++--- src/platform/silabs/CHIPDevicePlatformConfig.h | 8 ++++++-- third_party/silabs/efr32_sdk.gni | 9 +++++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h b/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h index c8f39692a69b0e..ea67df3ba27829 100644 --- a/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h +++ b/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h @@ -37,13 +37,16 @@ #define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 1 #if CHIP_DEVICE_CONFIG_ENABLE_SED + #define OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE 0 + // In seconds -#define SL_MLE_TIMEOUT_seconds (SL_SLEEP_TIME_MS / 1000) +#define SL_MLE_TIMEOUT_s (SL_OT_IDLE_INTERVAL / 1000) // Timeout after 2 missed checkin or 4 mins if sleep interval is too short. -#define OPENTHREAD_CONFIG_MLE_CHILD_TIMEOUT_DEFAULT ((SL_MLE_TIMEOUT_seconds < 120) ? 240 : ((SL_MLE_TIMEOUT_seconds * 2) + 1)) -#endif +#define OPENTHREAD_CONFIG_MLE_CHILD_TIMEOUT_DEFAULT ((SL_MLE_TIMEOUT_s < 120) ? 240 : ((SL_MLE_TIMEOUT_s * 2) + 1)) + +#endif // CHIP_DEVICE_CONFIG_ENABLE_SED /****Uncomment below section for OpenThread Debug logs*/ // #define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG diff --git a/src/platform/silabs/CHIPDevicePlatformConfig.h b/src/platform/silabs/CHIPDevicePlatformConfig.h index 45f9c83ace6272..fb749556e19b2c 100644 --- a/src/platform/silabs/CHIPDevicePlatformConfig.h +++ b/src/platform/silabs/CHIPDevicePlatformConfig.h @@ -117,13 +117,17 @@ #endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE #ifndef CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL -#define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL chip::System::Clock::Milliseconds32(SL_SLEEP_TIME_MS) +#define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL chip::System::Clock::Milliseconds32(SL_OT_IDLE_INTERVAL) #endif // CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL #ifndef CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL -#define CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL chip::System::Clock::Milliseconds32(200) +#define CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL chip::System::Clock::Milliseconds32(SL_OT_ACTIVE_INTERVAL) #endif // CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL +#ifndef CHIP_DEVICE_CONFIG_SED_ACTIVE_THRESHOLD +#define CHIP_DEVICE_CONFIG_SED_ACTIVE_THRESHOLD chip::System::Clock::Milliseconds32(SL_ACTIVE_MODE_THRESHOLD) +#endif // CHIP_DEVICE_CONFIG_SED_ACTIVE_THRESHOLD + #ifndef CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE #if defined(EFR32MG21) #define CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE (2 * 1024) diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index f84e257af916f5..5e6905ebb83e7c 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -45,7 +45,10 @@ declare_args() { # Enable Segger System View use_system_view = false - sleep_time_ms = 30000 # 30 seconds sleep + # ICD Configuration flags + sl_ot_idle_interval_ms = 30000 # 30s Idle Intervals + sl_ot_active_interval_ms = 200 # 500ms Active Intervals + sl_active_mode_threshold = 1000 # 1s Active mode threshold silabs_log_enabled = true @@ -337,7 +340,9 @@ template("efr32_sdk") { "CHIP_DEVICE_CONFIG_ENABLE_SED=1", "SL_CATALOG_POWER_MANAGER_PRESENT", "SL_CATALOG_SLEEPTIMER_PRESENT", - "SL_SLEEP_TIME_MS=${sleep_time_ms}", + "SL_OT_IDLE_INTERVAL=${sl_ot_idle_interval_ms}", + "SL_OT_ACTIVE_INTERVAL=${sl_ot_active_interval_ms}", + "SL_ACTIVE_MODE_THRESHOLD=${sl_active_mode_threshold}", ] if (defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi) { From d19744206ccbb9f9889a51a593506083e497a884 Mon Sep 17 00:00:00 2001 From: Artur Tynecki <77382963+ATmobica@users.noreply.github.com> Date: Thu, 27 Apr 2023 17:02:55 +0200 Subject: [PATCH 041/200] [OIS/example] Sharing lock-app cluster service between Linux and OIS platforms (#24551) * [Examples] Create common lock-app cluster service Move lock endpoint, manager and ZCL callbacks from Linux to lock-common directory. Create source set with lock cluster service files. Create cmake macro to add common lock-app sources to the specific target. Use lock-cluster-service in Linux lock-app example. Change "setting door lock state" logs to progress level to be informed of the lock status change directly. Sources can now be easily shared across platform implementations. Signed-off-by: ATmobica * [OIS] Use common lock-app sources Directly use of common lock cluster service sources in lock-app example instead of creating the copy. Lock-app integration test adaptation. Signed-off-by: ATmobica --------- Signed-off-by: ATmobica --- examples/all-clusters-app/linux/BUILD.gn | 10 +- .../all-clusters-minimal-app/linux/BUILD.gn | 10 +- examples/lock-app/linux/BUILD.gn | 9 +- examples/lock-app/lock-common/BUILD.gn | 19 + .../include/LockEndpoint.h | 2 +- .../include/LockManager.h | 2 +- examples/lock-app/lock-common/lock-app.cmake | 45 +++ .../src/LockEndpoint.cpp | 8 +- .../src/LockManager.cpp | 2 +- .../src/ZCLDoorLockCallbacks.cpp | 18 + examples/lock-app/openiotsdk/CMakeLists.txt | 11 +- .../lock-app/openiotsdk/main/LockEndpoint.cpp | 350 ------------------ .../lock-app/openiotsdk/main/LockManager.cpp | 247 ------------ .../lock-app/openiotsdk/main/ZclCallbacks.cpp | 107 ------ .../openiotsdk/main/include/LockEndpoint.h | 118 ------ .../openiotsdk/main/include/LockManager.h | 66 ---- .../integration-tests/lock-app/test_app.py | 4 +- 17 files changed, 113 insertions(+), 915 deletions(-) rename examples/lock-app/{linux => lock-common}/include/LockEndpoint.h (99%) rename examples/lock-app/{linux => lock-common}/include/LockManager.h (98%) create mode 100644 examples/lock-app/lock-common/lock-app.cmake rename examples/lock-app/{linux => lock-common}/src/LockEndpoint.cpp (98%) rename examples/lock-app/{linux => lock-common}/src/LockManager.cpp (99%) rename examples/lock-app/{linux => lock-common}/src/ZCLDoorLockCallbacks.cpp (88%) delete mode 100644 examples/lock-app/openiotsdk/main/LockEndpoint.cpp delete mode 100644 examples/lock-app/openiotsdk/main/LockManager.cpp delete mode 100644 examples/lock-app/openiotsdk/main/ZclCallbacks.cpp delete mode 100644 examples/lock-app/openiotsdk/main/include/LockEndpoint.h delete mode 100644 examples/lock-app/openiotsdk/main/include/LockManager.h diff --git a/examples/all-clusters-app/linux/BUILD.gn b/examples/all-clusters-app/linux/BUILD.gn index 6c71b7e61b64f5..1b8ff71bc66e76 100644 --- a/examples/all-clusters-app/linux/BUILD.gn +++ b/examples/all-clusters-app/linux/BUILD.gn @@ -52,14 +52,16 @@ source_set("chip-all-clusters-common") { source_set("chip-lock-app-common") { sources = [ - "${chip_root}/examples/lock-app/linux/src/LockEndpoint.cpp", - "${chip_root}/examples/lock-app/linux/src/LockManager.cpp", - "${chip_root}/examples/lock-app/linux/src/ZCLDoorLockCallbacks.cpp", + "${chip_root}/examples/lock-app/lock-common/include/LockEndpoint.h", + "${chip_root}/examples/lock-app/lock-common/include/LockManager.h", + "${chip_root}/examples/lock-app/lock-common/src/LockEndpoint.cpp", + "${chip_root}/examples/lock-app/lock-common/src/LockManager.cpp", + "${chip_root}/examples/lock-app/lock-common/src/ZCLDoorLockCallbacks.cpp", ] deps = [ "${chip_root}/examples/all-clusters-app/all-clusters-common" ] - include_dirs = [ "${chip_root}/examples/lock-app/linux/include" ] + include_dirs = [ "${chip_root}/examples/lock-app/lock-common/include" ] cflags = [ "-Wconversion" ] } diff --git a/examples/all-clusters-minimal-app/linux/BUILD.gn b/examples/all-clusters-minimal-app/linux/BUILD.gn index cf3f915fe0d828..24154fe758f958 100644 --- a/examples/all-clusters-minimal-app/linux/BUILD.gn +++ b/examples/all-clusters-minimal-app/linux/BUILD.gn @@ -49,15 +49,17 @@ source_set("chip-all-clusters-common") { source_set("chip-lock-app-common") { sources = [ - "${chip_root}/examples/lock-app/linux/src/LockEndpoint.cpp", - "${chip_root}/examples/lock-app/linux/src/LockManager.cpp", - "${chip_root}/examples/lock-app/linux/src/ZCLDoorLockCallbacks.cpp", + "${chip_root}/examples/lock-app/lock-common/include/LockEndpoint.h", + "${chip_root}/examples/lock-app/lock-common/include/LockManager.h", + "${chip_root}/examples/lock-app/lock-common/src/LockEndpoint.cpp", + "${chip_root}/examples/lock-app/lock-common/src/LockManager.cpp", + "${chip_root}/examples/lock-app/lock-common/src/ZCLDoorLockCallbacks.cpp", ] deps = [ "${chip_root}/examples/all-clusters-minimal-app/all-clusters-common" ] - include_dirs = [ "${chip_root}/examples/lock-app/linux/include" ] + include_dirs = [ "${chip_root}/examples/lock-app/lock-common/include" ] cflags = [ "-Wconversion" ] } diff --git a/examples/lock-app/linux/BUILD.gn b/examples/lock-app/linux/BUILD.gn index fc4bc76d9c8b2f..ce54d7d4fd906d 100644 --- a/examples/lock-app/linux/BUILD.gn +++ b/examples/lock-app/linux/BUILD.gn @@ -19,22 +19,17 @@ executable("chip-lock-app") { sources = [ "main.cpp", "src/LockAppCommandDelegate.cpp", - "src/LockEndpoint.cpp", - "src/LockManager.cpp", - "src/ZCLDoorLockCallbacks.cpp", ] deps = [ "${chip_root}/examples/lock-app/lock-common", + "${chip_root}/examples/lock-app/lock-common:lock-cluster-service", "${chip_root}/examples/platform/linux:app-main", "${chip_root}/src/lib", "${chip_root}/third_party/jsoncpp", ] - include_dirs = [ - "${chip_root}/examples/lock-app/lock-common/include", - "include", - ] + include_dirs = [ "include" ] cflags = [ "-Wconversion" ] diff --git a/examples/lock-app/lock-common/BUILD.gn b/examples/lock-app/lock-common/BUILD.gn index 1b1a7d31311a6a..4237883f3fb2b0 100644 --- a/examples/lock-app/lock-common/BUILD.gn +++ b/examples/lock-app/lock-common/BUILD.gn @@ -22,3 +22,22 @@ chip_data_model("lock-common") { zap_pregenerated_dir = "${chip_root}/zzz_generated/lock-app/zap-generated" is_server = true } + +config("config") { + include_dirs = [ "include" ] +} + +source_set("lock-cluster-service") { + deps = [ + "${chip_root}/examples/lock-app/lock-common", + "${chip_root}/src/lib", + ] + public_configs = [ ":config" ] + sources = [ + "include/LockEndpoint.h", + "include/LockManager.h", + "src/LockEndpoint.cpp", + "src/LockManager.cpp", + "src/ZCLDoorLockCallbacks.cpp", + ] +} diff --git a/examples/lock-app/linux/include/LockEndpoint.h b/examples/lock-app/lock-common/include/LockEndpoint.h similarity index 99% rename from examples/lock-app/linux/include/LockEndpoint.h rename to examples/lock-app/lock-common/include/LockEndpoint.h index f652ec2df6f0a8..cabbf5822e211e 100644 --- a/examples/lock-app/linux/include/LockEndpoint.h +++ b/examples/lock-app/lock-common/include/LockEndpoint.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2022-2023 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/examples/lock-app/linux/include/LockManager.h b/examples/lock-app/lock-common/include/LockManager.h similarity index 98% rename from examples/lock-app/linux/include/LockManager.h rename to examples/lock-app/lock-common/include/LockManager.h index 9f274abe487598..9eb313aa5d276c 100644 --- a/examples/lock-app/linux/include/LockManager.h +++ b/examples/lock-app/lock-common/include/LockManager.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2023 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/examples/lock-app/lock-common/lock-app.cmake b/examples/lock-app/lock-common/lock-app.cmake new file mode 100644 index 00000000000000..9cd897730b8f25 --- /dev/null +++ b/examples/lock-app/lock-common/lock-app.cmake @@ -0,0 +1,45 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +cmake_minimum_required(VERSION 3.21) + +set(CHIP_LOCK_COMMON_BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) + + +# Add common lock sources to the specific target +# [Args]: +# target - target name +# Available options are: +# SCOPE sources scope for the target, PRIVATE as default +macro(chip_add_lock_app_common target) + set(SCOPE PRIVATE) + cmake_parse_arguments(ARG "" "SCOPE" "" ${ARGN}) + if (ARG_SCOPE) + set(SCOPE ${ARG_SCOPE}) + endif() + + target_include_directories(${target} + ${SCOPE} + ${CHIP_LOCK_COMMON_BASE_DIR}/include + ) + + target_sources(${target} + ${SCOPE} + ${CHIP_LOCK_COMMON_BASE_DIR}/src/ZCLDoorLockCallbacks.cpp + ${CHIP_LOCK_COMMON_BASE_DIR}/src/LockManager.cpp + ${CHIP_LOCK_COMMON_BASE_DIR}/src/LockEndpoint.cpp + ) +endmacro() diff --git a/examples/lock-app/linux/src/LockEndpoint.cpp b/examples/lock-app/lock-common/src/LockEndpoint.cpp similarity index 98% rename from examples/lock-app/linux/src/LockEndpoint.cpp rename to examples/lock-app/lock-common/src/LockEndpoint.cpp index 6c68f9f3a12be0..db1fde79b9b4dc 100644 --- a/examples/lock-app/linux/src/LockEndpoint.cpp +++ b/examples/lock-app/lock-common/src/LockEndpoint.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2022-2023 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -392,8 +392,8 @@ bool LockEndpoint::setLockState(DlLockState lockState, const Optional #include diff --git a/examples/lock-app/openiotsdk/CMakeLists.txt b/examples/lock-app/openiotsdk/CMakeLists.txt index ec75b81afdf3d2..fca486fed81d09 100644 --- a/examples/lock-app/openiotsdk/CMakeLists.txt +++ b/examples/lock-app/openiotsdk/CMakeLists.txt @@ -19,8 +19,10 @@ cmake_minimum_required(VERSION 3.21) get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH) get_filename_component(OPEN_IOT_SDK_CONFIG ${CHIP_ROOT}/config/openiotsdk REALPATH) get_filename_component(OPEN_IOT_SDK_EXAMPLE_COMMON ${CHIP_ROOT}/examples/platform/openiotsdk REALPATH) +get_filename_component(LOCK_APP_COMMON ${CHIP_ROOT}/examples/lock-app/lock-common REALPATH) list(APPEND CMAKE_MODULE_PATH ${OPEN_IOT_SDK_CONFIG}/cmake) +list(APPEND CMAKE_MODULE_PATH ${LOCK_APP_COMMON}) set(APP_TARGET chip-openiotsdk-lock-app-example_ns) @@ -61,6 +63,12 @@ add_subdirectory(${OPEN_IOT_SDK_EXAMPLE_COMMON}/app ./app_build) chip_add_data_model(openiotsdk-app PUBLIC lock) +# Add common lock-app sources +include(lock-app) +chip_add_lock_app_common(openiotsdk-app + SCOPE PUBLIC +) + target_include_directories(${APP_TARGET} PRIVATE main/include @@ -69,9 +77,6 @@ target_include_directories(${APP_TARGET} target_sources(${APP_TARGET} PRIVATE main/main_ns.cpp - main/ZclCallbacks.cpp - main/LockManager.cpp - main/LockEndpoint.cpp ) target_link_libraries(${APP_TARGET} diff --git a/examples/lock-app/openiotsdk/main/LockEndpoint.cpp b/examples/lock-app/openiotsdk/main/LockEndpoint.cpp deleted file mode 100644 index 453520c6470cca..00000000000000 --- a/examples/lock-app/openiotsdk/main/LockEndpoint.cpp +++ /dev/null @@ -1,350 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "LockEndpoint.h" -#include - -using chip::to_underlying; - -bool LockEndpoint::Lock(const Optional & pin, OperationErrorEnum & err) -{ - return setLockState(DlLockState::kLocked, pin, err); -} - -bool LockEndpoint::Unlock(const Optional & pin, OperationErrorEnum & err) -{ - return setLockState(DlLockState::kUnlocked, pin, err); -} - -bool LockEndpoint::GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) const -{ - ChipLogDetail(Zcl, "Lock App: LockEndpoint::GetUser [endpoint=%d,userIndex=%hu]", mEndpointId, userIndex); - - auto adjustedUserIndex = static_cast(userIndex - 1); - if (adjustedUserIndex > mLockUsers.size()) - { - ChipLogError(Zcl, "Cannot get user - index out of range [endpoint=%d,index=%hu,adjustedIndex=%d]", mEndpointId, userIndex, - adjustedUserIndex); - return false; - } - - const auto & userInDb = mLockUsers[adjustedUserIndex]; - user.userStatus = userInDb.userStatus; - if (UserStatusEnum::kAvailable == user.userStatus) - { - ChipLogDetail(Zcl, "Found unoccupied user [endpoint=%d,adjustedIndex=%hu]", mEndpointId, adjustedUserIndex); - return true; - } - - user.userName = chip::CharSpan(userInDb.userName, strlen(userInDb.userName)); - user.credentials = chip::Span(userInDb.credentials.data(), userInDb.credentials.size()); - user.userUniqueId = userInDb.userUniqueId; - user.userType = userInDb.userType; - user.credentialRule = userInDb.credentialRule; - user.createdBy = userInDb.createdBy; - user.lastModifiedBy = userInDb.lastModifiedBy; - - ChipLogDetail(Zcl, - "Found occupied user " - "[endpoint=%d,adjustedIndex=%hu,name=\"%.*s\",credentialsCount=%u,uniqueId=%x,type=%u,credentialRule=%u," - "createdBy=%d,lastModifiedBy=%d]", - mEndpointId, adjustedUserIndex, static_cast(user.userName.size()), user.userName.data(), - static_cast(user.credentials.size()), user.userUniqueId, to_underlying(user.userType), - to_underlying(user.credentialRule), user.createdBy, user.lastModifiedBy); - - return true; -} - -bool LockEndpoint::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, - CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) -{ - ChipLogProgress(Zcl, - "SetUser " - "[endpoint=%d,userIndex=%u,creator=%d,modifier=%d,userName=\"%.*s\",uniqueId=%" PRIx32 - ",userStatus=%u,userType=%u," - "credentialRule=%u,credentials=%p,totalCredentials=%u]", - mEndpointId, userIndex, creator, modifier, static_cast(userName.size()), userName.data(), uniqueId, - to_underlying(userStatus), to_underlying(usertype), to_underlying(credentialRule), credentials, - static_cast(totalCredentials)); - - auto adjustedUserIndex = static_cast(userIndex - 1); - if (adjustedUserIndex > mLockUsers.size()) - { - ChipLogError(Zcl, "Cannot set user - index out of range [endpoint=%d,index=%d,adjustedUserIndex=%u]", mEndpointId, - userIndex, adjustedUserIndex); - return false; - } - - auto & userInStorage = mLockUsers[adjustedUserIndex]; - if (userName.size() > DOOR_LOCK_MAX_USER_NAME_SIZE) - { - ChipLogError(Zcl, "Cannot set user - user name is too long [endpoint=%d,index=%d,adjustedUserIndex=%u]", mEndpointId, - userIndex, adjustedUserIndex); - return false; - } - - if (totalCredentials > userInStorage.credentials.capacity()) - { - ChipLogError(Zcl, - "Cannot set user - total number of credentials is too big [endpoint=%d,index=%d,adjustedUserIndex=%u" - ",totalCredentials=%u,maxNumberOfCredentials=%u]", - mEndpointId, userIndex, adjustedUserIndex, static_cast(totalCredentials), - static_cast(userInStorage.credentials.capacity())); - return false; - } - - chip::Platform::CopyString(userInStorage.userName, userName); - userInStorage.userName[userName.size()] = 0; - userInStorage.userUniqueId = uniqueId; - userInStorage.userStatus = userStatus; - userInStorage.userType = usertype; - userInStorage.credentialRule = credentialRule; - userInStorage.lastModifiedBy = modifier; - userInStorage.createdBy = creator; - - userInStorage.credentials.clear(); - for (size_t i = 0; i < totalCredentials; ++i) - { - userInStorage.credentials.push_back(credentials[i]); - } - - ChipLogProgress(Zcl, "Successfully set the user [mEndpointId=%d,index=%d,adjustedIndex=%d]", mEndpointId, userIndex, - adjustedUserIndex); - - return true; -} - -bool LockEndpoint::GetCredential(uint16_t credentialIndex, CredentialTypeEnum credentialType, - EmberAfPluginDoorLockCredentialInfo & credential) const -{ - ChipLogDetail(Zcl, "GetCredential [endpoint=%d,credentialIndex=%u,credentialType=%u]", mEndpointId, credentialIndex, - to_underlying(credentialType)); - - if (credentialIndex >= mLockCredentials.size() || - (0 == credentialIndex && CredentialTypeEnum::kProgrammingPIN != credentialType)) - { - ChipLogError(Zcl, "Cannot get the credential - index out of range [endpoint=%d,index=%d]", mEndpointId, credentialIndex); - return false; - } - - const auto & credentialInStorage = mLockCredentials[credentialIndex]; - - credential.status = credentialInStorage.status; - if (DlCredentialStatus::kAvailable == credential.status) - { - ChipLogDetail(Zcl, "Found unoccupied credential [endpoint=%d,index=%u]", mEndpointId, credentialIndex); - return true; - } - credential.credentialType = credentialInStorage.credentialType; - credential.credentialData = chip::ByteSpan(credentialInStorage.credentialData, credentialInStorage.credentialDataSize); - credential.createdBy = credentialInStorage.createdBy; - credential.lastModifiedBy = credentialInStorage.modifiedBy; - - ChipLogDetail(Zcl, "Found occupied credential [endpoint=%d,index=%u,type=%u,dataSize=%u,createdBy=%u,modifiedBy=%u]", - mEndpointId, credentialIndex, to_underlying(credential.credentialType), - static_cast(credential.credentialData.size()), credential.createdBy, credential.lastModifiedBy); - - return true; -} - -bool LockEndpoint::SetCredential(uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, - const chip::ByteSpan & credentialData) -{ - ChipLogDetail( - Zcl, - "SetCredential " - "[endpoint=%d,credentialIndex=%u,credentialStatus=%u,credentialType=%u,credentialDataSize=%u,creator=%u,modifier=%u]", - mEndpointId, credentialIndex, to_underlying(credentialStatus), to_underlying(credentialType), - static_cast(credentialData.size()), creator, modifier); - - if (credentialIndex >= mLockCredentials.size() || - (0 == credentialIndex && CredentialTypeEnum::kProgrammingPIN != credentialType)) - { - ChipLogError(Zcl, "Cannot set the credential - index out of range [endpoint=%d,index=%d]", mEndpointId, credentialIndex); - return false; - } - - auto & credentialInStorage = mLockCredentials[credentialIndex]; - if (credentialData.size() > DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE) - { - ChipLogError(Zcl, - "Cannot get the credential - data size exceeds limit " - "[endpoint=%d,index=%d,dataSize=%u,maxDataSize=%u]", - mEndpointId, credentialIndex, static_cast(credentialData.size()), - static_cast(DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE)); - return false; - } - credentialInStorage.status = credentialStatus; - credentialInStorage.credentialType = credentialType; - credentialInStorage.createdBy = creator; - credentialInStorage.modifiedBy = modifier; - std::memcpy(credentialInStorage.credentialData, credentialData.data(), credentialData.size()); - credentialInStorage.credentialDataSize = credentialData.size(); - - ChipLogProgress(Zcl, "Successfully set the credential [mEndpointId=%d,index=%d,credentialType=%u,creator=%u,modifier=%u]", - mEndpointId, credentialIndex, to_underlying(credentialType), credentialInStorage.createdBy, - credentialInStorage.modifiedBy); - - return true; -} - -DlStatus LockEndpoint::GetSchedule(uint8_t weekDayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule) -{ - if (0 == userIndex || userIndex > mWeekDaySchedules.size()) - { - return DlStatus::kFailure; - } - - if (0 == weekDayIndex || weekDayIndex > mWeekDaySchedules.at(userIndex - 1).size()) - { - return DlStatus::kFailure; - } - - const auto & scheduleInStorage = mWeekDaySchedules.at(userIndex - 1).at(weekDayIndex - 1); - if (DlScheduleStatus::kAvailable == scheduleInStorage.status) - { - return DlStatus::kNotFound; - } - - schedule = scheduleInStorage.schedule; - - return DlStatus::kSuccess; -} - -DlStatus LockEndpoint::SetSchedule(uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, DaysMaskMap daysMask, - uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) -{ - if (0 == userIndex || userIndex > mWeekDaySchedules.size()) - { - return DlStatus::kFailure; - } - - if (0 == weekDayIndex || weekDayIndex > mWeekDaySchedules.at(userIndex - 1).size()) - { - return DlStatus::kFailure; - } - - auto & scheduleInStorage = mWeekDaySchedules.at(userIndex - 1).at(weekDayIndex - 1); - - scheduleInStorage.schedule.daysMask = daysMask; - scheduleInStorage.schedule.startHour = startHour; - scheduleInStorage.schedule.startMinute = startMinute; - scheduleInStorage.schedule.endHour = endHour; - scheduleInStorage.schedule.endMinute = endMinute; - scheduleInStorage.status = status; - - return DlStatus::kSuccess; -} - -DlStatus LockEndpoint::GetSchedule(uint8_t yearDayIndex, uint16_t userIndex, EmberAfPluginDoorLockYearDaySchedule & schedule) -{ - if (0 == userIndex || userIndex > mYearDaySchedules.size()) - { - return DlStatus::kFailure; - } - - if (0 == yearDayIndex || yearDayIndex > mYearDaySchedules.at(userIndex - 1).size()) - { - return DlStatus::kFailure; - } - - const auto & scheduleInStorage = mYearDaySchedules.at(userIndex - 1).at(yearDayIndex - 1); - if (DlScheduleStatus::kAvailable == scheduleInStorage.status) - { - return DlStatus::kNotFound; - } - - schedule = scheduleInStorage.schedule; - - return DlStatus::kSuccess; -} - -DlStatus LockEndpoint::SetSchedule(uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, uint32_t localStartTime, - uint32_t localEndTime) -{ - if (0 == userIndex || userIndex > mYearDaySchedules.size()) - { - return DlStatus::kFailure; - } - - if (0 == yearDayIndex || yearDayIndex > mYearDaySchedules.at(userIndex - 1).size()) - { - return DlStatus::kFailure; - } - - auto & scheduleInStorage = mYearDaySchedules.at(userIndex - 1).at(yearDayIndex - 1); - scheduleInStorage.schedule.localStartTime = localStartTime; - scheduleInStorage.schedule.localEndTime = localEndTime; - scheduleInStorage.status = status; - - return DlStatus::kSuccess; -} - -bool LockEndpoint::setLockState(DlLockState lockState, const Optional & pin, OperationErrorEnum & err) -{ - if (!pin.HasValue()) - { - ChipLogDetail(Zcl, "PIN code is not specified, setting door lock state to \"%s\" [endpointId=%d]", - lockStateToString(lockState), mEndpointId); - mLockState = lockState; - return true; - } - - // Check the PIN code - for (const auto & pinCredential : mLockCredentials) - { - if (pinCredential.credentialType != CredentialTypeEnum::kPin || pinCredential.status == DlCredentialStatus::kAvailable) - { - continue; - } - - chip::ByteSpan credentialData(pinCredential.credentialData, pinCredential.credentialDataSize); - if (credentialData.data_equal(pin.Value())) - { - ChipLogProgress(Zcl, "Setting door lock state to \"%s\" [endpointId=%d]", lockStateToString(lockState), mEndpointId); - - mLockState = lockState; - return true; - } - } - - ChipLogDetail(Zcl, - "Specified PIN code was not found in the database, ignoring command to set lock state to \"%s\" " - "[endpointId=%d]", - lockStateToString(lockState), mEndpointId); - - err = OperationErrorEnum::kInvalidCredential; - return false; -} - -const char * LockEndpoint::lockStateToString(DlLockState lockState) const -{ - switch (lockState) - { - case DlLockState::kNotFullyLocked: - return "Not Fully Locked"; - case DlLockState::kLocked: - return "Locked"; - case DlLockState::kUnlocked: - return "Unlocked"; - } - - return "Unknown"; -} diff --git a/examples/lock-app/openiotsdk/main/LockManager.cpp b/examples/lock-app/openiotsdk/main/LockManager.cpp deleted file mode 100644 index 68318b2d497b98..00000000000000 --- a/examples/lock-app/openiotsdk/main/LockManager.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "LockManager.h" - -#include - -#include -#include -#include - -using chip::to_underlying; - -LockManager LockManager::instance; - -LockManager & LockManager::Instance() -{ - return instance; -} - -bool LockManager::InitEndpoint(chip::EndpointId endpointId) -{ - uint16_t numberOfSupportedUsers = 0; - if (!DoorLockServer::Instance().GetNumberOfUserSupported(endpointId, numberOfSupportedUsers)) - { - ChipLogError(Zcl, - "Unable to get number of supported users when initializing lock endpoint, defaulting to 10 [endpointId=%d]", - endpointId); - numberOfSupportedUsers = CHIP_LOCK_MANAGER_USER_NUMBER; - } - - uint16_t numberOfSupportedCredentials = 0; - // We're planning to use shared storage for PIN and RFID users so we will have the maximum of both sizes her to simplify logic - uint16_t numberOfPINCredentialsSupported = 0; - uint16_t numberOfRFIDCredentialsSupported = 0; - if (!DoorLockServer::Instance().GetNumberOfPINCredentialsSupported(endpointId, numberOfPINCredentialsSupported) || - !DoorLockServer::Instance().GetNumberOfRFIDCredentialsSupported(endpointId, numberOfRFIDCredentialsSupported)) - { - ChipLogError( - Zcl, "Unable to get number of supported credentials when initializing lock endpoint, defaulting to 10 [endpointId=%d]", - endpointId); - numberOfSupportedCredentials = CHIP_LOCK_MANAGER_CREDENTIALS_NUMBER; - } - else - { - numberOfSupportedCredentials = std::max(numberOfPINCredentialsSupported, numberOfRFIDCredentialsSupported); - } - - uint8_t numberOfCredentialsSupportedPerUser = 0; - if (!DoorLockServer::Instance().GetNumberOfCredentialsSupportedPerUser(endpointId, numberOfCredentialsSupportedPerUser)) - { - ChipLogError(Zcl, - "Unable to get number of credentials supported per user when initializing lock endpoint, defaulting to 5 " - "[endpointId=%d]", - endpointId); - numberOfCredentialsSupportedPerUser = CHIP_LOCK_MANAGER_CREDENTIALS_PER_USER_NUMBER; - } - - uint8_t numberOfWeekDaySchedulesPerUser = 0; - if (!DoorLockServer::Instance().GetNumberOfWeekDaySchedulesPerUserSupported(endpointId, numberOfWeekDaySchedulesPerUser)) - { - ChipLogError(Zcl, - "Unable to get number of supported week day schedules per user when initializing lock endpoint, defaulting to " - "10 [endpointId=%d]", - endpointId); - numberOfWeekDaySchedulesPerUser = CHIP_LOCK_MANAGER_WEEK_DAY_SCHEDULES_PER_USER_NUMBER; - } - - uint8_t numberOfYearDaySchedulesPerUser = 0; - if (!DoorLockServer::Instance().GetNumberOfYearDaySchedulesPerUserSupported(endpointId, numberOfYearDaySchedulesPerUser)) - { - ChipLogError(Zcl, - "Unable to get number of supported year day schedules per user when initializing lock endpoint, defaulting to " - "10 [endpointId=%d]", - endpointId); - numberOfYearDaySchedulesPerUser = CHIP_LOCK_MANAGER_YEAR_DAY_SCHEDULES_PER_USER_NUMBER; - } - - mEndpoints.emplace_back(endpointId, numberOfSupportedUsers, numberOfSupportedCredentials, numberOfWeekDaySchedulesPerUser, - numberOfYearDaySchedulesPerUser, numberOfCredentialsSupportedPerUser); - - ChipLogProgress(Zcl, - "Initialized new lock door endpoint " - "[id=%d,users=%d,credentials=%d,weekDaySchedulesPerUser=%d,yearDaySchedulesPerUser=%d," - "numberOfCredentialsSupportedPerUser=%d]", - endpointId, numberOfSupportedUsers, numberOfSupportedCredentials, numberOfWeekDaySchedulesPerUser, - numberOfYearDaySchedulesPerUser, numberOfCredentialsSupportedPerUser); - - return true; -} - -bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to lock the door - endpoint does not exist or not initialized [endpointId=%d]", endpointId); - return false; - } - - VerifyOrReturnValue(lockEndpoint->Lock(pin, err), false); - - return DoorLockServer::Instance().SetLockState(endpointId, DlLockState::kLocked); -} - -bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to unlock the door - endpoint does not exist or not initialized [endpointId=%d]", endpointId); - return false; - } - - VerifyOrReturnValue(lockEndpoint->Unlock(pin, err), false); - - return DoorLockServer::Instance().SetLockState(endpointId, DlLockState::kUnlocked); -} - -bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to get the user - endpoint does not exist or not initialized [endpointId=%d]", endpointId); - return false; - } - return lockEndpoint->GetUser(userIndex, user); -} - -bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, - CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to set the user - endpoint does not exist or not initialized [endpointId=%d]", endpointId); - return false; - } - return lockEndpoint->SetUser(userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, - credentials, totalCredentials); -} - -bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, - EmberAfPluginDoorLockCredentialInfo & credential) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to get the credential - endpoint does not exist or not initialized [endpointId=%d]", endpointId); - return false; - } - return lockEndpoint->GetCredential(credentialIndex, credentialType, credential); -} - -bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, - const chip::ByteSpan & credentialData) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to set the credential - endpoint does not exist or not initialized [endpointId=%d]", endpointId); - return false; - } - return lockEndpoint->SetCredential(credentialIndex, creator, modifier, credentialStatus, credentialType, credentialData); -} - -DlStatus LockManager::GetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockWeekDaySchedule & schedule) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to get the week day schedule - endpoint does not exist or not initialized [endpointId=%d]", - endpointId); - return DlStatus::kFailure; - } - return lockEndpoint->GetSchedule(weekDayIndex, userIndex, schedule); -} - -DlStatus LockManager::SetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, - DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to set the week day schedule - endpoint does not exist or not initialized [endpointId=%d]", - endpointId); - return DlStatus::kFailure; - } - return lockEndpoint->SetSchedule(weekDayIndex, userIndex, status, daysMask, startHour, startMinute, endHour, endMinute); -} - -DlStatus LockManager::GetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockYearDaySchedule & schedule) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to get the year day schedule - endpoint does not exist or not initialized [endpointId=%d]", - endpointId); - return DlStatus::kFailure; - } - return lockEndpoint->GetSchedule(yearDayIndex, userIndex, schedule); -} - -DlStatus LockManager::SetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to set the year day schedule - endpoint does not exist or not initialized [endpointId=%d]", - endpointId); - return DlStatus::kFailure; - } - return lockEndpoint->SetSchedule(yearDayIndex, userIndex, status, localStartTime, localEndTime); -} - -LockEndpoint * LockManager::getEndpoint(chip::EndpointId endpointId) -{ - for (auto & mEndpoint : mEndpoints) - { - if (mEndpoint.GetEndpointId() == endpointId) - { - return &mEndpoint; - } - } - return nullptr; -} diff --git a/examples/lock-app/openiotsdk/main/ZclCallbacks.cpp b/examples/lock-app/openiotsdk/main/ZclCallbacks.cpp deleted file mode 100644 index 0ebcf686bbebcc..00000000000000 --- a/examples/lock-app/openiotsdk/main/ZclCallbacks.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * Copyright (c) 2020-2021 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "LockManager.h" - -using namespace chip; -using namespace chip::app::Clusters; -using namespace chip::app::Clusters::DoorLock; - -bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, - OperationErrorEnum & err) -{ - return LockManager::Instance().Lock(endpointId, pinCode, err); -} - -bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional & pinCode, - OperationErrorEnum & err) -{ - return LockManager::Instance().Unlock(endpointId, pinCode, err); -} - -bool emberAfPluginDoorLockGetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) -{ - return LockManager::Instance().GetUser(endpointId, userIndex, user); -} - -bool emberAfPluginDoorLockSetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, const chip::CharSpan & userName, uint32_t uniqueId, - UserStatusEnum userStatus, UserTypeEnum usertype, CredentialRuleEnum credentialRule, - const CredentialStruct * credentials, size_t totalCredentials) -{ - - return LockManager::Instance().SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, - credentialRule, credentials, totalCredentials); -} - -bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, - EmberAfPluginDoorLockCredentialInfo & credential) -{ - return LockManager::Instance().GetCredential(endpointId, credentialIndex, credentialType, credential); -} - -bool emberAfPluginDoorLockSetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, DlCredentialStatus credentialStatus, - CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) -{ - return LockManager::Instance().SetCredential(endpointId, credentialIndex, creator, modifier, credentialStatus, credentialType, - credentialData); -} - -DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - EmberAfPluginDoorLockWeekDaySchedule & schedule) -{ - return LockManager::Instance().GetSchedule(endpointId, weekdayIndex, userIndex, schedule); -} - -DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, - uint8_t endHour, uint8_t endMinute) -{ - return LockManager::Instance().SetSchedule(endpointId, weekdayIndex, userIndex, status, daysMask, startHour, startMinute, - endHour, endMinute); -} - -DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - DlScheduleStatus status, uint32_t localStartTime, uint32_t localEndTime) -{ - return LockManager::Instance().SetSchedule(endpointId, yearDayIndex, userIndex, status, localStartTime, localEndTime); -} - -DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockYearDaySchedule & schedule) -{ - return LockManager::Instance().GetSchedule(endpointId, yearDayIndex, userIndex, schedule); -} - -void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, - uint8_t * value) -{ - VerifyOrReturn(attributePath.mClusterId == DoorLock::Id && attributePath.mAttributeId == DoorLock::Attributes::LockState::Id); - - emberAfDoorLockClusterPrintln("Door Lock attribute changed"); -} - -void emberAfDoorLockClusterInitCallback(EndpointId endpoint) -{ - DoorLockServer::Instance().InitServer(endpoint); - LockManager::Instance().InitEndpoint(endpoint); -} diff --git a/examples/lock-app/openiotsdk/main/include/LockEndpoint.h b/examples/lock-app/openiotsdk/main/include/LockEndpoint.h deleted file mode 100644 index 069ab270707f1f..00000000000000 --- a/examples/lock-app/openiotsdk/main/include/LockEndpoint.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include - -struct LockUserInfo -{ - char userName[DOOR_LOCK_USER_NAME_BUFFER_SIZE]; - uint32_t userUniqueId; - UserStatusEnum userStatus; - UserTypeEnum userType; - CredentialRuleEnum credentialRule; - std::vector credentials; - chip::FabricIndex createdBy; - chip::FabricIndex lastModifiedBy; -}; - -struct LockCredentialInfo; -struct WeekDaysScheduleInfo; -struct YearDayScheduleInfo; - -static constexpr size_t DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE = 20; - -class LockEndpoint -{ -public: - LockEndpoint(chip::EndpointId endpointId, uint16_t numberOfLockUsersSupported, uint16_t numberOfCredentialsSupported, - uint8_t weekDaySchedulesPerUser, uint8_t yearDaySchedulesPerUser, uint8_t numberOfCredentialsPerUser) : - mEndpointId{ endpointId }, - mLockState{ DlLockState::kLocked }, mLockUsers(numberOfLockUsersSupported), - mLockCredentials(numberOfCredentialsSupported + 1), - mWeekDaySchedules(numberOfLockUsersSupported, std::vector(weekDaySchedulesPerUser)), - mYearDaySchedules(numberOfLockUsersSupported, std::vector(yearDaySchedulesPerUser)) - { - for (auto & lockUser : mLockUsers) - { - lockUser.credentials.reserve(numberOfCredentialsPerUser); - } - } - - inline chip::EndpointId GetEndpointId() const { return mEndpointId; } - - bool Lock(const Optional & pin, OperationErrorEnum & err); - bool Unlock(const Optional & pin, OperationErrorEnum & err); - - bool GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) const; - bool SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, - uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, CredentialRuleEnum credentialRule, - const CredentialStruct * credentials, size_t totalCredentials); - - bool GetCredential(uint16_t credentialIndex, CredentialTypeEnum credentialType, - EmberAfPluginDoorLockCredentialInfo & credential) const; - - bool SetCredential(uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, - const chip::ByteSpan & credentialData); - - DlStatus GetSchedule(uint8_t weekDayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule); - DlStatus GetSchedule(uint8_t yearDayIndex, uint16_t userIndex, EmberAfPluginDoorLockYearDaySchedule & schedule); - DlStatus SetSchedule(uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, - uint8_t startMinute, uint8_t endHour, uint8_t endMinute); - DlStatus SetSchedule(uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, uint32_t localStartTime, - uint32_t localEndTime); - -private: - bool setLockState(DlLockState lockState, const Optional & pin, OperationErrorEnum & err); - const char * lockStateToString(DlLockState lockState) const; - - chip::EndpointId mEndpointId; - DlLockState mLockState; - - // This is very naive implementation of users/credentials/schedules database and by no means the best practice. Proper storage - // of those items is out of scope of this example. - std::vector mLockUsers; - std::vector mLockCredentials; - std::vector> mWeekDaySchedules; - std::vector> mYearDaySchedules; -}; - -struct LockCredentialInfo -{ - DlCredentialStatus status; - CredentialTypeEnum credentialType; - chip::FabricIndex createdBy; - chip::FabricIndex modifiedBy; - uint8_t credentialData[DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE]; - size_t credentialDataSize; -}; - -struct WeekDaysScheduleInfo -{ - DlScheduleStatus status; - EmberAfPluginDoorLockWeekDaySchedule schedule; -}; - -struct YearDayScheduleInfo -{ - DlScheduleStatus status; - EmberAfPluginDoorLockYearDaySchedule schedule; -}; diff --git a/examples/lock-app/openiotsdk/main/include/LockManager.h b/examples/lock-app/openiotsdk/main/include/LockManager.h deleted file mode 100644 index 349fee22adee8a..00000000000000 --- a/examples/lock-app/openiotsdk/main/include/LockManager.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include -#include - -#include - -class LockManager -{ -public: - LockManager() {} - - bool InitEndpoint(chip::EndpointId endpointId); - - bool Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); - bool Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); - - bool GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user); - bool SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, - CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials); - - bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, - EmberAfPluginDoorLockCredentialInfo & credential); - - bool SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, - const chip::ByteSpan & credentialData); - - DlStatus GetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockWeekDaySchedule & schedule); - DlStatus GetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockYearDaySchedule & schedule); - DlStatus SetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, - DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); - DlStatus SetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime); - - static LockManager & Instance(); - -private: - LockEndpoint * getEndpoint(chip::EndpointId endpointId); - - std::vector mEndpoints; - - static LockManager instance; -}; diff --git a/src/test_driver/openiotsdk/integration-tests/lock-app/test_app.py b/src/test_driver/openiotsdk/integration-tests/lock-app/test_app.py index b2fc33ef64ffff..72ff8fdd78d8c1 100644 --- a/src/test_driver/openiotsdk/integration-tests/lock-app/test_app.py +++ b/src/test_driver/openiotsdk/integration-tests/lock-app/test_app.py @@ -154,7 +154,7 @@ def test_lock_ctrl(device, controller): LOCK_CTRL_TEST_PIN_CODE), requestTimeoutMs=1000) assert err == 0 - ret = device.wait_for_output("Setting door lock state to \"Locked\" [endpointId={}]".format(LOCK_CTRL_TEST_ENDPOINT_ID)) + ret = device.wait_for_output("setting door lock state to \"Locked\"") assert ret is not None and len(ret) > 0 err, res = read_zcl_attribute( @@ -167,7 +167,7 @@ def test_lock_ctrl(device, controller): LOCK_CTRL_TEST_PIN_CODE), requestTimeoutMs=1000) assert err == 0 - ret = device.wait_for_output("Setting door lock state to \"Unlocked\" [endpointId={}]".format(LOCK_CTRL_TEST_ENDPOINT_ID)) + ret = device.wait_for_output("setting door lock state to \"Unlocked\"") assert ret is not None and len(ret) > 0 err, res = read_zcl_attribute( From 5a684771b3b5031b79bd1fb915028fe3b067c117 Mon Sep 17 00:00:00 2001 From: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com> Date: Thu, 27 Apr 2023 20:41:06 +0530 Subject: [PATCH 042/200] adding lock and unlock for window app (#26276) --- examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp | 2 ++ examples/window-app/silabs/efr32/src/WindowAppImpl.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp b/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp index 2d65b5a2117451..f260d858412a47 100644 --- a/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp +++ b/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp @@ -167,7 +167,9 @@ void WindowAppImpl::OnTaskCallback(void * parameter) } SILABS_LOG("APP: Done WiFi Init"); /* We will init server when we get IP */ + chip::DeviceLayer::PlatformMgr().LockChipStack(); sWiFiNetworkCommissioningInstance.Init(); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); /* added for commissioning with wifi */ #endif diff --git a/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp b/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp index 734a4b4bc5d1a3..e2032125538076 100644 --- a/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp +++ b/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp @@ -168,7 +168,9 @@ void WindowAppImpl::OnTaskCallback(void * parameter) } SILABS_LOG("APP: Done WiFi Init"); /* We will init server when we get IP */ + chip::DeviceLayer::PlatformMgr().LockChipStack(); sWiFiNetworkCommissioningInstance.Init(); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); /* added for commisioning with wifi */ #endif From 636cb29b36e5542a3706bb59b468547c13da72fa Mon Sep 17 00:00:00 2001 From: Timothy Maes Date: Thu, 27 Apr 2023 22:10:54 +0200 Subject: [PATCH 043/200] Use SOFTWARE_UDPATE_IGNORED error iso UNSUPPORTED_EXCHANGE_VERSION (#26261) --- docs/ERROR_CODES.md | 1 - src/lib/core/CHIPError.cpp | 3 --- src/lib/core/CHIPError.h | 9 +-------- src/lib/core/tests/TestCHIPErrorStr.cpp | 1 - src/platform/qpg/OTAImageProcessorImpl.cpp | 3 ++- 5 files changed, 3 insertions(+), 14 deletions(-) diff --git a/docs/ERROR_CODES.md b/docs/ERROR_CODES.md index 03bf49fe4b3ccb..d4fd79ed0466c7 100644 --- a/docs/ERROR_CODES.md +++ b/docs/ERROR_CODES.md @@ -21,7 +21,6 @@ This file was **AUTOMATICALLY** generated by | 2 | 0x02 | `CHIP_ERROR_CONNECTION_ABORTED` | | 3 | 0x03 | `CHIP_ERROR_INCORRECT_STATE` | | 4 | 0x04 | `CHIP_ERROR_MESSAGE_TOO_LONG` | -| 5 | 0x05 | `CHIP_ERROR_UNSUPPORTED_EXCHANGE_VERSION` | | 6 | 0x06 | `CHIP_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS` | | 7 | 0x07 | `CHIP_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER` | | 8 | 0x08 | `CHIP_ERROR_NO_CONNECTION_HANDLER` | diff --git a/src/lib/core/CHIPError.cpp b/src/lib/core/CHIPError.cpp index e6985efc890146..53f9b7260f530f 100644 --- a/src/lib/core/CHIPError.cpp +++ b/src/lib/core/CHIPError.cpp @@ -74,9 +74,6 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err) case CHIP_ERROR_MESSAGE_TOO_LONG.AsInteger(): desc = "Message too long"; break; - case CHIP_ERROR_UNSUPPORTED_EXCHANGE_VERSION.AsInteger(): - desc = "Unsupported exchange version"; - break; case CHIP_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS.AsInteger(): desc = "Too many unsolicited message handlers"; break; diff --git a/src/lib/core/CHIPError.h b/src/lib/core/CHIPError.h index fbc6ba4e88d8c1..e91229e4b3f799 100644 --- a/src/lib/core/CHIPError.h +++ b/src/lib/core/CHIPError.h @@ -466,14 +466,7 @@ using CHIP_ERROR = ::chip::ChipError; */ #define CHIP_ERROR_MESSAGE_TOO_LONG CHIP_CORE_ERROR(0x04) -/** - * @def CHIP_ERROR_UNSUPPORTED_EXCHANGE_VERSION - * - * @brief - * An exchange version is not supported. - * - */ -#define CHIP_ERROR_UNSUPPORTED_EXCHANGE_VERSION CHIP_CORE_ERROR(0x05) +// AVAILABLE: 0x05 /** * @def CHIP_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS diff --git a/src/lib/core/tests/TestCHIPErrorStr.cpp b/src/lib/core/tests/TestCHIPErrorStr.cpp index b5fabd64afe145..bb7d368b9e63cd 100644 --- a/src/lib/core/tests/TestCHIPErrorStr.cpp +++ b/src/lib/core/tests/TestCHIPErrorStr.cpp @@ -53,7 +53,6 @@ static const CHIP_ERROR kTestElements[] = CHIP_ERROR_CONNECTION_ABORTED, CHIP_ERROR_INCORRECT_STATE, CHIP_ERROR_MESSAGE_TOO_LONG, - CHIP_ERROR_UNSUPPORTED_EXCHANGE_VERSION, CHIP_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS, CHIP_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER, CHIP_ERROR_NO_CONNECTION_HANDLER, diff --git a/src/platform/qpg/OTAImageProcessorImpl.cpp b/src/platform/qpg/OTAImageProcessorImpl.cpp index 3a1191b930313c..dea726280dc9b1 100644 --- a/src/platform/qpg/OTAImageProcessorImpl.cpp +++ b/src/platform/qpg/OTAImageProcessorImpl.cpp @@ -94,7 +94,8 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessHeader(ByteSpan & block) if (true != qvCHIP_OtaValidateImage(qvCHIP_OtaImgHeader)) { - return CHIP_ERROR_UNSUPPORTED_EXCHANGE_VERSION; + // Dropping image due to invalid header + return CHIP_DEVICE_ERROR_SOFTWARE_UPDATE_IGNORED; } } From 88ed6bd0a190dd16317f9dbb453fb6e4bb5ef861 Mon Sep 17 00:00:00 2001 From: eric-ocasio-nxp <49490515+eric-ocasio-nxp@users.noreply.github.com> Date: Thu, 27 Apr 2023 15:12:35 -0500 Subject: [PATCH 044/200] ModeSelect: Gate inclusion of on-off-server.h based on whether an on-off cluster is present in the app (#26263) * Gate inclusion of on-off-server.h based on whether an on-off cluster is present in the application. Build fails when no on-off cluster is present. * Need to move the gate so that it's after #include so that the macro gating macro is defined. It seems the headers includes have changed between the version of the file I was using (compnay-internal fork) and the one in master. --- src/app/clusters/mode-select-server/mode-select-server.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/clusters/mode-select-server/mode-select-server.cpp b/src/app/clusters/mode-select-server/mode-select-server.cpp index fdb19152f1473f..f4aac43abedb25 100644 --- a/src/app/clusters/mode-select-server/mode-select-server.cpp +++ b/src/app/clusters/mode-select-server/mode-select-server.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -34,6 +33,10 @@ #include #include +#ifdef EMBER_AF_PLUGIN_ON_OFF +#include +#endif // EMBER_AF_PLUGIN_ON_OFF + using namespace std; using namespace chip; using namespace chip::app; From 617c06256456c15c05073b7c4469e79463237e25 Mon Sep 17 00:00:00 2001 From: Marc Lepage <67919234+mlepage-google@users.noreply.github.com> Date: Thu, 27 Apr 2023 16:44:29 -0400 Subject: [PATCH 045/200] Async send sigma3 (#25695) * Break CASESession::SendSigma3 into fg/bg parts This unblocks the main event loop while performance intensive (e.g. crypto) parts of the process occur. * Fix host tests * Remove temp log statements * Restyle * Refactor CASESession::SendSigma3 Add more structure to manage multiple steps of work. * Remove temporary logging * Restyle * Minor cleanup * Minor cleanup * Restyle * Use Platform::SharedPtr Also add alias template for Platform::WeakPtr. * Add mutex to FabricTable This supports locking during SignWithOpKeypair, and other operations that may alter state in the fabric table, while CASESession is performing work in the background during session establishment. CASESession registers as a fabric table listener, and when a fabric is removed (e.g. timeout) it attempts to cancel any outstanding work, and also clears out the fabric index in the work helper data. Therefore, if outstanding work has made it into SignWithOpKeypair, it should be OK until complete. It still relies on other tasks not altering FabricInfo, or the configured OperationalKeystore, but that would have had to have been true before anyways. The mutex was not made recursive. It's omitted from a few functions, which should be OK for now, and there should be cleanup on a subsequent commit (and probably fix up const-ness of member functions, and factoring of API vs. impl functions). This commit is to flush out build/test errors on all CI platforms, and to discuss/review/comment on the general approach. * Remove mutex, only async sometimes It's tricky to async background the signing operation, because of the two ways operational signing occurs. Legacy way: opkeypair manually added for fabric info Recommended way: opkeystore handles everything Removed std::mutex because it wasn't supported by all platforms. Instead, made background signing occur only if using the operational keystore (recommended way), since implementors can perform any needed mutual exclusion in the operational keystore. If using manually added operational keypairs (legacy way), keep signing in the foreground, since it's not feasible to mutex the entire fabric table and typically the operations is simpler anyways. * Clean up error handling * Restyle * Only store data.fabricTable if fg case Store only one of data.fabricTable or data.keystore. * Declare wither signing in background is supported OperationalKeystore declares whether it supports this capability. If so, then CASE session establishment may take advantage of it. If not, then CASE session establishment must use foreground. * Make some variables const * Clean up a few comments --- src/credentials/FabricTable.h | 8 + src/crypto/OperationalKeystore.h | 14 +- src/lib/support/CHIPMem.h | 3 + src/protocols/secure_channel/CASESession.cpp | 420 ++++++++++++++---- src/protocols/secure_channel/CASESession.h | 40 +- .../secure_channel/tests/TestCASESession.cpp | 18 +- 6 files changed, 385 insertions(+), 118 deletions(-) diff --git a/src/credentials/FabricTable.h b/src/credentials/FabricTable.h index 42f88024b877c6..1b01e1f4fd4a4f 100644 --- a/src/credentials/FabricTable.h +++ b/src/credentials/FabricTable.h @@ -717,6 +717,14 @@ class DLL_EXPORT FabricTable */ bool HasOperationalKeyForFabric(FabricIndex fabricIndex) const; + /** + * @brief Returns the operational keystore. This is used for + * CASE and the only way the keystore should be used. + * + * @return The operational keystore, nullptr otherwise. + */ + const Crypto::OperationalKeystore * GetOperationalKeystore() { return mOperationalKeystore; } + /** * @brief Add a pending trusted root certificate for the next fabric created with `AddNewPendingFabric*` methods. * diff --git a/src/crypto/OperationalKeystore.h b/src/crypto/OperationalKeystore.h index bfa846b9d1a8be..6af92629174810 100644 --- a/src/crypto/OperationalKeystore.h +++ b/src/crypto/OperationalKeystore.h @@ -148,6 +148,19 @@ class OperationalKeystore virtual void RevertPendingKeypair() = 0; // ==== Primary operation required: signature + /** + * @brief Whether `SignWithOpKeypair` may be performed in the background. + * + * If true, `CASESession` may attempt to perform `SignWithOpKeypair` in the + * background. In this case, `OperationalKeystore` should protect itself, + * e.g. with a mutex, as the signing could occur at any time during session + * establishment. + * + * @retval true if `SignWithOpKeypair` may be performed in the background + * @retval false if `SignWithOpKeypair` may NOT be performed in the background + */ + virtual bool SupportsSignWithOpKeypairInBackground() const { return false; } + /** * @brief Sign a message with a fabric's currently-active operational keypair. * @@ -164,7 +177,6 @@ class OperationalKeystore * @retval CHIP_ERROR_INVALID_FABRIC_INDEX if no active key is found for the given `fabricIndex` or if * `fabricIndex` is invalid. * @retval other CHIP_ERROR value on internal crypto engine errors - * */ virtual CHIP_ERROR SignWithOpKeypair(FabricIndex fabricIndex, const ByteSpan & message, Crypto::P256ECDSASignature & outSignature) const = 0; diff --git a/src/lib/support/CHIPMem.h b/src/lib/support/CHIPMem.h index a1e27c20b73ce3..b4b78aca647e3a 100644 --- a/src/lib/support/CHIPMem.h +++ b/src/lib/support/CHIPMem.h @@ -193,6 +193,9 @@ inline SharedPtr MakeShared(Args &&... args) return SharedPtr(New(std::forward(args)...), Deleter()); } +template +using WeakPtr = std::weak_ptr; + // See MemoryDebugCheckPointer(). extern bool MemoryInternalCheckPointer(const void * p, size_t min_size); diff --git a/src/protocols/secure_channel/CASESession.cpp b/src/protocols/secure_channel/CASESession.cpp index 1abd1f1b1e9e6b..20b3567cb5d74b 100644 --- a/src/protocols/secure_channel/CASESession.cpp +++ b/src/protocols/secure_channel/CASESession.cpp @@ -25,7 +25,9 @@ */ #include +#include #include +#include #include #include @@ -41,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -129,6 +132,185 @@ static constexpr ExchangeContext::Timeout kExpectedLowProcessingTime = System static constexpr ExchangeContext::Timeout kExpectedSigma1ProcessingTime = kExpectedLowProcessingTime; static constexpr ExchangeContext::Timeout kExpectedHighProcessingTime = System::Clock::Seconds16(30); +// Helper for managing a session's outstanding work. +// Holds work data which is provided to a scheduled work callback (standalone), +// then (if not canceled) to a scheduled after work callback (on the session). +template +class CASESession::WorkHelper +{ +public: + // Work callback, processed in the background via `PlatformManager::ScheduleBackgroundWork`. + // This is a non-member function which does not use the associated session. + // The return value is passed to the after work callback (called afterward). + // Set `cancel` to true if calling the after work callback is not necessary. + typedef CHIP_ERROR (*WorkCallback)(DATA & data, bool & cancel); + + // After work callback, processed in the main Matter task via `PlatformManager::ScheduleWork`. + // This is a member function to be called on the associated session after the work callback. + // The `status` value is the result of the work callback (called beforehand). + typedef CHIP_ERROR (CASESession::*AfterWorkCallback)(DATA & data, CHIP_ERROR status); + + // Create a work helper using the specified session, work callback, after work callback, and data (template arg). + // Lifetime is not managed, see `Create` for that option. + WorkHelper(CASESession & session, WorkCallback workCallback, AfterWorkCallback afterWorkCallback) : + mSession(&session), mWorkCallback(workCallback), mAfterWorkCallback(afterWorkCallback) + {} + + // Create a work helper using the specified session, work callback, after work callback, and data (template arg). + // Lifetime is managed by sharing between the caller (typically the session) and the helper itself (while work is scheduled). + static Platform::SharedPtr Create(CASESession & session, WorkCallback workCallback, + AfterWorkCallback afterWorkCallback) + { + auto ptr = Platform::MakeShared(session, workCallback, afterWorkCallback); + if (ptr) + { + ptr->mWeakPtr = ptr; // used by `ScheduleWork` + } + return ptr; + } + + // Do the work immediately. + // No scheduling, no outstanding work, no shared lifetime management. + CHIP_ERROR DoWork() + { + if (!mSession || !mWorkCallback || !mAfterWorkCallback) + { + return CHIP_ERROR_INCORRECT_STATE; + } + WorkHelper * helper = this; + bool cancel = false; + helper->mStatus = helper->mWorkCallback(helper->mData, cancel); + if (!cancel) + { + helper->mStatus = (helper->mSession->*(helper->mAfterWorkCallback))(helper->mData, helper->mStatus); + } + return helper->mStatus; + } + + // Schedule the work after configuring the data. + // If lifetime is managed, the helper shares management while work is outstanding. + CHIP_ERROR ScheduleWork() + { + if (!mSession || !mWorkCallback || !mAfterWorkCallback) + { + return CHIP_ERROR_INCORRECT_STATE; + } + mStrongPtr = mWeakPtr.lock(); // set in `Create` + auto status = DeviceLayer::PlatformMgr().ScheduleBackgroundWork(WorkHandler, reinterpret_cast(this)); + if (status != CHIP_NO_ERROR) + { + mStrongPtr.reset(); + } + return status; + } + + // Cancel the work, by clearing the associated session. + void CancelWork() { mSession.store(nullptr); } + +private: + // Handler for the work callback. + static void WorkHandler(intptr_t arg) + { + WorkHelper * helper = reinterpret_cast(arg); + bool cancel = false; + VerifyOrExit(helper->mSession.load(), ;); // cancelled by `CancelWork`? + helper->mStatus = helper->mWorkCallback(helper->mData, cancel); + VerifyOrExit(!cancel, ;); // canceled by `mWorkCallback`? + VerifyOrExit(helper->mSession.load(), ;); // cancelled by `CancelWork`? + SuccessOrExit(DeviceLayer::PlatformMgr().ScheduleWork(AfterWorkHandler, reinterpret_cast(helper))); + return; + exit: + helper->mStrongPtr.reset(); + } + + // Handler for the after work callback. + static void AfterWorkHandler(intptr_t arg) + { + // Since this runs in the main Matter thread, the session shouldn't be otherwise used (messages, timers, etc.) + WorkHelper * helper = reinterpret_cast(arg); + if (auto * session = helper->mSession.load()) + { + (session->*(helper->mAfterWorkCallback))(helper->mData, helper->mStatus); + } + helper->mStrongPtr.reset(); + } + +private: + // Lifetime management: `ScheduleWork` sets `mStrongPtr` from `mWeakPtr`. + Platform::WeakPtr mWeakPtr; + + // Lifetime management: `ScheduleWork` sets `mStrongPtr` from `mWeakPtr`. + Platform::SharedPtr mStrongPtr; + + // Associated session, cleared by `CancelWork`. + std::atomic mSession; + + // Work callback, called by `WorkHandler`. + WorkCallback mWorkCallback; + + // After work callback, called by `AfterWorkHandler`. + AfterWorkCallback mAfterWorkCallback; + + // Return value of `mWorkCallback`, passed to `mAfterWorkCallback`. + CHIP_ERROR mStatus; + +public: + // Data passed to `mWorkCallback` and `mAfterWorkCallback`. + DATA mData; +}; + +struct CASESession::SendSigma3Data +{ + std::atomic fabricIndex; + + // Use one or the other + const FabricTable * fabricTable; + const Crypto::OperationalKeystore * keystore; + + chip::Platform::ScopedMemoryBuffer msg_R3_Signed; + size_t msg_r3_signed_len; + + chip::Platform::ScopedMemoryBuffer msg_R3_Encrypted; + size_t msg_r3_encrypted_len; + + chip::Platform::ScopedMemoryBuffer icacBuf; + MutableByteSpan icaCert; + + chip::Platform::ScopedMemoryBuffer nocBuf; + MutableByteSpan nocCert; + + P256ECDSASignature tbsData3Signature; +}; + +struct CASESession::HandleSigma3Work +{ + // Status of background processing. + CHIP_ERROR status; + + // Session to use after background processing. + CASESession * session; + + // Sequence number used to coordinate foreground/background work for a + // particular session establishment. + int sequence; + + chip::Platform::ScopedMemoryBuffer msg_R3_Signed; + size_t msg_r3_signed_len; + + ByteSpan initiatorNOC; + ByteSpan initiatorICAC; + + uint8_t rootCertBuf[kMaxCHIPCertLength]; + ByteSpan fabricRCAC; + + P256ECDSASignature tbsData3Signature; + + FabricId fabricId; + NodeId initiatorNodeId; + + ValidationContext validContext; +}; + CASESession::~CASESession() { // Let's clear out any security state stored in the object, before destroying it. @@ -144,6 +326,14 @@ void CASESession::OnSessionReleased() void CASESession::Clear() { + // Cancel any outstanding work. + if (mSendSigma3Helper) + { + mSendSigma3Helper->mData.fabricIndex = kUndefinedFabricIndex; + mSendSigma3Helper->CancelWork(); + mSendSigma3Helper.reset(); + } + // This function zeroes out and resets the memory used by the object. // It's done so that no security related information will be leaked. mCommissioningHash.Clear(); @@ -925,7 +1115,7 @@ CHIP_ERROR CASESession::HandleSigma2_and_SendSigma3(System::PacketBufferHandle & { MATTER_TRACE_EVENT_SCOPE("HandleSigma2_and_SendSigma3", "CASESession"); ReturnErrorOnFailure(HandleSigma2(std::move(msg))); - ReturnErrorOnFailure(SendSigma3()); + ReturnErrorOnFailure(SendSigma3a()); return CHIP_NO_ERROR; } @@ -1099,92 +1289,156 @@ CHIP_ERROR CASESession::HandleSigma2(System::PacketBufferHandle && msg) return err; } -CHIP_ERROR CASESession::SendSigma3() +CHIP_ERROR CASESession::SendSigma3a() { MATTER_TRACE_EVENT_SCOPE("SendSigma3", "CASESession"); CHIP_ERROR err = CHIP_NO_ERROR; - MutableByteSpan messageDigestSpan(mMessageDigest); - System::PacketBufferHandle msg_R3; - size_t data_len; - - chip::Platform::ScopedMemoryBuffer msg_R3_Encrypted; - size_t msg_r3_encrypted_len; + ChipLogDetail(SecureChannel, "Sending Sigma3"); - uint8_t msg_salt[kIPKSize + kSHA256_Hash_Length]; + auto helper = WorkHelper::Create(*this, &SendSigma3b, &CASESession::SendSigma3c); + VerifyOrExit(helper, err = CHIP_ERROR_NO_MEMORY); + { + auto & data = helper->mData; - AutoReleaseSessionKey sr3k(*mSessionManager->GetSessionKeystore()); + VerifyOrExit(mFabricsTable != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + data.fabricIndex = mFabricIndex; + data.fabricTable = nullptr; + data.keystore = nullptr; - chip::Platform::ScopedMemoryBuffer msg_R3_Signed; - size_t msg_r3_signed_len; + { + const FabricInfo * fabricInfo = mFabricsTable->FindFabricWithIndex(mFabricIndex); + VerifyOrExit(fabricInfo != nullptr, err = CHIP_ERROR_KEY_NOT_FOUND); + auto * keystore = mFabricsTable->GetOperationalKeystore(); + if (!fabricInfo->HasOperationalKey() && keystore != nullptr && keystore->SupportsSignWithOpKeypairInBackground()) + { + // NOTE: used to sign in background. + data.keystore = keystore; + } + else + { + // NOTE: used to sign in foreground. + data.fabricTable = mFabricsTable; + } + } - P256ECDSASignature tbsData3Signature; + VerifyOrExit(mEphemeralKey != nullptr, err = CHIP_ERROR_INTERNAL); - chip::Platform::ScopedMemoryBuffer icacBuf; - MutableByteSpan icaCert; + VerifyOrExit(data.icacBuf.Alloc(kMaxCHIPCertLength), err = CHIP_ERROR_NO_MEMORY); + data.icaCert = MutableByteSpan{ data.icacBuf.Get(), kMaxCHIPCertLength }; - chip::Platform::ScopedMemoryBuffer nocBuf; - MutableByteSpan nocCert; + VerifyOrExit(data.nocBuf.Alloc(kMaxCHIPCertLength), err = CHIP_ERROR_NO_MEMORY); + data.nocCert = MutableByteSpan{ data.nocBuf.Get(), kMaxCHIPCertLength }; - ChipLogDetail(SecureChannel, "Sending Sigma3"); + SuccessOrExit(err = mFabricsTable->FetchICACert(mFabricIndex, data.icaCert)); + SuccessOrExit(err = mFabricsTable->FetchNOCCert(mFabricIndex, data.nocCert)); - VerifyOrExit(mEphemeralKey != nullptr, err = CHIP_ERROR_INTERNAL); - VerifyOrExit(icacBuf.Alloc(kMaxCHIPCertLength), err = CHIP_ERROR_NO_MEMORY); - icaCert = MutableByteSpan{ icacBuf.Get(), kMaxCHIPCertLength }; + // Prepare Sigma3 TBS Data Blob + data.msg_r3_signed_len = + TLV::EstimateStructOverhead(data.icaCert.size(), data.nocCert.size(), kP256_PublicKey_Length, kP256_PublicKey_Length); - VerifyOrExit(nocBuf.Alloc(kMaxCHIPCertLength), err = CHIP_ERROR_NO_MEMORY); - nocCert = MutableByteSpan{ nocBuf.Get(), kMaxCHIPCertLength }; + VerifyOrExit(data.msg_R3_Signed.Alloc(data.msg_r3_signed_len), err = CHIP_ERROR_NO_MEMORY); - VerifyOrExit(mFabricsTable != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + SuccessOrExit(err = ConstructTBSData( + data.nocCert, data.icaCert, ByteSpan(mEphemeralKey->Pubkey(), mEphemeralKey->Pubkey().Length()), + ByteSpan(mRemotePubKey, mRemotePubKey.Length()), data.msg_R3_Signed.Get(), data.msg_r3_signed_len)); - SuccessOrExit(err = mFabricsTable->FetchICACert(mFabricIndex, icaCert)); - SuccessOrExit(err = mFabricsTable->FetchNOCCert(mFabricIndex, nocCert)); + if (data.keystore != nullptr) + { + SuccessOrExit(err = helper->ScheduleWork()); + mSendSigma3Helper = helper; + mExchangeCtxt->WillSendMessage(); + mState = State::kSendSigma3Pending; + } + else + { + SuccessOrExit(err = helper->DoWork()); + } + } - // Prepare Sigma3 TBS Data Blob - msg_r3_signed_len = TLV::EstimateStructOverhead(icaCert.size(), nocCert.size(), kP256_PublicKey_Length, kP256_PublicKey_Length); +exit: + if (err != CHIP_NO_ERROR) + { + SendStatusReport(mExchangeCtxt, kProtocolCodeInvalidParam); + mState = State::kInitialized; + } - VerifyOrExit(msg_R3_Signed.Alloc(msg_r3_signed_len), err = CHIP_ERROR_NO_MEMORY); + return err; +} - SuccessOrExit(err = ConstructTBSData(nocCert, icaCert, ByteSpan(mEphemeralKey->Pubkey(), mEphemeralKey->Pubkey().Length()), - ByteSpan(mRemotePubKey, mRemotePubKey.Length()), msg_R3_Signed.Get(), msg_r3_signed_len)); +CHIP_ERROR CASESession::SendSigma3b(SendSigma3Data & data, bool & cancel) +{ + CHIP_ERROR err = CHIP_NO_ERROR; // Generate a signature - err = mFabricsTable->SignWithOpKeypair(mFabricIndex, ByteSpan{ msg_R3_Signed.Get(), msg_r3_signed_len }, tbsData3Signature); + if (data.keystore != nullptr) + { + // Recommended case: delegate to operational keystore + err = data.keystore->SignWithOpKeypair(data.fabricIndex, ByteSpan{ data.msg_R3_Signed.Get(), data.msg_r3_signed_len }, + data.tbsData3Signature); + } + else + { + // Legacy case: delegate to fabric table fabric info + err = data.fabricTable->SignWithOpKeypair(data.fabricIndex, ByteSpan{ data.msg_R3_Signed.Get(), data.msg_r3_signed_len }, + data.tbsData3Signature); + } SuccessOrExit(err); // Prepare Sigma3 TBE Data Blob - msg_r3_encrypted_len = TLV::EstimateStructOverhead(nocCert.size(), icaCert.size(), tbsData3Signature.Length()); + data.msg_r3_encrypted_len = + TLV::EstimateStructOverhead(data.nocCert.size(), data.icaCert.size(), data.tbsData3Signature.Length()); - VerifyOrExit(msg_R3_Encrypted.Alloc(msg_r3_encrypted_len + CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES), err = CHIP_ERROR_NO_MEMORY); + VerifyOrExit(data.msg_R3_Encrypted.Alloc(data.msg_r3_encrypted_len + CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES), + err = CHIP_ERROR_NO_MEMORY); { TLV::TLVWriter tlvWriter; TLV::TLVType outerContainerType = TLV::kTLVType_NotSpecified; - tlvWriter.Init(msg_R3_Encrypted.Get(), msg_r3_encrypted_len); + tlvWriter.Init(data.msg_R3_Encrypted.Get(), data.msg_r3_encrypted_len); SuccessOrExit(err = tlvWriter.StartContainer(TLV::AnonymousTag(), TLV::kTLVType_Structure, outerContainerType)); - SuccessOrExit(err = tlvWriter.Put(TLV::ContextTag(kTag_TBEData_SenderNOC), nocCert)); - if (!icaCert.empty()) + SuccessOrExit(err = tlvWriter.Put(TLV::ContextTag(kTag_TBEData_SenderNOC), data.nocCert)); + if (!data.icaCert.empty()) { - SuccessOrExit(err = tlvWriter.Put(TLV::ContextTag(kTag_TBEData_SenderICAC), icaCert)); + SuccessOrExit(err = tlvWriter.Put(TLV::ContextTag(kTag_TBEData_SenderICAC), data.icaCert)); } // We are now done with ICAC and NOC certs so we can release the memory. { - icacBuf.Free(); - icaCert = MutableByteSpan{}; + data.icacBuf.Free(); + data.icaCert = MutableByteSpan{}; - nocBuf.Free(); - nocCert = MutableByteSpan{}; + data.nocBuf.Free(); + data.nocCert = MutableByteSpan{}; } - SuccessOrExit(err = tlvWriter.PutBytes(TLV::ContextTag(kTag_TBEData_Signature), tbsData3Signature.ConstBytes(), - static_cast(tbsData3Signature.Length()))); + SuccessOrExit(err = tlvWriter.PutBytes(TLV::ContextTag(kTag_TBEData_Signature), data.tbsData3Signature.ConstBytes(), + static_cast(data.tbsData3Signature.Length()))); SuccessOrExit(err = tlvWriter.EndContainer(outerContainerType)); SuccessOrExit(err = tlvWriter.Finalize()); - msg_r3_encrypted_len = static_cast(tlvWriter.GetLengthWritten()); + data.msg_r3_encrypted_len = static_cast(tlvWriter.GetLengthWritten()); } +exit: + return err; +} + +CHIP_ERROR CASESession::SendSigma3c(SendSigma3Data & data, CHIP_ERROR status) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + System::PacketBufferHandle msg_R3; + size_t data_len; + + uint8_t msg_salt[kIPKSize + kSHA256_Hash_Length]; + + AutoReleaseSessionKey sr3k(*mSessionManager->GetSessionKeystore()); + + VerifyOrDieWithMsg(data.keystore == nullptr || mState == State::kSendSigma3Pending, SecureChannel, "Bad internal state."); + + SuccessOrExit(err = status); + // Generate S3K key { MutableByteSpan saltSpan(msg_salt); @@ -1193,12 +1447,13 @@ CHIP_ERROR CASESession::SendSigma3() } // Generated Encrypted data blob - SuccessOrExit(err = AES_CCM_encrypt(msg_R3_Encrypted.Get(), msg_r3_encrypted_len, nullptr, 0, sr3k.KeyHandle(), kTBEData3_Nonce, - kTBEDataNonceLength, msg_R3_Encrypted.Get(), msg_R3_Encrypted.Get() + msg_r3_encrypted_len, - CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES)); + SuccessOrExit(err = + AES_CCM_encrypt(data.msg_R3_Encrypted.Get(), data.msg_r3_encrypted_len, nullptr, 0, sr3k.KeyHandle(), + kTBEData3_Nonce, kTBEDataNonceLength, data.msg_R3_Encrypted.Get(), + data.msg_R3_Encrypted.Get() + data.msg_r3_encrypted_len, CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES)); // Generate Sigma3 Msg - data_len = TLV::EstimateStructOverhead(CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES, msg_r3_encrypted_len); + data_len = TLV::EstimateStructOverhead(CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES, data.msg_r3_encrypted_len); msg_R3 = System::PacketBufferHandle::New(data_len); VerifyOrExit(!msg_R3.IsNull(), err = CHIP_ERROR_NO_MEMORY); @@ -1210,8 +1465,8 @@ CHIP_ERROR CASESession::SendSigma3() tlvWriter.Init(std::move(msg_R3)); err = tlvWriter.StartContainer(TLV::AnonymousTag(), TLV::kTLVType_Structure, outerContainerType); SuccessOrExit(err); - err = tlvWriter.PutBytes(TLV::ContextTag(1), msg_R3_Encrypted.Get(), - static_cast(msg_r3_encrypted_len + CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES)); + err = tlvWriter.PutBytes(TLV::ContextTag(1), data.msg_R3_Encrypted.Get(), + static_cast(data.msg_r3_encrypted_len + CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES)); SuccessOrExit(err); err = tlvWriter.EndContainer(outerContainerType); SuccessOrExit(err); @@ -1229,50 +1484,29 @@ CHIP_ERROR CASESession::SendSigma3() ChipLogProgress(SecureChannel, "Sent Sigma3 msg"); - err = mCommissioningHash.Finish(messageDigestSpan); - SuccessOrExit(err); + { + MutableByteSpan messageDigestSpan(mMessageDigest); + SuccessOrExit(err = mCommissioningHash.Finish(messageDigestSpan)); + } mState = State::kSentSigma3; exit: + mSendSigma3Helper.reset(); - if (err != CHIP_NO_ERROR) + // If data.keystore is set, processing occurred in the background, so if an error occurred, + // need to send status report (normally occurs in SendSigma3a), and discard exchange and + // abort pending establish (normally occurs in OnMessageReceived). + if (data.keystore != nullptr && err != CHIP_NO_ERROR) { SendStatusReport(mExchangeCtxt, kProtocolCodeInvalidParam); - mState = State::kInitialized; + DiscardExchange(); + AbortPendingEstablish(err); } + return err; } -struct CASESession::Sigma3Work -{ - // Status of background processing. - CHIP_ERROR status; - - // Session to use after background processing. - CASESession * session; - - // Sequence number used to coordinate foreground/background work for a - // particular session establishment. - int sequence; - - chip::Platform::ScopedMemoryBuffer msg_R3_Signed; - size_t msg_r3_signed_len; - - ByteSpan initiatorNOC; - ByteSpan initiatorICAC; - - uint8_t rootCertBuf[kMaxCHIPCertLength]; - ByteSpan fabricRCAC; - - P256ECDSASignature tbsData3Signature; - - FabricId fabricId; - NodeId initiatorNodeId; - - ValidationContext validContext; -}; - CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg) { MATTER_TRACE_EVENT_SCOPE("HandleSigma3", "CASESession"); @@ -1297,7 +1531,7 @@ CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg) ChipLogProgress(SecureChannel, "Received Sigma3 msg"); - auto * workPtr = Platform::New(); + auto * workPtr = Platform::New(); VerifyOrExit(workPtr != nullptr, err = CHIP_ERROR_NO_MEMORY); { auto & work = *workPtr; @@ -1415,12 +1649,12 @@ CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg) } } - SuccessOrExit( - err = DeviceLayer::PlatformMgr().ScheduleBackgroundWork( - [](intptr_t arg) { HandleSigma3b(*reinterpret_cast(arg)); }, reinterpret_cast(&work))); + SuccessOrExit(err = DeviceLayer::PlatformMgr().ScheduleBackgroundWork( + [](intptr_t arg) { HandleSigma3b(*reinterpret_cast(arg)); }, + reinterpret_cast(&work))); workPtr = nullptr; // scheduling succeeded, so don't delete mExchangeCtxt->WillSendMessage(); - mState = State::kBackgroundPending; + mState = State::kHandleSigma3Pending; } exit: @@ -1434,7 +1668,7 @@ CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg) return err; } -void CASESession::HandleSigma3b(Sigma3Work & work) +void CASESession::HandleSigma3b(HandleSigma3Work & work) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -1471,7 +1705,7 @@ void CASESession::HandleSigma3b(Sigma3Work & work) auto err2 = DeviceLayer::PlatformMgr().ScheduleWork( [](intptr_t arg) { - auto & work2 = *reinterpret_cast(arg); + auto & work2 = *reinterpret_cast(arg); work2.session->HandleSigma3c(work2); }, reinterpret_cast(&work)); @@ -1482,7 +1716,7 @@ void CASESession::HandleSigma3b(Sigma3Work & work) } } -CHIP_ERROR CASESession::HandleSigma3c(Sigma3Work & work) +CHIP_ERROR CASESession::HandleSigma3c(HandleSigma3Work & work) { CHIP_ERROR err = CHIP_NO_ERROR; bool ignoreFailure = true; @@ -1490,7 +1724,7 @@ CHIP_ERROR CASESession::HandleSigma3c(Sigma3Work & work) // Special case: if for whatever reason not in expected state or sequence, // don't do anything, including sending a status report or aborting the // pending establish. - VerifyOrExit(mState == State::kBackgroundPending, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mState == State::kHandleSigma3Pending, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mSequence == work.sequence, err = CHIP_ERROR_INCORRECT_STATE); ignoreFailure = false; diff --git a/src/protocols/secure_channel/CASESession.h b/src/protocols/secure_channel/CASESession.h index b6516aa5ca0612..21578e592ba907 100644 --- a/src/protocols/secure_channel/CASESession.h +++ b/src/protocols/secure_channel/CASESession.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -66,7 +67,7 @@ class DLL_EXPORT CASESession : public Messaging::UnsolicitedMessageHandler, /** * @brief - * Initialize using configured fabrics and wait for session establishment requests. + * Initialize using configured fabrics and wait for session establishment requests (as a responder). * * @param sessionManager session manager from which to allocate a secure session object * @param fabricTable Table of fabrics that are currently configured on the device @@ -88,7 +89,7 @@ class DLL_EXPORT CASESession : public Messaging::UnsolicitedMessageHandler, /** * @brief - * Create and send session establishment request using device's operational credentials. + * Create and send session establishment request (as an initiator) using device's operational credentials. * * @param sessionManager session manager from which to allocate a secure session object * @param fabricTable The fabric table that contains a fabric in common with the peer @@ -194,15 +195,16 @@ class DLL_EXPORT CASESession : public Messaging::UnsolicitedMessageHandler, friend class TestCASESession; enum class State : uint8_t { - kInitialized = 0, - kSentSigma1 = 1, - kSentSigma2 = 2, - kSentSigma3 = 3, - kSentSigma1Resume = 4, - kSentSigma2Resume = 5, - kFinished = 6, - kFinishedViaResume = 7, - kBackgroundPending = 8, + kInitialized = 0, + kSentSigma1 = 1, + kSentSigma2 = 2, + kSentSigma3 = 3, + kSentSigma1Resume = 4, + kSentSigma2Resume = 5, + kFinished = 6, + kFinishedViaResume = 7, + kSendSigma3Pending = 8, + kHandleSigma3Pending = 9, }; /* @@ -233,11 +235,15 @@ class DLL_EXPORT CASESession : public Messaging::UnsolicitedMessageHandler, CHIP_ERROR HandleSigma2(System::PacketBufferHandle && msg); CHIP_ERROR HandleSigma2Resume(System::PacketBufferHandle && msg); - CHIP_ERROR SendSigma3(); - struct Sigma3Work; + struct SendSigma3Data; + CHIP_ERROR SendSigma3a(); + static CHIP_ERROR SendSigma3b(SendSigma3Data & data, bool & cancel); + CHIP_ERROR SendSigma3c(SendSigma3Data & data, CHIP_ERROR status); + + struct HandleSigma3Work; CHIP_ERROR HandleSigma3a(System::PacketBufferHandle && msg); - static void HandleSigma3b(Sigma3Work & work); - CHIP_ERROR HandleSigma3c(Sigma3Work & work); + static void HandleSigma3b(HandleSigma3Work & work); + CHIP_ERROR HandleSigma3c(HandleSigma3Work & work); CHIP_ERROR SendSigma2Resume(); @@ -301,6 +307,10 @@ class DLL_EXPORT CASESession : public Messaging::UnsolicitedMessageHandler, // particular session establishment. int mSequence = 0; + template + class WorkHelper; + Platform::SharedPtr> mSendSigma3Helper; + State mState; #if CONFIG_BUILD_FOR_HOST_UNIT_TEST diff --git a/src/protocols/secure_channel/tests/TestCASESession.cpp b/src/protocols/secure_channel/tests/TestCASESession.cpp index a863b3ca57dae8..11d5000f71df03 100644 --- a/src/protocols/secure_channel/tests/TestCASESession.cpp +++ b/src/protocols/secure_channel/tests/TestCASESession.cpp @@ -60,16 +60,16 @@ namespace { void ServiceEvents(TestContext & ctx) { - // Service any messages - ctx.DrainAndServiceIO(); - - // Messages may have scheduled work, so service them - chip::DeviceLayer::PlatformMgr().ScheduleWork([](intptr_t) -> void { chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); }, - (intptr_t) nullptr); - chip::DeviceLayer::PlatformMgr().RunEventLoop(); + // Takes a few rounds of this because handling IO messages may schedule work, + // and scheduled work may queue messages for sending... + for (int i = 0; i < 3; ++i) + { + ctx.DrainAndServiceIO(); - // Work may have sent messages, so service them - ctx.DrainAndServiceIO(); + chip::DeviceLayer::PlatformMgr().ScheduleWork( + [](intptr_t) -> void { chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); }, (intptr_t) nullptr); + chip::DeviceLayer::PlatformMgr().RunEventLoop(); + } } class TemporarySessionManager From e4d000d29ed09ad2dd74125b22a854305a526393 Mon Sep 17 00:00:00 2001 From: Sergei Lissianoi <54454955+selissia@users.noreply.github.com> Date: Thu, 27 Apr 2023 16:53:53 -0400 Subject: [PATCH 046/200] [Silabs] Move NVM semaphore creation to nvm3_lockBegin() (#26270) * Move NVM initialization to sl_platform_init() in matter_support submodule Also move nvm3_Sem creation to nvm3_lockBegin() * Restore the call to nvm3_open(), it's safe to call multiple times --- src/platform/silabs/SilabsConfig.cpp | 15 +++++++-------- third_party/silabs/matter_support | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/platform/silabs/SilabsConfig.cpp b/src/platform/silabs/SilabsConfig.cpp index d07b9ced36cfc0..950b6040490c0a 100644 --- a/src/platform/silabs/SilabsConfig.cpp +++ b/src/platform/silabs/SilabsConfig.cpp @@ -43,6 +43,12 @@ static StaticSemaphore_t nvm3_SemStruct; void nvm3_lockBegin(void) { + if (nvm3_Sem == NULL) + { + nvm3_Sem = xSemaphoreCreateBinaryStatic(&nvm3_SemStruct); + xSemaphoreGive(nvm3_Sem); + } + VerifyOrDie(nvm3_Sem != NULL); xSemaphoreTake(nvm3_Sem, portMAX_DELAY); } @@ -65,15 +71,8 @@ namespace Internal { CHIP_ERROR SilabsConfig::Init() { -#ifndef BRD4325A // TODO: fix semaphore usage in nvm3_lock for siwx917. use weak implementation for that board instead - nvm3_Sem = xSemaphoreCreateBinaryStatic(&nvm3_SemStruct); + // nvm3_Sem is created in nvm3_lockBegin() - if (nvm3_Sem == NULL) - { - return CHIP_ERROR_NO_MEMORY; - } - xSemaphoreGive(nvm3_Sem); -#endif // not BRD4325A return MapNvm3Error(nvm3_open(nvm3_defaultHandle, nvm3_defaultInit)); } diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 4d93227fc8679d..2bc3f28d778850 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 4d93227fc8679d66f0dd8d408b114425ca73bc0c +Subproject commit 2bc3f28d778850417f34c7201cbe78bd72e3ee78 From e62d3ddaeeaed47535060f9d542ef87c655fef97 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 28 Apr 2023 00:10:31 -0400 Subject: [PATCH 047/200] Deprecate MTROnboardingPayloadParser. (#26272) We forgot to do this when we deprecated the QRCode/Manual parsers. --- src/darwin/Framework/CHIP/MTRManualSetupPayloadParser.h | 2 +- src/darwin/Framework/CHIP/MTROnboardingPayloadParser.h | 3 ++- src/darwin/Framework/CHIP/MTRQRCodeSetupPayloadParser.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRManualSetupPayloadParser.h b/src/darwin/Framework/CHIP/MTRManualSetupPayloadParser.h index a01493cd634bf7..9dc5d702a3c2a4 100644 --- a/src/darwin/Framework/CHIP/MTRManualSetupPayloadParser.h +++ b/src/darwin/Framework/CHIP/MTRManualSetupPayloadParser.h @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN -MTR_DEPRECATED("Please use [MTRSetupPayload setupPayloadWithOnboardingPayload", ios(16.1, 16.4), macos(13.0, 13.3), +MTR_DEPRECATED("Please use [MTRSetupPayload setupPayloadWithOnboardingPayload:error:]", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) @interface MTRManualSetupPayloadParser : NSObject - (instancetype)initWithDecimalStringRepresentation:(NSString *)decimalStringRepresentation; diff --git a/src/darwin/Framework/CHIP/MTROnboardingPayloadParser.h b/src/darwin/Framework/CHIP/MTROnboardingPayloadParser.h index b84672b791695f..2adbb29804cc43 100644 --- a/src/darwin/Framework/CHIP/MTROnboardingPayloadParser.h +++ b/src/darwin/Framework/CHIP/MTROnboardingPayloadParser.h @@ -25,8 +25,9 @@ typedef NS_ENUM(NSUInteger, MTROnboardingPayloadType) { MTROnboardingPayloadTypeQRCode = 0, MTROnboardingPayloadTypeManualCode, MTROnboardingPayloadTypeNFC -}; +} MTR_NEWLY_DEPRECATED("MTROnboardingPayloadType is unused"); +MTR_NEWLY_DEPRECATED("Please use [MTRSetupPayload setupPayloadWithOnboardingPayload:error:]") @interface MTROnboardingPayloadParser : NSObject + (MTRSetupPayload * _Nullable)setupPayloadForOnboardingPayload:(NSString *)onboardingPayload diff --git a/src/darwin/Framework/CHIP/MTRQRCodeSetupPayloadParser.h b/src/darwin/Framework/CHIP/MTRQRCodeSetupPayloadParser.h index 5e4172267221ec..5f71b2668c6a6c 100644 --- a/src/darwin/Framework/CHIP/MTRQRCodeSetupPayloadParser.h +++ b/src/darwin/Framework/CHIP/MTRQRCodeSetupPayloadParser.h @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN -MTR_DEPRECATED("Please use [MTRSetupPayload setupPayloadWithOnboardingPayload", ios(16.1, 16.4), macos(13.0, 13.3), +MTR_DEPRECATED("Please use [MTRSetupPayload setupPayloadWithOnboardingPayload:error:]", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) @interface MTRQRCodeSetupPayloadParser : NSObject - (instancetype)initWithBase38Representation:(NSString *)base38Representation; From f1096a5d76d7830ce2b7e5ecc5bb342270d95dfe Mon Sep 17 00:00:00 2001 From: Grzegorz Ferenc <41291385+greg-fer@users.noreply.github.com> Date: Fri, 28 Apr 2023 08:14:09 +0200 Subject: [PATCH 048/200] doc: tools: add tools section and pages (#26262) * doc: tools: add tools section and pages Added tools section and pages in documentation. This adds readmies for chip-cert and spake2p to the doc pool. Signed-off-by: Grzegorz Ferenc * doc: move NXP manufacturing guide doc to fix links Moved the NXP manufacturing data guide into docs/guides. Added the guide to the doc pool and updated links. Signed-off-by: Grzegorz Ferenc * Restyled by prettier-markdown --------- Signed-off-by: Grzegorz Ferenc Co-authored-by: Restyled.io --- docs/conf.py | 5 ++ docs/guides/index.md | 1 + .../guides/nxp_manufacturing_flow.md | 2 +- docs/index.md | 1 + docs/tools/index.md | 63 +++++++++++++++++++ .../nxp/k32w/k32w0/README.md | 2 +- .../lighting-app/nxp/k32w/k32w0/README.md | 2 +- examples/lock-app/nxp/k32w/k32w0/README.md | 2 +- .../nxp/factory_data_generator/README.md | 4 +- scripts/tools/nxp/ota/README.md | 2 +- scripts/tools/silabs/README.md | 2 +- src/tools/chip-cert/README.md | 2 +- 12 files changed, 79 insertions(+), 9 deletions(-) rename examples/platform/nxp/doc/manufacturing_flow.md => docs/guides/nxp_manufacturing_flow.md (99%) create mode 100644 docs/tools/index.md diff --git a/docs/conf.py b/docs/conf.py index bf83e215be05b5..1f2f0d96cf74e8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -32,6 +32,9 @@ "examples/thermostat/nxp/linux-se05x/README.md", "examples/common/m5stack-tft/repo", "docs/guides/README.md", + "scripts/tools/memory/memdf/README.md", + "scripts/tools/memory/platform/README.md", + "scripts/tools/memory/README-GitHub-CI.md", ] @@ -69,6 +72,8 @@ (MATTER_BASE, "examples/**/*.png"), (MATTER_BASE, "examples/**/*.jpg"), (MATTER_BASE, "examples/**/*.JPG"), + (MATTER_BASE, "src/tools/**/*.md"), + (MATTER_BASE, "scripts/tools/**/*.md"), ] external_content_link_prefixes = [ "src/", diff --git a/docs/guides/index.md b/docs/guides/index.md index c6a488f8e8add5..5d93bbb9b012ae 100644 --- a/docs/guides/index.md +++ b/docs/guides/index.md @@ -34,6 +34,7 @@ esp32/README - [nRF Connect - Software Update](./nrfconnect_examples_software_update.md) - [NXP - Android Commissioning](./nxp_k32w_android_commissioning.md) - [NXP - Linux Examples](./nxp_imx8m_linux_examples.md) +- [NXP - Manufacturing Data](./nxp_manufacturing_flow.md) - [Silicon Labs - Documentation](https://github.com/SiliconLabs/matter#readme) - [Silicon Labs - Building](./silabs_efr32_building.md) - [Silicon Labs - Software Update](./silabs_efr32_software_update.md) diff --git a/examples/platform/nxp/doc/manufacturing_flow.md b/docs/guides/nxp_manufacturing_flow.md similarity index 99% rename from examples/platform/nxp/doc/manufacturing_flow.md rename to docs/guides/nxp_manufacturing_flow.md index bfa064407ea229..019cfa67a38680 100644 --- a/examples/platform/nxp/doc/manufacturing_flow.md +++ b/docs/guides/nxp_manufacturing_flow.md @@ -2,7 +2,7 @@ orphan: true --- -## Manufacturing data +# NXP manufacturing data guide By default, the example application is configured to use generic test certificates and provisioning data embedded with the application code. It is diff --git a/docs/index.md b/docs/index.md index 690386ab19c636..cd865b4d31027e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -13,6 +13,7 @@ discussion/index guides/index style/index examples/index +tools/index BUG_REPORT code_generation ERROR_CODES diff --git a/docs/tools/index.md b/docs/tools/index.md new file mode 100644 index 00000000000000..003573ed5ebb14 --- /dev/null +++ b/docs/tools/index.md @@ -0,0 +1,63 @@ +# Tools + +The Matter SDK provides tools that allow you to generate and manage different +aspects of the Matter development. + +## C++ tools + +Source files for these tools are located at `src/tools`. + +```{toctree} +:glob: +:maxdepth: 1 + +../src/tools/chip-cert/README +../src/tools/spake2p/README + +``` + +## Python tools + +Source files for these tools are located at `scripts/tools`. + +### General tools + +```{toctree} +:glob: +:maxdepth: 1 + +../scripts/tools/memory/README +../scripts/tools/spake2p/README + +``` + +### NXP tools + +```{toctree} +:glob: +:maxdepth: 1 + +../scripts/tools/nxp/factory_data_generator/README +../scripts/tools/nxp/ota/README + +``` + +### Silabs tools + +```{toctree} +:glob: +:maxdepth: 1 + +../scripts/tools/silabs/README + +``` + +### Telink tools + +```{toctree} +:glob: +:maxdepth: 1 + +../scripts/tools/telink/readme + +``` diff --git a/examples/contact-sensor-app/nxp/k32w/k32w0/README.md b/examples/contact-sensor-app/nxp/k32w/k32w0/README.md index af446f80a6bd99..54854b41613622 100644 --- a/examples/contact-sensor-app/nxp/k32w/k32w0/README.md +++ b/examples/contact-sensor-app/nxp/k32w/k32w0/README.md @@ -241,7 +241,7 @@ The resulting output file can be found in out/debug/chip-k32w0x-contact-example. ## Manufacturing data See -[Guide for writing manufacturing data on NXP devices](../../../../platform/nxp/doc/manufacturing_flow.md). +[Guide for writing manufacturing data on NXP devices](../../../../../docs/guides/nxp_manufacturing_flow.md). There are factory data generated binaries available in examples/platform/nxp/k32w/k32w0/scripts/demo_generated_factory_data folder. diff --git a/examples/lighting-app/nxp/k32w/k32w0/README.md b/examples/lighting-app/nxp/k32w/k32w0/README.md index 7de06266209374..1bebb18a50e650 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/README.md +++ b/examples/lighting-app/nxp/k32w/k32w0/README.md @@ -254,7 +254,7 @@ The resulting output file can be found in out/debug/chip-k32w0x-light-example. ## Manufacturing data See -[Guide for writing manufacturing data on NXP devices](../../../../platform/nxp/doc/manufacturing_flow.md). +[Guide for writing manufacturing data on NXP devices](../../../../../docs/guides/nxp_manufacturing_flow.md). There are factory data generated binaries available in examples/platform/nxp/k32w/k32w0/scripts/demo_generated_factory_data folder. diff --git a/examples/lock-app/nxp/k32w/k32w0/README.md b/examples/lock-app/nxp/k32w/k32w0/README.md index d788a785016c1e..3a2f027e447ab8 100644 --- a/examples/lock-app/nxp/k32w/k32w0/README.md +++ b/examples/lock-app/nxp/k32w/k32w0/README.md @@ -227,7 +227,7 @@ The resulting output file can be found in out/debug/chip-k32w0x-lock-example. ## Manufacturing data See -[Guide for writing manufacturing data on NXP devices](../../../../platform/nxp/doc/manufacturing_flow.md). +[Guide for writing manufacturing data on NXP devices](../../../../../docs/guides/nxp_manufacturing_flow.md). There are factory data generated binaries available in examples/platform/nxp/k32w/k32w0/scripts/demo_generated_factory_data folder. diff --git a/scripts/tools/nxp/factory_data_generator/README.md b/scripts/tools/nxp/factory_data_generator/README.md index 74380f0ff8d502..38f65d4b7cbaef 100644 --- a/scripts/tools/nxp/factory_data_generator/README.md +++ b/scripts/tools/nxp/factory_data_generator/README.md @@ -1,7 +1,7 @@ -## NXP Factory Data Generator +# NXP Factory Data Generator For usage of the tool, please see -[Guide for writing manufacturing data on NXP devices](../../../../examples/platform/nxp/doc/manufacturing_flow.md). +[Guide for writing manufacturing data on NXP devices](../../../../docs/guides/nxp_manufacturing_flow.md). ## Tool implementation diff --git a/scripts/tools/nxp/ota/README.md b/scripts/tools/nxp/ota/README.md index 923e9a5dfe1797..e1848a007f3441 100644 --- a/scripts/tools/nxp/ota/README.md +++ b/scripts/tools/nxp/ota/README.md @@ -116,7 +116,7 @@ private: update OTA image. If the `PAA` changes, make sure to generate the new certificates using the new `PAA` (which is only used by the controller, e.g. `chip-tool`). Please see the -[manufacturing flow guide](../../../../examples/platform/nxp/doc/manufacturing_flow.md) +[manufacturing flow guide](../../../../docs/guides/nxp_manufacturing_flow.md) for generating new certificates. Example of OTA image generation with factory data and application update (using diff --git a/scripts/tools/silabs/README.md b/scripts/tools/silabs/README.md index e042606b1ff472..0d24f1af4870c2 100644 --- a/scripts/tools/silabs/README.md +++ b/scripts/tools/silabs/README.md @@ -1,4 +1,4 @@ -#`FactoryDataProvider` for EFR32 Matter device +# `FactoryDataProvider` for EFR32 Matter device ## Introduction diff --git a/src/tools/chip-cert/README.md b/src/tools/chip-cert/README.md index 9b2b1fe9bda7ad..400e5307387c4a 100644 --- a/src/tools/chip-cert/README.md +++ b/src/tools/chip-cert/README.md @@ -809,7 +809,7 @@ HELP OPTIONS Print the version and then exit. ``` -#### gen-cd example +#### print-cd example An example of printing a Certificate Declaration (CD), which is provided as a command line argument in a hex format: From 6ec5f812b2fa9ab5f29112bb858237af81bc1fcd Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Fri, 28 Apr 2023 10:56:51 +0200 Subject: [PATCH 049/200] Fix TestDnssd exit after last HandleResolved call (#26138) * Fix TestDnssd exit after last HandleResolved call * Fix typo in comment * Use dedicated context instead of global state * Use Setup/Teardown for DNS-SD test suite * Test timeout in case of Avahi not running * Use ChipDnssdStopBrowse before exit * Fix typo in comment * Cancel timer before stopping event loop * Avoid deadlock when stopping event loop on non-matter thread * Update src/platform/tests/TestDnssd.cpp * Remove unnecessary comment --- src/platform/tests/TestConfigurationMgr.cpp | 2 +- src/platform/tests/TestConnectivityMgr.cpp | 2 +- src/platform/tests/TestDnssd.cpp | 225 +++++++++++--------- src/platform/tests/TestKeyValueStoreMgr.cpp | 2 +- src/platform/tests/TestPlatformMgr.cpp | 2 +- src/platform/tests/TestPlatformTime.cpp | 2 +- 6 files changed, 125 insertions(+), 110 deletions(-) diff --git a/src/platform/tests/TestConfigurationMgr.cpp b/src/platform/tests/TestConfigurationMgr.cpp index aafdf4a63cfa31..dafe5b209725a2 100644 --- a/src/platform/tests/TestConfigurationMgr.cpp +++ b/src/platform/tests/TestConfigurationMgr.cpp @@ -499,7 +499,7 @@ int TestConfigurationMgr() { nlTestSuite theSuite = { "ConfigurationMgr tests", &sTests[0], TestConfigurationMgr_Setup, TestConfigurationMgr_Teardown }; - // Run test suit againt one context. + // Run test suite against one context. nlTestRunner(&theSuite, nullptr); return nlTestRunnerStats(&theSuite); } diff --git a/src/platform/tests/TestConnectivityMgr.cpp b/src/platform/tests/TestConnectivityMgr.cpp index 932be3dcfc5b1a..3a4548c43ef2a7 100644 --- a/src/platform/tests/TestConnectivityMgr.cpp +++ b/src/platform/tests/TestConnectivityMgr.cpp @@ -99,7 +99,7 @@ int TestConnectivityMgr() { nlTestSuite theSuite = { "ConfigurationMgr tests", &sTests[0], TestConnectivityMgr_Setup, TestConnectivityMgr_Teardown }; - // Run test suit againt one context. + // Run test suite against one context. nlTestRunner(&theSuite, nullptr); return nlTestRunnerStats(&theSuite); } diff --git a/src/platform/tests/TestDnssd.cpp b/src/platform/tests/TestDnssd.cpp index 4a0437ce35bfb6..d7e4ed18554f74 100644 --- a/src/platform/tests/TestDnssd.cpp +++ b/src/platform/tests/TestDnssd.cpp @@ -1,6 +1,21 @@ -#include -#include -#include +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include #include @@ -14,15 +29,37 @@ using chip::Dnssd::DnssdService; using chip::Dnssd::DnssdServiceProtocol; using chip::Dnssd::TextEntry; -static unsigned int gBrowsedServicesCount = 0; -static unsigned int gResolvedServicesCount = 0; -static bool gEndOfInput = false; +namespace { + +struct DnssdContext +{ + nlTestSuite * mTestSuite; + + std::atomic mTimeoutExpired{ false }; + + intptr_t mBrowseIdentifier = 0; + + unsigned int mBrowsedServicesCount = 0; + unsigned int mResolvedServicesCount = 0; + bool mEndOfInput = false; +}; + +} // namespace + +static void Timeout(chip::System::Layer * systemLayer, void * context) +{ + auto * ctx = static_cast(context); + ChipLogError(DeviceLayer, "mDNS test timeout, is avahi daemon running?"); + ctx->mTimeoutExpired = true; + chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); +} static void HandleResolve(void * context, DnssdService * result, const chip::Span & addresses, CHIP_ERROR error) { + auto * ctx = static_cast(context); + auto * suite = ctx->mTestSuite; char addrBuf[100]; - nlTestSuite * suite = static_cast(context); NL_TEST_ASSERT(suite, result != nullptr); NL_TEST_ASSERT(suite, error == CHIP_NO_ERROR); @@ -30,31 +67,42 @@ static void HandleResolve(void * context, DnssdService * result, const chip::Spa if (!addresses.empty()) { addresses.data()[0].ToString(addrBuf, sizeof(addrBuf)); - printf("Service[%u] at [%s]:%u\n", gResolvedServicesCount, addrBuf, result->mPort); + printf("Service[%u] at [%s]:%u\n", ctx->mResolvedServicesCount, addrBuf, result->mPort); } NL_TEST_ASSERT(suite, result->mTextEntrySize == 1); NL_TEST_ASSERT(suite, strcmp(result->mTextEntries[0].mKey, "key") == 0); NL_TEST_ASSERT(suite, strcmp(reinterpret_cast(result->mTextEntries[0].mData), "val") == 0); - if (gBrowsedServicesCount == ++gResolvedServicesCount) + if (ctx->mBrowsedServicesCount == ++ctx->mResolvedServicesCount) { - chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); - chip::DeviceLayer::PlatformMgr().Shutdown(); - exit(0); + chip::DeviceLayer::SystemLayer().CancelTimer(Timeout, context); + // StopEventLoopTask can be called from any thread, but when called from + // non-Matter one it will lock the Matter stack. The same locking rules + // are required when the resolve callback (this one) is called. In order + // to avoid deadlocks, we need to call the StopEventLoopTask from inside + // the Matter event loop by scheduling a lambda. + chip::DeviceLayer::SystemLayer().ScheduleLambda([]() { + // After last service is resolved, stop the event loop, + // so the test case can gracefully exit. + chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); + }); } } static void HandleBrowse(void * context, DnssdService * services, size_t servicesSize, bool finalBrowse, CHIP_ERROR error) { - nlTestSuite * suite = static_cast(context); + auto * ctx = static_cast(context); + auto * suite = ctx->mTestSuite; // Make sure that we will not be called again after end-of-input is set - NL_TEST_ASSERT(suite, gEndOfInput == false); - NL_TEST_ASSERT(suite, error == CHIP_NO_ERROR); + NL_TEST_ASSERT(suite, ctx->mEndOfInput == false); + // Cancelled error is expected when the browse is stopped with + // ChipDnssdStopBrowse(), so we will not assert on it. + NL_TEST_ASSERT(suite, error == CHIP_NO_ERROR || error == CHIP_ERROR_CANCELLED); - gBrowsedServicesCount += servicesSize; - gEndOfInput = finalBrowse; + ctx->mBrowsedServicesCount += servicesSize; + ctx->mEndOfInput = finalBrowse; if (servicesSize > 0) { @@ -63,22 +111,31 @@ static void HandleBrowse(void * context, DnssdService * services, size_t service { printf("Service[%u] name %s\n", i, services[i].mName); printf("Service[%u] type %s\n", i, services[i].mType); - NL_TEST_ASSERT(suite, ChipDnssdResolve(&services[i], services[i].mInterface, HandleResolve, suite) == CHIP_NO_ERROR); + NL_TEST_ASSERT(suite, ChipDnssdResolve(&services[i], services[i].mInterface, HandleResolve, context) == CHIP_NO_ERROR); } } } -static void HandlePublish(void * context, const char * type, const char * instanceName, CHIP_ERROR error) {} +static void DnssdErrorCallback(void * context, CHIP_ERROR error) +{ + auto * ctx = static_cast(context); + NL_TEST_ASSERT(ctx->mTestSuite, error == CHIP_NO_ERROR); +} + +static void HandlePublish(void * context, const char * type, const char * instanceName, CHIP_ERROR error) +{ + auto * ctx = static_cast(context); + NL_TEST_ASSERT(ctx->mTestSuite, error == CHIP_NO_ERROR); +} -static void InitCallback(void * context, CHIP_ERROR error) +static void TestDnssdPubSub_DnssdInitCallback(void * context, CHIP_ERROR error) { - DnssdService service; - TextEntry entry; - char key[] = "key"; - char val[] = "val"; - nlTestSuite * suite = static_cast(context); + auto * ctx = static_cast(context); + NL_TEST_ASSERT(ctx->mTestSuite, error == CHIP_NO_ERROR); + auto * suite = ctx->mTestSuite; - NL_TEST_ASSERT(suite, error == CHIP_NO_ERROR); + DnssdService service{}; + TextEntry entry{ "key", reinterpret_cast("val"), 3 }; service.mInterface = chip::Inet::InterfaceId::Null(); service.mPort = 80; @@ -87,107 +144,65 @@ static void InitCallback(void * context, CHIP_ERROR error) strcpy(service.mType, "_mock"); service.mAddressType = chip::Inet::IPAddressType::kAny; service.mProtocol = DnssdServiceProtocol::kDnssdProtocolTcp; - entry.mKey = key; - entry.mData = reinterpret_cast(val); - entry.mDataSize = strlen(reinterpret_cast(entry.mData)); service.mTextEntries = &entry; service.mTextEntrySize = 1; service.mSubTypes = nullptr; service.mSubTypeSize = 0; - NL_TEST_ASSERT(suite, ChipDnssdPublishService(&service, HandlePublish) == CHIP_NO_ERROR); - intptr_t browseIdentifier; - ChipDnssdBrowse("_mock", DnssdServiceProtocol::kDnssdProtocolTcp, chip::Inet::IPAddressType::kAny, - chip::Inet::InterfaceId::Null(), HandleBrowse, suite, &browseIdentifier); -} + NL_TEST_ASSERT(suite, ChipDnssdPublishService(&service, HandlePublish, context) == CHIP_NO_ERROR); -static void ErrorCallback(void * context, CHIP_ERROR error) -{ - VerifyOrDieWithMsg(error == CHIP_NO_ERROR, DeviceLayer, "Mdns error: %" CHIP_ERROR_FORMAT "\n", error.Format()); + NL_TEST_ASSERT(suite, + ChipDnssdBrowse("_mock", DnssdServiceProtocol::kDnssdProtocolTcp, chip::Inet::IPAddressType::kAny, + chip::Inet::InterfaceId::Null(), HandleBrowse, context, + &ctx->mBrowseIdentifier) == CHIP_NO_ERROR); } void TestDnssdPubSub(nlTestSuite * inSuite, void * inContext) { - chip::Platform::MemoryInit(); - chip::DeviceLayer::PlatformMgr().InitChipStack(); - NL_TEST_ASSERT(inSuite, chip::Dnssd::ChipDnssdInit(InitCallback, ErrorCallback, inSuite) == CHIP_NO_ERROR); + DnssdContext context; + context.mTestSuite = inSuite; + + NL_TEST_ASSERT(inSuite, + chip::Dnssd::ChipDnssdInit(TestDnssdPubSub_DnssdInitCallback, DnssdErrorCallback, &context) == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, + chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(5), Timeout, &context) == + CHIP_NO_ERROR); ChipLogProgress(DeviceLayer, "Start EventLoop"); chip::DeviceLayer::PlatformMgr().RunEventLoop(); ChipLogProgress(DeviceLayer, "End EventLoop"); -} - -static const nlTest sTests[] = { NL_TEST_DEF("Test Dnssd::PubSub", TestDnssdPubSub), NL_TEST_SENTINEL() }; - -int TestDnssd() -{ - std::mutex mtx; - std::condition_variable readyCondition; - bool ready = false; + NL_TEST_ASSERT(inSuite, !context.mTimeoutExpired); - std::condition_variable doneCondition; - bool done = false; - bool shutdown = false; + // Stop browsing so we can safely shutdown DNS-SD + chip::Dnssd::ChipDnssdStopBrowse(context.mBrowseIdentifier); - int retVal = EXIT_FAILURE; - - std::thread t([&]() { - { - std::lock_guard lock(mtx); - ready = true; - readyCondition.notify_one(); - } - - nlTestSuite theSuite = { "CHIP DeviceLayer mdns tests", &sTests[0], nullptr, nullptr }; - - nlTestRunner(&theSuite, nullptr); - retVal = nlTestRunnerStats(&theSuite); - - { - std::lock_guard lock(mtx); - done = true; - doneCondition.notify_all(); - } - }); - - { - std::unique_lock lock(mtx); - readyCondition.wait(lock, [&] { return ready; }); + chip::Dnssd::ChipDnssdShutdown(); +} - doneCondition.wait_for(lock, std::chrono::seconds(5)); - if (!done) - { - fprintf(stderr, "mDNS test timeout, is avahi daemon running?\n"); +static const nlTest sTests[] = { NL_TEST_DEF("Test Dnssd::PubSub", TestDnssdPubSub), NL_TEST_SENTINEL() }; - // - // This will stop the event loop above, and wait till it has actually stopped - // (i.e exited RunEventLoop()). - // - chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); - chip::Dnssd::ChipDnssdShutdown(); - chip::DeviceLayer::PlatformMgr().Shutdown(); - shutdown = true; - - doneCondition.wait_for(lock, std::chrono::seconds(1)); - if (!done) - { - fprintf(stderr, "Orderly shutdown of the platform main loop failed as well.\n"); - } - retVal = EXIT_FAILURE; - } - } - t.join(); +int TestDnssd_Setup(void * inContext) +{ + VerifyOrReturnError(chip::Platform::MemoryInit() == CHIP_NO_ERROR, FAILURE); + VerifyOrReturnError(chip::DeviceLayer::PlatformMgr().InitChipStack() == CHIP_NO_ERROR, FAILURE); + return SUCCESS; +} - if (!shutdown) - { - chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); - chip::Dnssd::ChipDnssdShutdown(); - chip::DeviceLayer::PlatformMgr().Shutdown(); - } +int TestDnssd_Teardown(void * inContext) +{ + chip::DeviceLayer::PlatformMgr().Shutdown(); chip::Platform::MemoryShutdown(); + return SUCCESS; +} + +int TestDnssd() +{ + nlTestSuite theSuite = { "CHIP DeviceLayer mDNS tests", &sTests[0], TestDnssd_Setup, TestDnssd_Teardown }; - return retVal; + // Run test suite against one context. + nlTestRunner(&theSuite, nullptr); + return nlTestRunnerStats(&theSuite); } CHIP_REGISTER_TEST_SUITE(TestDnssd); diff --git a/src/platform/tests/TestKeyValueStoreMgr.cpp b/src/platform/tests/TestKeyValueStoreMgr.cpp index fad7e490078069..33d70713730461 100644 --- a/src/platform/tests/TestKeyValueStoreMgr.cpp +++ b/src/platform/tests/TestKeyValueStoreMgr.cpp @@ -353,7 +353,7 @@ int TestKeyValueStoreMgr() { nlTestSuite theSuite = { "KeyValueStoreMgr tests", &sTests[0], TestKeyValueStoreMgr_Setup, TestKeyValueStoreMgr_Teardown }; - // Run test suit againt one context. + // Run test suite against one context. nlTestRunner(&theSuite, nullptr); return nlTestRunnerStats(&theSuite); } diff --git a/src/platform/tests/TestPlatformMgr.cpp b/src/platform/tests/TestPlatformMgr.cpp index 449e96d30eddbd..239817d9417465 100644 --- a/src/platform/tests/TestPlatformMgr.cpp +++ b/src/platform/tests/TestPlatformMgr.cpp @@ -287,7 +287,7 @@ int TestPlatformMgr() { nlTestSuite theSuite = { "PlatformMgr tests", &sTests[0], TestPlatformMgr_Setup, TestPlatformMgr_Teardown }; - // Run test suit againt one context. + // Run test suite against one context. nlTestRunner(&theSuite, nullptr); return nlTestRunnerStats(&theSuite); } diff --git a/src/platform/tests/TestPlatformTime.cpp b/src/platform/tests/TestPlatformTime.cpp index 95698f0d696f15..8c4e9b838e3dfe 100644 --- a/src/platform/tests/TestPlatformTime.cpp +++ b/src/platform/tests/TestPlatformTime.cpp @@ -125,7 +125,7 @@ int TestPlatformTime() { nlTestSuite theSuite = { "PlatformTime tests", &sTests[0], nullptr, nullptr }; - // Run test suit againt one context. + // Run test suite against one context. nlTestRunner(&theSuite, nullptr); return nlTestRunnerStats(&theSuite); } From 77d72a84039fea5b551378d9f7d5119f5d9a16ab Mon Sep 17 00:00:00 2001 From: Sharad Binjola <31142146+sharadb-amazon@users.noreply.github.com> Date: Fri, 28 Apr 2023 07:53:21 -0700 Subject: [PATCH 050/200] tv-casting-app: Synchronizing discovery APIs, updating NetworkCommissioning FeatureMap to 1 (#26150) --- .../com/chip/casting/app/MainActivity.java | 2 +- .../jni/com/chip/casting/TvCastingApp.java | 103 +++++++----- .../tv-casting-common/tv-casting-app.matter | 2 +- .../tv-casting-common/tv-casting-app.zap | 148 +++++++++--------- 4 files changed, 140 insertions(+), 115 deletions(-) diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MainActivity.java b/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MainActivity.java index db3725c99c6afb..864f993544c760 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MainActivity.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MainActivity.java @@ -76,7 +76,7 @@ public void handleDisconnect() { * TvCastingApp */ private boolean initJni() { - tvCastingApp = new TvCastingApp(); + tvCastingApp = TvCastingApp.getInstance(); tvCastingApp.setDACProvider(new DACProviderStub()); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java index f9efdb75c1ff2f..7fc9d44da14186 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java @@ -38,17 +38,30 @@ public class TvCastingApp { private static final List DISCOVERY_TARGET_DEVICE_TYPE_FILTER = Arrays.asList(35L); // Video player = 35; + private static TvCastingApp sInstance; private Context applicationContext; private ChipAppServer chipAppServer; private NsdManagerServiceResolver.NsdManagerResolverAvailState nsdManagerResolverAvailState; private boolean discoveryStarted = false; + private Object discoveryLock = new Object(); private WifiManager.MulticastLock multicastLock; private NsdManager nsdManager; private NsdDiscoveryListener nsdDiscoveryListener; + private TvCastingApp() {} + + public static TvCastingApp getInstance() { + if (sInstance == null) { + sInstance = new TvCastingApp(); + } + return sInstance; + } + public boolean initApp(Context applicationContext, AppParameters appParameters) { - if (applicationContext == null || appParameters == null) { + if (applicationContext == null + || appParameters == null + || appParameters.getConfigurationManager() == null) { return false; } @@ -106,50 +119,62 @@ public boolean initApp(Context applicationContext, AppParameters appParameters) public void discoverVideoPlayerCommissioners( SuccessCallback discoverySuccessCallback, FailureCallback discoveryFailureCallback) { - Log.d(TAG, "TvCastingApp.discoverVideoPlayerCommissioners called"); + synchronized (discoveryLock) { + Log.d(TAG, "TvCastingApp.discoverVideoPlayerCommissioners called"); - if (this.discoveryStarted) { - Log.d(TAG, "Discovery already started, stopping before starting again"); - stopVideoPlayerDiscovery(); - } + if (this.discoveryStarted) { + Log.d(TAG, "Discovery already started, stopping before starting again"); + stopVideoPlayerDiscovery(); + } - List preCommissionedVideoPlayers = readCachedVideoPlayers(); - - WifiManager wifiManager = - (WifiManager) applicationContext.getSystemService(Context.WIFI_SERVICE); - multicastLock = wifiManager.createMulticastLock("multicastLock"); - multicastLock.setReferenceCounted(true); - multicastLock.acquire(); - - nsdManager = (NsdManager) applicationContext.getSystemService(Context.NSD_SERVICE); - nsdDiscoveryListener = - new NsdDiscoveryListener( - nsdManager, - DISCOVERY_TARGET_SERVICE_TYPE, - DISCOVERY_TARGET_DEVICE_TYPE_FILTER, - preCommissionedVideoPlayers, - discoverySuccessCallback, - discoveryFailureCallback, - nsdManagerResolverAvailState); - - nsdManager.discoverServices( - DISCOVERY_TARGET_SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, nsdDiscoveryListener); - Log.d(TAG, "TvCastingApp.discoverVideoPlayerCommissioners started"); - this.discoveryStarted = true; + List preCommissionedVideoPlayers = readCachedVideoPlayers(); + + WifiManager wifiManager = + (WifiManager) applicationContext.getSystemService(Context.WIFI_SERVICE); + multicastLock = wifiManager.createMulticastLock("multicastLock"); + multicastLock.setReferenceCounted(true); + multicastLock.acquire(); + + nsdManager = (NsdManager) applicationContext.getSystemService(Context.NSD_SERVICE); + nsdDiscoveryListener = + new NsdDiscoveryListener( + nsdManager, + DISCOVERY_TARGET_SERVICE_TYPE, + DISCOVERY_TARGET_DEVICE_TYPE_FILTER, + preCommissionedVideoPlayers, + discoverySuccessCallback, + discoveryFailureCallback, + nsdManagerResolverAvailState); + + nsdManager.discoverServices( + DISCOVERY_TARGET_SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, nsdDiscoveryListener); + Log.d(TAG, "TvCastingApp.discoverVideoPlayerCommissioners started"); + this.discoveryStarted = true; + } } public void stopVideoPlayerDiscovery() { - Log.d(TAG, "TvCastingApp trying to stop video player discovery"); - if (this.discoveryStarted - && nsdManager != null - && multicastLock != null - && nsdDiscoveryListener != null) { - Log.d(TAG, "TvCastingApp stopping Video Player commissioner discovery"); - nsdManager.stopServiceDiscovery(nsdDiscoveryListener); - if (multicastLock.isHeld()) { - multicastLock.release(); + synchronized (discoveryLock) { + Log.d(TAG, "TvCastingApp trying to stop video player discovery"); + if (this.discoveryStarted + && nsdManager != null + && multicastLock != null + && nsdDiscoveryListener != null) { + Log.d(TAG, "TvCastingApp stopping Video Player commissioner discovery"); + try { + nsdManager.stopServiceDiscovery(nsdDiscoveryListener); + } catch (IllegalArgumentException e) { + Log.w( + TAG, + "TvCastingApp received exception on calling nsdManager.stopServiceDiscovery() " + + e.getMessage()); + } + + if (multicastLock.isHeld()) { + multicastLock.release(); + } + this.discoveryStarted = false; } - this.discoveryStarted = false; } } diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter index a9a59ac12418c6..15be98246b7b73 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter @@ -2023,7 +2023,7 @@ endpoint 0 { ram attribute lastNetworkingStatus; ram attribute lastNetworkID; ram attribute lastConnectErrorValue; - ram attribute featureMap default = 5; + ram attribute featureMap default = 1; ram attribute clusterRevision default = 1; } diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap b/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap index 199ce4901cad79..134634cc5e62d4 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap @@ -2313,7 +2313,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "5", + "defaultValue": "1", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2422,7 +2422,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -2438,7 +2438,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -2454,7 +2454,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -2470,7 +2470,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -3951,7 +3951,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -3967,7 +3967,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -3983,7 +3983,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -3999,7 +3999,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -7762,7 +7762,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -7778,7 +7778,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -7794,7 +7794,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -7810,7 +7810,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8200,7 +8200,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8216,7 +8216,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8232,7 +8232,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8248,7 +8248,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8528,7 +8528,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8544,7 +8544,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8560,7 +8560,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8576,7 +8576,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8692,7 +8692,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8708,7 +8708,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8724,7 +8724,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8740,7 +8740,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -12922,7 +12922,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -12938,7 +12938,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -12954,7 +12954,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -12970,7 +12970,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13144,7 +13144,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13160,7 +13160,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13176,7 +13176,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13192,7 +13192,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13344,7 +13344,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13360,7 +13360,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13376,7 +13376,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13392,7 +13392,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13704,7 +13704,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13720,7 +13720,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13736,7 +13736,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13752,7 +13752,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13918,7 +13918,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13934,7 +13934,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13950,7 +13950,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13966,7 +13966,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14076,7 +14076,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14092,7 +14092,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14108,7 +14108,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14124,7 +14124,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14244,7 +14244,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14260,7 +14260,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14276,7 +14276,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14292,7 +14292,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14442,7 +14442,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14458,7 +14458,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14474,7 +14474,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14490,7 +14490,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14640,7 +14640,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14656,7 +14656,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14672,7 +14672,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14688,7 +14688,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14856,7 +14856,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14872,7 +14872,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14888,7 +14888,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -14904,7 +14904,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -15116,7 +15116,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -15132,7 +15132,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -15148,7 +15148,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -15164,7 +15164,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -15180,7 +15180,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -15316,7 +15316,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -15332,7 +15332,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -15348,7 +15348,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -15364,7 +15364,7 @@ "side": "server", "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", From 60e5508df04d00eb073a27980925ec121308147d Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Fri, 28 Apr 2023 22:38:26 +0530 Subject: [PATCH 051/200] [Silabs] Adds fix for LastNetworkID & LastConnectErrorValue have null value after device reset (#26237) * Adds support for NetworkStatusChangeCallback * Remove err * Moves logic to ConnectWiFiNetwork * Adds null check print * Adds UpdateNetworkingStatus API * Adds SSID length check * Refactors UpdateNetworkingStatus invocation in the ChangeWiFiStationState function * Restyled by clang-format --------- Co-authored-by: Restyled.io --- .../platform/silabs/efr32/BaseApplication.cpp | 2 +- .../silabs/ConnectivityManagerImpl_WIFI.cpp | 3 +- .../silabs/NetworkCommissioningWiFiDriver.cpp | 40 ++++++++++++++++--- .../silabs/NetworkCommissioningWiFiDriver.h | 2 + 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/examples/platform/silabs/efr32/BaseApplication.cpp b/examples/platform/silabs/efr32/BaseApplication.cpp index 6ce48e736d121e..8d088bd4de3e13 100644 --- a/examples/platform/silabs/efr32/BaseApplication.cpp +++ b/examples/platform/silabs/efr32/BaseApplication.cpp @@ -173,7 +173,7 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj) SILABS_LOG("APP: Wait WiFi Init"); while (!wfx_hw_ready()) { - vTaskDelay(10); + vTaskDelay(pdMS_TO_TICKS(10)); } SILABS_LOG("APP: Done WiFi Init"); /* We will init server when we get IP */ diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index 6b10b294b5ad02..0c113604f625df 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -397,7 +397,7 @@ void ConnectivityManagerImpl::OnStationConnected() void ConnectivityManagerImpl::OnStationDisconnected() { - // TODO Invoke WARM to perform actions that occur when the WiFi station interface goes down. + // TODO: Invoke WARM to perform actions that occur when the WiFi station interface goes down. // Alert other components of the new state. ChipDeviceEvent event; @@ -420,6 +420,7 @@ void ConnectivityManagerImpl::ChangeWiFiStationState(WiFiStationState newState) ChipLogProgress(DeviceLayer, "WiFi station state change: %s -> %s", WiFiStationStateToStr(mWiFiStationState), WiFiStationStateToStr(newState)); mWiFiStationState = newState; + NetworkCommissioning::SlWiFiDriver::GetInstance().UpdateNetworkingStatus(); } } diff --git a/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp b/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp index 5f108213f193ec..5778263466ceeb 100644 --- a/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp +++ b/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp @@ -38,10 +38,11 @@ SlScanResponseIterator mScanResponseIter CHIP_ERROR SlWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusChangeCallback) { CHIP_ERROR err; - size_t ssidLen = 0; - size_t credentialsLen = 0; - mpScanCallback = nullptr; - mpConnectCallback = nullptr; + size_t ssidLen = 0; + size_t credentialsLen = 0; + mpScanCallback = nullptr; + mpConnectCallback = nullptr; + mpStatusChangeCallback = networkStatusChangeCallback; #ifdef SL_ONNETWORK_PAIRING memcpy(&mSavedNetwork.ssid[0], SL_WIFI_SSID, sizeof(SL_WIFI_SSID)); @@ -135,11 +136,12 @@ Status SlWiFiDriver::ReorderNetwork(ByteSpan networkId, uint8_t index, MutableCh CHIP_ERROR SlWiFiDriver::ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, const char * key, uint8_t keyLen) { + int32_t status = SL_STATUS_OK; if (ConnectivityMgr().IsWiFiStationProvisioned()) { ChipLogProgress(DeviceLayer, "Disconecting for current wifi"); - int32_t status = wfx_sta_discon(); - if (status != 0) + status = wfx_sta_discon(); + if (status != SL_STATUS_OK) { return CHIP_ERROR_INTERNAL; } @@ -159,6 +161,32 @@ CHIP_ERROR SlWiFiDriver::ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, return CHIP_NO_ERROR; } +// TODO: Re-write implementation with proper driver based callback +void SlWiFiDriver::UpdateNetworkingStatus() +{ + if (mpStatusChangeCallback == nullptr) + { + ChipLogError(NetworkProvisioning, "networkStatusChangeCallback is nil"); + return; + } + + if (mStagingNetwork.ssidLen == 0) + { + ChipLogError(NetworkProvisioning, "ssidLen is 0"); + return; + } + + ByteSpan networkId = ByteSpan((const unsigned char *) mStagingNetwork.ssid, mStagingNetwork.ssidLen); + if (!wfx_is_sta_connected()) + { + mpStatusChangeCallback->OnNetworkingStatusChange(Status::kUnknownError, MakeOptional(networkId), + MakeOptional((int32_t) SL_STATUS_FAIL)); + return; + } + mpStatusChangeCallback->OnNetworkingStatusChange(Status::kSuccess, MakeOptional(networkId), + MakeOptional((int32_t) SL_STATUS_OK)); +} + void SlWiFiDriver::OnConnectWiFiNetwork() { if (mpConnectCallback) diff --git a/src/platform/silabs/NetworkCommissioningWiFiDriver.h b/src/platform/silabs/NetworkCommissioningWiFiDriver.h index 7e7dad3f3e9cdc..fd73568a6ba98b 100644 --- a/src/platform/silabs/NetworkCommissioningWiFiDriver.h +++ b/src/platform/silabs/NetworkCommissioningWiFiDriver.h @@ -123,6 +123,7 @@ class SlWiFiDriver final : public WiFiDriver chip::BitFlags ConvertSecuritytype(wfx_sec_t security); void OnConnectWiFiNetwork(); + void UpdateNetworkingStatus(); static SlWiFiDriver & GetInstance() { static SlWiFiDriver instance; @@ -138,6 +139,7 @@ class SlWiFiDriver final : public WiFiDriver WiFiNetwork mStagingNetwork = {}; ScanCallback * mpScanCallback; ConnectCallback * mpConnectCallback; + NetworkStatusChangeCallback * mpStatusChangeCallback = nullptr; }; } // namespace NetworkCommissioning From af6cb3a6d7d4cd9a4eb38ec49687260bc5ec96e7 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Fri, 28 Apr 2023 15:27:01 -0400 Subject: [PATCH 052/200] Set a recursion depth limit for TLV (#26301) * Set a recursion depth limit for TLV * Restyled by clang-format * Restyled by prettier-markdown --------- Co-authored-by: Andrei Litvin Co-authored-by: Restyled.io --- docs/ERROR_CODES.md | 1 + src/lib/core/CHIPError.cpp | 3 +++ src/lib/core/CHIPError.h | 5 ++++- src/lib/core/TLVUtilities.cpp | 13 +++++++++++++ src/lib/core/tests/TestCHIPErrorStr.cpp | 1 + 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/ERROR_CODES.md b/docs/ERROR_CODES.md index d4fd79ed0466c7..38aa66f59f34d0 100644 --- a/docs/ERROR_CODES.md +++ b/docs/ERROR_CODES.md @@ -21,6 +21,7 @@ This file was **AUTOMATICALLY** generated by | 2 | 0x02 | `CHIP_ERROR_CONNECTION_ABORTED` | | 3 | 0x03 | `CHIP_ERROR_INCORRECT_STATE` | | 4 | 0x04 | `CHIP_ERROR_MESSAGE_TOO_LONG` | +| 5 | 0x05 | `CHIP_ERROR_RECURSION_DEPTH_LIMIT` | | 6 | 0x06 | `CHIP_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS` | | 7 | 0x07 | `CHIP_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER` | | 8 | 0x08 | `CHIP_ERROR_NO_CONNECTION_HANDLER` | diff --git a/src/lib/core/CHIPError.cpp b/src/lib/core/CHIPError.cpp index 53f9b7260f530f..1b25f608b88a15 100644 --- a/src/lib/core/CHIPError.cpp +++ b/src/lib/core/CHIPError.cpp @@ -74,6 +74,9 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err) case CHIP_ERROR_MESSAGE_TOO_LONG.AsInteger(): desc = "Message too long"; break; + case CHIP_ERROR_RECURSION_DEPTH_LIMIT.AsInteger(): + desc = "Recursion depth limit reached"; + break; case CHIP_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS.AsInteger(): desc = "Too many unsolicited message handlers"; break; diff --git a/src/lib/core/CHIPError.h b/src/lib/core/CHIPError.h index e91229e4b3f799..d4471f1b996f76 100644 --- a/src/lib/core/CHIPError.h +++ b/src/lib/core/CHIPError.h @@ -466,7 +466,10 @@ using CHIP_ERROR = ::chip::ChipError; */ #define CHIP_ERROR_MESSAGE_TOO_LONG CHIP_CORE_ERROR(0x04) -// AVAILABLE: 0x05 +/** + * Recursion depth overflow + */ +#define CHIP_ERROR_RECURSION_DEPTH_LIMIT CHIP_CORE_ERROR(0x05) /** * @def CHIP_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS diff --git a/src/lib/core/TLVUtilities.cpp b/src/lib/core/TLVUtilities.cpp index 443adc6ef79ca5..65a88a36bb18b2 100644 --- a/src/lib/core/TLVUtilities.cpp +++ b/src/lib/core/TLVUtilities.cpp @@ -33,6 +33,14 @@ namespace TLV { namespace Utilities { +namespace { + +// Sets up a limit on recursion depth, to avoid any stack overflows +// on very deep TLV structures. Embedded has limited stack space. +constexpr size_t kMaxRecursionDepth = 10; + +} // namespace + struct FindContext { const Tag & mTag; @@ -63,6 +71,11 @@ static CHIP_ERROR Iterate(TLVReader & aReader, size_t aDepth, IterateHandler aHa { CHIP_ERROR retval = CHIP_NO_ERROR; + if (aDepth >= kMaxRecursionDepth) + { + return CHIP_ERROR_RECURSION_DEPTH_LIMIT; + } + if (aReader.GetType() == kTLVType_NotSpecified) { ReturnErrorOnFailure(aReader.Next()); diff --git a/src/lib/core/tests/TestCHIPErrorStr.cpp b/src/lib/core/tests/TestCHIPErrorStr.cpp index bb7d368b9e63cd..87c0967e385c47 100644 --- a/src/lib/core/tests/TestCHIPErrorStr.cpp +++ b/src/lib/core/tests/TestCHIPErrorStr.cpp @@ -53,6 +53,7 @@ static const CHIP_ERROR kTestElements[] = CHIP_ERROR_CONNECTION_ABORTED, CHIP_ERROR_INCORRECT_STATE, CHIP_ERROR_MESSAGE_TOO_LONG, + CHIP_ERROR_RECURSION_DEPTH_LIMIT, CHIP_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS, CHIP_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER, CHIP_ERROR_NO_CONNECTION_HANDLER, From bedffde3e8fdae4dd7e12f0b0c96b0062d8947a3 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Fri, 28 Apr 2023 17:25:48 -0400 Subject: [PATCH 053/200] Fix pigweed RPC logging on ESP32 (#26282) --- config/esp32/components/chip/Kconfig | 6 +++--- src/platform/ESP32/Logging.cpp | 27 ++++++--------------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index e92764e5dfa078..077331b16cb3ef 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -112,9 +112,9 @@ menu "CHIP Core" int "Set threshold in ms" default 700 help - Time threshold for events dispatching. By default set to 0 to - to disable event dispatching time measurement and suppress the - logs for Long dispatch time. + Time threshold for warning that dispatched took too long. You can + set this default set to 0 to to disable event dispatching time + measurement and suppress the logs "Long dispatch time:...". # TODO: add log level selection diff --git a/src/platform/ESP32/Logging.cpp b/src/platform/ESP32/Logging.cpp index 7f96a70dabecb2..b2fbaac3cfbd1a 100644 --- a/src/platform/ESP32/Logging.cpp +++ b/src/platform/ESP32/Logging.cpp @@ -26,35 +26,20 @@ void ENFORCE_FORMAT(3, 0) LogV(const char * module, uint8_t category, const char snprintf(tag, sizeof(tag), "chip[%s]", module); tag[sizeof(tag) - 1] = 0; + char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; + vsnprintf(formattedMsg, sizeof(formattedMsg), msg, v); + switch (category) { case kLogCategory_Error: - if (esp_log_default_level >= ESP_LOG_ERROR) - { - printf(LOG_COLOR_E "E"); // set color - printf(" (%u) %s: ", esp_log_timestamp(), tag); // add timestamp - esp_log_writev(ESP_LOG_ERROR, tag, msg, v); - printf(LOG_RESET_COLOR "\n"); - } + ESP_LOGE(tag, "%s", formattedMsg); break; case kLogCategory_Progress: default: - if (esp_log_default_level >= ESP_LOG_INFO) - { - printf(LOG_COLOR_I "I"); // set color - printf(" (%u) %s: ", esp_log_timestamp(), tag); // add timestamp - esp_log_writev(ESP_LOG_INFO, tag, msg, v); - printf(LOG_RESET_COLOR "\n"); - } + ESP_LOGI(tag, "%s", formattedMsg); break; case kLogCategory_Detail: - if (esp_log_default_level >= ESP_LOG_DEBUG) - { - printf(LOG_COLOR_D "D"); // set color - printf(" (%u) %s: ", esp_log_timestamp(), tag); // add timestamp - esp_log_writev(ESP_LOG_DEBUG, tag, msg, v); - printf(LOG_RESET_COLOR "\n"); - } + ESP_LOGD(tag, "%s", formattedMsg); break; } } From 6211b743f6c2b29fed37184c1384917a6c6f533b Mon Sep 17 00:00:00 2001 From: Marius Tache <102153746+marius-alex-tache@users.noreply.github.com> Date: Sat, 29 Apr 2023 07:23:27 +0300 Subject: [PATCH 054/200] Fix pigweed tokenizer port (#26283) Issue introduced in: https://github.com/project-chip/connectedhomeip/pull/25351 Encoded message should also contain the token. Signed-off-by: Marius Tache --- src/lib/support/logging/CHIPLogging.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/support/logging/CHIPLogging.cpp b/src/lib/support/logging/CHIPLogging.cpp index 27b93e802f7991..fae093cd9cca5c 100644 --- a/src/lib/support/logging/CHIPLogging.cpp +++ b/src/lib/support/logging/CHIPLogging.cpp @@ -53,10 +53,13 @@ void HandleTokenizedLog(uint32_t levels, pw_tokenizer_Token token, pw_tokenizer_ { uint8_t encoded_message[PW_TOKENIZER_CFG_ENCODING_BUFFER_SIZE_BYTES]; + memcpy(encoded_message, &token, sizeof(token)); + va_list args; va_start(args, types); // Use the C argument encoding API, since the C++ API requires C++17. - const size_t encoded_size = pw_tokenizer_EncodeArgs(types, args, encoded_message, sizeof(encoded_message)); + const size_t encoded_size = sizeof(token) + + pw_tokenizer_EncodeArgs(types, args, encoded_message + sizeof(token), sizeof(encoded_message) - sizeof(token)); va_end(args); uint8_t log_category = levels >> 8 & 0xFF; From 29f0d36540d45e6fc7530a677a562d0ffc854f9a Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Sat, 29 Apr 2023 07:55:20 +0200 Subject: [PATCH 055/200] Enable thread safety analysis for system mutex (#23678) * Enable thread safety analysis for system mutex Thread Safety Analysis [1] is a clang extension tool which adds static analysis for potential race conditions. This commit adds support for such thread safety analysis to Matter system mutex class. Simple usage: int state CHIP_GUARDED_BY(stateMtx); chip::System::Mutex stateMtx; void setState(int value) { chip::System::MutexUniqueLock lock(stateMtx); state = value; } [1] https://clang.llvm.org/docs/ThreadSafetyAnalysis.html * Reuse thread safety config from pigweed * No need to wrap std::lock_guard since clang c++ std library provides such functionality out of the box. The only requirements is that the _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1 is defined. * Use thread safety with ConnectivityManagerImpl to prove that it works --- build/config/compiler/BUILD.gn | 3 ++ src/platform/Linux/ConnectivityManagerImpl.h | 3 +- src/system/SystemMutex.h | 42 +++++++++++++++++--- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 577dac76c66642..d03db67b0f2322 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -259,6 +259,7 @@ config("strict_warnings") { cflags_cc = [ "-Wnon-virtual-dtor" ] + configs = [] ldflags = [] if (is_clang) { @@ -269,6 +270,8 @@ config("strict_warnings") { "-Wformat-type-confusion", ] + configs += [ "$dir_pw_build:clang_thread_safety_warnings" ] + # TODO: can make this back fatal in once pigweed updates can be taken again. # See https://github.com/project-chip/connectedhomeip/pull/22079 # diff --git a/src/platform/Linux/ConnectivityManagerImpl.h b/src/platform/Linux/ConnectivityManagerImpl.h index f534bf067eb1c4..f3bcc2cedcb8f4 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.h +++ b/src/platform/Linux/ConnectivityManagerImpl.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #endif @@ -207,7 +208,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, static bool mAssociationStarted; static BitFlags mConnectivityFlag; - static GDBusWpaSupplicant mWpaSupplicant; + static GDBusWpaSupplicant mWpaSupplicant CHIP_GUARDED_BY(mWpaSupplicantMutex); // Access to mWpaSupplicant has to be protected by a mutex because it is accessed from // the CHIP event loop thread and dedicated D-Bus thread started by platform manager. static std::mutex mWpaSupplicantMutex; diff --git a/src/system/SystemMutex.h b/src/system/SystemMutex.h index c697ea52b9cc64..bb0d67fd7d91c4 100644 --- a/src/system/SystemMutex.h +++ b/src/system/SystemMutex.h @@ -63,6 +63,34 @@ namespace chip { namespace System { +// Enable thread safety attributes only with clang. +#if defined(__clang__) && (!defined(SWIG)) +#define CHIP_TSA_ATTRIBUTE__(x) __attribute__((x)) +#else +#define CHIP_TSA_ATTRIBUTE__(x) +#endif + +#define CHIP_CAPABILITY(x) CHIP_TSA_ATTRIBUTE__(capability(x)) +#define CHIP_SCOPED_CAPABILITY CHIP_TSA_ATTRIBUTE__(scoped_lockable) +#define CHIP_GUARDED_BY(x) CHIP_TSA_ATTRIBUTE__(guarded_by(x)) +#define CHIP_PT_GUARDED_BY(x) CHIP_TSA_ATTRIBUTE__(pt_guarded_by(x)) +#define CHIP_ACQUIRED_BEFORE(...) CHIP_TSA_ATTRIBUTE__(acquired_before(__VA_ARGS__)) +#define CHIP_ACQUIRED_AFTER(...) CHIP_TSA_ATTRIBUTE__(acquired_after(__VA_ARGS__)) +#define CHIP_REQUIRES(...) CHIP_TSA_ATTRIBUTE__(requires_capability(__VA_ARGS__)) +#define CHIP_REQUIRES_SHARED(...) CHIP_TSA_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__)) +#define CHIP_ACQUIRE(...) CHIP_TSA_ATTRIBUTE__(acquire_capability(__VA_ARGS__)) +#define CHIP_ACQUIRE_SHARED(...) CHIP_TSA_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__)) +#define CHIP_RELEASE(...) CHIP_TSA_ATTRIBUTE__(release_capability(__VA_ARGS__)) +#define CHIP_RELEASE_SHARED(...) CHIP_TSA_ATTRIBUTE__(release_shared_capability(__VA_ARGS__)) +#define CHIP_RELEASE_GENERIC(...) CHIP_TSA_ATTRIBUTE__(release_generic_capability(__VA_ARGS__)) +#define CHIP_TRY_ACQUIRE(...) CHIP_TSA_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__)) +#define CHIP_TRY_ACQUIRE_SHARED(...) CHIP_TSA_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__)) +#define CHIP_EXCLUDES(...) CHIP_TSA_ATTRIBUTE__(locks_excluded(__VA_ARGS__)) +#define CHIP_ASSERT_CAPABILITY(x) CHIP_TSA_ATTRIBUTE__(assert_capability(x)) +#define CHIP_ASSERT_SHARED_CAPABILITY(x) CHIP_TSA_ATTRIBUTE__(assert_shared_capability(x)) +#define CHIP_RETURN_CAPABILITY(x) CHIP_TSA_ATTRIBUTE__(lock_returned(x)) +#define CHIP_NO_THREAD_SAFETY_ANALYSIS CHIP_TSA_ATTRIBUTE__(no_thread_safety_analysis) + /** * @class Mutex * @@ -73,8 +101,12 @@ namespace System { * objects with \c static storage duration and uninitialized memory. Use \c Init method to initialize. The copy/move * operators are not provided. * + * @note + * This class is compatible with \c std::lock_guard and provides + * annotations for thread safety analysis. + * */ -class DLL_EXPORT Mutex +class DLL_EXPORT CHIP_CAPABILITY("mutex") Mutex { public: Mutex() = default; @@ -84,12 +116,12 @@ class DLL_EXPORT Mutex inline bool isInitialized() { return mInitialized; } #endif // CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING - void Lock(); /**< Acquire the mutual exclusion lock, blocking the current thread indefinitely if necessary. */ - void Unlock(); /**< Release the mutual exclusion lock (can block on some systems until scheduler completes). */ + void Lock() CHIP_ACQUIRE(); /**< Acquire the mutual exclusion lock, blocking the current thread indefinitely if necessary. */ + void Unlock() CHIP_RELEASE(); /**< Release the mutual exclusion lock (can block on some systems until scheduler completes). */ // Synonyms for compatibility with std::lock_guard. - void lock() { Lock(); } - void unlock() { Unlock(); } + void lock() CHIP_ACQUIRE() { Lock(); } + void unlock() CHIP_RELEASE() { Unlock(); } private: #if CHIP_SYSTEM_CONFIG_POSIX_LOCKING From b515086fe5106cc1e0321934ce15e9cbad25b5ec Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Sat, 29 Apr 2023 09:32:30 -0700 Subject: [PATCH 056/200] lock flask version for cirque (#26306) --- .../docker/images/chip-build-cirque/requirements_nogrpc.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/docker/images/chip-build-cirque/requirements_nogrpc.txt b/integrations/docker/images/chip-build-cirque/requirements_nogrpc.txt index be3d07c234eb36..508ad6d8ddef61 100644 --- a/integrations/docker/images/chip-build-cirque/requirements_nogrpc.txt +++ b/integrations/docker/images/chip-build-cirque/requirements_nogrpc.txt @@ -1,6 +1,6 @@ cmd2 docker >= 4.1.0 -flask >= 1.1.0 +flask == 2.2.2 pycodestyle >= 2.5.0 pylint == 2.4 pyroute2 >= 0.5.7 From 309e9f1afc989cea5927063d8a592e5eecb0b3ea Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Sat, 29 Apr 2023 12:32:47 -0400 Subject: [PATCH 057/200] Ensure that DataModel::Encode does not encode kUnknownEnumValue for enums. (#26299) This should help prevent those values leaking out on the wire. Fixes https://github.com/project-chip/connectedhomeip/issues/24368 --- .../chip-tool/include/CHIPProjectAppConfig.h | 5 ++- examples/darwin-framework-tool/BUILD.gn | 6 ++++ examples/darwin-framework-tool/args.gni | 11 +++++++ .../include/CHIPProjectAppConfig.h | 31 +++++++++++++++++++ scripts/build/build_darwin_framework.py | 5 +++ src/app/data-model/Encode.h | 27 +++++++++++++++- src/app/tests/suites/TestCluster.yaml | 7 ++--- src/app/tests/suites/TestEvents.yaml | 6 ++-- .../Framework/chip_xcode_build_connector.sh | 9 ++++++ src/lib/core/CHIPConfig.h | 11 +++++++ .../chip-tool/zap-generated/test/Commands.h | 14 +++------ .../zap-generated/test/Commands.h | 19 ++++-------- 12 files changed, 118 insertions(+), 33 deletions(-) create mode 100644 examples/darwin-framework-tool/include/CHIPProjectAppConfig.h diff --git a/examples/chip-tool/include/CHIPProjectAppConfig.h b/examples/chip-tool/include/CHIPProjectAppConfig.h index 36ce69c2007feb..bc8ee25a03645e 100644 --- a/examples/chip-tool/include/CHIPProjectAppConfig.h +++ b/examples/chip-tool/include/CHIPProjectAppConfig.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020-2022 Project CHIP Authors + * Copyright (c) 2020-2023 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,4 +63,7 @@ // Enable some test-only interaction model APIs. #define CONFIG_BUILD_FOR_HOST_UNIT_TEST 1 +// Allow us, for test purposes, to encode invalid enum values. +#define CHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES 1 + #endif /* CHIPPROJECTCONFIG_H */ diff --git a/examples/darwin-framework-tool/BUILD.gn b/examples/darwin-framework-tool/BUILD.gn index 67939fcb311f28..b920356a29b3a3 100644 --- a/examples/darwin-framework-tool/BUILD.gn +++ b/examples/darwin-framework-tool/BUILD.gn @@ -100,6 +100,12 @@ action("build-darwin-framework") { args += [ "--no-clang" ] } + if (config_enable_yaml_tests) { + args += [ "--enable_encoding_sentinel_enum_values" ] + } else { + args += [ "--no-enable_encoding_sentinel_enum_values" ] + } + output_name = "Matter.framework" outputs = [ "${root_out_dir}/macos_framework_output/Build/Products/${output_sdk_type}/${output_name}", diff --git a/examples/darwin-framework-tool/args.gni b/examples/darwin-framework-tool/args.gni index 0cd237a8409fa7..8308b2a9bcffaa 100644 --- a/examples/darwin-framework-tool/args.gni +++ b/examples/darwin-framework-tool/args.gni @@ -16,4 +16,15 @@ import("//build_overrides/chip.gni") import("${chip_root}/config/standalone/args.gni") +import("${chip_root}/examples/chip-tool/chip-tool.gni") + chip_crypto = "boringssl" + +if (config_enable_yaml_tests) { + chip_device_project_config_include = "" + chip_project_config_include = "" + + chip_project_config_include_dirs = + [ "${chip_root}/examples/darwin-framework-tool/include" ] + chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] +} diff --git a/examples/darwin-framework-tool/include/CHIPProjectAppConfig.h b/examples/darwin-framework-tool/include/CHIPProjectAppConfig.h new file mode 100644 index 00000000000000..6f1764a52df56b --- /dev/null +++ b/examples/darwin-framework-tool/include/CHIPProjectAppConfig.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Project configuration for Darwin Framework Tool. + * + */ +#ifndef CHIPPROJECTCONFIG_H +#define CHIPPROJECTCONFIG_H + +// Enable some test-only interaction model APIs. +#define CONFIG_BUILD_FOR_HOST_UNIT_TEST 1 + +// Allow us, for test purposes, to encode invalid enum values. +#define CHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES 1 + +#endif /* CHIPPROJECTCONFIG_H */ diff --git a/scripts/build/build_darwin_framework.py b/scripts/build/build_darwin_framework.py index af7e428c27be07..edb854d7d173ab 100644 --- a/scripts/build/build_darwin_framework.py +++ b/scripts/build/build_darwin_framework.py @@ -82,6 +82,7 @@ def build_darwin_framework(args): 'CHIP_IS_ASAN': args.asan, 'CHIP_IS_BLE': args.ble, 'CHIP_IS_CLANG': args.clang, + 'CHIP_ENABLE_ENCODING_SENTINEL_ENUM_VALUES': args.enable_encoding_sentinel_enum_values } for option in options: command += ["{}={}".format(option, "YES" if options[option] else "NO")] @@ -116,6 +117,9 @@ def build_darwin_framework(args): get_file_from_pigweed("libclang_rt.asan_osx_dynamic.dylib") ] + if args.enable_encoding_sentinel_enum_values: + cflags += ["-DCHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES=1"] + command += ["OTHER_CFLAGS=" + ' '.join(cflags), "OTHER_LDFLAGS=" + ' '.join(ldflags)] command_result = run_command(command) print("Build Framework Result: {}".format(command_result)) @@ -158,6 +162,7 @@ def build_darwin_framework(args): parser.add_argument('--asan', action=argparse.BooleanOptionalAction) parser.add_argument('--ble', action=argparse.BooleanOptionalAction) parser.add_argument('--clang', action=argparse.BooleanOptionalAction) + parser.add_argument('--enable_encoding_sentinel_enum_values', action=argparse.BooleanOptionalAction) args = parser.parse_args() build_darwin_framework(args) diff --git a/src/app/data-model/Encode.h b/src/app/data-model/Encode.h index 3e930a1c0ec24a..0546098a74184d 100644 --- a/src/app/data-model/Encode.h +++ b/src/app/data-model/Encode.h @@ -31,6 +31,18 @@ namespace chip { namespace app { namespace DataModel { +namespace detail { +// A way to detect whether an enum has a kUnknownEnumValue value, for use in enable_if. +template +using VoidType = void; + +template +constexpr bool HasUnknownValue = false; + +template +constexpr bool HasUnknownValue> = true; +} // namespace detail + /* * @brief * Set of overloaded encode methods that based on the type of cluster element passed in, @@ -48,9 +60,22 @@ CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag, X x) return writer.Put(tag, x); } -template ::value, int> = 0> +template ::value && !detail::HasUnknownValue, int> = 0> +CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag, X x) +{ + return writer.Put(tag, x); +} + +template ::value && detail::HasUnknownValue, int> = 0> CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag, X x) { +#if !CHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES + if (x == X::kUnknownEnumValue) + { + return CHIP_IM_GLOBAL_STATUS(ConstraintError); + } +#endif // !CHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES + return writer.Put(tag, x); } diff --git a/src/app/tests/suites/TestCluster.yaml b/src/app/tests/suites/TestCluster.yaml index 5f127d112aeca9..e89a892dd32ee5 100644 --- a/src/app/tests/suites/TestCluster.yaml +++ b/src/app/tests/suites/TestCluster.yaml @@ -1068,11 +1068,8 @@ tests: - name: "arg2" value: 101 response: - values: - - name: "arg1" - value: 20003 - - name: "arg2" - value: 4 + # Attempting to echo back the invalid enum value should fail. + error: FAILURE # Tests for Struct diff --git a/src/app/tests/suites/TestEvents.yaml b/src/app/tests/suites/TestEvents.yaml index e43dc0f5423c75..03f314fea3bdbe 100644 --- a/src/app/tests/suites/TestEvents.yaml +++ b/src/app/tests/suites/TestEvents.yaml @@ -80,7 +80,7 @@ tests: - name: "arg1" value: 3 - name: "arg2" - value: 4 + value: 1 - name: "arg3" value: false response: @@ -95,7 +95,7 @@ tests: - values: - value: { arg1: 1, arg2: 2, arg3: true } - values: - - value: { arg1: 3, arg2: 4, arg3: false } + - value: { arg1: 3, arg2: 1, arg3: false } - label: "Subscribe to the event" command: "subscribeEvent" @@ -106,7 +106,7 @@ tests: - values: - value: { arg1: 1, arg2: 2, arg3: true } - values: - - value: { arg1: 3, arg2: 4, arg3: false } + - value: { arg1: 3, arg2: 1, arg3: false } - label: "Generate a third event on the accessory" command: "TestEmitTestEventRequest" diff --git a/src/darwin/Framework/chip_xcode_build_connector.sh b/src/darwin/Framework/chip_xcode_build_connector.sh index 55227ed2b5330f..eee0afeed97506 100755 --- a/src/darwin/Framework/chip_xcode_build_connector.sh +++ b/src/darwin/Framework/chip_xcode_build_connector.sh @@ -58,6 +58,9 @@ for define in "${defines[@]}"; do esac target_defines+=,\"${define//\"/\\\"}\" done +[[ $CHIP_ENABLE_ENCODING_SENTINEL_ENUM_VALUES == YES ]] && { + target_defines+=,\"CHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES=1\" +} target_defines=[${target_defines:1}] declare target_arch= @@ -142,6 +145,12 @@ declare -a args=( ) } +[[ $CHIP_ENABLE_ENCODING_SENTINEL_ENUM_VALUES == YES ]] && { + args+=( + 'enable_encoding_sentinel_enum_values=true' + ) +} + # search current (or $2) and its parent directories until # a name match is found, which is output on stdout find_in_ancestors() { diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index 4052c17a446bfa..961db5250e7d63 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -914,6 +914,17 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; #define CONFIG_BUILD_FOR_HOST_UNIT_TEST 0 #endif +/** + * @def CHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES + * + * @brief Defines whether encoding the "not a known enum value" enum values is + * allowed. Should only be enabled in certain test applications. This + * flag must not be enabled on actual devices. + */ +#ifndef CHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES +#define CHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES 0 +#endif + /** * @def CHIP_CONFIG_LAMBDA_EVENT_SIZE * diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 1666169997e780..1696aa2afc2543 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -58751,13 +58751,7 @@ class TestClusterSuite : public TestCommand } break; case 156: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::UnitTesting::Commands::TestEnumsResponse::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("arg1", value.arg1, 20003U)); - VerifyOrReturn(CheckValue("arg2", value.arg2, 4U)); - } + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 157: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -66197,7 +66191,7 @@ class TestEventsSuite : public TestCommand chip::app::Clusters::UnitTesting::Events::TestEvent::DecodableType value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckValue("testEvent.arg1", value.arg1, 3U)); - VerifyOrReturn(CheckValue("testEvent.arg2", value.arg2, 4U)); + VerifyOrReturn(CheckValue("testEvent.arg2", value.arg2, 1U)); VerifyOrReturn(CheckValue("testEvent.arg3", value.arg3, false)); } mTestSubStepIndex++; @@ -66227,7 +66221,7 @@ class TestEventsSuite : public TestCommand chip::app::Clusters::UnitTesting::Events::TestEvent::DecodableType value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckValue("testEvent.arg1", value.arg1, 3U)); - VerifyOrReturn(CheckValue("testEvent.arg2", value.arg2, 4U)); + VerifyOrReturn(CheckValue("testEvent.arg2", value.arg2, 1U)); VerifyOrReturn(CheckValue("testEvent.arg3", value.arg3, false)); } mTestSubStepIndex++; @@ -66334,7 +66328,7 @@ class TestEventsSuite : public TestCommand ListFreer listFreer; chip::app::Clusters::UnitTesting::Commands::TestEmitTestEventRequest::Type value; value.arg1 = 3U; - value.arg2 = static_cast(4); + value.arg2 = static_cast(1); value.arg3 = false; return SendCommand(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Commands::TestEmitTestEventRequest::Id, value, chip::NullOptional 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 391eef964a706e..bfccaf83dbe46f 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -82389,7 +82389,7 @@ class TestCluster : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 156: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 157: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -87068,18 +87068,11 @@ class TestCluster : public TestCommandBridge { completion:^(MTRUnitTestingClusterTestEnumsResponseParams * _Nullable values, NSError * _Nullable err) { NSLog(@"Send a command with a vendor_id and invalid enum Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("arg1", actualValue, 20003U)); - } - - { - id actualValue = values.arg2; - VerifyOrReturn(CheckValue("arg2", actualValue, 4U)); - } - + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code + : EMBER_ZCL_STATUS_FAILURE) + : 0, + EMBER_ZCL_STATUS_FAILURE)); NextTest(); }]; From 3d84c9dea3aa77e7881c0f873109ca0a269b90c9 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 1 May 2023 10:34:08 -0400 Subject: [PATCH 058/200] Remove the kDNSServiceInterfaceIndexLocalOnly special-case on Darwin. (#26287) Interface kDNSServiceInterfaceIndexLocalOnly means the _registration_ is local-only, not that the registered host is localhost and has a loopback address. There can be local-only registrations for other hosts, and we need to do actual address resolution. To make this work right in our unit test setup, fix our registration code for the local-only case (which tests use) to register hostname -> IP mappings, which it was not doing before. --- src/platform/Darwin/DnssdContexts.cpp | 22 +++++------ .../Darwin/DnssdHostNameRegistrar.cpp | 37 +++++++++++++++---- src/platform/Darwin/DnssdHostNameRegistrar.h | 12 ++++-- src/platform/Darwin/DnssdImpl.cpp | 6 --- src/platform/Darwin/DnssdImpl.h | 1 - 5 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/platform/Darwin/DnssdContexts.cpp b/src/platform/Darwin/DnssdContexts.cpp index 832b33637d88fa..27bb5140a55651 100644 --- a/src/platform/Darwin/DnssdContexts.cpp +++ b/src/platform/Darwin/DnssdContexts.cpp @@ -420,7 +420,6 @@ CHIP_ERROR ResolveContext::OnNewAddress(uint32_t interfaceId, const struct socka chip::Inet::IPAddress ip; ReturnErrorOnFailure(chip::Inet::IPAddress::GetIPAddressFromSockAddr(*address, ip)); - interfaces[interfaceId].addresses.push_back(ip); #ifdef CHIP_PROGRESS_LOGGING char addrStr[INET6_ADDRSTRLEN]; @@ -428,19 +427,18 @@ CHIP_ERROR ResolveContext::OnNewAddress(uint32_t interfaceId, const struct socka ChipLogProgress(Discovery, "Mdns: %s interface: %" PRIu32 " ip:%s", __func__, interfaceId, addrStr); #endif // CHIP_PROGRESS_LOGGING - return CHIP_NO_ERROR; -} + if (ip.IsIPv6LinkLocal() && interfaceId == kDNSServiceInterfaceIndexLocalOnly) + { + // We need a real interface to use a link-local address. Just ignore + // this one, because trying to use it will simply lead to "No route to + // host" errors. + ChipLogProgress(Discovery, "Mdns: Ignoring link-local address with no usable interface"); + return CHIP_NO_ERROR; + } -CHIP_ERROR ResolveContext::OnNewLocalOnlyAddress() -{ - sockaddr_in6 sockaddr; - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sin6_len = sizeof(sockaddr); - sockaddr.sin6_family = AF_INET6; - sockaddr.sin6_addr = in6addr_loopback; - sockaddr.sin6_port = htons((unsigned short) interfaces[kDNSServiceInterfaceIndexLocalOnly].service.mPort); + interfaces[interfaceId].addresses.push_back(ip); - return OnNewAddress(kDNSServiceInterfaceIndexLocalOnly, reinterpret_cast(&sockaddr)); + return CHIP_NO_ERROR; } bool ResolveContext::HasAddress() diff --git a/src/platform/Darwin/DnssdHostNameRegistrar.cpp b/src/platform/Darwin/DnssdHostNameRegistrar.cpp index 572aa043043e4d..287bc0bec3380f 100644 --- a/src/platform/Darwin/DnssdHostNameRegistrar.cpp +++ b/src/platform/Darwin/DnssdHostNameRegistrar.cpp @@ -284,9 +284,31 @@ DNSServiceErrorType HostNameRegistrar::Init(const char * hostname, Inet::IPAddre CHIP_ERROR HostNameRegistrar::Register() { - // If the target interface is kDNSServiceInterfaceIndexLocalOnly, there are no interfaces to register against - // the dns daemon. - VerifyOrReturnError(!IsLocalOnly(), CHIP_NO_ERROR); + // If the target interface is kDNSServiceInterfaceIndexLocalOnly, just + // register the loopback addresses. + if (IsLocalOnly()) + { + ReturnErrorOnFailure(ResetSharedConnection()); + + InetInterfacesVector inetInterfaces; + Inet6InterfacesVector inet6Interfaces; + // Instead of mInterfaceId (which will not match any actual interface), + // use kDNSServiceInterfaceIndexAny and restrict to loopback interfaces. + GetInterfaceAddresses(kDNSServiceInterfaceIndexAny, mAddressType, inetInterfaces, inet6Interfaces, + true /* searchLoopbackOnly */); + + // But we register the IPs with mInterfaceId, not the actual interface + // IDs, so that resolution code that is grouping addresses by interface + // ends up doing the right thing, since we registered our SRV record on + // mInterfaceId. + // + // And only register the IPv6 ones, for simplicity. + for (auto & interface : inet6Interfaces) + { + ReturnErrorOnFailure(RegisterInterface(mInterfaceId, interface.second, kDNSServiceType_AAAA)); + } + return CHIP_NO_ERROR; + } return StartMonitorInterfaces(^(InetInterfacesVector inetInterfaces, Inet6InterfacesVector inet6Interfaces) { ReturnOnFailure(ResetSharedConnection()); @@ -305,11 +327,10 @@ CHIP_ERROR HostNameRegistrar::RegisterInterface(uint32_t interfaceId, uint16_t r void HostNameRegistrar::Unregister() { - // If the target interface is kDNSServiceInterfaceIndexLocalOnly, there are no interfaces to register against - // the dns daemon. - VerifyOrReturn(!IsLocalOnly()); - - StopMonitorInterfaces(); + if (!IsLocalOnly()) + { + StopMonitorInterfaces(); + } StopSharedConnection(); } diff --git a/src/platform/Darwin/DnssdHostNameRegistrar.h b/src/platform/Darwin/DnssdHostNameRegistrar.h index 9bb5ce463cfdf6..68de1407298dfb 100644 --- a/src/platform/Darwin/DnssdHostNameRegistrar.h +++ b/src/platform/Darwin/DnssdHostNameRegistrar.h @@ -50,14 +50,18 @@ namespace Dnssd { { for (auto & interface : interfaces) { auto interfaceId = interface.first; - auto interfaceAddress = static_cast(&interface.second); - auto interfaceAddressLen = sizeof(interface.second); - LogErrorOnFailure( - RegisterInterface(interfaceId, type, interfaceAddress, static_cast(interfaceAddressLen))); + LogErrorOnFailure(RegisterInterface(interfaceId, interface.second, type)); } } + template CHIP_ERROR RegisterInterface(uint32_t interfaceId, const T & interfaceAddress, uint16_t type) + { + auto interfaceAddressLen = sizeof(interfaceAddress); + + return RegisterInterface(interfaceId, type, &interfaceAddress, static_cast(interfaceAddressLen)); + } + CHIP_ERROR RegisterInterface(uint32_t interfaceId, uint16_t rtype, const void * rdata, uint16_t rdlen); CHIP_ERROR StartSharedConnection(); diff --git a/src/platform/Darwin/DnssdImpl.cpp b/src/platform/Darwin/DnssdImpl.cpp index acf65e09511534..c3e839e3308249 100644 --- a/src/platform/Darwin/DnssdImpl.cpp +++ b/src/platform/Darwin/DnssdImpl.cpp @@ -328,12 +328,6 @@ static void OnResolve(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t inter if (kDNSServiceErr_NoError == err) { sdCtx->OnNewInterface(interfaceId, fullname, hostname, port, txtLen, txtRecord); - if (kDNSServiceInterfaceIndexLocalOnly == interfaceId) - { - sdCtx->OnNewLocalOnlyAddress(); - sdCtx->Finalize(); - return; - } } if (!(flags & kDNSServiceFlagsMoreComing)) diff --git a/src/platform/Darwin/DnssdImpl.h b/src/platform/Darwin/DnssdImpl.h index d599b052cdb1f6..9b624bae73e4f3 100644 --- a/src/platform/Darwin/DnssdImpl.h +++ b/src/platform/Darwin/DnssdImpl.h @@ -204,7 +204,6 @@ struct ResolveContext : public GenericContext void DispatchSuccess() override; CHIP_ERROR OnNewAddress(uint32_t interfaceId, const struct sockaddr * address); - CHIP_ERROR OnNewLocalOnlyAddress(); bool HasAddress(); void OnNewInterface(uint32_t interfaceId, const char * fullname, const char * hostname, uint16_t port, uint16_t txtLen, From 51dabc860c2a9538f4912b82010938d6e3694ee7 Mon Sep 17 00:00:00 2001 From: Wang Qixiang <43193572+wqx6@users.noreply.github.com> Date: Mon, 1 May 2023 22:34:55 +0800 Subject: [PATCH 059/200] ESP32: Fix route hook iterator issue (#26249) --- src/platform/ESP32/route_hook/ESP32RouteHook.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/ESP32/route_hook/ESP32RouteHook.c b/src/platform/ESP32/route_hook/ESP32RouteHook.c index a63df118619ed3..df19adf1de13e8 100644 --- a/src/platform/ESP32/route_hook/ESP32RouteHook.c +++ b/src/platform/ESP32/route_hook/ESP32RouteHook.c @@ -163,7 +163,7 @@ esp_err_t esp_route_hook_init(esp_netif_t * netif) lwip_netif = netif_get_by_index((uint8_t) netif_idx); ESP_RETURN_ON_FALSE(lwip_netif != NULL, ESP_ERR_INVALID_ARG, TAG, "Invalid network interface"); - for (esp_route_hook_t * iter = s_hooks; iter != NULL; iter++) + for (esp_route_hook_t * iter = s_hooks; iter != NULL; iter = iter->next) { if (iter->netif == lwip_netif) { From c9a6c1de7593d00cb917dd4069b0a25fde47939d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 10:37:55 -0400 Subject: [PATCH 060/200] Bump third_party/openthread/repo from `6bfcc0d` to `34ecac8` (#26311) Bumps [third_party/openthread/repo](https://github.com/openthread/openthread) from `6bfcc0d` to `34ecac8`. - [Release notes](https://github.com/openthread/openthread/releases) - [Commits](https://github.com/openthread/openthread/compare/6bfcc0d7d495fcc7bcf1cdd4070bee14c391ef95...34ecac8536f6a8e23391b7f25b7ec401bf1ae305) --- updated-dependencies: - dependency-name: third_party/openthread/repo dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- third_party/openthread/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/openthread/repo b/third_party/openthread/repo index 6bfcc0d7d495fc..34ecac8536f6a8 160000 --- a/third_party/openthread/repo +++ b/third_party/openthread/repo @@ -1 +1 @@ -Subproject commit 6bfcc0d7d495fcc7bcf1cdd4070bee14c391ef95 +Subproject commit 34ecac8536f6a8e23391b7f25b7ec401bf1ae305 From 8478a1a394bc2ea2322a9c093db2b4bf2be09410 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 1 May 2023 15:00:13 -0400 Subject: [PATCH 061/200] Encode as much of a list as possible as a single IB when reading. (#26286) Instead of doing one IB to start empty list and one IB per item, switch to doing one IB with as many items as we can fit in our packet (with a REPLACE path), then one IB per item with ADD paths as now. This reduces the data transferred for a wildcard-everything read from lighting-app from 26 AttributeReport packets to 12. Fixes https://github.com/project-chip/connectedhomeip/issues/26271 --- src/app/AttributeAccessInterface.cpp | 89 ++++-- src/app/AttributeAccessInterface.h | 68 +++-- src/app/tests/TestAttributeValueEncoder.cpp | 312 +++++++++++++++----- src/app/tests/TestReadInteraction.cpp | 75 ++++- 4 files changed, 416 insertions(+), 128 deletions(-) diff --git a/src/app/AttributeAccessInterface.cpp b/src/app/AttributeAccessInterface.cpp index e9ca4325b1f3d2..0c5a85c2fe92f8 100644 --- a/src/app/AttributeAccessInterface.cpp +++ b/src/app/AttributeAccessInterface.cpp @@ -55,39 +55,82 @@ CHIP_ERROR AttributeReportBuilder::FinishAttribute(AttributeReportIBs::Builder & return aAttributeReportIBsBuilder.GetAttributeReport().EndOfAttributeReportIB().GetError(); } +namespace { + +constexpr uint32_t kEndOfListByteCount = 1; +// 2 bytes: one to end the AttributeDataIB and one to end the AttributeReportIB. +constexpr uint32_t kEndOfAttributeReportIBByteCount = 2; +constexpr TLV::TLVType kAttributeDataIBType = TLV::kTLVType_Structure; + +} // anonymous namespace + CHIP_ERROR AttributeValueEncoder::EnsureListStarted() { - if (mCurrentEncodingListIndex == kInvalidListIndex) + VerifyOrDie(mCurrentEncodingListIndex == kInvalidListIndex); + + mEncodingInitialList = (mEncodeState.mCurrentEncodingListIndex == kInvalidListIndex); + if (mEncodingInitialList) { - if (mEncodeState.mCurrentEncodingListIndex == kInvalidListIndex) - { - // Clear mAllowPartialData flag here since this encode procedure is not atomic. - // The most common error in this function is CHIP_ERROR_NO_MEMORY / CHIP_ERROR_BUFFER_TOO_SMALL, just revert and try - // next time is ok. - mEncodeState.mAllowPartialData = false; - // Spec 10.5.4.3.1, 10.5.4.6 (Replace a list w/ Multiple IBs) - // Put an empty array before encoding the first array element for list chunking. - AttributeReportBuilder builder; - - mPath.mListOp = ConcreteDataAttributePath::ListOperation::ReplaceAll; - ReturnErrorOnFailure(builder.PrepareAttribute(mAttributeReportIBsBuilder, mPath, mDataVersion)); - ReturnErrorOnFailure(builder.EncodeValue(mAttributeReportIBsBuilder, DataModel::List())); - - ReturnErrorOnFailure(builder.FinishAttribute(mAttributeReportIBsBuilder)); - mEncodeState.mCurrentEncodingListIndex = 0; - } - mCurrentEncodingListIndex = 0; + // Clear mAllowPartialData flag here since this encode procedure is not atomic. + // The most common error in this function is CHIP_ERROR_NO_MEMORY / CHIP_ERROR_BUFFER_TOO_SMALL, just revert and try + // next time is ok. + mEncodeState.mAllowPartialData = false; + + AttributeReportBuilder builder; + + mPath.mListOp = ConcreteDataAttributePath::ListOperation::ReplaceAll; + ReturnErrorOnFailure(builder.PrepareAttribute(mAttributeReportIBsBuilder, mPath, mDataVersion)); + + auto * attributeDataWriter = mAttributeReportIBsBuilder.GetAttributeReport().GetAttributeData().GetWriter(); + TLV::TLVType outerType; + ReturnErrorOnFailure( + attributeDataWriter->StartContainer(TLV::ContextTag(AttributeDataIB::Tag::kData), TLV::kTLVType_Array, outerType)); + VerifyOrDie(outerType == kAttributeDataIBType); + + // Instead of reserving hardcoded amounts, we could checkpoint the + // writer, encode array end and FinishAttribute, check that this fits, + // measure how much the writer advanced, then restore the checkpoint, + // reserve the measured value, and save it. But that's probably more + // cycles than just reserving this known constant. + ReturnErrorOnFailure( + mAttributeReportIBsBuilder.GetWriter()->ReserveBuffer(kEndOfAttributeReportIBByteCount + kEndOfListByteCount)); + + mEncodeState.mCurrentEncodingListIndex = 0; } + else + { + // For all elements in the list, a report with append operation will be generated. This will not be changed during encoding + // of each report since the users cannot access mPath. + mPath.mListOp = ConcreteDataAttributePath::ListOperation::AppendItem; + } + + mCurrentEncodingListIndex = 0; - // After encoding the empty list, the remaining items are atomically encoded into the buffer. Tell report engine to not + // After encoding the initial list start, the remaining items are atomically encoded into the buffer. Tell report engine to not // revert partial data. mEncodeState.mAllowPartialData = true; - // For all elements in the list, a report with append operation will be generated. This will not be changed during encoding - // of each report since the users cannot access mPath. - mPath.mListOp = ConcreteDataAttributePath::ListOperation::AppendItem; return CHIP_NO_ERROR; } +void AttributeValueEncoder::EnsureListEnded() +{ + if (!mEncodingInitialList) + { + // Nothing to do. + return; + } + + // Unreserve the space we reserved just for this. Crash if anything here + // fails, because that would mean that we've corrupted our data, and since + // mEncodeState.mAllowPartialData is true nothing will clean up for us here. + auto * attributeDataWriter = mAttributeReportIBsBuilder.GetAttributeReport().GetAttributeData().GetWriter(); + VerifyOrDie(attributeDataWriter->UnreserveBuffer(kEndOfListByteCount + kEndOfAttributeReportIBByteCount) == CHIP_NO_ERROR); + VerifyOrDie(attributeDataWriter->EndContainer(kAttributeDataIBType) == CHIP_NO_ERROR); + + AttributeReportBuilder builder; + VerifyOrDie(builder.FinishAttribute(mAttributeReportIBsBuilder) == CHIP_NO_ERROR); +} + } // namespace app } // namespace chip diff --git a/src/app/AttributeAccessInterface.h b/src/app/AttributeAccessInterface.h index e61c97195187d3..2b16392e107fb1 100644 --- a/src/app/AttributeAccessInterface.h +++ b/src/app/AttributeAccessInterface.h @@ -77,18 +77,18 @@ class AttributeReportBuilder * EncodeValue encodes the value field of the report, it should be called exactly once. */ template ::value, bool> = true, typename... Ts> - CHIP_ERROR EncodeValue(AttributeReportIBs::Builder & aAttributeReportIBs, T && item, Ts &&... aArgs) + CHIP_ERROR EncodeValue(AttributeReportIBs::Builder & aAttributeReportIBs, TLV::Tag tag, T && item, Ts &&... aArgs) { - return DataModel::Encode(*(aAttributeReportIBs.GetAttributeReport().GetAttributeData().GetWriter()), - TLV::ContextTag(AttributeDataIB::Tag::kData), item, std::forward(aArgs)...); + return DataModel::Encode(*(aAttributeReportIBs.GetAttributeReport().GetAttributeData().GetWriter()), tag, item, + std::forward(aArgs)...); } template ::value, bool> = true, typename... Ts> - CHIP_ERROR EncodeValue(AttributeReportIBs::Builder & aAttributeReportIBs, FabricIndex accessingFabricIndex, T && item, - Ts &&... aArgs) + CHIP_ERROR EncodeValue(AttributeReportIBs::Builder & aAttributeReportIBs, TLV::Tag tag, FabricIndex accessingFabricIndex, + T && item, Ts &&... aArgs) { - return DataModel::EncodeForRead(*(aAttributeReportIBs.GetAttributeReport().GetAttributeData().GetWriter()), - TLV::ContextTag(AttributeDataIB::Tag::kData), accessingFabricIndex, item); + return DataModel::EncodeForRead(*(aAttributeReportIBs.GetAttributeReport().GetAttributeData().GetWriter()), tag, + accessingFabricIndex, item, std::forward(aArgs)...); } }; @@ -224,10 +224,19 @@ class AttributeValueEncoder // An empty list is encoded iff both mCurrentEncodingListIndex and mEncodeState.mCurrentEncodingListIndex are invalid // values. After encoding the empty list, mEncodeState.mCurrentEncodingListIndex and mCurrentEncodingListIndex are set to 0. ReturnErrorOnFailure(EnsureListStarted()); - ReturnErrorOnFailure(aCallback(ListEncodeHelper(*this))); - // The Encode procedure finished without any error, clear the state. - mEncodeState = AttributeEncodeState(); - return CHIP_NO_ERROR; + CHIP_ERROR err = aCallback(ListEncodeHelper(*this)); + + // Even if encoding list items failed, make sure we EnsureListEnded(). + // Since we encode list items atomically, in the case when we just + // didn't fit the next item we want to make sure our list is properly + // ended before the reporting engine starts chunking. + EnsureListEnded(); + if (err == CHIP_NO_ERROR) + { + // The Encode procedure finished without any error, clear the state. + mEncodeState = AttributeEncodeState(); + } + return err; } bool TriedEncode() const { return mTriedEncode; } @@ -261,7 +270,17 @@ class AttributeValueEncoder TLV::TLVWriter backup; mAttributeReportIBsBuilder.Checkpoint(backup); - CHIP_ERROR err = EncodeAttributeReportIB(std::forward(aArgs)...); + CHIP_ERROR err; + if (mEncodingInitialList) + { + // Just encode a single item, with an anonymous tag. + AttributeReportBuilder builder; + err = builder.EncodeValue(mAttributeReportIBsBuilder, TLV::AnonymousTag(), std::forward(aArgs)...); + } + else + { + err = EncodeAttributeReportIB(std::forward(aArgs)...); + } if (err != CHIP_NO_ERROR) { // For list chunking, ReportEngine should not rollback the buffer when CHIP_ERROR_NO_MEMORY or similar error occurred. @@ -288,32 +307,39 @@ class AttributeValueEncoder CHIP_ERROR EncodeAttributeReportIB(Ts &&... aArgs) { AttributeReportBuilder builder; - ReturnErrorOnFailure(builder.PrepareAttribute(mAttributeReportIBsBuilder, mPath, mDataVersion)); - ReturnErrorOnFailure(builder.EncodeValue(mAttributeReportIBsBuilder, std::forward(aArgs)...)); + ReturnErrorOnFailure(builder.EncodeValue(mAttributeReportIBsBuilder, TLV::ContextTag(AttributeDataIB::Tag::kData), + std::forward(aArgs)...)); return builder.FinishAttribute(mAttributeReportIBsBuilder); } /** - * EnsureListStarted encodes the first item of one report with lists (an - * empty list), as needed. + * EnsureListStarted sets our mCurrentEncodingListIndex to 0, and: * - * If internal state indicates we have already encoded the empty list, this function will encode nothing, set - * mCurrentEncodingListIndex to 0 and return CHIP_NO_ERROR. + * * If we are just starting the list, gets us ready to encode list items. * - * In all cases this function guarantees that mPath.mListOp is AppendItem - * after it returns, because at that point we will be encoding the list - * items. + * * If we are continuing a chunked list, guarantees that mPath.mListOp is + * AppendItem after it returns. */ CHIP_ERROR EnsureListStarted(); + /** + * EnsureListEnded writes out the end of the list and our attribute data IB, + * if we were encoding our initial list + */ + void EnsureListEnded(); + bool mTriedEncode = false; AttributeReportIBs::Builder & mAttributeReportIBsBuilder; const FabricIndex mAccessingFabricIndex; ConcreteDataAttributePath mPath; DataVersion mDataVersion; bool mIsFabricFiltered = false; + // mEncodingInitialList is true if we're encoding a list and we have not + // started chunking it yet, so we're encoding a single attribute report IB + // for the whole list, not one per item. + bool mEncodingInitialList = false; AttributeEncodeState mEncodeState; ListIndex mCurrentEncodingListIndex = kInvalidListIndex; }; diff --git a/src/app/tests/TestAttributeValueEncoder.cpp b/src/app/tests/TestAttributeValueEncoder.cpp index 8c044929ad21d6..991f0ab0169307 100644 --- a/src/app/tests/TestAttributeValueEncoder.cpp +++ b/src/app/tests/TestAttributeValueEncoder.cpp @@ -148,9 +148,9 @@ void TestEncodeListOfBools1(nlTestSuite * aSuite, void * aContext) 0x36, 0x02, // Start 1 byte tag array + Tag (02) (Attribute Value) 0x09, // True 0x08, // False - 0x18, - 0x18, // End of container - 0x18, // End of container + 0x18, // End of array + 0x18, // End of attribute data structure + 0x18, // End of attribute structure // clang-format on }; VERIFY_BUFFER_STATE(aSuite, test, expected); @@ -179,38 +179,12 @@ void TestEncodeListOfBools2(nlTestSuite * aSuite, void * aContext) 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc 0x18, // End of container - // Intended empty array 0x36, 0x02, // Start 1 byte tag array + Tag (02) (Attribute Value) - 0x18, // End of container - 0x18, // End of container - 0x18, // End of container - - 0x15, // Start anonymous struct - 0x35, 0x01, // Start 1 byte tag struct + Tag (01) - 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) - 0x37, 0x01, // Start 1 byte tag list + Tag (01) (Attribute Path) - 0x24, 0x02, 0x55, // Tag (02) Value (1 byte uint) 0x55 - 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa - 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc - 0x34, 0x05, // Tag (05) Null - 0x18, // End of container - 0x29, 0x02, // Tag (02) Value True (Attribute Value) - 0x18, // End of container - 0x18, // End of container - - 0x15, // Start anonymous struct - 0x35, 0x01, // Start 1 byte tag struct + Tag (01) - 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) - 0x37, 0x01, // Start 1 byte tag list + Tag (01) (Attribute Path) - 0x24, 0x02, 0x55, // Tag (02) Value (1 byte uint) 0x55 - 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa - 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc - 0x34, 0x05, // Tag (05) Null - 0x18, // End of container - 0x28, 0x02, // Tag (02) Value False (Attribute Value) - 0x18, // End of container - 0x18, // End of container - + 0x09, // True + 0x08, // False + 0x18, // End of array + 0x18, // End of attribute data structure + 0x18, // End of attribute structure // clang-format on }; VERIFY_BUFFER_STATE(aSuite, test, expected); @@ -279,26 +253,14 @@ void TestEncodeFabricScoped(nlTestSuite * aSuite, void * aContext) 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc 0x18, // End of container - // Intended empty array 0x36, 0x02, // Start 1 byte tag array + Tag (02) (Attribute Value) - 0x18, // End of container - 0x18, // End of container - 0x18, // End of container - 0x15, // Start anonymous struct - 0x35, 0x01, // Start 1 byte tag struct + Tag (01) - 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) - 0x37, 0x01, // Start 1 byte tag list + Tag (01) (Attribute Path) - 0x24, 0x02, 0x55, // Tag (02) Value (1 byte uint) 0x55 - 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa - 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc - 0x34, 0x05, // Tag (05) Null - 0x18, // End of container (attribute path) - 0x35, 0x02, // Tag 02 (attribute data) - 0x30, 0x01, 0x00, // Tag 1, OCTET_STRING length 0 (data) - 0x24, 0xFE, 0x01, // Tag 0xFE, UINT8 Value 1 (fabric index) - 0x18, - 0x18, - 0x18, + 0x15, // Start anonymous structure + 0x30, 0x01, 0x00, // Tag 1, OCTET_STRING length 0 (data) + 0x24, 0xFE, 0x01, // Tag 0xFE, UINT8 Value 1 (fabric index) + 0x18, // End of array element (structure) + 0x18, // End of array + 0x18, // End of attribute data structure + 0x18, // End of attribute structure // clang-format on }; VERIFY_BUFFER_STATE(aSuite, test, expected); @@ -308,7 +270,7 @@ void TestEncodeListChunking(nlTestSuite * aSuite, void * aContext) { AttributeValueEncoder::AttributeEncodeState state; - bool list[] = { true, false }; + bool list[] = { true, false, false, true, true, false }; auto listEncoder = [&list](const auto & encoder) -> CHIP_ERROR { for (auto & item : list) { @@ -318,8 +280,14 @@ void TestEncodeListChunking(nlTestSuite * aSuite, void * aContext) }; { - // Use 60 bytes buffer to force chunking. The kTestFabricIndex is not effective in this test. - LimitedTestSetup<60> test1(aSuite, kTestFabricIndex); + // Use 30 bytes buffer to force chunking after the first "false". The kTestFabricIndex is + // not effective in this test. + // + // We only encode 28 bytes, because we don't encode our last two "close container" bits + // corresponding to the "test overhead" container starts. But TLVWriter automatically + // reserves space when containers are opened, so we have to have enough space to have + // encoded those last two close containers. + LimitedTestSetup<30> test1(aSuite, kTestFabricIndex); CHIP_ERROR err = test1.encoder.EncodeList(listEncoder); NL_TEST_ASSERT(aSuite, err == CHIP_ERROR_NO_MEMORY || err == CHIP_ERROR_BUFFER_TOO_SMALL); state = test1.encoder.GetState(); @@ -335,12 +303,64 @@ void TestEncodeListChunking(nlTestSuite * aSuite, void * aContext) 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc 0x18, // End of container - // Intended empty array 0x36, 0x02, // Start 1 byte tag array + Tag (02) (Attribute Value) + 0x09, // True + 0x08, // False + 0x18, // End of array + 0x18, // End of attribute data structure + 0x18, // End of attribute structure + // clang-format on + }; + VERIFY_BUFFER_STATE(aSuite, test1, expected); + } + { + // Use 30 bytes buffer to force chunking after the second "false". The kTestFabricIndex is + // not effective in this test. + LimitedTestSetup<30> test2(aSuite, 0, state); + CHIP_ERROR err = test2.encoder.EncodeList(listEncoder); + NL_TEST_ASSERT(aSuite, err == CHIP_ERROR_NO_MEMORY || err == CHIP_ERROR_BUFFER_TOO_SMALL); + state = test2.encoder.GetState(); + + const uint8_t expected[] = { + // clang-format off + 0x15, 0x36, 0x01, // Test overhead, Start Anonymous struct + Start 1 byte Tag Array + Tag (01) + 0x15, // Start anonymous struct + 0x35, 0x01, // Start 1 byte tag struct + Tag (01) + 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) + 0x37, 0x01, // Start 1 byte tag list + Tag (01) (Attribute Path) + 0x24, 0x02, 0x55, // Tag (02) Value (1 byte uint) 0x55 + 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa + 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc + 0x34, 0x05, // Tag (05) Null 0x18, // End of container + 0x28, 0x02, // Tag (02) Value False (Attribute Value) 0x18, // End of container 0x18, // End of container + // clang-format on + }; + VERIFY_BUFFER_STATE(aSuite, test2, expected); + } + { + // Allow encoding everything else. The kTestFabricIndex is not effective in this test. + TestSetup test3(aSuite, 0, state); + CHIP_ERROR err = test3.encoder.EncodeList(listEncoder); + NL_TEST_ASSERT(aSuite, err == CHIP_NO_ERROR); + const uint8_t expected[] = { + // clang-format off + 0x15, 0x36, 0x01, // Test overhead, Start Anonymous struct + Start 1 byte Tag Array + Tag (01) + 0x15, // Start anonymous struct + 0x35, 0x01, // Start 1 byte tag struct + Tag (01) + 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) + 0x37, 0x01, // Start 1 byte tag list + Tag (01) (Attribute Path) + 0x24, 0x02, 0x55, // Tag (02) Value (1 byte uint) 0x55 + 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa + 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc + 0x34, 0x05, // Tag (05) Null + 0x18, // End of container + 0x29, 0x02, // Tag (02) Value True (Attribute Value) + 0x18, // End of container + 0x18, // End of container 0x15, // Start anonymous struct 0x35, 0x01, // Start 1 byte tag struct + Tag (01) 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) @@ -353,19 +373,168 @@ void TestEncodeListChunking(nlTestSuite * aSuite, void * aContext) 0x29, 0x02, // Tag (02) Value True (Attribute Value) 0x18, // End of container 0x18, // End of container + 0x15, // Start anonymous struct + 0x35, 0x01, // Start 1 byte tag struct + Tag (01) + 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) + 0x37, 0x01, // Start 1 byte tag list + Tag (01) (Attribute Path) + 0x24, 0x02, 0x55, // Tag (02) Value (1 byte uint) 0x55 + 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa + 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc + 0x34, 0x05, // Tag (05) Null + 0x18, // End of container + 0x28, 0x02, // Tag (02) Value False (Attribute Value) + 0x18, // End of container + 0x18, // End of container + // clang-format on + }; + VERIFY_BUFFER_STATE(aSuite, test3, expected); + } +} + +void TestEncodeListChunking2(nlTestSuite * aSuite, void * aContext) +{ + AttributeValueEncoder::AttributeEncodeState state; + + bool list[] = { true, false, false, true, true, false }; + auto listEncoder = [&list](const auto & encoder) -> CHIP_ERROR { + for (auto & item : list) + { + ReturnErrorOnFailure(encoder.Encode(item)); + } + return CHIP_NO_ERROR; + }; + + { + // Use 28 bytes buffer to force chunking right after we start the list. kTestFabricIndex is + // not effective in this test. + // + // We only encode 26 bytes, because we don't encode our last two "close container" bits + // corresponding to the "test overhead" container starts. But TLVWriter automatically + // reserves space when containers are opened, so we have to have enough space to have + // encoded those last two close containers. + LimitedTestSetup<28> test1(aSuite, kTestFabricIndex); + CHIP_ERROR err = test1.encoder.EncodeList(listEncoder); + NL_TEST_ASSERT(aSuite, err == CHIP_ERROR_NO_MEMORY || err == CHIP_ERROR_BUFFER_TOO_SMALL); + state = test1.encoder.GetState(); + + const uint8_t expected[] = { + // clang-format off + 0x15, 0x36, 0x01, // Test overhead, Start Anonymous struct + Start 1 byte Tag Array + Tag (01) + 0x15, // Start anonymous struct + 0x35, 0x01, // Start 1 byte tag struct + Tag (01) + 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) + 0x37, 0x01, // Start 1 byte tag list + Tag (01) (Attribute Path) + 0x24, 0x02, 0x55, // Tag (02) Value (1 byte uint) 0x55 + 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa + 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc + 0x18, // End of container + 0x36, 0x02, // Start 1 byte tag array + Tag (02) (Attribute Value) + 0x18, // End of array + 0x18, // End of attribute data structure + 0x18, // End of attribute structure // clang-format on }; VERIFY_BUFFER_STATE(aSuite, test1, expected); } { - // Use 60 bytes buffer to force chunking. The kTestFabricIndex is not effective in this test. - LimitedTestSetup<60> test2(aSuite, 0, state); + // Use 30 bytes buffer to force chunking after the first "true". The kTestFabricIndex is not + // effective in this test. + LimitedTestSetup<30> test2(aSuite, 0, state); CHIP_ERROR err = test2.encoder.EncodeList(listEncoder); + NL_TEST_ASSERT(aSuite, err == CHIP_ERROR_NO_MEMORY || err == CHIP_ERROR_BUFFER_TOO_SMALL); + state = test2.encoder.GetState(); + + const uint8_t expected[] = { + // clang-format off + 0x15, 0x36, 0x01, // Test overhead, Start Anonymous struct + Start 1 byte Tag Array + Tag (01) + 0x15, // Start anonymous struct + 0x35, 0x01, // Start 1 byte tag struct + Tag (01) + 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) + 0x37, 0x01, // Start 1 byte tag list + Tag (01) (Attribute Path) + 0x24, 0x02, 0x55, // Tag (02) Value (1 byte uint) 0x55 + 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa + 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc + 0x34, 0x05, // Tag (05) Null + 0x18, // End of container + 0x29, 0x02, // Tag (02) Value True (Attribute Value) + 0x18, // End of container + 0x18, // End of container + // clang-format on + }; + VERIFY_BUFFER_STATE(aSuite, test2, expected); + } + { + // Use 60 bytes buffer to force chunking after the second "false". The kTestFabricIndex is not + // effective in this test. + LimitedTestSetup<60> test3(aSuite, 0, state); + CHIP_ERROR err = test3.encoder.EncodeList(listEncoder); + NL_TEST_ASSERT(aSuite, err == CHIP_ERROR_NO_MEMORY || err == CHIP_ERROR_BUFFER_TOO_SMALL); + state = test3.encoder.GetState(); + + const uint8_t expected[] = { + // clang-format off + 0x15, 0x36, 0x01, // Test overhead, Start Anonymous struct + Start 1 byte Tag Array + Tag (01) + 0x15, // Start anonymous struct + 0x35, 0x01, // Start 1 byte tag struct + Tag (01) + 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) + 0x37, 0x01, // Start 1 byte tag list + Tag (01) (Attribute Path) + 0x24, 0x02, 0x55, // Tag (02) Value (1 byte uint) 0x55 + 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa + 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc + 0x34, 0x05, // Tag (05) Null + 0x18, // End of container + 0x28, 0x02, // Tag (02) Value False (Attribute Value) + 0x18, // End of container + 0x18, // End of container + 0x15, // Start anonymous struct + 0x35, 0x01, // Start 1 byte tag struct + Tag (01) + 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) + 0x37, 0x01, // Start 1 byte tag list + Tag (01) (Attribute Path) + 0x24, 0x02, 0x55, // Tag (02) Value (1 byte uint) 0x55 + 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa + 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc + 0x34, 0x05, // Tag (05) Null + 0x18, // End of container + 0x28, 0x02, // Tag (02) Value False (Attribute Value) + 0x18, // End of container + 0x18, // End of container + // clang-format on + }; + VERIFY_BUFFER_STATE(aSuite, test3, expected); + } + { + // Allow encoding everything else. The kTestFabricIndex is not effective in this test. + TestSetup test4(aSuite, 0, state); + CHIP_ERROR err = test4.encoder.EncodeList(listEncoder); NL_TEST_ASSERT(aSuite, err == CHIP_NO_ERROR); const uint8_t expected[] = { // clang-format off 0x15, 0x36, 0x01, // Test overhead, Start Anonymous struct + Start 1 byte Tag Array + Tag (01) + 0x15, // Start anonymous struct + 0x35, 0x01, // Start 1 byte tag struct + Tag (01) + 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) + 0x37, 0x01, // Start 1 byte tag list + Tag (01) (Attribute Path) + 0x24, 0x02, 0x55, // Tag (02) Value (1 byte uint) 0x55 + 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa + 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc + 0x34, 0x05, // Tag (05) Null + 0x18, // End of container + 0x29, 0x02, // Tag (02) Value True (Attribute Value) + 0x18, // End of container + 0x18, // End of container + 0x15, // Start anonymous struct + 0x35, 0x01, // Start 1 byte tag struct + Tag (01) + 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) + 0x37, 0x01, // Start 1 byte tag list + Tag (01) (Attribute Path) + 0x24, 0x02, 0x55, // Tag (02) Value (1 byte uint) 0x55 + 0x24, 0x03, 0xaa, // Tag (03) Value (1 byte uint) 0xaa + 0x24, 0x04, 0xcc, // Tag (04) Value (1 byte uint) 0xcc + 0x34, 0x05, // Tag (05) Null + 0x18, // End of container + 0x29, 0x02, // Tag (02) Value True (Attribute Value) + 0x18, // End of container + 0x18, // End of container 0x15, // Start anonymous struct 0x35, 0x01, // Start 1 byte tag struct + Tag (01) 0x24, 0x00, 0x99, // Tag (00) Value (1 byte uint) 0x99 (Attribute Version) @@ -380,7 +549,7 @@ void TestEncodeListChunking(nlTestSuite * aSuite, void * aContext) 0x18, // End of container // clang-format on }; - VERIFY_BUFFER_STATE(aSuite, test2, expected); + VERIFY_BUFFER_STATE(aSuite, test4, expected); } } @@ -389,15 +558,20 @@ void TestEncodeListChunking(nlTestSuite * aSuite, void * aContext) } // anonymous namespace namespace { -const nlTest sTests[] = { NL_TEST_DEF("TestEncodeNothing", TestEncodeNothing), - NL_TEST_DEF("TestEncodeBool", TestEncodeBool), - NL_TEST_DEF("TestEncodeEmptyList1", TestEncodeEmptyList1), - NL_TEST_DEF("TestEncodeEmptyList2", TestEncodeEmptyList2), - NL_TEST_DEF("TestEncodeListOfBools1", TestEncodeListOfBools1), - NL_TEST_DEF("TestEncodeListOfBools2", TestEncodeListOfBools2), - NL_TEST_DEF("TestEncodeListChunking", TestEncodeListChunking), - NL_TEST_DEF("TestEncodeFabricScoped", TestEncodeFabricScoped), - NL_TEST_SENTINEL() }; +const nlTest sTests[] = { + // clang-format off + NL_TEST_DEF("TestEncodeNothing", TestEncodeNothing), + NL_TEST_DEF("TestEncodeBool", TestEncodeBool), + NL_TEST_DEF("TestEncodeEmptyList1", TestEncodeEmptyList1), + NL_TEST_DEF("TestEncodeEmptyList2", TestEncodeEmptyList2), + NL_TEST_DEF("TestEncodeListOfBools1", TestEncodeListOfBools1), + NL_TEST_DEF("TestEncodeListOfBools2", TestEncodeListOfBools2), + NL_TEST_DEF("TestEncodeListChunking", TestEncodeListChunking), + NL_TEST_DEF("TestEncodeListChunking2", TestEncodeListChunking2), + NL_TEST_DEF("TestEncodeFabricScoped", TestEncodeFabricScoped), + NL_TEST_SENTINEL() + // clang-format on +}; } int TestAttributeValueEncoder() diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index b7f0d2b3df0e0e..d49a4fa61a5be7 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -173,6 +173,24 @@ class MockInteractionModelApp : public chip::app::ReadClient::Callback mReceivedAttributePaths.push_back(aPath); mNumAttributeResponse++; mGotReport = true; + + if (aPath.IsListItemOperation()) + { + mNumArrayItems++; + } + else if (aPath.IsListOperation()) + { + // This is an entire list of things; count up how many. + chip::TLV::TLVType containerType; + if (apData->EnterContainer(containerType) == CHIP_NO_ERROR) + { + size_t count = 0; + if (chip::TLV::Utilities::Count(*apData, count, /* aRecurse = */ false) == CHIP_NO_ERROR) + { + mNumArrayItems += static_cast(count); + } + } + } } mLastStatusReceived = status; } @@ -207,6 +225,7 @@ class MockInteractionModelApp : public chip::app::ReadClient::Callback bool mGotEventResponse = false; int mNumReadEventFailureStatusReceived = 0; int mNumAttributeResponse = 0; + int mNumArrayItems = 0; bool mGotReport = false; bool mReadError = false; chip::app::ReadHandler * mpReadHandler = nullptr; @@ -1192,7 +1211,9 @@ void TestReadInteraction::TestReadChunking(nlTestSuite * apSuite, void * apConte ctx.DrainAndServiceIO(); - NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 7); // One empty string, with 6 array evelemtns. + // We get one chunk with 3 array elements, and then one chunk per element. + NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 4); + NL_TEST_ASSERT(apSuite, delegate.mNumArrayItems == 6); NL_TEST_ASSERT(apSuite, delegate.mGotReport); NL_TEST_ASSERT(apSuite, !delegate.mReadError); // By now we should have closed all exchanges and sent all pending acks, so @@ -1236,12 +1257,16 @@ void TestReadInteraction::TestSetDirtyBetweenChunks(nlTestSuite * apSuite, void { int currentAttributeResponsesWhenSetDirty = 0; + int currentArrayItemsWhenSetDirty = 0; class DirtyingMockDelegate : public MockInteractionModelApp { public: - DirtyingMockDelegate(AttributePathParams (&aReadPaths)[2], int & aNumAttributeResponsesWhenSetDirty) : - mReadPaths(aReadPaths), mNumAttributeResponsesWhenSetDirty(aNumAttributeResponsesWhenSetDirty) + DirtyingMockDelegate(AttributePathParams (&aReadPaths)[2], int & aNumAttributeResponsesWhenSetDirty, + int & aNumArrayItemsWhenSetDirty) : + mReadPaths(aReadPaths), + mNumAttributeResponsesWhenSetDirty(aNumAttributeResponsesWhenSetDirty), + mNumArrayItemsWhenSetDirty(aNumArrayItemsWhenSetDirty) {} private: @@ -1285,6 +1310,7 @@ void TestReadInteraction::TestSetDirtyBetweenChunks(nlTestSuite * apSuite, void // We're finishing out the message where we decided to // SetDirty. ++mNumAttributeResponsesWhenSetDirty; + ++mNumArrayItemsWhenSetDirty; } } @@ -1302,6 +1328,7 @@ void TestReadInteraction::TestSetDirtyBetweenChunks(nlTestSuite * apSuite, void { // At this time, we are in the middle of report for second item. mNumAttributeResponsesWhenSetDirty = mNumAttributeResponse; + mNumArrayItemsWhenSetDirty = mNumArrayItems; InteractionModelEngine::GetInstance()->GetReportingEngine().SetDirty(dirtyPath); } } @@ -1316,9 +1343,10 @@ void TestReadInteraction::TestSetDirtyBetweenChunks(nlTestSuite * apSuite, void bool mDidSetDirty = false; AttributePathParams (&mReadPaths)[2]; int & mNumAttributeResponsesWhenSetDirty; + int & mNumArrayItemsWhenSetDirty; }; - DirtyingMockDelegate delegate(attributePathParams, currentAttributeResponsesWhenSetDirty); + DirtyingMockDelegate delegate(attributePathParams, currentAttributeResponsesWhenSetDirty, currentArrayItemsWhenSetDirty); NL_TEST_ASSERT(apSuite, !delegate.mGotEventResponse); app::ReadClient readClient(chip::app::InteractionModelEngine::GetInstance(), &ctx.GetExchangeManager(), delegate, @@ -1329,11 +1357,13 @@ void TestReadInteraction::TestSetDirtyBetweenChunks(nlTestSuite * apSuite, void ctx.DrainAndServiceIO(); - // We should receive another (6 + 1) = 7 attribute reports since the underlying path iterator should be reset to the - // beginning of the cluster it is currently iterating. + // We should receive another (3 + 1) = 4 attribute reports represeting 6 + // array items, since the underlying path iterator should be reset to + // the beginning of the cluster it is currently iterating. ChipLogError(DataManagement, "OLD: %d\n", currentAttributeResponsesWhenSetDirty); ChipLogError(DataManagement, "NEW: %d\n", delegate.mNumAttributeResponse); - NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == currentAttributeResponsesWhenSetDirty + 7); + NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == currentAttributeResponsesWhenSetDirty + 4); + NL_TEST_ASSERT(apSuite, delegate.mNumArrayItems == currentArrayItemsWhenSetDirty + 6); NL_TEST_ASSERT(apSuite, delegate.mGotReport); NL_TEST_ASSERT(apSuite, !delegate.mReadError); // By now we should have closed all exchanges and sent all pending acks, so @@ -1868,9 +1898,14 @@ void TestReadInteraction::TestSubscribeWildcard(nlTestSuite * apSuite, void * ap NL_TEST_ASSERT(apSuite, delegate.mGotReport); // We have 29 attributes in our mock attribute storage. And we subscribed twice. - // And attribute 3/2/4 is a list with 6 elements and list chunking is applied to it, thus we should receive ( 29 + 6 ) * 2 = - // 70 attribute data in total. - NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 70); + // And attribute 3/2/4 is a list with 6 elements and list chunking is + // applied to it, but the way the packet boundaries fall we get two of + // its items as a single list, followed by 4 more single items for one + // of our subscriptions, but every item as a separate IB for the other. + // + // Thus we should receive 29*2 + 4 + 6 = 68 attribute data in total. + NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 68); + NL_TEST_ASSERT(apSuite, delegate.mNumArrayItems == 12); NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadHandlers(ReadHandler::InteractionType::Subscribe) == 1); NL_TEST_ASSERT(apSuite, engine->ActiveHandlerAt(0) != nullptr); delegate.mpReadHandler = engine->ActiveHandlerAt(0); @@ -1901,6 +1936,7 @@ void TestReadInteraction::TestSubscribeWildcard(nlTestSuite * apSuite, void * ap delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false); delegate.mGotReport = false; delegate.mNumAttributeResponse = 0; + delegate.mNumArrayItems = 0; AttributePathParams dirtyPath; dirtyPath.mEndpointId = Test::kMockEndpoint3; @@ -1921,10 +1957,16 @@ void TestReadInteraction::TestSubscribeWildcard(nlTestSuite * apSuite, void * ap NL_TEST_ASSERT(apSuite, delegate.mGotReport); // Mock endpoint3 has 13 attributes in total, and we subscribed twice. - // And attribute 3/2/4 is a list with 6 elements and list chunking is applied to it, thus we should receive ( 13 + 6 ) * - // 2 = 28 attribute data in total. + // And attribute 3/2/4 is a list with 6 elements and list chunking + // is applied to it, but the way the packet boundaries fall we get two of + // its items as a single list, followed by 4 more items for one + // of our subscriptions, and 3 items as a single list followed by 3 + // more items for the other. + // + // Thus we should receive 13*2 + 4 + 3 = 33 attribute data in total. ChipLogError(DataManagement, "RESPO: %d\n", delegate.mNumAttributeResponse); - NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 38); + NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 33); + NL_TEST_ASSERT(apSuite, delegate.mNumArrayItems == 12); } } @@ -2925,6 +2967,7 @@ void TestReadInteraction::TestPostSubscribeRoundtripChunkReport(nlTestSuite * ap err = engine->GetReportingEngine().SetDirty(dirtyPath1); delegate.mGotReport = false; delegate.mNumAttributeResponse = 0; + delegate.mNumArrayItems = 0; // wait for min interval 2 seconds(in test, we use 1.9second considering the time variation), expect no event is received, // then wait for 0.5 seconds, then all chunked dirty reports are sent out, which would not honor minInterval @@ -2949,8 +2992,10 @@ void TestReadInteraction::TestPostSubscribeRoundtripChunkReport(nlTestSuite * ap } ctx.DrainAndServiceIO(); } - // Two chunked reports carry 7 attributeDataIB - NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 7); + // Two chunked reports carry 4 attributeDataIB: 1 with a list of 3 items, + // and then one per remaining item. + NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 4); + NL_TEST_ASSERT(apSuite, delegate.mNumArrayItems == 6); NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadClients() == 0); engine->Shutdown(); From d53080da037bd8399a6213b92a835bb4120c48a4 Mon Sep 17 00:00:00 2001 From: Marc Lepage <67919234+mlepage-google@users.noreply.github.com> Date: Mon, 1 May 2023 16:37:05 -0400 Subject: [PATCH 062/200] Use work helper with CASE handle sigma3 (#26300) * Use work helper with CASE handle sigma3 WorkHelper was introduced to help with CASESession::SendSigma3. Now use it to help with CASESession::HandleSigma3. Part of issue #26280. * Unscope a block --- src/protocols/secure_channel/CASESession.cpp | 141 +++++++------------ src/protocols/secure_channel/CASESession.h | 11 +- 2 files changed, 55 insertions(+), 97 deletions(-) diff --git a/src/protocols/secure_channel/CASESession.cpp b/src/protocols/secure_channel/CASESession.cpp index 20b3567cb5d74b..2e2fcda957b391 100644 --- a/src/protocols/secure_channel/CASESession.cpp +++ b/src/protocols/secure_channel/CASESession.cpp @@ -177,9 +177,9 @@ class CASESession::WorkHelper { return CHIP_ERROR_INCORRECT_STATE; } - WorkHelper * helper = this; - bool cancel = false; - helper->mStatus = helper->mWorkCallback(helper->mData, cancel); + auto * helper = this; + bool cancel = false; + helper->mStatus = helper->mWorkCallback(helper->mData, cancel); if (!cancel) { helper->mStatus = (helper->mSession->*(helper->mAfterWorkCallback))(helper->mData, helper->mStatus); @@ -211,8 +211,8 @@ class CASESession::WorkHelper // Handler for the work callback. static void WorkHandler(intptr_t arg) { - WorkHelper * helper = reinterpret_cast(arg); - bool cancel = false; + auto * helper = reinterpret_cast(arg); + bool cancel = false; VerifyOrExit(helper->mSession.load(), ;); // cancelled by `CancelWork`? helper->mStatus = helper->mWorkCallback(helper->mData, cancel); VerifyOrExit(!cancel, ;); // canceled by `mWorkCallback`? @@ -227,7 +227,7 @@ class CASESession::WorkHelper static void AfterWorkHandler(intptr_t arg) { // Since this runs in the main Matter thread, the session shouldn't be otherwise used (messages, timers, etc.) - WorkHelper * helper = reinterpret_cast(arg); + auto * helper = reinterpret_cast(arg); if (auto * session = helper->mSession.load()) { (session->*(helper->mAfterWorkCallback))(helper->mData, helper->mStatus); @@ -282,18 +282,8 @@ struct CASESession::SendSigma3Data P256ECDSASignature tbsData3Signature; }; -struct CASESession::HandleSigma3Work +struct CASESession::HandleSigma3Data { - // Status of background processing. - CHIP_ERROR status; - - // Session to use after background processing. - CASESession * session; - - // Sequence number used to coordinate foreground/background work for a - // particular session establishment. - int sequence; - chip::Platform::ScopedMemoryBuffer msg_R3_Signed; size_t msg_r3_signed_len; @@ -333,6 +323,11 @@ void CASESession::Clear() mSendSigma3Helper->CancelWork(); mSendSigma3Helper.reset(); } + if (mHandleSigma3Helper) + { + mHandleSigma3Helper->CancelWork(); + mHandleSigma3Helper.reset(); + } // This function zeroes out and resets the memory used by the object. // It's done so that no security related information will be leaked. @@ -405,10 +400,6 @@ CASESession::PrepareForSessionEstablishment(SessionManager & sessionManager, Fab CHIP_ERROR err = CHIP_NO_ERROR; - // Sequence number used to coordinate foreground/background work for a - // particular session establishment. - mSequence++; - SuccessOrExit(err = fabricTable->AddFabricDelegate(this)); mFabricsTable = fabricTable; @@ -1531,23 +1522,16 @@ CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg) ChipLogProgress(SecureChannel, "Received Sigma3 msg"); - auto * workPtr = Platform::New(); - VerifyOrExit(workPtr != nullptr, err = CHIP_ERROR_NO_MEMORY); + auto helper = WorkHelper::Create(*this, &HandleSigma3b, &CASESession::HandleSigma3c); + VerifyOrExit(helper, err = CHIP_ERROR_NO_MEMORY); { - auto & work = *workPtr; - - // Used to call back into the session after background event processing. - // It happens that there's only one pairing session (in CASEServer) - // so it will still be available for use. Use a sequence number to - // coordinate. - work.session = this; - work.sequence = mSequence; + auto & data = helper->mData; { VerifyOrExit(mFabricsTable != nullptr, err = CHIP_ERROR_INCORRECT_STATE); const auto * fabricInfo = mFabricsTable->FindFabricWithIndex(mFabricIndex); VerifyOrExit(fabricInfo != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - work.fabricId = fabricInfo->GetFabricId(); + data.fabricId = fabricInfo->GetFabricId(); } VerifyOrExit(mEphemeralKey != nullptr, err = CHIP_ERROR_INTERNAL); @@ -1558,7 +1542,7 @@ CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg) // Fetch encrypted data max_msg_r3_signed_enc_len = TLV::EstimateStructOverhead(Credentials::kMaxCHIPCertLength, Credentials::kMaxCHIPCertLength, - work.tbsData3Signature.Length(), kCaseOverheadForFutureTbeData); + data.tbsData3Signature.Length(), kCaseOverheadForFutureTbeData); SuccessOrExit(err = tlvReader.Next(TLV::kTLVType_ByteString, TLV::ContextTag(kTag_Sigma3_Encrypted3))); @@ -1592,74 +1576,70 @@ CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg) SuccessOrExit(err = decryptedDataTlvReader.EnterContainer(containerType)); SuccessOrExit(err = decryptedDataTlvReader.Next(TLV::kTLVType_ByteString, TLV::ContextTag(kTag_TBEData_SenderNOC))); - SuccessOrExit(err = decryptedDataTlvReader.Get(work.initiatorNOC)); + SuccessOrExit(err = decryptedDataTlvReader.Get(data.initiatorNOC)); SuccessOrExit(err = decryptedDataTlvReader.Next()); if (TLV::TagNumFromTag(decryptedDataTlvReader.GetTag()) == kTag_TBEData_SenderICAC) { VerifyOrExit(decryptedDataTlvReader.GetType() == TLV::kTLVType_ByteString, err = CHIP_ERROR_WRONG_TLV_TYPE); - SuccessOrExit(err = decryptedDataTlvReader.Get(work.initiatorICAC)); + SuccessOrExit(err = decryptedDataTlvReader.Get(data.initiatorICAC)); SuccessOrExit(err = decryptedDataTlvReader.Next(TLV::kTLVType_ByteString, TLV::ContextTag(kTag_TBEData_Signature))); } // Step 4 - Construct Sigma3 TBS Data - work.msg_r3_signed_len = TLV::EstimateStructOverhead(sizeof(uint16_t), work.initiatorNOC.size(), work.initiatorICAC.size(), + data.msg_r3_signed_len = TLV::EstimateStructOverhead(sizeof(uint16_t), data.initiatorNOC.size(), data.initiatorICAC.size(), kP256_PublicKey_Length, kP256_PublicKey_Length); - VerifyOrExit(work.msg_R3_Signed.Alloc(work.msg_r3_signed_len), err = CHIP_ERROR_NO_MEMORY); + VerifyOrExit(data.msg_R3_Signed.Alloc(data.msg_r3_signed_len), err = CHIP_ERROR_NO_MEMORY); - SuccessOrExit(err = ConstructTBSData(work.initiatorNOC, work.initiatorICAC, ByteSpan(mRemotePubKey, mRemotePubKey.Length()), + SuccessOrExit(err = ConstructTBSData(data.initiatorNOC, data.initiatorICAC, ByteSpan(mRemotePubKey, mRemotePubKey.Length()), ByteSpan(mEphemeralKey->Pubkey(), mEphemeralKey->Pubkey().Length()), - work.msg_R3_Signed.Get(), work.msg_r3_signed_len)); + data.msg_R3_Signed.Get(), data.msg_r3_signed_len)); VerifyOrExit(TLV::TagNumFromTag(decryptedDataTlvReader.GetTag()) == kTag_TBEData_Signature, err = CHIP_ERROR_INVALID_TLV_TAG); - VerifyOrExit(work.tbsData3Signature.Capacity() >= decryptedDataTlvReader.GetLength(), err = CHIP_ERROR_INVALID_TLV_ELEMENT); - work.tbsData3Signature.SetLength(decryptedDataTlvReader.GetLength()); - SuccessOrExit(err = decryptedDataTlvReader.GetBytes(work.tbsData3Signature.Bytes(), work.tbsData3Signature.Length())); + VerifyOrExit(data.tbsData3Signature.Capacity() >= decryptedDataTlvReader.GetLength(), err = CHIP_ERROR_INVALID_TLV_ELEMENT); + data.tbsData3Signature.SetLength(decryptedDataTlvReader.GetLength()); + SuccessOrExit(err = decryptedDataTlvReader.GetBytes(data.tbsData3Signature.Bytes(), data.tbsData3Signature.Length())); // Prepare for Step 5/6 { - MutableByteSpan fabricRCAC{ work.rootCertBuf }; + MutableByteSpan fabricRCAC{ data.rootCertBuf }; SuccessOrExit(err = mFabricsTable->FetchRootCert(mFabricIndex, fabricRCAC)); - work.fabricRCAC = fabricRCAC; + data.fabricRCAC = fabricRCAC; // TODO probably should make SetEffectiveTime static and call closer to VerifyCredentials SuccessOrExit(err = SetEffectiveTime()); } // Copy remaining needed data into work structure { - work.validContext = mValidContext; + data.validContext = mValidContext; // initiatorNOC and initiatorICAC are spans into msg_R3_Encrypted // which is going away, so to save memory, redirect them to their // copies in msg_R3_signed, which is staying around TLV::TLVReader signedDataTlvReader; - signedDataTlvReader.Init(work.msg_R3_Signed.Get(), work.msg_r3_signed_len); + signedDataTlvReader.Init(data.msg_R3_Signed.Get(), data.msg_r3_signed_len); SuccessOrExit(err = signedDataTlvReader.Next(TLV::kTLVType_Structure, TLV::AnonymousTag())); SuccessOrExit(err = signedDataTlvReader.EnterContainer(containerType)); SuccessOrExit(err = signedDataTlvReader.Next(TLV::kTLVType_ByteString, TLV::ContextTag(kTag_TBSData_SenderNOC))); - SuccessOrExit(err = signedDataTlvReader.Get(work.initiatorNOC)); + SuccessOrExit(err = signedDataTlvReader.Get(data.initiatorNOC)); - if (!work.initiatorICAC.empty()) + if (!data.initiatorICAC.empty()) { SuccessOrExit(err = signedDataTlvReader.Next(TLV::kTLVType_ByteString, TLV::ContextTag(kTag_TBSData_SenderICAC))); - SuccessOrExit(err = signedDataTlvReader.Get(work.initiatorICAC)); + SuccessOrExit(err = signedDataTlvReader.Get(data.initiatorICAC)); } } - SuccessOrExit(err = DeviceLayer::PlatformMgr().ScheduleBackgroundWork( - [](intptr_t arg) { HandleSigma3b(*reinterpret_cast(arg)); }, - reinterpret_cast(&work))); - workPtr = nullptr; // scheduling succeeded, so don't delete + SuccessOrExit(err = helper->ScheduleWork()); + mHandleSigma3Helper = helper; mExchangeCtxt->WillSendMessage(); mState = State::kHandleSigma3Pending; } exit: - Platform::Delete(workPtr); - if (err != CHIP_NO_ERROR) { SendStatusReport(mExchangeCtxt, kProtocolCodeInvalidParam); @@ -1668,7 +1648,7 @@ CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg) return err; } -void CASESession::HandleSigma3b(HandleSigma3Work & work) +CHIP_ERROR CASESession::HandleSigma3b(HandleSigma3Data & data, bool & cancel) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -1678,9 +1658,9 @@ void CASESession::HandleSigma3b(HandleSigma3Work & work) CompressedFabricId unused; FabricId initiatorFabricId; P256PublicKey initiatorPublicKey; - SuccessOrExit(err = FabricTable::VerifyCredentials(work.initiatorNOC, work.initiatorICAC, work.fabricRCAC, work.validContext, - unused, initiatorFabricId, work.initiatorNodeId, initiatorPublicKey)); - VerifyOrExit(work.fabricId == initiatorFabricId, err = CHIP_ERROR_INVALID_CASE_PARAMETER); + SuccessOrExit(err = FabricTable::VerifyCredentials(data.initiatorNOC, data.initiatorICAC, data.fabricRCAC, data.validContext, + unused, initiatorFabricId, data.initiatorNodeId, initiatorPublicKey)); + VerifyOrExit(data.fabricId == initiatorFabricId, err = CHIP_ERROR_INVALID_CASE_PARAMETER); // TODO - Validate message signature prior to validating the received operational credentials. // The op cert check requires traversal of cert chain, that is a more expensive operation. @@ -1692,46 +1672,27 @@ void CASESession::HandleSigma3b(HandleSigma3Work & work) { P256PublicKeyHSM initiatorPublicKeyHSM; memcpy(Uint8::to_uchar(initiatorPublicKeyHSM), initiatorPublicKey.Bytes(), initiatorPublicKey.Length()); - SuccessOrExit(err = initiatorPublicKeyHSM.ECDSA_validate_msg_signature(work.msg_R3_Signed.Get(), work.msg_r3_signed_len, - work.tbsData3Signature)); + SuccessOrExit(err = initiatorPublicKeyHSM.ECDSA_validate_msg_signature(data.msg_R3_Signed.Get(), data.msg_r3_signed_len, + data.tbsData3Signature)); } #else - SuccessOrExit(err = initiatorPublicKey.ECDSA_validate_msg_signature(work.msg_R3_Signed.Get(), work.msg_r3_signed_len, - work.tbsData3Signature)); + SuccessOrExit(err = initiatorPublicKey.ECDSA_validate_msg_signature(data.msg_R3_Signed.Get(), data.msg_r3_signed_len, + data.tbsData3Signature)); #endif exit: - work.status = err; - - auto err2 = DeviceLayer::PlatformMgr().ScheduleWork( - [](intptr_t arg) { - auto & work2 = *reinterpret_cast(arg); - work2.session->HandleSigma3c(work2); - }, - reinterpret_cast(&work)); - - if (err2 != CHIP_NO_ERROR) - { - Platform::Delete(&work); // scheduling failed, so delete - } + return err; } -CHIP_ERROR CASESession::HandleSigma3c(HandleSigma3Work & work) +CHIP_ERROR CASESession::HandleSigma3c(HandleSigma3Data & data, CHIP_ERROR status) { - CHIP_ERROR err = CHIP_NO_ERROR; - bool ignoreFailure = true; + CHIP_ERROR err = CHIP_NO_ERROR; - // Special case: if for whatever reason not in expected state or sequence, - // don't do anything, including sending a status report or aborting the - // pending establish. VerifyOrExit(mState == State::kHandleSigma3Pending, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(mSequence == work.sequence, err = CHIP_ERROR_INCORRECT_STATE); - - ignoreFailure = false; - SuccessOrExit(err = work.status); + SuccessOrExit(err = status); - mPeerNodeId = work.initiatorNodeId; + mPeerNodeId = data.initiatorNodeId; { MutableByteSpan messageDigestSpan(mMessageDigest); @@ -1740,7 +1701,7 @@ CHIP_ERROR CASESession::HandleSigma3c(HandleSigma3Work & work) // Retrieve peer CASE Authenticated Tags (CATs) from peer's NOC. { - SuccessOrExit(err = ExtractCATsFromOpCert(work.initiatorNOC, mPeerCATs)); + SuccessOrExit(err = ExtractCATsFromOpCert(data.initiatorNOC, mPeerCATs)); } if (mSessionResumptionStorage != nullptr) @@ -1758,9 +1719,9 @@ CHIP_ERROR CASESession::HandleSigma3c(HandleSigma3Work & work) Finish(); exit: - Platform::Delete(&work); + mHandleSigma3Helper.reset(); - if (err != CHIP_NO_ERROR && !ignoreFailure) + if (err != CHIP_NO_ERROR) { SendStatusReport(mExchangeCtxt, kProtocolCodeInvalidParam); // Abort the pending establish, which is normally done by CASESession::OnMessageReceived, diff --git a/src/protocols/secure_channel/CASESession.h b/src/protocols/secure_channel/CASESession.h index 21578e592ba907..f0caa1675f7845 100644 --- a/src/protocols/secure_channel/CASESession.h +++ b/src/protocols/secure_channel/CASESession.h @@ -240,10 +240,10 @@ class DLL_EXPORT CASESession : public Messaging::UnsolicitedMessageHandler, static CHIP_ERROR SendSigma3b(SendSigma3Data & data, bool & cancel); CHIP_ERROR SendSigma3c(SendSigma3Data & data, CHIP_ERROR status); - struct HandleSigma3Work; + struct HandleSigma3Data; CHIP_ERROR HandleSigma3a(System::PacketBufferHandle && msg); - static void HandleSigma3b(HandleSigma3Work & work); - CHIP_ERROR HandleSigma3c(HandleSigma3Work & work); + static CHIP_ERROR HandleSigma3b(HandleSigma3Data & data, bool & cancel); + CHIP_ERROR HandleSigma3c(HandleSigma3Data & data, CHIP_ERROR status); CHIP_ERROR SendSigma2Resume(); @@ -303,13 +303,10 @@ class DLL_EXPORT CASESession : public Messaging::UnsolicitedMessageHandler, // Sigma1 initiator random, maintained to be reused post-Sigma1, such as when generating Sigma2 S2RK key uint8_t mInitiatorRandom[kSigmaParamRandomNumberSize]; - // Sequence number used to coordinate foreground/background work for a - // particular session establishment. - int mSequence = 0; - template class WorkHelper; Platform::SharedPtr> mSendSigma3Helper; + Platform::SharedPtr> mHandleSigma3Helper; State mState; From 8b686a9fa74dc29ee0f9296b2a4391d285556e75 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 16:40:53 -0400 Subject: [PATCH 063/200] Bump third_party/pigweed/repo from `b88cd71` to `5c4ea8e` (#26312) Bumps [third_party/pigweed/repo](https://github.com/google/pigweed) from `b88cd71` to `5c4ea8e`. - [Release notes](https://github.com/google/pigweed/releases) - [Commits](https://github.com/google/pigweed/compare/b88cd71d271c41e34a36dfc1c435e1e6ee3bc72a...5c4ea8e31764a8ab1c55b7df4086fe610c4bf4af) --- updated-dependencies: - dependency-name: third_party/pigweed/repo dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- third_party/pigweed/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index b88cd71d271c41..5c4ea8e31764a8 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit b88cd71d271c41e34a36dfc1c435e1e6ee3bc72a +Subproject commit 5c4ea8e31764a8ab1c55b7df4086fe610c4bf4af From 314443421063d54c5f92877939fcb9ea909386bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 16:41:35 -0400 Subject: [PATCH 064/200] Bump third_party/mbedtls/repo from `e323fb3` to `a31c6eb` (#26310) Bumps [third_party/mbedtls/repo](https://github.com/ARMmbed/mbedtls) from `e323fb3` to `a31c6eb`. - [Release notes](https://github.com/ARMmbed/mbedtls/releases) - [Commits](https://github.com/ARMmbed/mbedtls/compare/e323fb3ab5bf9dbdec8731c29108697e8d611755...a31c6eb509fd67b9c21721f0d0f38c1468f706c7) --- updated-dependencies: - dependency-name: third_party/mbedtls/repo dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- third_party/mbedtls/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/mbedtls/repo b/third_party/mbedtls/repo index e323fb3ab5bf9d..a31c6eb509fd67 160000 --- a/third_party/mbedtls/repo +++ b/third_party/mbedtls/repo @@ -1 +1 @@ -Subproject commit e323fb3ab5bf9dbdec8731c29108697e8d611755 +Subproject commit a31c6eb509fd67b9c21721f0d0f38c1468f706c7 From fa505f6a7bdb3a3b9649196cb8d40296ab97ecae Mon Sep 17 00:00:00 2001 From: Jean-Francois Penven <67962328+jepenven-silabs@users.noreply.github.com> Date: Mon, 1 May 2023 23:08:34 -0400 Subject: [PATCH 065/200] [Silabs] Rename sources files (#26315) * Rename sources files * PascalCase --- src/platform/silabs/SiWx917/BUILD.gn | 2 +- src/platform/silabs/efr32/BUILD.gn | 2 +- .../silabs/platformAbstraction/{GSDK_SPAM.cpp => GsdkSpam.cpp} | 0 .../platformAbstraction/{WiseMCU_SPAM.cpp => WiseMcuSpam.cpp} | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename src/platform/silabs/platformAbstraction/{GSDK_SPAM.cpp => GsdkSpam.cpp} (100%) rename src/platform/silabs/platformAbstraction/{WiseMCU_SPAM.cpp => WiseMcuSpam.cpp} (100%) diff --git a/src/platform/silabs/SiWx917/BUILD.gn b/src/platform/silabs/SiWx917/BUILD.gn index 346c4ad20652ff..db98b116c98507 100644 --- a/src/platform/silabs/SiWx917/BUILD.gn +++ b/src/platform/silabs/SiWx917/BUILD.gn @@ -55,7 +55,7 @@ static_library("SiWx917") { "${silabs_platform_dir}/SystemPlatformConfig.h", "${silabs_platform_dir}/platformAbstraction/SilabsPlatform.h", "${silabs_platform_dir}/platformAbstraction/SilabsPlatformBase.h", - "${silabs_platform_dir}/platformAbstraction/WiseMCU_SPAM.cpp", + "${silabs_platform_dir}/platformAbstraction/WiseMcuSpam.cpp", "../../FreeRTOS/SystemTimeSupport.cpp", "../../SingletonConfigurationManager.cpp", "BLEManagerImpl.cpp", diff --git a/src/platform/silabs/efr32/BUILD.gn b/src/platform/silabs/efr32/BUILD.gn index 7b80bf07111915..1a848e54820bed 100644 --- a/src/platform/silabs/efr32/BUILD.gn +++ b/src/platform/silabs/efr32/BUILD.gn @@ -57,7 +57,7 @@ static_library("efr32") { "${silabs_platform_dir}/SilabsConfig.cpp", "${silabs_platform_dir}/SilabsConfig.h", "${silabs_platform_dir}/SystemPlatformConfig.h", - "${silabs_platform_dir}/platformAbstraction/GSDK_SPAM.cpp", + "${silabs_platform_dir}/platformAbstraction/GsdkSpam.cpp", "${silabs_platform_dir}/platformAbstraction/SilabsPlatform.h", "${silabs_platform_dir}/platformAbstraction/SilabsPlatformBase.h", "../../FreeRTOS/SystemTimeSupport.cpp", diff --git a/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp b/src/platform/silabs/platformAbstraction/GsdkSpam.cpp similarity index 100% rename from src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp rename to src/platform/silabs/platformAbstraction/GsdkSpam.cpp diff --git a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp similarity index 100% rename from src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp rename to src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp From f587c34e3a41aabbf2994d60450a9e2c0fbfa5ab Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Tue, 2 May 2023 09:34:38 -0400 Subject: [PATCH 066/200] Update Test_TC_OO_2_4 to reflect testspec PR#2464 update (#26314) * Update Test_TC_OO_2_4 to reflectup testspec PR#2464 update * Address PR comment --- .../suites/certification/Test_TC_OO_2_4.yaml | 24 ++++----------- .../chip-tool/zap-generated/test/Commands.h | 15 +++++----- .../zap-generated/test/Commands.h | 29 ++++++++++++++----- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_OO_2_4.yaml b/src/app/tests/suites/certification/Test_TC_OO_2_4.yaml index 736a8706b92072..0b7caf3b680d21 100644 --- a/src/app/tests/suites/certification/Test_TC_OO_2_4.yaml +++ b/src/app/tests/suites/certification/Test_TC_OO_2_4.yaml @@ -238,24 +238,12 @@ tests: PICS: OO.S.C00.Rsp command: "Off" - # We get an acknowledgment that the command off above is received, but it takes - # a few milliseconds for the off command to actually turn it off. Without this - # delay the preceding reboot command might happen before the command is fully - # processed resulting in flaky test failure that comes from the readAddribute - # verification after the reboot. - # TODO once https://github.com/CHIP-Specifications/chip-test-plans/pull/2464 is - # merged, change this command to a readAtribute and update PICS code to - # OO.S.A0000. PR is blocked from being merged at this time due to freeze for - # SVE. Likely after March 17th, 2023 this PR can be merged and associated - # changes made here to officially fix the flake discovered by CI. - - label: "Wait for send Off command to take affect" - PICS: PICS_SDK_CI_ONLY - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 10 + - label: "TH reads the OnOff attribute from the DUT" + PICS: OO.S.A0000 + command: "readAttribute" + attribute: "OnOff" + response: + value: 0 - label: "Reboot target device" PICS: PICS_SDK_CI_ONLY diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 1696aa2afc2543..74fe8807e0ca3a 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -37863,7 +37863,11 @@ class Test_TC_OO_2_4Suite : public TestCommand break; case 27: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; + { + bool value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("onOff", value, 0)); + } break; case 28: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -38115,12 +38119,9 @@ class Test_TC_OO_2_4Suite : public TestCommand ); } case 27: { - LogStep(27, "Wait for send Off command to take affect"); - VerifyOrDo(!ShouldSkip("PICS_SDK_CI_ONLY"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10UL; - return WaitForMs(kIdentityAlpha, value); + LogStep(27, "TH reads the OnOff attribute from the DUT"); + VerifyOrDo(!ShouldSkip("OO.S.A0000"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OnOff::Id, OnOff::Attributes::OnOff::Id, true, chip::NullOptional); } case 28: { LogStep(28, "Reboot target device"); 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 bfccaf83dbe46f..217820fc3a6d98 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -52823,12 +52823,12 @@ class Test_TC_OO_2_4 : public TestCommandBridge { err = TestThSendsOffCommandToDut_26(); break; case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Wait for send Off command to take affect\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { + ChipLogProgress(chipTool, " ***** Test Step 27 : TH reads the OnOff attribute from the DUT\n"); + if (ShouldSkip("OO.S.A0000")) { NextTest(); return; } - err = TestWaitForSendOffCommandToTakeAffect_27(); + err = TestThReadsTheOnOffAttributeFromTheDut_27(); break; case 28: ChipLogProgress(chipTool, " ***** Test Step 28 : Reboot target device\n"); @@ -53358,12 +53358,27 @@ class Test_TC_OO_2_4 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestWaitForSendOffCommandToTakeAffect_27() + CHIP_ERROR TestThReadsTheOnOffAttributeFromTheDut_27() { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10UL; - return WaitForMs("alpha", value); + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads the OnOff attribute from the DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; } CHIP_ERROR TestRebootTargetDevice_28() From ab59adc28a5986e19c33f5a2da622e49832f68e3 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 2 May 2023 10:45:44 -0400 Subject: [PATCH 067/200] Add ProductAppearance attribute support. (#25742) * Add ProductAppearance attribute support. * Regenerate generated code. --- .../all-clusters-app.matter | 42 +- .../all-clusters-common/all-clusters-app.zap | 21 +- .../all-clusters-app/linux/main-common.cpp | 63 +++ .../all-clusters-minimal-app.matter | 38 ++ .../bridge-common/bridge-app.matter | 38 ++ ...p_rootnode_dimmablelight_bCwGYSDpoe.matter | 38 ++ ...de_colortemperaturelight_hbUnzYVeyn.matter | 38 ++ .../rootnode_contactsensor_lFAGG1bfRO.matter | 38 ++ .../rootnode_dimmablelight_bCwGYSDpoe.matter | 38 ++ .../rootnode_doorlock_aNKYAreMXE.matter | 38 ++ ...tnode_extendedcolorlight_8lcaaYJVAa.matter | 38 ++ .../devices/rootnode_fan_7N2TobIlOX.matter | 38 ++ .../rootnode_flowsensor_1zVxHedlaV.matter | 38 ++ ...tnode_heatingcoolingunit_ncdGai1E5a.matter | 38 ++ .../rootnode_humiditysensor_Xyj4gda6Hb.matter | 38 ++ .../rootnode_lightsensor_lZQycTFcJK.matter | 38 ++ ...rootnode_occupancysensor_iHyVgifZuo.matter | 38 ++ .../rootnode_onofflight_bbs1b7IaOV.matter | 38 ++ ...ootnode_onofflightswitch_FsPlMr090Q.matter | 38 ++ ...rootnode_onoffpluginunit_Wtf8ss5EBY.matter | 38 ++ .../rootnode_pressuresensor_s0qC9wLH4k.matter | 38 ++ .../rootnode_speaker_RpzeXdimqA.matter | 38 ++ ...otnode_temperaturesensor_Qy1zkNW7c3.matter | 38 ++ .../rootnode_thermostat_bm3fb8dhYi.matter | 38 ++ .../rootnode_windowcovering_RLCxaGi9Yx.matter | 38 ++ .../contact-sensor-app.matter | 38 ++ .../bridge-common/bridge-app.matter | 38 ++ .../light-switch-app.matter | 38 ++ .../data_model/lighting-app-thread.matter | 38 ++ .../data_model/lighting-app-wifi.matter | 38 ++ .../lighting-common/lighting-app.matter | 38 ++ .../nxp/zap/lighting-on-off.matter | 38 ++ examples/lighting-app/qpg/zap/light.matter | 38 ++ .../data_model/lighting-wifi-app.matter | 38 ++ .../data_model/lighting-thread-app.matter | 38 ++ .../efr32/data_model/lighting-wifi-app.matter | 38 ++ examples/lock-app/lock-common/lock-app.matter | 38 ++ examples/lock-app/nxp/zap/lock-app.matter | 38 ++ examples/lock-app/qpg/zap/lock.matter | 38 ++ .../ota-provider-app.matter | 38 ++ .../ota-requestor-app.matter | 38 ++ .../placeholder/linux/apps/app1/config.matter | 38 ++ .../placeholder/linux/apps/app2/config.matter | 38 ++ examples/pump-app/pump-common/pump-app.matter | 38 ++ .../pump-controller-app.matter | 38 ++ .../temperature-measurement.matter | 38 ++ .../thermostat-common/thermostat.matter | 38 ++ examples/tv-app/tv-common/tv-app.matter | 38 ++ .../tv-casting-common/tv-casting-app.matter | 38 ++ examples/window-app/common/window-app.matter | 38 ++ .../basic-information/basic-information.cpp | 33 ++ .../tests/suites/TestBasicInformation.yaml | 8 + .../certification/Test_TC_BINFO_1_1.yaml | 2 +- .../chip/basic-information-cluster.xml | 44 ++- .../chip/bridged-device-basic-information.xml | 43 ++ .../zcl/zcl-with-test-extensions.json | 3 +- src/app/zap-templates/zcl/zcl.json | 3 +- .../data_model/controller-clusters.matter | 78 ++++ .../data_model/controller-clusters.zap | 16 + .../CHIPAttributeTLVValueDecoder.cpp | 101 +++++ .../chip/devicecontroller/ChipIdLookup.java | 6 + .../chip/devicecontroller/ChipStructs.java | 50 +++ .../python/chip/clusters/CHIPClusters.py | 12 + .../python/chip/clusters/Objects.py | 147 +++++++ .../CHIP/templates/availability.yaml | 111 ++++++ .../MTRAttributeTLVValueDecoder.mm | 34 ++ .../CHIP/zap-generated/MTRBaseClusters.h | 97 +++++ .../CHIP/zap-generated/MTRBaseClusters.mm | 101 +++++ .../CHIP/zap-generated/MTRCallbackBridge.h | 368 ++++++++++++++++++ .../CHIP/zap-generated/MTRCallbackBridge.mm | 259 ++++++++++++ .../CHIP/zap-generated/MTRClusterConstants.h | 2 + .../CHIP/zap-generated/MTRClusters.h | 4 + .../CHIP/zap-generated/MTRClusters.mm | 17 + .../CHIP/zap-generated/MTRStructsObjc.h | 11 + .../CHIP/zap-generated/MTRStructsObjc.mm | 62 +++ .../platform/DeviceInstanceInfoProvider.h | 25 ++ .../zap-generated/cluster-enums-check.h | 96 +++++ .../app-common/zap-generated/cluster-enums.h | 100 ++++- .../zap-generated/cluster-objects.cpp | 96 +++++ .../zap-generated/cluster-objects.h | 75 ++++ .../app-common/zap-generated/ids/Attributes.h | 8 + .../zap-generated/cluster/Commands.h | 11 + .../cluster/ComplexArgumentParser.cpp | 66 ++++ .../cluster/ComplexArgumentParser.h | 11 + .../cluster/logging/DataModelLogger.cpp | 62 +++ .../cluster/logging/DataModelLogger.h | 7 + .../chip-tool/zap-generated/test/Commands.h | 33 +- .../zap-generated/cluster/Commands.h | 149 +++++++ .../zap-generated/test/Commands.h | 53 ++- 89 files changed, 4291 insertions(+), 25 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 7d5c990db66e81..0cf14341ac4d1f 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -702,11 +702,49 @@ server cluster Actions = 37 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } @@ -742,6 +780,7 @@ server cluster BasicInformation = 40 { readonly attribute boolean reachable = 17; readonly attribute char_string<32> uniqueID = 18; readonly attribute CapabilityMinimaStruct capabilityMinima = 19; + readonly attribute ProductAppearanceStruct productAppearance = 20; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4644,8 +4683,9 @@ endpoint 0 { ram attribute reachable default = 1; callback attribute uniqueID; callback attribute capabilityMinima; + callback attribute productAppearance; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; + ram attribute clusterRevision default = 2; } server cluster OtaSoftwareUpdateRequestor { diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 7bdd60bf91a82f..8c645de17c904b 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -1508,6 +1508,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "ProductAppearance", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "ProductAppearanceStruct", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, @@ -1534,7 +1550,7 @@ "storageOption": "RAM", "singleton": 1, "bounded": 0, - "defaultValue": "1", + "defaultValue": "2", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -25498,5 +25514,6 @@ "endpointVersion": 1, "deviceIdentifier": 61442 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/all-clusters-app/linux/main-common.cpp b/examples/all-clusters-app/linux/main-common.cpp index b4724ad6f7cb45..39a4bf381a710b 100644 --- a/examples/all-clusters-app/linux/main-common.cpp +++ b/examples/all-clusters-app/linux/main-common.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -138,6 +139,61 @@ Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(kNetw #endif Clusters::NetworkCommissioning::Instance sEthernetNetworkCommissioningInstance(kNetworkCommissioningEndpointMain, &sEthernetDriver); + +class ExampleDeviceInstanceInfoProvider : public DeviceInstanceInfoProvider +{ +public: + void Init(DeviceInstanceInfoProvider * defaultProvider) { mDefaultProvider = defaultProvider; } + + CHIP_ERROR GetVendorName(char * buf, size_t bufSize) override { return mDefaultProvider->GetVendorName(buf, bufSize); } + CHIP_ERROR GetVendorId(uint16_t & vendorId) override { return mDefaultProvider->GetVendorId(vendorId); } + CHIP_ERROR GetProductName(char * buf, size_t bufSize) override { return mDefaultProvider->GetProductName(buf, bufSize); } + CHIP_ERROR GetProductId(uint16_t & productId) override { return mDefaultProvider->GetProductId(productId); } + CHIP_ERROR GetPartNumber(char * buf, size_t bufSize) override { return mDefaultProvider->GetPartNumber(buf, bufSize); } + CHIP_ERROR GetProductURL(char * buf, size_t bufSize) override { return mDefaultProvider->GetPartNumber(buf, bufSize); } + CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override { return mDefaultProvider->GetProductLabel(buf, bufSize); } + CHIP_ERROR GetSerialNumber(char * buf, size_t bufSize) override { return mDefaultProvider->GetSerialNumber(buf, bufSize); } + CHIP_ERROR GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) override + { + return mDefaultProvider->GetManufacturingDate(year, month, day); + } + CHIP_ERROR GetHardwareVersion(uint16_t & hardwareVersion) override + { + return mDefaultProvider->GetHardwareVersion(hardwareVersion); + } + CHIP_ERROR GetHardwareVersionString(char * buf, size_t bufSize) override + { + return mDefaultProvider->GetHardwareVersionString(buf, bufSize); + } + CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) override + { + return mDefaultProvider->GetRotatingDeviceIdUniqueId(uniqueIdSpan); + } + CHIP_ERROR GetProductFinish(Clusters::BasicInformation::ProductFinishEnum * finish) override; + CHIP_ERROR GetProductPrimaryColor(Clusters::BasicInformation::ColorEnum * primaryColor) override; + +private: + DeviceInstanceInfoProvider * mDefaultProvider; +}; + +CHIP_ERROR ExampleDeviceInstanceInfoProvider::GetProductFinish(Clusters::BasicInformation::ProductFinishEnum * finish) +{ + // Our example device claims to have a Satin finish for now. We can make + // this configurable as needed. + *finish = Clusters::BasicInformation::ProductFinishEnum::kSatin; + return CHIP_NO_ERROR; +} + +CHIP_ERROR ExampleDeviceInstanceInfoProvider::GetProductPrimaryColor(Clusters::BasicInformation::ColorEnum * primaryColor) +{ + // Our example device claims to have a nice purple color for now. We can + // make this configurable as needed. + *primaryColor = Clusters::BasicInformation::ColorEnum::kPurple; + return CHIP_NO_ERROR; +} + +ExampleDeviceInstanceInfoProvider gExampleDeviceInstanceInfoProvider; + } // namespace void ApplicationInit() @@ -201,6 +257,13 @@ void ApplicationInit() ChipLogError(NotSpecified, "Failed to start CHIP NamedPipeCommands"); sChipNamedPipeCommands.Stop(); } + + auto * defaultProvider = GetDeviceInstanceInfoProvider(); + if (defaultProvider != &gExampleDeviceInstanceInfoProvider) + { + gExampleDeviceInstanceInfoProvider.Init(defaultProvider); + SetDeviceInstanceInfoProvider(&gExampleDeviceInstanceInfoProvider); + } } void ApplicationExit() diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index 059bdeae17cece..c5a85c03abaadb 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -572,11 +572,49 @@ server cluster Actions = 37 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/bridge-app/bridge-common/bridge-app.matter b/examples/bridge-app/bridge-common/bridge-app.matter index daba86d8bc6f4d..93733fa58ac7ad 100644 --- a/examples/bridge-app/bridge-common/bridge-app.matter +++ b/examples/bridge-app/bridge-common/bridge-app.matter @@ -489,11 +489,49 @@ server cluster Actions = 37 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter index ebfed65a08b58a..6a4d8ddd2f6e67 100644 --- a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter +++ b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter @@ -380,11 +380,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter index 91b0651858b406..d3e2e4f1d767a7 100644 --- a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter +++ b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter @@ -379,11 +379,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter index 498da4410bed50..67a9957cc7e5c9 100644 --- a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter +++ b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter @@ -228,11 +228,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter index 9aa81192def114..b02fd871ece659 100644 --- a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter +++ b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter @@ -380,11 +380,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter index 22dcc0bda58b39..4a65b6ec23dd33 100644 --- a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter +++ b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter @@ -228,11 +228,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter index f2032ab4d31d43..b930a77109fdd0 100644 --- a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter +++ b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter @@ -377,11 +377,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter b/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter index 4368aa72bdd833..0184f55ea7dc1d 100644 --- a/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter +++ b/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter @@ -218,11 +218,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter index 24758353832c93..5a6ce98fdf76a1 100644 --- a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter +++ b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter @@ -299,11 +299,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter index e1fc1b04c861bf..5645faafec18e9 100644 --- a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter +++ b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter @@ -370,11 +370,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter index df557981fbdbc7..85c29d39db7e2e 100644 --- a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter +++ b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter @@ -299,11 +299,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter index 6ed3b14735881e..914ff39853f2c1 100644 --- a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter +++ b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter @@ -299,11 +299,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter index 3f67b78294ded4..7fb1b7d3fee8c5 100644 --- a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter +++ b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter @@ -299,11 +299,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter index 877a4c644963f9..6d224d2d25837f 100644 --- a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter +++ b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter @@ -377,11 +377,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter index 5e4c5884675454..55bf7b8a647c60 100644 --- a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter +++ b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter @@ -340,11 +340,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter index 0ebc72edbb5e36..50878d3fd877d6 100644 --- a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter +++ b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter @@ -276,11 +276,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter index 039cd18e0d056f..21db6a5ffb2314 100644 --- a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter +++ b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter @@ -299,11 +299,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter index 4e9566c593ea0e..35e6efc6ffd53c 100644 --- a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter +++ b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter @@ -371,11 +371,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter index 938c70b6e55d79..d1ed28a7454369 100644 --- a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter +++ b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter @@ -299,11 +299,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter index bd7919c6893af6..322bfa30fe6fcf 100644 --- a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter +++ b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter @@ -228,11 +228,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter index 6ff843421b7718..df34979e9d7eaa 100644 --- a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter +++ b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter @@ -228,11 +228,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter index f2a6f825f3d187..041ffa8bb9ef2c 100644 --- a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter +++ b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter @@ -218,11 +218,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/dynamic-bridge-app/bridge-common/bridge-app.matter b/examples/dynamic-bridge-app/bridge-common/bridge-app.matter index d553e9435e7aeb..c9b18b9e0f0a40 100644 --- a/examples/dynamic-bridge-app/bridge-common/bridge-app.matter +++ b/examples/dynamic-bridge-app/bridge-common/bridge-app.matter @@ -489,11 +489,49 @@ server cluster Actions = 37 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.matter b/examples/light-switch-app/light-switch-common/light-switch-app.matter index cba838c3007d9b..c807d33312b042 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.matter +++ b/examples/light-switch-app/light-switch-common/light-switch-app.matter @@ -526,11 +526,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter index b900049325d2cf..10d41625f70b25 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter @@ -388,11 +388,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter index 7cc2012ef8c2c4..cd4d0833e0f95d 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter @@ -388,11 +388,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index 1bf9cb4b9dc21b..ac3941ed0da579 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -388,11 +388,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/lighting-app/nxp/zap/lighting-on-off.matter b/examples/lighting-app/nxp/zap/lighting-on-off.matter index 1b6e340cb799b3..b3228bd4b1f59c 100644 --- a/examples/lighting-app/nxp/zap/lighting-on-off.matter +++ b/examples/lighting-app/nxp/zap/lighting-on-off.matter @@ -380,11 +380,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/lighting-app/qpg/zap/light.matter b/examples/lighting-app/qpg/zap/light.matter index b6b9cb244c744b..690c1ef00c3472 100644 --- a/examples/lighting-app/qpg/zap/light.matter +++ b/examples/lighting-app/qpg/zap/light.matter @@ -383,11 +383,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/lighting-app/silabs/SiWx917/data_model/lighting-wifi-app.matter b/examples/lighting-app/silabs/SiWx917/data_model/lighting-wifi-app.matter index 08811edf0b16d4..10f515bf7763a1 100644 --- a/examples/lighting-app/silabs/SiWx917/data_model/lighting-wifi-app.matter +++ b/examples/lighting-app/silabs/SiWx917/data_model/lighting-wifi-app.matter @@ -388,11 +388,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/lighting-app/silabs/efr32/data_model/lighting-thread-app.matter b/examples/lighting-app/silabs/efr32/data_model/lighting-thread-app.matter index 25f2346c1139d2..4ed286292677b3 100644 --- a/examples/lighting-app/silabs/efr32/data_model/lighting-thread-app.matter +++ b/examples/lighting-app/silabs/efr32/data_model/lighting-thread-app.matter @@ -388,11 +388,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/lighting-app/silabs/efr32/data_model/lighting-wifi-app.matter b/examples/lighting-app/silabs/efr32/data_model/lighting-wifi-app.matter index 08811edf0b16d4..10f515bf7763a1 100644 --- a/examples/lighting-app/silabs/efr32/data_model/lighting-wifi-app.matter +++ b/examples/lighting-app/silabs/efr32/data_model/lighting-wifi-app.matter @@ -388,11 +388,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/lock-app/lock-common/lock-app.matter b/examples/lock-app/lock-common/lock-app.matter index 81abd19965fe32..d3d4f7f68bbdb8 100644 --- a/examples/lock-app/lock-common/lock-app.matter +++ b/examples/lock-app/lock-common/lock-app.matter @@ -195,11 +195,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/lock-app/nxp/zap/lock-app.matter b/examples/lock-app/nxp/zap/lock-app.matter index b09e5a23a74e92..cbe34d3abc1db1 100644 --- a/examples/lock-app/nxp/zap/lock-app.matter +++ b/examples/lock-app/nxp/zap/lock-app.matter @@ -152,11 +152,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/lock-app/qpg/zap/lock.matter b/examples/lock-app/qpg/zap/lock.matter index 2d46c41f4051a2..4466f92a12e4a7 100644 --- a/examples/lock-app/qpg/zap/lock.matter +++ b/examples/lock-app/qpg/zap/lock.matter @@ -217,11 +217,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter b/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter index 1482f14797d7e0..af44c58c246f4c 100644 --- a/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter +++ b/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter @@ -180,11 +180,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter index b806568768bd64..1d69db27f6a3ec 100644 --- a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter +++ b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter @@ -280,11 +280,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index 1ed428f54b89a9..368ed130bfe1c9 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -648,11 +648,49 @@ server cluster Actions = 37 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/placeholder/linux/apps/app2/config.matter b/examples/placeholder/linux/apps/app2/config.matter index cb867628e21df7..71f3160070bad4 100644 --- a/examples/placeholder/linux/apps/app2/config.matter +++ b/examples/placeholder/linux/apps/app2/config.matter @@ -648,11 +648,49 @@ server cluster Actions = 37 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/pump-app/pump-common/pump-app.matter b/examples/pump-app/pump-common/pump-app.matter index 68f06b0fe512c3..0f01768c57a550 100644 --- a/examples/pump-app/pump-common/pump-app.matter +++ b/examples/pump-app/pump-common/pump-app.matter @@ -309,11 +309,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter b/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter index ec9f7cbefecf59..197a8f44784a43 100644 --- a/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter +++ b/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter @@ -234,11 +234,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter b/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter index f8bd756cfc8cdd..5d113b5e8d9693 100644 --- a/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter +++ b/examples/temperature-measurement-app/temperature-measurement-common/temperature-measurement.matter @@ -107,11 +107,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/thermostat/thermostat-common/thermostat.matter b/examples/thermostat/thermostat-common/thermostat.matter index 5711a58d2c24d8..9779243ed3b287 100644 --- a/examples/thermostat/thermostat-common/thermostat.matter +++ b/examples/thermostat/thermostat-common/thermostat.matter @@ -402,11 +402,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/tv-app/tv-common/tv-app.matter b/examples/tv-app/tv-common/tv-app.matter index 38684c4cb92787..db232108fbddd7 100644 --- a/examples/tv-app/tv-common/tv-app.matter +++ b/examples/tv-app/tv-common/tv-app.matter @@ -297,11 +297,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter index 15be98246b7b73..abb8e9f1edb116 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter @@ -454,11 +454,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/examples/window-app/common/window-app.matter b/examples/window-app/common/window-app.matter index 0ac80a3916d20e..20956c32c6ab69 100644 --- a/examples/window-app/common/window-app.matter +++ b/examples/window-app/common/window-app.matter @@ -335,11 +335,49 @@ server cluster AccessControl = 31 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ server cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } diff --git a/src/app/clusters/basic-information/basic-information.cpp b/src/app/clusters/basic-information/basic-information.cpp index 3e98375670d513..57f297f1e1c4ad 100644 --- a/src/app/clusters/basic-information/basic-information.cpp +++ b/src/app/clusters/basic-information/basic-information.cpp @@ -58,6 +58,7 @@ class BasicAttrAccess : public AttributeAccessInterface CHIP_ERROR ReadDataModelRevision(AttributeValueEncoder & aEncoder); CHIP_ERROR ReadLocation(AttributeValueEncoder & aEncoder); CHIP_ERROR WriteLocation(AttributeValueDecoder & aDecoder); + CHIP_ERROR ReadProductAppearance(AttributeValueEncoder & aEncoder); }; BasicAttrAccess gAttrAccess; @@ -281,6 +282,11 @@ CHIP_ERROR BasicAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attrib break; } + case ProductAppearance::Id: { + status = ReadProductAppearance(aEncoder); + break; + } + default: // We did not find a processing path, the caller will delegate elsewhere. break; @@ -343,6 +349,33 @@ CHIP_ERROR BasicAttrAccess::WriteLocation(AttributeValueDecoder & aDecoder) return DeviceLayer::ConfigurationMgr().StoreCountryCode(location.data(), location.size()); } +CHIP_ERROR BasicAttrAccess::ReadProductAppearance(AttributeValueEncoder & aEncoder) +{ + auto * provider = GetDeviceInstanceInfoProvider(); + ProductFinishEnum finish; + ReturnErrorOnFailure(provider->GetProductFinish(&finish)); + + ColorEnum color; + CHIP_ERROR colorStatus = provider->GetProductPrimaryColor(&color); + if (colorStatus != CHIP_NO_ERROR && colorStatus != CHIP_ERROR_NOT_IMPLEMENTED) + { + return colorStatus; + } + + Structs::ProductAppearanceStruct::Type productAppearance; + productAppearance.finish = finish; + if (colorStatus == CHIP_NO_ERROR) + { + productAppearance.primaryColor.SetNonNull(color); + } + else + { + productAppearance.primaryColor.SetNull(); + } + + return aEncoder.Encode(productAppearance); +} + class PlatformMgrDelegate : public DeviceLayer::PlatformManagerDelegate { void OnStartUp(uint32_t softwareVersion) override diff --git a/src/app/tests/suites/TestBasicInformation.yaml b/src/app/tests/suites/TestBasicInformation.yaml index 8dce39f49b6d89..19f1af3cb2ec53 100644 --- a/src/app/tests/suites/TestBasicInformation.yaml +++ b/src/app/tests/suites/TestBasicInformation.yaml @@ -77,6 +77,7 @@ tests: 17, 18, 19, + 20, 0xFFF8, # GeneratedCommandList 0xFFF9, # AcceptedCommandList 0xFFFB, # AttributeList @@ -155,3 +156,10 @@ tests: attribute: "LocalConfigDisabled" arguments: value: false + + - label: "Read the ProductApppearance value" + command: "readAttribute" + attribute: "ProductAppearance" + response: + # For now all-clusters-app is a satin purple. + value: { Finish: 2, PrimaryColor: 5 } diff --git a/src/app/tests/suites/certification/Test_TC_BINFO_1_1.yaml b/src/app/tests/suites/certification/Test_TC_BINFO_1_1.yaml index c21058ce983913..670f5e2972122e 100644 --- a/src/app/tests/suites/certification/Test_TC_BINFO_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_BINFO_1_1.yaml @@ -38,7 +38,7 @@ tests: command: "readAttribute" attribute: "ClusterRevision" response: - value: 1 + value: 2 constraints: type: int16u diff --git a/src/app/zap-templates/zcl/data-model/chip/basic-information-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/basic-information-cluster.xml index cfe5e82dca20fa..4c9cd6cbd55d46 100644 --- a/src/app/zap-templates/zcl/data-model/chip/basic-information-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/basic-information-cluster.xml @@ -23,6 +23,47 @@ limitations under the License. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Basic Information CHIP @@ -31,7 +72,7 @@ limitations under the License. This cluster provides attributes and events for determining basic information about Nodes, which supports both Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. - + DataModelRevision VendorName @@ -65,6 +106,7 @@ limitations under the License. Reachable UniqueID CapabilityMinima + ProductAppearance The StartUp event SHALL be emitted by a Node as soon as reasonable after completing a boot or reboot process. diff --git a/src/app/zap-templates/zcl/data-model/chip/bridged-device-basic-information.xml b/src/app/zap-templates/zcl/data-model/chip/bridged-device-basic-information.xml index 61e0cc011ad8d7..1179eb9ec5d44d 100644 --- a/src/app/zap-templates/zcl/data-model/chip/bridged-device-basic-information.xml +++ b/src/app/zap-templates/zcl/data-model/chip/bridged-device-basic-information.xml @@ -16,6 +16,48 @@ limitations under the License. --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bridged Device Basic Information CHIP @@ -44,6 +86,7 @@ limitations under the License. SerialNumber Reachable UniqueID + ProductAppearance The StartUp event SHALL be emitted by a Node as soon as reasonable after completing a boot or reboot process. diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index 31c0bdafb533bb..0630b770710483 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -139,7 +139,8 @@ "ProductLabel", "SerialNumber", "UniqueID", - "CapabilityMinima" + "CapabilityMinima", + "ProductAppearance" ], "Descriptor": ["ClusterRevision"], "Ethernet Network Diagnostics": [ diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index 989130f2ab0c88..a4908975f74213 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -137,7 +137,8 @@ "ProductLabel", "SerialNumber", "UniqueID", - "CapabilityMinima" + "CapabilityMinima", + "ProductAppearance" ], "Descriptor": ["ClusterRevision"], "Ethernet Network Diagnostics": [ diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index a77f66684da4c4..cf47d784ff7407 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -815,11 +815,49 @@ client cluster Actions = 37 { Commissioning and operational determination of Node characteristics, such as Vendor ID, Product ID and serial number, which apply to the whole Node. Also allows setting user device information such as location. */ client cluster BasicInformation = 40 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + struct CapabilityMinimaStruct { int16u caseSessionsPerFabric = 0; int16u subscriptionsPerFabric = 1; } + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } @@ -855,6 +893,7 @@ client cluster BasicInformation = 40 { readonly attribute optional boolean reachable = 17; readonly attribute optional char_string<32> uniqueID = 18; readonly attribute CapabilityMinimaStruct capabilityMinima = 19; + readonly attribute optional ProductAppearanceStruct productAppearance = 20; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2038,6 +2077,44 @@ client cluster EthernetNetworkDiagnostics = 55 { collection of attributes that the Node MAY collect to aid in conveying information regarding the Bridged Device to a user, such as the vendor name, the model name, or user-assigned name. */ client cluster BridgedDeviceBasicInformation = 57 { + enum ColorEnum : ENUM8 { + kBlack = 0; + kNavy = 1; + kGreen = 2; + kTeal = 3; + kMaroon = 4; + kPurple = 5; + kOlive = 6; + kGray = 7; + kBlue = 8; + kLime = 9; + kAqua = 10; + kRed = 11; + kFuchsia = 12; + kYellow = 13; + kWhite = 14; + kNickel = 15; + kChrome = 16; + kBrass = 17; + kCopper = 18; + kSilver = 19; + kGold = 20; + } + + enum ProductFinishEnum : ENUM8 { + kOther = 0; + kMatte = 1; + kSatin = 2; + kPolished = 3; + kRugged = 4; + kFabric = 5; + } + + struct ProductAppearanceStruct { + ProductFinishEnum finish = 0; + nullable ColorEnum primaryColor = 1; + } + critical event StartUp = 0 { INT32U softwareVersion = 0; } @@ -2067,6 +2144,7 @@ client cluster BridgedDeviceBasicInformation = 57 { readonly attribute optional char_string<32> serialNumber = 15; readonly attribute boolean reachable = 17; readonly attribute optional char_string<32> uniqueID = 18; + readonly attribute optional ProductAppearanceStruct productAppearance = 20; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index b9da13cdd78caf..841e8579296d87 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -3132,6 +3132,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "ProductAppearance", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "ProductAppearanceStruct", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "GeneratedCommandList", "code": 65528, diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index 4e02a196cc0db1..e4586c7b7a6a83 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -3100,6 +3100,56 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR value_caseSessionsPerFabric, value_subscriptionsPerFabric); return value; } + case Attributes::ProductAppearance::Id: { + using TypeInfo = Attributes::ProductAppearance::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + jobject value_finish; + std::string value_finishClassName = "java/lang/Integer"; + std::string value_finishCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(value_finishClassName.c_str(), + value_finishCtorSignature.c_str(), + static_cast(cppValue.finish), value_finish); + jobject value_primaryColor; + if (cppValue.primaryColor.IsNull()) + { + value_primaryColor = nullptr; + } + else + { + std::string value_primaryColorClassName = "java/lang/Integer"; + std::string value_primaryColorCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + value_primaryColorClassName.c_str(), value_primaryColorCtorSignature.c_str(), + static_cast(cppValue.primaryColor.Value()), value_primaryColor); + } + + jclass productAppearanceStructStructClass_0; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$BasicInformationClusterProductAppearanceStruct", + productAppearanceStructStructClass_0); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$BasicInformationClusterProductAppearanceStruct"); + return nullptr; + } + jmethodID productAppearanceStructStructCtor_0 = + env->GetMethodID(productAppearanceStructStructClass_0, "", "(Ljava/lang/Integer;Ljava/lang/Integer;)V"); + if (productAppearanceStructStructCtor_0 == nullptr) + { + ChipLogError(Zcl, "Could not find ChipStructs$BasicInformationClusterProductAppearanceStruct constructor"); + return nullptr; + } + + value = env->NewObject(productAppearanceStructStructClass_0, productAppearanceStructStructCtor_0, value_finish, + value_primaryColor); + return value; + } case Attributes::GeneratedCommandList::Id: { using TypeInfo = Attributes::GeneratedCommandList::TypeInfo; TypeInfo::DecodableType cppValue; @@ -8789,6 +8839,57 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } + case Attributes::ProductAppearance::Id: { + using TypeInfo = Attributes::ProductAppearance::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + jobject value_finish; + std::string value_finishClassName = "java/lang/Integer"; + std::string value_finishCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(value_finishClassName.c_str(), + value_finishCtorSignature.c_str(), + static_cast(cppValue.finish), value_finish); + jobject value_primaryColor; + if (cppValue.primaryColor.IsNull()) + { + value_primaryColor = nullptr; + } + else + { + std::string value_primaryColorClassName = "java/lang/Integer"; + std::string value_primaryColorCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + value_primaryColorClassName.c_str(), value_primaryColorCtorSignature.c_str(), + static_cast(cppValue.primaryColor.Value()), value_primaryColor); + } + + jclass productAppearanceStructStructClass_0; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$BridgedDeviceBasicInformationClusterProductAppearanceStruct", + productAppearanceStructStructClass_0); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$BridgedDeviceBasicInformationClusterProductAppearanceStruct"); + return nullptr; + } + jmethodID productAppearanceStructStructCtor_0 = + env->GetMethodID(productAppearanceStructStructClass_0, "", "(Ljava/lang/Integer;Ljava/lang/Integer;)V"); + if (productAppearanceStructStructCtor_0 == nullptr) + { + ChipLogError(Zcl, + "Could not find ChipStructs$BridgedDeviceBasicInformationClusterProductAppearanceStruct constructor"); + return nullptr; + } + + value = env->NewObject(productAppearanceStructStructClass_0, productAppearanceStructStructCtor_0, value_finish, + value_primaryColor); + return value; + } case Attributes::GeneratedCommandList::Id: { using TypeInfo = Attributes::GeneratedCommandList::TypeInfo; TypeInfo::DecodableType cppValue; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java index 3ec024468a2f3d..3a707bb8a5bad4 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java @@ -679,6 +679,9 @@ public static String attributeIdToName(long clusterId, long attributeId) { if (attributeId == 19L) { return "CapabilityMinima"; } + if (attributeId == 20L) { + return "ProductAppearance"; + } if (attributeId == 65528L) { return "GeneratedCommandList"; } @@ -1519,6 +1522,9 @@ public static String attributeIdToName(long clusterId, long attributeId) { if (attributeId == 18L) { return "UniqueID"; } + if (attributeId == 20L) { + return "ProductAppearance"; + } if (attributeId == 65528L) { return "GeneratedCommandList"; } diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java index 56810ab1fb2871..e78e5c00913076 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java @@ -350,6 +350,31 @@ public String toString() { } } + public static class BasicInformationClusterProductAppearanceStruct { + public Integer finish; + public @Nullable Integer primaryColor; + + public BasicInformationClusterProductAppearanceStruct( + Integer finish, @Nullable Integer primaryColor) { + this.finish = finish; + this.primaryColor = primaryColor; + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("BasicInformationClusterProductAppearanceStruct {\n"); + output.append("\tfinish: "); + output.append(finish); + output.append("\n"); + output.append("\tprimaryColor: "); + output.append(primaryColor); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } + } + public static class OtaSoftwareUpdateRequestorClusterProviderLocation { public Long providerNodeID; public Integer endpoint; @@ -1004,6 +1029,31 @@ public String toString() { } } + public static class BridgedDeviceBasicInformationClusterProductAppearanceStruct { + public Integer finish; + public @Nullable Integer primaryColor; + + public BridgedDeviceBasicInformationClusterProductAppearanceStruct( + Integer finish, @Nullable Integer primaryColor) { + this.finish = finish; + this.primaryColor = primaryColor; + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("BridgedDeviceBasicInformationClusterProductAppearanceStruct {\n"); + output.append("\tfinish: "); + output.append(finish); + output.append("\n"); + output.append("\tprimaryColor: "); + output.append(primaryColor); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } + } + public static class OperationalCredentialsClusterFabricDescriptorStruct { public byte[] rootPublicKey; public Integer vendorID; diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 63da4fe4764472..647fa2721d6ebb 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -1313,6 +1313,12 @@ class ChipClusters: "type": "", "reportable": True, }, + 0x00000014: { + "attributeName": "ProductAppearance", + "attributeId": 0x00000014, + "type": "", + "reportable": True, + }, 0x0000FFF8: { "attributeName": "GeneratedCommandList", "attributeId": 0x0000FFF8, @@ -3188,6 +3194,12 @@ class ChipClusters: "type": "str", "reportable": True, }, + 0x00000014: { + "attributeName": "ProductAppearance", + "attributeId": 0x00000014, + "type": "", + "reportable": True, + }, 0x0000FFF8: { "attributeName": "GeneratedCommandList", "attributeId": 0x0000FFF8, diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 951c635ea4ebfa..224ef39d7564eb 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -4021,6 +4021,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="reachable", Tag=0x00000011, Type=typing.Optional[bool]), ClusterObjectFieldDescriptor(Label="uniqueID", Tag=0x00000012, Type=typing.Optional[str]), ClusterObjectFieldDescriptor(Label="capabilityMinima", Tag=0x00000013, Type=BasicInformation.Structs.CapabilityMinimaStruct), + ClusterObjectFieldDescriptor(Label="productAppearance", Tag=0x00000014, Type=typing.Optional[BasicInformation.Structs.ProductAppearanceStruct]), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), @@ -4049,6 +4050,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: reachable: 'typing.Optional[bool]' = None uniqueID: 'typing.Optional[str]' = None capabilityMinima: 'BasicInformation.Structs.CapabilityMinimaStruct' = None + productAppearance: 'typing.Optional[BasicInformation.Structs.ProductAppearanceStruct]' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None eventList: 'typing.List[uint]' = None @@ -4056,6 +4058,48 @@ def descriptor(cls) -> ClusterObjectDescriptor: featureMap: 'uint' = None clusterRevision: 'uint' = None + class Enums: + class ColorEnum(MatterIntEnum): + kBlack = 0x00 + kNavy = 0x01 + kGreen = 0x02 + kTeal = 0x03 + kMaroon = 0x04 + kPurple = 0x05 + kOlive = 0x06 + kGray = 0x07 + kBlue = 0x08 + kLime = 0x09 + kAqua = 0x0A + kRed = 0x0B + kFuchsia = 0x0C + kYellow = 0x0D + kWhite = 0x0E + kNickel = 0x0F + kChrome = 0x10 + kBrass = 0x11 + kCopper = 0x12 + kSilver = 0x13 + kGold = 0x14 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 21, + + class ProductFinishEnum(MatterIntEnum): + kOther = 0x00 + kMatte = 0x01 + kSatin = 0x02 + kPolished = 0x03 + kRugged = 0x04 + kFabric = 0x05 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 6, + class Structs: @dataclass class CapabilityMinimaStruct(ClusterObject): @@ -4070,6 +4114,19 @@ def descriptor(cls) -> ClusterObjectDescriptor: caseSessionsPerFabric: 'uint' = 0 subscriptionsPerFabric: 'uint' = 0 + @dataclass + class ProductAppearanceStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="finish", Tag=0, Type=BasicInformation.Enums.ProductFinishEnum), + ClusterObjectFieldDescriptor(Label="primaryColor", Tag=1, Type=typing.Union[Nullable, BasicInformation.Enums.ColorEnum]), + ]) + + finish: 'BasicInformation.Enums.ProductFinishEnum' = 0 + primaryColor: 'typing.Union[Nullable, BasicInformation.Enums.ColorEnum]' = NullValue + class Commands: @dataclass class MfgSpecificPing(ClusterCommand): @@ -4405,6 +4462,22 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'BasicInformation.Structs.CapabilityMinimaStruct' = field(default_factory=lambda: BasicInformation.Structs.CapabilityMinimaStruct()) + @dataclass + class ProductAppearance(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0028 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000014 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Optional[BasicInformation.Structs.ProductAppearanceStruct]) + + value: 'typing.Optional[BasicInformation.Structs.ProductAppearanceStruct]' = None + @dataclass class GeneratedCommandList(ClusterAttributeDescriptor): @ChipUtility.classproperty @@ -11364,6 +11437,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="serialNumber", Tag=0x0000000F, Type=typing.Optional[str]), ClusterObjectFieldDescriptor(Label="reachable", Tag=0x00000011, Type=bool), ClusterObjectFieldDescriptor(Label="uniqueID", Tag=0x00000012, Type=typing.Optional[str]), + ClusterObjectFieldDescriptor(Label="productAppearance", Tag=0x00000014, Type=typing.Optional[BridgedDeviceBasicInformation.Structs.ProductAppearanceStruct]), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), @@ -11387,6 +11461,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: serialNumber: 'typing.Optional[str]' = None reachable: 'bool' = None uniqueID: 'typing.Optional[str]' = None + productAppearance: 'typing.Optional[BridgedDeviceBasicInformation.Structs.ProductAppearanceStruct]' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None eventList: 'typing.List[uint]' = None @@ -11394,6 +11469,62 @@ def descriptor(cls) -> ClusterObjectDescriptor: featureMap: 'uint' = None clusterRevision: 'uint' = None + class Enums: + class ColorEnum(MatterIntEnum): + kBlack = 0x00 + kNavy = 0x01 + kGreen = 0x02 + kTeal = 0x03 + kMaroon = 0x04 + kPurple = 0x05 + kOlive = 0x06 + kGray = 0x07 + kBlue = 0x08 + kLime = 0x09 + kAqua = 0x0A + kRed = 0x0B + kFuchsia = 0x0C + kYellow = 0x0D + kWhite = 0x0E + kNickel = 0x0F + kChrome = 0x10 + kBrass = 0x11 + kCopper = 0x12 + kSilver = 0x13 + kGold = 0x14 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 21, + + class ProductFinishEnum(MatterIntEnum): + kOther = 0x00 + kMatte = 0x01 + kSatin = 0x02 + kPolished = 0x03 + kRugged = 0x04 + kFabric = 0x05 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 6, + + class Structs: + @dataclass + class ProductAppearanceStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="finish", Tag=0, Type=BridgedDeviceBasicInformation.Enums.ProductFinishEnum), + ClusterObjectFieldDescriptor(Label="primaryColor", Tag=1, Type=typing.Union[Nullable, BridgedDeviceBasicInformation.Enums.ColorEnum]), + ]) + + finish: 'BridgedDeviceBasicInformation.Enums.ProductFinishEnum' = 0 + primaryColor: 'typing.Union[Nullable, BridgedDeviceBasicInformation.Enums.ColorEnum]' = NullValue + class Attributes: @dataclass class VendorName(ClusterAttributeDescriptor): @@ -11635,6 +11766,22 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'typing.Optional[str]' = None + @dataclass + class ProductAppearance(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0039 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000014 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Optional[BridgedDeviceBasicInformation.Structs.ProductAppearanceStruct]) + + value: 'typing.Optional[BridgedDeviceBasicInformation.Structs.ProductAppearanceStruct]' = None + @dataclass class GeneratedCommandList(ClusterAttributeDescriptor): @ChipUtility.classproperty diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index 6727e5bff1861b..33e51e15d8e722 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -7024,6 +7024,93 @@ - release: "TBD" versions: "future" introduced: + attributes: + BasicInformation: + - ProductAppearance + BridgedDeviceBasicInformation: + - ProductAppearance + structs: + BasicInformation: + - ProductAppearanceStruct + BridgedDeviceBasicInformation: + - ProductAppearanceStruct + struct fields: + BasicInformation: + ProductAppearanceStruct: + - finish + - primaryColor + BridgedDeviceBasicInformation: + ProductAppearanceStruct: + - finish + - primaryColor + enums: + BasicInformation: + - ColorEnum + - ProductFinishEnum + BridgedDeviceBasicInformation: + - ColorEnum + - ProductFinishEnum + enum values: + BasicInformation: + ColorEnum: + - Black + - Navy + - Green + - Teal + - Maroon + - Purple + - Olive + - Gray + - Blue + - Lime + - Aqua + - Red + - Fuchsia + - Yellow + - White + - Nickel + - Chrome + - Brass + - Copper + - Silver + - Gold + ProductFinishEnum: + - Matte + - Satin + - Polished + - Rugged + - Fabric + - Other + BridgedDeviceBasicInformation: + ColorEnum: + - Black + - Navy + - Green + - Teal + - Maroon + - Purple + - Olive + - Gray + - Blue + - Lime + - Aqua + - Red + - Fuchsia + - Yellow + - White + - Nickel + - Chrome + - Brass + - Copper + - Silver + - Gold + ProductFinishEnum: + - Matte + - Satin + - Polished + - Rugged + - Fabric + - Other bitmaps: Groups: - GroupsFeature @@ -7060,6 +7147,30 @@ - PressureFeature PumpConfigurationAndControl: - PumpFeature + removed: + attributes: + # The ProductAppearance bits never happened for the old Basic and + # BridgedDeviceBasic cluster names. + Basic: + - ProductAppearance + BridgedDeviceBasic: + - ProductAppearance + structs: + # The ProductAppearance bits never happened for the old Basic and + # BridgedDeviceBasic cluster names. + Basic: + - ProductAppearanceStruct + BridgedDeviceBasic: + - ProductAppearanceStruct + enums: + # The ProductAppearance bits never happened for the old Basic and + # BridgedDeviceBasic cluster names. + Basic: + - ProductFinishEnum + - ColorEnum + BridgedDeviceBasic: + - ProductFinishEnum + - ColorEnum renames: bitmaps: Groups: diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index 568ea996ca72d5..c656e1f7c89e5d 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -2307,6 +2307,23 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & value.subscriptionsPerFabric = [NSNumber numberWithUnsignedShort:cppValue.subscriptionsPerFabric]; return value; } + case Attributes::ProductAppearance::Id: { + using TypeInfo = Attributes::ProductAppearance::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + MTRBasicInformationClusterProductAppearanceStruct * _Nonnull value; + value = [MTRBasicInformationClusterProductAppearanceStruct new]; + value.finish = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.finish)]; + if (cppValue.primaryColor.IsNull()) { + value.primaryColor = nil; + } else { + value.primaryColor = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.primaryColor.Value())]; + } + return value; + } case Attributes::GeneratedCommandList::Id: { using TypeInfo = Attributes::GeneratedCommandList::TypeInfo; TypeInfo::DecodableType cppValue; @@ -6450,6 +6467,23 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & value = [[NSString alloc] initWithBytes:cppValue.data() length:cppValue.size() encoding:NSUTF8StringEncoding]; return value; } + case Attributes::ProductAppearance::Id: { + using TypeInfo = Attributes::ProductAppearance::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct * _Nonnull value; + value = [MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct new]; + value.finish = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.finish)]; + if (cppValue.primaryColor.IsNull()) { + value.primaryColor = nil; + } else { + value.primaryColor = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.primaryColor.Value())]; + } + return value; + } case Attributes::GeneratedCommandList::Id: { using TypeInfo = Attributes::GeneratedCommandList::TypeInfo; TypeInfo::DecodableType cppValue; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index c2960dafd0aad1..f55d7231050d42 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -2400,6 +2400,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) NSError * _Nullable error))completion API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +- (void)readAttributeProductAppearanceWithCompletion:(void (^)(MTRBasicInformationClusterProductAppearanceStruct * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeProductAppearanceWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRBasicInformationClusterProductAppearanceStruct * _Nullable value, + NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE; ++ (void)readAttributeProductAppearanceWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)(MTRBasicInformationClusterProductAppearanceStruct * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; + - (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params @@ -6174,6 +6187,24 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) completion:(void (^)(NSString * _Nullable value, NSError * _Nullable error))completion API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +- (void)readAttributeProductAppearanceWithCompletion: + (void (^)(MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeProductAppearanceWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler: + (void (^)( + MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct * _Nullable value, + NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE; ++ (void) + readAttributeProductAppearanceWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)( + MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; + - (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params @@ -18985,6 +19016,39 @@ typedef NS_OPTIONS(uint16_t, MTRActionsCommandBits) { MTRActionsCommandBitsDisableActionWithDuration API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x800, } API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +typedef NS_ENUM(uint8_t, MTRBasicInformationColor) { + MTRBasicInformationColorBlack MTR_NEWLY_AVAILABLE = 0x00, + MTRBasicInformationColorNavy MTR_NEWLY_AVAILABLE = 0x01, + MTRBasicInformationColorGreen MTR_NEWLY_AVAILABLE = 0x02, + MTRBasicInformationColorTeal MTR_NEWLY_AVAILABLE = 0x03, + MTRBasicInformationColorMaroon MTR_NEWLY_AVAILABLE = 0x04, + MTRBasicInformationColorPurple MTR_NEWLY_AVAILABLE = 0x05, + MTRBasicInformationColorOlive MTR_NEWLY_AVAILABLE = 0x06, + MTRBasicInformationColorGray MTR_NEWLY_AVAILABLE = 0x07, + MTRBasicInformationColorBlue MTR_NEWLY_AVAILABLE = 0x08, + MTRBasicInformationColorLime MTR_NEWLY_AVAILABLE = 0x09, + MTRBasicInformationColorAqua MTR_NEWLY_AVAILABLE = 0x0A, + MTRBasicInformationColorRed MTR_NEWLY_AVAILABLE = 0x0B, + MTRBasicInformationColorFuchsia MTR_NEWLY_AVAILABLE = 0x0C, + MTRBasicInformationColorYellow MTR_NEWLY_AVAILABLE = 0x0D, + MTRBasicInformationColorWhite MTR_NEWLY_AVAILABLE = 0x0E, + MTRBasicInformationColorNickel MTR_NEWLY_AVAILABLE = 0x0F, + MTRBasicInformationColorChrome MTR_NEWLY_AVAILABLE = 0x10, + MTRBasicInformationColorBrass MTR_NEWLY_AVAILABLE = 0x11, + MTRBasicInformationColorCopper MTR_NEWLY_AVAILABLE = 0x12, + MTRBasicInformationColorSilver MTR_NEWLY_AVAILABLE = 0x13, + MTRBasicInformationColorGold MTR_NEWLY_AVAILABLE = 0x14, +} MTR_NEWLY_AVAILABLE; + +typedef NS_ENUM(uint8_t, MTRBasicInformationProductFinish) { + MTRBasicInformationProductFinishOther MTR_NEWLY_AVAILABLE = 0x00, + MTRBasicInformationProductFinishMatte MTR_NEWLY_AVAILABLE = 0x01, + MTRBasicInformationProductFinishSatin MTR_NEWLY_AVAILABLE = 0x02, + MTRBasicInformationProductFinishPolished MTR_NEWLY_AVAILABLE = 0x03, + MTRBasicInformationProductFinishRugged MTR_NEWLY_AVAILABLE = 0x04, + MTRBasicInformationProductFinishFabric MTR_NEWLY_AVAILABLE = 0x05, +} MTR_NEWLY_AVAILABLE; + typedef NS_ENUM(uint8_t, MTROTASoftwareUpdateProviderOTAApplyUpdateAction) { MTROTASoftwareUpdateProviderOTAApplyUpdateActionProceed API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00, MTROTASoftwareUpdateProviderOTAApplyUpdateActionAwaitNextAction API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @@ -19926,6 +19990,39 @@ typedef NS_ENUM(uint8_t, MTRTimeSynchronizationTimeSource) { MTRTimeSynchronizationTimeSourceGnss API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x10, } API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +typedef NS_ENUM(uint8_t, MTRBridgedDeviceBasicInformationColor) { + MTRBridgedDeviceBasicInformationColorBlack MTR_NEWLY_AVAILABLE = 0x00, + MTRBridgedDeviceBasicInformationColorNavy MTR_NEWLY_AVAILABLE = 0x01, + MTRBridgedDeviceBasicInformationColorGreen MTR_NEWLY_AVAILABLE = 0x02, + MTRBridgedDeviceBasicInformationColorTeal MTR_NEWLY_AVAILABLE = 0x03, + MTRBridgedDeviceBasicInformationColorMaroon MTR_NEWLY_AVAILABLE = 0x04, + MTRBridgedDeviceBasicInformationColorPurple MTR_NEWLY_AVAILABLE = 0x05, + MTRBridgedDeviceBasicInformationColorOlive MTR_NEWLY_AVAILABLE = 0x06, + MTRBridgedDeviceBasicInformationColorGray MTR_NEWLY_AVAILABLE = 0x07, + MTRBridgedDeviceBasicInformationColorBlue MTR_NEWLY_AVAILABLE = 0x08, + MTRBridgedDeviceBasicInformationColorLime MTR_NEWLY_AVAILABLE = 0x09, + MTRBridgedDeviceBasicInformationColorAqua MTR_NEWLY_AVAILABLE = 0x0A, + MTRBridgedDeviceBasicInformationColorRed MTR_NEWLY_AVAILABLE = 0x0B, + MTRBridgedDeviceBasicInformationColorFuchsia MTR_NEWLY_AVAILABLE = 0x0C, + MTRBridgedDeviceBasicInformationColorYellow MTR_NEWLY_AVAILABLE = 0x0D, + MTRBridgedDeviceBasicInformationColorWhite MTR_NEWLY_AVAILABLE = 0x0E, + MTRBridgedDeviceBasicInformationColorNickel MTR_NEWLY_AVAILABLE = 0x0F, + MTRBridgedDeviceBasicInformationColorChrome MTR_NEWLY_AVAILABLE = 0x10, + MTRBridgedDeviceBasicInformationColorBrass MTR_NEWLY_AVAILABLE = 0x11, + MTRBridgedDeviceBasicInformationColorCopper MTR_NEWLY_AVAILABLE = 0x12, + MTRBridgedDeviceBasicInformationColorSilver MTR_NEWLY_AVAILABLE = 0x13, + MTRBridgedDeviceBasicInformationColorGold MTR_NEWLY_AVAILABLE = 0x14, +} MTR_NEWLY_AVAILABLE; + +typedef NS_ENUM(uint8_t, MTRBridgedDeviceBasicInformationProductFinish) { + MTRBridgedDeviceBasicInformationProductFinishOther MTR_NEWLY_AVAILABLE = 0x00, + MTRBridgedDeviceBasicInformationProductFinishMatte MTR_NEWLY_AVAILABLE = 0x01, + MTRBridgedDeviceBasicInformationProductFinishSatin MTR_NEWLY_AVAILABLE = 0x02, + MTRBridgedDeviceBasicInformationProductFinishPolished MTR_NEWLY_AVAILABLE = 0x03, + MTRBridgedDeviceBasicInformationProductFinishRugged MTR_NEWLY_AVAILABLE = 0x04, + MTRBridgedDeviceBasicInformationProductFinishFabric MTR_NEWLY_AVAILABLE = 0x05, +} MTR_NEWLY_AVAILABLE; + typedef NS_OPTIONS(uint32_t, MTRSwitchFeature) { MTRSwitchFeatureLatchingSwitch API_AVAILABLE(ios(16.2), macos(13.1), watchos(9.2), tvos(16.2)) = 0x1, MTRSwitchFeatureMomentarySwitch API_AVAILABLE(ios(16.2), macos(13.1), watchos(9.2), tvos(16.2)) = 0x2, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index 86a9e2d3c69d75..9feecb955c4311 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -14127,6 +14127,54 @@ + (void)readAttributeCapabilityMinimaWithClusterStateCache:(MTRClusterStateCache }); } +- (void)readAttributeProductAppearanceWithCompletion:(void (^)(MTRBasicInformationClusterProductAppearanceStruct * _Nullable value, + NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = BasicInformation::Attributes::ProductAppearance::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeProductAppearanceWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRBasicInformationClusterProductAppearanceStruct * _Nullable value, + NSError * _Nullable error))reportHandler +{ + using TypeInfo = BasicInformation::Attributes::ProductAppearance::TypeInfo; + MTRSubscribeAttribute(params, subscriptionEstablished, reportHandler, + self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeProductAppearanceWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)(MTRBasicInformationClusterProductAppearanceStruct * _Nullable value, + NSError * _Nullable error))completion +{ + auto * bridge = new MTRBasicInformationProductAppearanceStructAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(BasicInformationProductAppearanceStructAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = BasicInformation::Attributes::ProductAppearance::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + - (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion { MTRReadParams * params = [[MTRReadParams alloc] init]; @@ -38083,6 +38131,59 @@ + (void)readAttributeUniqueIDWithClusterStateCache:(MTRClusterStateCacheContaine }); } +- (void)readAttributeProductAppearanceWithCompletion: + (void (^)( + MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = BridgedDeviceBasicInformation::Attributes::ProductAppearance::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeProductAppearanceWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler: + (void (^)( + MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct * _Nullable value, + NSError * _Nullable error))reportHandler +{ + using TypeInfo = BridgedDeviceBasicInformation::Attributes::ProductAppearance::TypeInfo; + MTRSubscribeAttribute(params, subscriptionEstablished, + reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + ++ (void) + readAttributeProductAppearanceWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)( + MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct * _Nullable value, + NSError * _Nullable error))completion +{ + auto * bridge = new MTRBridgedDeviceBasicInformationProductAppearanceStructAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(BridgedDeviceBasicInformationProductAppearanceStructAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = BridgedDeviceBasicInformation::Attributes::ProductAppearance::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + - (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion { MTRReadParams * params = [[MTRReadParams alloc] init]; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h index f3a7deead776d0..ac61e7fc8f2ddb 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h @@ -191,6 +191,13 @@ typedef void (*NullableActionsClusterActionTypeEnumAttributeCallback)( typedef void (*ActionsClusterEndpointListTypeEnumAttributeCallback)(void *, chip::app::Clusters::Actions::EndpointListTypeEnum); typedef void (*NullableActionsClusterEndpointListTypeEnumAttributeCallback)( void *, const chip::app::DataModel::Nullable &); +typedef void (*BasicInformationClusterColorEnumAttributeCallback)(void *, chip::app::Clusters::BasicInformation::ColorEnum); +typedef void (*NullableBasicInformationClusterColorEnumAttributeCallback)( + void *, const chip::app::DataModel::Nullable &); +typedef void (*BasicInformationClusterProductFinishEnumAttributeCallback)(void *, + chip::app::Clusters::BasicInformation::ProductFinishEnum); +typedef void (*NullableBasicInformationClusterProductFinishEnumAttributeCallback)( + void *, const chip::app::DataModel::Nullable &); typedef void (*OTASoftwareUpdateProviderClusterOTAApplyUpdateActionAttributeCallback)( void *, chip::app::Clusters::OtaSoftwareUpdateProvider::OTAApplyUpdateAction); typedef void (*NullableOTASoftwareUpdateProviderClusterOTAApplyUpdateActionAttributeCallback)( @@ -346,6 +353,14 @@ typedef void (*TimeSynchronizationClusterTimeSourceEnumAttributeCallback)(void * chip::app::Clusters::TimeSynchronization::TimeSourceEnum); typedef void (*NullableTimeSynchronizationClusterTimeSourceEnumAttributeCallback)( void *, const chip::app::DataModel::Nullable &); +typedef void (*BridgedDeviceBasicInformationClusterColorEnumAttributeCallback)( + void *, chip::app::Clusters::BridgedDeviceBasicInformation::ColorEnum); +typedef void (*NullableBridgedDeviceBasicInformationClusterColorEnumAttributeCallback)( + void *, const chip::app::DataModel::Nullable &); +typedef void (*BridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallback)( + void *, chip::app::Clusters::BridgedDeviceBasicInformation::ProductFinishEnum); +typedef void (*NullableBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallback)( + void *, const chip::app::DataModel::Nullable &); typedef void (*AdministratorCommissioningClusterCommissioningWindowStatusEnumAttributeCallback)( void *, chip::app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum); typedef void (*NullableAdministratorCommissioningClusterCommissioningWindowStatusEnumAttributeCallback)( @@ -644,6 +659,8 @@ typedef void (*ActionsAttributeListListAttributeCallback)(void * context, const chip::app::DataModel::DecodableList & data); typedef void (*BasicInformationCapabilityMinimaStructAttributeCallback)( void *, const chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::DecodableType &); +typedef void (*BasicInformationProductAppearanceStructAttributeCallback)( + void *, const chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::DecodableType &); typedef void (*BasicInformationGeneratedCommandListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); typedef void (*BasicInformationAcceptedCommandListListAttributeCallback)( @@ -794,6 +811,8 @@ typedef void (*EthernetNetworkDiagnosticsAcceptedCommandListListAttributeCallbac void * context, const chip::app::DataModel::DecodableList & data); typedef void (*EthernetNetworkDiagnosticsAttributeListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); +typedef void (*BridgedDeviceBasicInformationProductAppearanceStructAttributeCallback)( + void *, const chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::DecodableType &); typedef void (*BridgedDeviceBasicInformationGeneratedCommandListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); typedef void (*BridgedDeviceBasicInformationAcceptedCommandListListAttributeCallback)( @@ -3389,6 +3408,40 @@ class MTRBasicInformationCapabilityMinimaStructAttributeCallbackSubscriptionBrid MTRSubscriptionEstablishedHandler mEstablishedHandler; }; +class MTRBasicInformationProductAppearanceStructAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRBasicInformationProductAppearanceStructAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRBasicInformationProductAppearanceStructAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, + const chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::DecodableType & value); +}; + +class MTRBasicInformationProductAppearanceStructAttributeCallbackSubscriptionBridge + : public MTRBasicInformationProductAppearanceStructAttributeCallbackBridge +{ +public: + MTRBasicInformationProductAppearanceStructAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRBasicInformationProductAppearanceStructAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRBasicInformationProductAppearanceStructAttributeCallbackBridge::KeepAliveOnCallback; + using MTRBasicInformationProductAppearanceStructAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + class MTRBasicInformationGeneratedCommandListListAttributeCallbackBridge : public MTRCallbackBridge { @@ -5645,6 +5698,43 @@ class MTREthernetNetworkDiagnosticsAttributeListListAttributeCallbackSubscriptio MTRSubscriptionEstablishedHandler mEstablishedHandler; }; +class MTRBridgedDeviceBasicInformationProductAppearanceStructAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRBridgedDeviceBasicInformationProductAppearanceStructAttributeCallbackBridge(dispatch_queue_t queue, + ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRBridgedDeviceBasicInformationProductAppearanceStructAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, + OnSuccessFn){}; + + static void + OnSuccessFn(void * context, + const chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::DecodableType & value); +}; + +class MTRBridgedDeviceBasicInformationProductAppearanceStructAttributeCallbackSubscriptionBridge + : public MTRBridgedDeviceBasicInformationProductAppearanceStructAttributeCallbackBridge +{ +public: + MTRBridgedDeviceBasicInformationProductAppearanceStructAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRBridgedDeviceBasicInformationProductAppearanceStructAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRBridgedDeviceBasicInformationProductAppearanceStructAttributeCallbackBridge::KeepAliveOnCallback; + using MTRBridgedDeviceBasicInformationProductAppearanceStructAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + class MTRBridgedDeviceBasicInformationGeneratedCommandListListAttributeCallbackBridge : public MTRCallbackBridge { @@ -12811,6 +12901,140 @@ class MTRNullableActionsClusterEndpointListTypeEnumAttributeCallbackSubscription MTRSubscriptionEstablishedHandler mEstablishedHandler; }; +class MTRBasicInformationClusterColorEnumAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRBasicInformationClusterColorEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRBasicInformationClusterColorEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, chip::app::Clusters::BasicInformation::ColorEnum value); +}; + +class MTRBasicInformationClusterColorEnumAttributeCallbackSubscriptionBridge + : public MTRBasicInformationClusterColorEnumAttributeCallbackBridge +{ +public: + MTRBasicInformationClusterColorEnumAttributeCallbackSubscriptionBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRBasicInformationClusterColorEnumAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRBasicInformationClusterColorEnumAttributeCallbackBridge::KeepAliveOnCallback; + using MTRBasicInformationClusterColorEnumAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRNullableBasicInformationClusterColorEnumAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRNullableBasicInformationClusterColorEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRNullableBasicInformationClusterColorEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, + const chip::app::DataModel::Nullable & value); +}; + +class MTRNullableBasicInformationClusterColorEnumAttributeCallbackSubscriptionBridge + : public MTRNullableBasicInformationClusterColorEnumAttributeCallbackBridge +{ +public: + MTRNullableBasicInformationClusterColorEnumAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRNullableBasicInformationClusterColorEnumAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRNullableBasicInformationClusterColorEnumAttributeCallbackBridge::KeepAliveOnCallback; + using MTRNullableBasicInformationClusterColorEnumAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRBasicInformationClusterProductFinishEnumAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRBasicInformationClusterProductFinishEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRBasicInformationClusterProductFinishEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, chip::app::Clusters::BasicInformation::ProductFinishEnum value); +}; + +class MTRBasicInformationClusterProductFinishEnumAttributeCallbackSubscriptionBridge + : public MTRBasicInformationClusterProductFinishEnumAttributeCallbackBridge +{ +public: + MTRBasicInformationClusterProductFinishEnumAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRBasicInformationClusterProductFinishEnumAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRBasicInformationClusterProductFinishEnumAttributeCallbackBridge::KeepAliveOnCallback; + using MTRBasicInformationClusterProductFinishEnumAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRNullableBasicInformationClusterProductFinishEnumAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRNullableBasicInformationClusterProductFinishEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRNullableBasicInformationClusterProductFinishEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, + const chip::app::DataModel::Nullable & value); +}; + +class MTRNullableBasicInformationClusterProductFinishEnumAttributeCallbackSubscriptionBridge + : public MTRNullableBasicInformationClusterProductFinishEnumAttributeCallbackBridge +{ +public: + MTRNullableBasicInformationClusterProductFinishEnumAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRNullableBasicInformationClusterProductFinishEnumAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRNullableBasicInformationClusterProductFinishEnumAttributeCallbackBridge::KeepAliveOnCallback; + using MTRNullableBasicInformationClusterProductFinishEnumAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + class MTROTASoftwareUpdateProviderClusterOTAApplyUpdateActionAttributeCallbackBridge : public MTRCallbackBridge { @@ -15664,6 +15888,150 @@ class MTRNullableTimeSynchronizationClusterTimeSourceEnumAttributeCallbackSubscr MTRSubscriptionEstablishedHandler mEstablishedHandler; }; +class MTRBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, chip::app::Clusters::BridgedDeviceBasicInformation::ColorEnum value); +}; + +class MTRBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackSubscriptionBridge + : public MTRBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge +{ +public: + MTRBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge::KeepAliveOnCallback; + using MTRBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRNullableBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRNullableBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge(dispatch_queue_t queue, + ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRNullableBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, + OnSuccessFn){}; + + static void + OnSuccessFn(void * context, + const chip::app::DataModel::Nullable & value); +}; + +class MTRNullableBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackSubscriptionBridge + : public MTRNullableBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge +{ +public: + MTRNullableBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRNullableBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRNullableBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge::KeepAliveOnCallback; + using MTRNullableBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge(dispatch_queue_t queue, + ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, + OnSuccessFn){}; + + static void OnSuccessFn(void * context, chip::app::Clusters::BridgedDeviceBasicInformation::ProductFinishEnum value); +}; + +class MTRBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackSubscriptionBridge + : public MTRBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge +{ +public: + MTRBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge::KeepAliveOnCallback; + using MTRBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRNullableBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRNullableBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge(dispatch_queue_t queue, + ResponseHandler handler) : + MTRCallbackBridge(queue, handler, + OnSuccessFn){}; + + MTRNullableBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge(dispatch_queue_t queue, + ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, + OnSuccessFn){}; + + static void OnSuccessFn( + void * context, + const chip::app::DataModel::Nullable & value); +}; + +class MTRNullableBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackSubscriptionBridge + : public MTRNullableBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge +{ +public: + MTRNullableBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRNullableBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRNullableBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge::KeepAliveOnCallback; + using MTRNullableBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + class MTRAdministratorCommissioningClusterCommissioningWindowStatusEnumAttributeCallbackBridge : public MTRCallbackBridge { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm index 2dd1e11290d64c..0fecca0312771c 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm @@ -2461,6 +2461,35 @@ } } +void MTRBasicInformationProductAppearanceStructAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::DecodableType & value) +{ + MTRBasicInformationClusterProductAppearanceStruct * _Nonnull objCValue; + objCValue = [MTRBasicInformationClusterProductAppearanceStruct new]; + objCValue.finish = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.finish)]; + if (value.primaryColor.IsNull()) { + objCValue.primaryColor = nil; + } else { + objCValue.primaryColor = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.primaryColor.Value())]; + } + DispatchSuccess(context, objCValue); +}; + +void MTRBasicInformationProductAppearanceStructAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + void MTRBasicInformationGeneratedCommandListListAttributeCallbackBridge::OnSuccessFn( void * context, const chip::app::DataModel::DecodableList & value) { @@ -5105,6 +5134,35 @@ } } +void MTRBridgedDeviceBasicInformationProductAppearanceStructAttributeCallbackBridge::OnSuccessFn(void * context, + const chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::DecodableType & value) +{ + MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct * _Nonnull objCValue; + objCValue = [MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct new]; + objCValue.finish = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.finish)]; + if (value.primaryColor.IsNull()) { + objCValue.primaryColor = nil; + } else { + objCValue.primaryColor = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.primaryColor.Value())]; + } + DispatchSuccess(context, objCValue); +}; + +void MTRBridgedDeviceBasicInformationProductAppearanceStructAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + void MTRBridgedDeviceBasicInformationGeneratedCommandListListAttributeCallbackBridge::OnSuccessFn( void * context, const chip::app::DataModel::DecodableList & value) { @@ -13919,6 +13977,106 @@ } } +void MTRBasicInformationClusterColorEnumAttributeCallbackBridge::OnSuccessFn( + void * context, chip::app::Clusters::BasicInformation::ColorEnum value) +{ + NSNumber * _Nonnull objCValue; + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value)]; + DispatchSuccess(context, objCValue); +}; + +void MTRBasicInformationClusterColorEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRNullableBasicInformationClusterColorEnumAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::DataModel::Nullable & value) +{ + NSNumber * _Nullable objCValue; + if (value.IsNull()) { + objCValue = nil; + } else { + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.Value())]; + } + DispatchSuccess(context, objCValue); +}; + +void MTRNullableBasicInformationClusterColorEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRBasicInformationClusterProductFinishEnumAttributeCallbackBridge::OnSuccessFn( + void * context, chip::app::Clusters::BasicInformation::ProductFinishEnum value) +{ + NSNumber * _Nonnull objCValue; + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value)]; + DispatchSuccess(context, objCValue); +}; + +void MTRBasicInformationClusterProductFinishEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRNullableBasicInformationClusterProductFinishEnumAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::DataModel::Nullable & value) +{ + NSNumber * _Nullable objCValue; + if (value.IsNull()) { + objCValue = nil; + } else { + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.Value())]; + } + DispatchSuccess(context, objCValue); +}; + +void MTRNullableBasicInformationClusterProductFinishEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + void MTROTASoftwareUpdateProviderClusterOTAApplyUpdateActionAttributeCallbackBridge::OnSuccessFn( void * context, chip::app::Clusters::OtaSoftwareUpdateProvider::OTAApplyUpdateAction value) { @@ -15972,6 +16130,107 @@ } } +void MTRBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge::OnSuccessFn( + void * context, chip::app::Clusters::BridgedDeviceBasicInformation::ColorEnum value) +{ + NSNumber * _Nonnull objCValue; + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value)]; + DispatchSuccess(context, objCValue); +}; + +void MTRBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRNullableBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::DataModel::Nullable & value) +{ + NSNumber * _Nullable objCValue; + if (value.IsNull()) { + objCValue = nil; + } else { + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.Value())]; + } + DispatchSuccess(context, objCValue); +}; + +void MTRNullableBridgedDeviceBasicInformationClusterColorEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge::OnSuccessFn( + void * context, chip::app::Clusters::BridgedDeviceBasicInformation::ProductFinishEnum value) +{ + NSNumber * _Nonnull objCValue; + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value)]; + DispatchSuccess(context, objCValue); +}; + +void MTRBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRNullableBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackBridge::OnSuccessFn(void * context, + const chip::app::DataModel::Nullable & value) +{ + NSNumber * _Nullable objCValue; + if (value.IsNull()) { + objCValue = nil; + } else { + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.Value())]; + } + DispatchSuccess(context, objCValue); +}; + +void MTRNullableBridgedDeviceBasicInformationClusterProductFinishEnumAttributeCallbackSubscriptionBridge:: + OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + void MTRAdministratorCommissioningClusterCommissioningWindowStatusEnumAttributeCallbackBridge::OnSuccessFn( void * context, chip::app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum value) { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index 03490e7005d0de..5d5fbcead09a84 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -1194,6 +1194,7 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { MTRAttributeIDTypeClusterBasicInformationAttributeCapabilityMinimaID API_AVAILABLE( ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000013, + MTRAttributeIDTypeClusterBasicInformationAttributeProductAppearanceID MTR_NEWLY_AVAILABLE = 0x00000014, MTRAttributeIDTypeClusterBasicInformationAttributeGeneratedCommandListID API_AVAILABLE( ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, @@ -3072,6 +3073,7 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeUniqueIDID API_AVAILABLE( ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000012, + MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeProductAppearanceID MTR_NEWLY_AVAILABLE = 0x00000014, MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeGeneratedCommandListID API_AVAILABLE( ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h index 9d1d401fe294aa..d3e350a7701cf6 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h @@ -1013,6 +1013,8 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) - (NSDictionary *)readAttributeCapabilityMinimaWithParams:(MTRReadParams * _Nullable)params API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +- (NSDictionary *)readAttributeProductAppearanceWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + - (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); @@ -2239,6 +2241,8 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) - (NSDictionary *)readAttributeUniqueIDWithParams:(MTRReadParams * _Nullable)params API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +- (NSDictionary *)readAttributeProductAppearanceWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + - (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm index e13f27f1464c38..1e2ea16be32dfd 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -5919,6 +5919,14 @@ - (void)writeAttributeLocalConfigDisabledWithValue:(NSDictionary params:params]; } +- (NSDictionary *)readAttributeProductAppearanceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeBasicInformationID) + attributeID:@(MTRAttributeIDTypeClusterBasicInformationAttributeProductAppearanceID) + params:params]; +} + - (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params { return [self.device readAttributeWithEndpointID:@(_endpoint) @@ -10346,6 +10354,15 @@ - (void)writeAttributeNodeLabelWithValue:(NSDictionary *)dataVal params:params]; } +- (NSDictionary *)readAttributeProductAppearanceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device + readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeBridgedDeviceBasicInformationID) + attributeID:@(MTRAttributeIDTypeClusterBridgedDeviceBasicInformationAttributeProductAppearanceID) + params:params]; +} + - (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params { return [self.device diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h index ad2c33f3483205..f0711c27592b29 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -155,6 +155,11 @@ MTR_DEPRECATED("Please use MTRBasicInformationClusterCapabilityMinimaStruct", io tvos(16.1, 16.4)) @interface MTRBasicClusterCapabilityMinimaStruct : MTRBasicInformationClusterCapabilityMinimaStruct @end +MTR_NEWLY_AVAILABLE +@interface MTRBasicInformationClusterProductAppearanceStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull finish MTR_NEWLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable primaryColor MTR_NEWLY_AVAILABLE; +@end API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @interface MTRBasicInformationClusterStartUpEvent : NSObject @@ -496,6 +501,12 @@ MTR_DEPRECATED("Please use MTRTimeSynchronizationClusterTimeZoneStruct", ios(16. @interface MTRTimeSynchronizationClusterTimeZoneType : MTRTimeSynchronizationClusterTimeZoneStruct @end +MTR_NEWLY_AVAILABLE +@interface MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull finish MTR_NEWLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable primaryColor MTR_NEWLY_AVAILABLE; +@end + API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @interface MTRBridgedDeviceBasicInformationClusterStartUpEvent : NSObject @property (nonatomic, copy) NSNumber * _Nonnull softwareVersion API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm index f1022f235eaede..d079a7173770b8 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -565,6 +565,37 @@ - (NSString *)description @implementation MTRBasicClusterCapabilityMinimaStruct : MTRBasicInformationClusterCapabilityMinimaStruct @end +@implementation MTRBasicInformationClusterProductAppearanceStruct +- (instancetype)init +{ + if (self = [super init]) { + + _finish = @(0); + + _primaryColor = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRBasicInformationClusterProductAppearanceStruct alloc] init]; + + other.finish = self.finish; + other.primaryColor = self.primaryColor; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = + [NSString stringWithFormat:@"<%@: finish:%@; primaryColor:%@; >", NSStringFromClass([self class]), _finish, _primaryColor]; + return descriptionString; +} + +@end + @implementation MTRBasicInformationClusterStartUpEvent - (instancetype)init { @@ -1885,6 +1916,37 @@ - (NSString *)description @implementation MTRTimeSynchronizationClusterTimeZoneType : MTRTimeSynchronizationClusterTimeZoneStruct @end +@implementation MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct +- (instancetype)init +{ + if (self = [super init]) { + + _finish = @(0); + + _primaryColor = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct alloc] init]; + + other.finish = self.finish; + other.primaryColor = self.primaryColor; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = + [NSString stringWithFormat:@"<%@: finish:%@; primaryColor:%@; >", NSStringFromClass([self class]), _finish, _primaryColor]; + return descriptionString; +} + +@end + @implementation MTRBridgedDeviceBasicInformationClusterStartUpEvent - (instancetype)init { diff --git a/src/include/platform/DeviceInstanceInfoProvider.h b/src/include/platform/DeviceInstanceInfoProvider.h index 16e431ae432fff..c072df6b55a999 100644 --- a/src/include/platform/DeviceInstanceInfoProvider.h +++ b/src/include/platform/DeviceInstanceInfoProvider.h @@ -17,6 +17,7 @@ #pragma once #include +#include #include namespace chip { @@ -169,6 +170,30 @@ class DeviceInstanceInfoProvider * if access fails. */ virtual CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) = 0; + + /** + * @brief Obtain the product's finish from the device's factory data. + * + * If the product finish is not available, this should return + * CHIP_ERROR_NOT_IMPLEMENTED, and the Basic Information ProductAppearance attribute should + * not be implemented for the device. + */ + virtual CHIP_ERROR GetProductFinish(app::Clusters::BasicInformation::ProductFinishEnum * finish) + { + return CHIP_ERROR_NOT_IMPLEMENTED; + } + + /** + * @brief Obtain the product's primary color from the device's factory data. + * + * If the primary color finish is not available or does not exist (e.g. the + * device wants to return null for the color in the Basic Information + * ProductAppearance attribute), this should return CHIP_ERROR_NOT_IMPLEMENTED. + */ + virtual CHIP_ERROR GetProductPrimaryColor(app::Clusters::BasicInformation::ColorEnum * primaryColor) + { + return CHIP_ERROR_NOT_IMPLEMENTED; + } }; /** diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h index d401935344cecb..dd8a0282fdab6d 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h @@ -284,6 +284,54 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(Actions::EndpointListTy } } +static auto __attribute__((unused)) EnsureKnownEnumValue(BasicInformation::ColorEnum val) +{ + using EnumType = BasicInformation::ColorEnum; + switch (val) + { + case EnumType::kBlack: + case EnumType::kNavy: + case EnumType::kGreen: + case EnumType::kTeal: + case EnumType::kMaroon: + case EnumType::kPurple: + case EnumType::kOlive: + case EnumType::kGray: + case EnumType::kBlue: + case EnumType::kLime: + case EnumType::kAqua: + case EnumType::kRed: + case EnumType::kFuchsia: + case EnumType::kYellow: + case EnumType::kWhite: + case EnumType::kNickel: + case EnumType::kChrome: + case EnumType::kBrass: + case EnumType::kCopper: + case EnumType::kSilver: + case EnumType::kGold: + return val; + default: + return static_cast(21); + } +} +static auto __attribute__((unused)) EnsureKnownEnumValue(BasicInformation::ProductFinishEnum val) +{ + using EnumType = BasicInformation::ProductFinishEnum; + switch (val) + { + case EnumType::kOther: + case EnumType::kMatte: + case EnumType::kSatin: + case EnumType::kPolished: + case EnumType::kRugged: + case EnumType::kFabric: + return val; + default: + return static_cast(6); + } +} + static auto __attribute__((unused)) EnsureKnownEnumValue(OtaSoftwareUpdateProvider::OTAApplyUpdateAction val) { using EnumType = OtaSoftwareUpdateProvider::OTAApplyUpdateAction; @@ -1091,6 +1139,54 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::Ti } } +static auto __attribute__((unused)) EnsureKnownEnumValue(BridgedDeviceBasicInformation::ColorEnum val) +{ + using EnumType = BridgedDeviceBasicInformation::ColorEnum; + switch (val) + { + case EnumType::kBlack: + case EnumType::kNavy: + case EnumType::kGreen: + case EnumType::kTeal: + case EnumType::kMaroon: + case EnumType::kPurple: + case EnumType::kOlive: + case EnumType::kGray: + case EnumType::kBlue: + case EnumType::kLime: + case EnumType::kAqua: + case EnumType::kRed: + case EnumType::kFuchsia: + case EnumType::kYellow: + case EnumType::kWhite: + case EnumType::kNickel: + case EnumType::kChrome: + case EnumType::kBrass: + case EnumType::kCopper: + case EnumType::kSilver: + case EnumType::kGold: + return val; + default: + return static_cast(21); + } +} +static auto __attribute__((unused)) EnsureKnownEnumValue(BridgedDeviceBasicInformation::ProductFinishEnum val) +{ + using EnumType = BridgedDeviceBasicInformation::ProductFinishEnum; + switch (val) + { + case EnumType::kOther: + case EnumType::kMatte: + case EnumType::kSatin: + case EnumType::kPolished: + case EnumType::kRugged: + case EnumType::kFabric: + return val; + default: + return static_cast(6); + } +} + static auto __attribute__((unused)) EnsureKnownEnumValue(AdministratorCommissioning::CommissioningWindowStatusEnum val) { using EnumType = AdministratorCommissioning::CommissioningWindowStatusEnum; diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index d9f35548eedd69..9b423e822a7e64 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -370,7 +370,55 @@ enum class CommandBits : uint16_t }; } // namespace Actions -namespace BasicInformation {} // namespace BasicInformation +namespace BasicInformation { + +// Enum for ColorEnum +enum class ColorEnum : uint8_t +{ + kBlack = 0x00, + kNavy = 0x01, + kGreen = 0x02, + kTeal = 0x03, + kMaroon = 0x04, + kPurple = 0x05, + kOlive = 0x06, + kGray = 0x07, + kBlue = 0x08, + kLime = 0x09, + kAqua = 0x0A, + kRed = 0x0B, + kFuchsia = 0x0C, + kYellow = 0x0D, + kWhite = 0x0E, + kNickel = 0x0F, + kChrome = 0x10, + kBrass = 0x11, + kCopper = 0x12, + kSilver = 0x13, + kGold = 0x14, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 21, +}; + +// Enum for ProductFinishEnum +enum class ProductFinishEnum : uint8_t +{ + kOther = 0x00, + kMatte = 0x01, + kSatin = 0x02, + kPolished = 0x03, + kRugged = 0x04, + kFabric = 0x05, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 6, +}; +} // namespace BasicInformation namespace OtaSoftwareUpdateProvider { @@ -1251,7 +1299,55 @@ enum class TimeSourceEnum : uint8_t }; } // namespace TimeSynchronization -namespace BridgedDeviceBasicInformation {} // namespace BridgedDeviceBasicInformation +namespace BridgedDeviceBasicInformation { + +// Enum for ColorEnum +enum class ColorEnum : uint8_t +{ + kBlack = 0x00, + kNavy = 0x01, + kGreen = 0x02, + kTeal = 0x03, + kMaroon = 0x04, + kPurple = 0x05, + kOlive = 0x06, + kGray = 0x07, + kBlue = 0x08, + kLime = 0x09, + kAqua = 0x0A, + kRed = 0x0B, + kFuchsia = 0x0C, + kYellow = 0x0D, + kWhite = 0x0E, + kNickel = 0x0F, + kChrome = 0x10, + kBrass = 0x11, + kCopper = 0x12, + kSilver = 0x13, + kGold = 0x14, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 21, +}; + +// Enum for ProductFinishEnum +enum class ProductFinishEnum : uint8_t +{ + kOther = 0x00, + kMatte = 0x01, + kSatin = 0x02, + kPolished = 0x03, + kRugged = 0x04, + kFabric = 0x05, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 6, +}; +} // namespace BridgedDeviceBasicInformation namespace Switch { diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index a37e57cacbc576..d7d8ea5bb57a79 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -3991,6 +3991,50 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } } // namespace CapabilityMinimaStruct +namespace ProductAppearanceStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kFinish), finish)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kPrimaryColor), primaryColor)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + err = reader.EnterContainer(outer); + ReturnErrorOnFailure(err); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kFinish): + ReturnErrorOnFailure(DataModel::Decode(reader, finish)); + break; + case to_underlying(Fields::kPrimaryColor): + ReturnErrorOnFailure(DataModel::Decode(reader, primaryColor)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + + return CHIP_NO_ERROR; +} + +} // namespace ProductAppearanceStruct } // namespace Structs namespace Commands { @@ -4094,6 +4138,9 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre case Attributes::CapabilityMinima::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, capabilityMinima)); break; + case Attributes::ProductAppearance::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, productAppearance)); + break; case Attributes::GeneratedCommandList::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, generatedCommandList)); break; @@ -8241,6 +8288,52 @@ namespace Events {} // namespace Events } // namespace TimeSynchronization namespace BridgedDeviceBasicInformation { +namespace Structs { +namespace ProductAppearanceStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kFinish), finish)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kPrimaryColor), primaryColor)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + err = reader.EnterContainer(outer); + ReturnErrorOnFailure(err); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kFinish): + ReturnErrorOnFailure(DataModel::Decode(reader, finish)); + break; + case to_underlying(Fields::kPrimaryColor): + ReturnErrorOnFailure(DataModel::Decode(reader, primaryColor)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + + return CHIP_NO_ERROR; +} + +} // namespace ProductAppearanceStruct +} // namespace Structs namespace Commands {} // namespace Commands @@ -8294,6 +8387,9 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre case Attributes::UniqueID::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, uniqueID)); break; + case Attributes::ProductAppearance::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, productAppearance)); + break; case Attributes::GeneratedCommandList::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, generatedCommandList)); break; diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index 076c4097b13647..68ee013cd179aa 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -4526,6 +4526,29 @@ struct Type using DecodableType = Type; } // namespace CapabilityMinimaStruct +namespace ProductAppearanceStruct { +enum class Fields : uint8_t +{ + kFinish = 0, + kPrimaryColor = 1, +}; + +struct Type +{ +public: + ProductFinishEnum finish = static_cast(0); + DataModel::Nullable primaryColor; + + CHIP_ERROR Decode(TLV::TLVReader & reader); + + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +using DecodableType = Type; + +} // namespace ProductAppearanceStruct } // namespace Structs namespace Commands { @@ -4823,6 +4846,18 @@ struct TypeInfo static constexpr bool MustUseTimedWrite() { return false; } }; } // namespace CapabilityMinima +namespace ProductAppearance { +struct TypeInfo +{ + using Type = chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::Type; + using DecodableType = chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::DecodableType; + using DecodableArgType = const chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::DecodableType &; + + static constexpr ClusterId GetClusterId() { return Clusters::BasicInformation::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::ProductAppearance::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace ProductAppearance namespace GeneratedCommandList { struct TypeInfo : public Clusters::Globals::Attributes::GeneratedCommandList::TypeInfo { @@ -4888,6 +4923,7 @@ struct TypeInfo Attributes::Reachable::TypeInfo::DecodableType reachable = static_cast(0); Attributes::UniqueID::TypeInfo::DecodableType uniqueID; Attributes::CapabilityMinima::TypeInfo::DecodableType capabilityMinima; + Attributes::ProductAppearance::TypeInfo::DecodableType productAppearance; Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; Attributes::EventList::TypeInfo::DecodableType eventList; @@ -10556,6 +10592,31 @@ struct TypeInfo } // namespace Attributes } // namespace TimeSynchronization namespace BridgedDeviceBasicInformation { +namespace Structs { +namespace ProductAppearanceStruct { +enum class Fields : uint8_t +{ + kFinish = 0, + kPrimaryColor = 1, +}; + +struct Type +{ +public: + ProductFinishEnum finish = static_cast(0); + DataModel::Nullable primaryColor; + + CHIP_ERROR Decode(TLV::TLVReader & reader); + + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +using DecodableType = Type; + +} // namespace ProductAppearanceStruct +} // namespace Structs namespace Attributes { @@ -10750,6 +10811,19 @@ struct TypeInfo static constexpr size_t MaxLength() { return 32; } }; } // namespace UniqueID +namespace ProductAppearance { +struct TypeInfo +{ + using Type = chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::Type; + using DecodableType = chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::DecodableType; + using DecodableArgType = + const chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::DecodableType &; + + static constexpr ClusterId GetClusterId() { return Clusters::BridgedDeviceBasicInformation::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::ProductAppearance::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace ProductAppearance namespace GeneratedCommandList { struct TypeInfo : public Clusters::Globals::Attributes::GeneratedCommandList::TypeInfo { @@ -10810,6 +10884,7 @@ struct TypeInfo Attributes::SerialNumber::TypeInfo::DecodableType serialNumber; Attributes::Reachable::TypeInfo::DecodableType reachable = static_cast(0); Attributes::UniqueID::TypeInfo::DecodableType uniqueID; + Attributes::ProductAppearance::TypeInfo::DecodableType productAppearance; Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; Attributes::EventList::TypeInfo::DecodableType eventList; diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h index 62102d5fed1e5f..d141f4e3d8fedf 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h @@ -706,6 +706,10 @@ namespace CapabilityMinima { static constexpr AttributeId Id = 0x00000013; } // namespace CapabilityMinima +namespace ProductAppearance { +static constexpr AttributeId Id = 0x00000014; +} // namespace ProductAppearance + namespace GeneratedCommandList { static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; } // namespace GeneratedCommandList @@ -1928,6 +1932,10 @@ namespace UniqueID { static constexpr AttributeId Id = 0x00000012; } // namespace UniqueID +namespace ProductAppearance { +static constexpr AttributeId Id = 0x00000014; +} // namespace ProductAppearance + namespace GeneratedCommandList { static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; } // namespace GeneratedCommandList diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 98e822796ecc4a..8a0226fa4c76bb 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -1853,6 +1853,7 @@ class ActionsDisableActionWithDuration : public ClusterCommand | * Reachable | 0x0011 | | * UniqueID | 0x0012 | | * CapabilityMinima | 0x0013 | +| * ProductAppearance | 0x0014 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -3018,6 +3019,7 @@ class TimeSynchronizationSetUtcTime : public ClusterCommand | * SerialNumber | 0x000F | | * Reachable | 0x0011 | | * UniqueID | 0x0012 | +| * ProductAppearance | 0x0014 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -9359,6 +9361,7 @@ void registerClusterBasicInformation(Commands & commands, CredentialIssuerComman make_unique(Id, "reachable", Attributes::Reachable::Id, credsIssuerConfig), // make_unique(Id, "unique-id", Attributes::UniqueID::Id, credsIssuerConfig), // make_unique(Id, "capability-minima", Attributes::CapabilityMinima::Id, credsIssuerConfig), // + make_unique(Id, "product-appearance", Attributes::ProductAppearance::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // @@ -9406,6 +9409,8 @@ void registerClusterBasicInformation(Commands & commands, CredentialIssuerComman credsIssuerConfig), // make_unique>( Id, "capability-minima", Attributes::CapabilityMinima::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>( + Id, "product-appearance", Attributes::ProductAppearance::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // @@ -9440,6 +9445,7 @@ void registerClusterBasicInformation(Commands & commands, CredentialIssuerComman make_unique(Id, "reachable", Attributes::Reachable::Id, credsIssuerConfig), // make_unique(Id, "unique-id", Attributes::UniqueID::Id, credsIssuerConfig), // make_unique(Id, "capability-minima", Attributes::CapabilityMinima::Id, credsIssuerConfig), // + make_unique(Id, "product-appearance", Attributes::ProductAppearance::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // @@ -11119,6 +11125,7 @@ void registerClusterBridgedDeviceBasicInformation(Commands & commands, Credentia make_unique(Id, "serial-number", Attributes::SerialNumber::Id, credsIssuerConfig), // make_unique(Id, "reachable", Attributes::Reachable::Id, credsIssuerConfig), // make_unique(Id, "unique-id", Attributes::UniqueID::Id, credsIssuerConfig), // + make_unique(Id, "product-appearance", Attributes::ProductAppearance::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // @@ -11156,6 +11163,9 @@ void registerClusterBridgedDeviceBasicInformation(Commands & commands, Credentia credsIssuerConfig), // make_unique>(Id, "unique-id", Attributes::UniqueID::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique< + WriteAttributeAsComplex>( + Id, "product-appearance", Attributes::ProductAppearance::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // @@ -11185,6 +11195,7 @@ void registerClusterBridgedDeviceBasicInformation(Commands & commands, Credentia make_unique(Id, "serial-number", Attributes::SerialNumber::Id, credsIssuerConfig), // make_unique(Id, "reachable", Attributes::Reachable::Id, credsIssuerConfig), // make_unique(Id, "unique-id", Attributes::UniqueID::Id, credsIssuerConfig), // + make_unique(Id, "product-appearance", Attributes::ProductAppearance::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp index 3d128bfb24f2e8..5594ef89c48bf2 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp @@ -486,6 +486,38 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::BasicInformation::Stru ComplexArgumentParser::Finalize(request.subscriptionsPerFabric); } +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ProductAppearanceStruct.finish", "finish", value.isMember("finish"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ProductAppearanceStruct.primaryColor", "primaryColor", + value.isMember("primaryColor"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "finish"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.finish, value["finish"])); + valueCopy.removeMember("finish"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "primaryColor"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.primaryColor, value["primaryColor"])); + valueCopy.removeMember("primaryColor"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.finish); + ComplexArgumentParser::Finalize(request.primaryColor); +} + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request, Json::Value & value) @@ -1364,6 +1396,40 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::TimeSynchronization::S ComplexArgumentParser::Finalize(request.name); } +CHIP_ERROR +ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ProductAppearanceStruct.finish", "finish", value.isMember("finish"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ProductAppearanceStruct.primaryColor", "primaryColor", + value.isMember("primaryColor"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "finish"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.finish, value["finish"])); + valueCopy.removeMember("finish"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "primaryColor"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.primaryColor, value["primaryColor"])); + valueCopy.removeMember("primaryColor"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize( + chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.finish); + ComplexArgumentParser::Finalize(request.primaryColor); +} + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request, diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h index 990126cbc87187..1827e5cbb930fa 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h @@ -82,6 +82,11 @@ static CHIP_ERROR Setup(const char * label, chip::app::Clusters::BasicInformatio static void Finalize(chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request); +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request, Json::Value & value); @@ -167,6 +172,12 @@ static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TimeSynchroniza static void Finalize(chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request); +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request, Json::Value & value); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index e85d4920b846c2..210e152050a010 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -428,6 +428,32 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("Finish", indent + 1, value.finish); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Finish'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("PrimaryColor", indent + 1, value.primaryColor); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PrimaryColor'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType & value) @@ -1256,6 +1282,32 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } +CHIP_ERROR DataModelLogger::LogValue( + const char * label, size_t indent, + const chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("Finish", indent + 1, value.finish); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Finish'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("PrimaryColor", indent + 1, value.primaryColor); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PrimaryColor'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::DecodableType & value) @@ -5074,6 +5126,11 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("CapabilityMinima", 1, value); } + case BasicInformation::Attributes::ProductAppearance::Id: { + chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ProductAppearance", 1, value); + } case BasicInformation::Attributes::GeneratedCommandList::Id: { chip::app::DataModel::DecodableList value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); @@ -6502,6 +6559,11 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("UniqueID", 1, value); } + case BridgedDeviceBasicInformation::Attributes::ProductAppearance::Id: { + chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ProductAppearance", 1, value); + } case BridgedDeviceBasicInformation::Attributes::GeneratedCommandList::Id: { chip::app::DataModel::DecodableList value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h index 368f75af3cfc10..459c2c13f31cb7 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -56,6 +56,9 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType & value); @@ -107,6 +110,10 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::DecodableType & value); +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::BridgedDeviceBasicInformation::Structs::ProductAppearanceStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::DecodableType & value); diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 74fe8807e0ca3a..a0ab20c57b930e 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -20497,7 +20497,7 @@ class Test_TC_BINFO_1_1Suite : public TestCommand { uint16_t value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("clusterRevision", value, 1U)); + VerifyOrReturn(CheckValue("clusterRevision", value, 2U)); VerifyOrReturn(CheckConstraintType("value", "int16u", "int16u")); } break; @@ -68841,7 +68841,7 @@ class TestBasicInformationSuite : public TestCommand { public: TestBasicInformationSuite(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("TestBasicInformation", 18, credsIssuerConfig) + TestCommand("TestBasicInformation", 19, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("cluster", &mCluster); @@ -68948,16 +68948,18 @@ class TestBasicInformationSuite : public TestCommand VerifyOrReturn(CheckNextListItemDecodes("attributeList", iter_0, 19)); VerifyOrReturn(CheckValue("attributeList[19]", iter_0.GetValue(), 19UL)); VerifyOrReturn(CheckNextListItemDecodes("attributeList", iter_0, 20)); - VerifyOrReturn(CheckValue("attributeList[20]", iter_0.GetValue(), 65528UL)); + VerifyOrReturn(CheckValue("attributeList[20]", iter_0.GetValue(), 20UL)); VerifyOrReturn(CheckNextListItemDecodes("attributeList", iter_0, 21)); - VerifyOrReturn(CheckValue("attributeList[21]", iter_0.GetValue(), 65529UL)); + VerifyOrReturn(CheckValue("attributeList[21]", iter_0.GetValue(), 65528UL)); VerifyOrReturn(CheckNextListItemDecodes("attributeList", iter_0, 22)); - VerifyOrReturn(CheckValue("attributeList[22]", iter_0.GetValue(), 65531UL)); + VerifyOrReturn(CheckValue("attributeList[22]", iter_0.GetValue(), 65529UL)); VerifyOrReturn(CheckNextListItemDecodes("attributeList", iter_0, 23)); - VerifyOrReturn(CheckValue("attributeList[23]", iter_0.GetValue(), 65532UL)); + VerifyOrReturn(CheckValue("attributeList[23]", iter_0.GetValue(), 65531UL)); VerifyOrReturn(CheckNextListItemDecodes("attributeList", iter_0, 24)); - VerifyOrReturn(CheckValue("attributeList[24]", iter_0.GetValue(), 65533UL)); - VerifyOrReturn(CheckNoMoreListItems("attributeList", iter_0, 25)); + VerifyOrReturn(CheckValue("attributeList[24]", iter_0.GetValue(), 65532UL)); + VerifyOrReturn(CheckNextListItemDecodes("attributeList", iter_0, 25)); + VerifyOrReturn(CheckValue("attributeList[25]", iter_0.GetValue(), 65533UL)); + VerifyOrReturn(CheckNoMoreListItems("attributeList", iter_0, 26)); } } break; @@ -69029,6 +69031,16 @@ class TestBasicInformationSuite : public TestCommand case 17: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::Clusters::BasicInformation::Structs::ProductAppearanceStruct::DecodableType value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("productAppearance.finish", value.finish, 2U)); + VerifyOrReturn(CheckValueNonNull("productAppearance.primaryColor", value.primaryColor)); + VerifyOrReturn(CheckValue("productAppearance.primaryColor.Value()", value.primaryColor.Value(), 5U)); + } + break; default: LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); } @@ -69159,6 +69171,11 @@ class TestBasicInformationSuite : public TestCommand BasicInformation::Attributes::LocalConfigDisabled::Id, value, chip::NullOptional, chip::NullOptional); } + case 18: { + LogStep(18, "Read the ProductApppearance value"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), BasicInformation::Id, + BasicInformation::Attributes::ProductAppearance::Id, true, chip::NullOptional); + } } return CHIP_NO_ERROR; } diff --git a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h index 3c52df46823049..fec7a5add44c0c 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -10964,6 +10964,7 @@ class SubscribeAttributeActionsClusterRevision : public SubscribeAttribute { | * Reachable | 0x0011 | | * UniqueID | 0x0012 | | * CapabilityMinima | 0x0013 | +| * ProductAppearance | 0x0014 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -12503,6 +12504,77 @@ class SubscribeAttributeBasicInformationCapabilityMinima : public SubscribeAttri } }; +/* + * Attribute ProductAppearance + */ +class ReadBasicInformationProductAppearance : public ReadAttribute { +public: + ReadBasicInformationProductAppearance() + : ReadAttribute("product-appearance") + { + } + + ~ReadBasicInformationProductAppearance() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000028) ReadAttribute (0x00000014) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeProductAppearanceWithCompletion:^( + MTRBasicInformationClusterProductAppearanceStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"BasicInformation.ProductAppearance response %@", [value description]); + if (error != nil) { + LogNSError("BasicInformation ProductAppearance read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeBasicInformationProductAppearance : public SubscribeAttribute { +public: + SubscribeAttributeBasicInformationProductAppearance() + : SubscribeAttribute("product-appearance") + { + } + + ~SubscribeAttributeBasicInformationProductAppearance() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000028) ReportAttribute (0x00000014) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeProductAppearanceWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(MTRBasicInformationClusterProductAppearanceStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"BasicInformation.ProductAppearance response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + /* * Attribute GeneratedCommandList */ @@ -30591,6 +30663,7 @@ class SubscribeAttributeEthernetNetworkDiagnosticsClusterRevision : public Subsc | * SerialNumber | 0x000F | | * Reachable | 0x0011 | | * UniqueID | 0x0012 | +| * ProductAppearance | 0x0014 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -31697,6 +31770,78 @@ class SubscribeAttributeBridgedDeviceBasicInformationUniqueID : public Subscribe } }; +/* + * Attribute ProductAppearance + */ +class ReadBridgedDeviceBasicInformationProductAppearance : public ReadAttribute { +public: + ReadBridgedDeviceBasicInformationProductAppearance() + : ReadAttribute("product-appearance") + { + } + + ~ReadBridgedDeviceBasicInformationProductAppearance() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000039) ReadAttribute (0x00000014) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeProductAppearanceWithCompletion:^( + MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"BridgedDeviceBasicInformation.ProductAppearance response %@", [value description]); + if (error != nil) { + LogNSError("BridgedDeviceBasicInformation ProductAppearance read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeBridgedDeviceBasicInformationProductAppearance : public SubscribeAttribute { +public: + SubscribeAttributeBridgedDeviceBasicInformationProductAppearance() + : SubscribeAttribute("product-appearance") + { + } + + ~SubscribeAttributeBridgedDeviceBasicInformationProductAppearance() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000039) ReportAttribute (0x00000014) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeProductAppearanceWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^( + MTRBridgedDeviceBasicInformationClusterProductAppearanceStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"BridgedDeviceBasicInformation.ProductAppearance response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + /* * Attribute GeneratedCommandList */ @@ -98029,6 +98174,8 @@ void registerClusterBasicInformation(Commands & commands) make_unique(), // make_unique(), // make_unique(), // + make_unique(), // + make_unique(), // make_unique(), // make_unique(), // make_unique(), // @@ -98806,6 +98953,8 @@ void registerClusterBridgedDeviceBasicInformation(Commands & commands) make_unique(), // make_unique(), // make_unique(), // + make_unique(), // + make_unique(), // make_unique(), // make_unique(), // make_unique(), // 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 217820fc3a6d98..2ac0dea95d5047 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -24524,7 +24524,7 @@ class Test_TC_BINFO_1_1 : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); } VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); @@ -101033,6 +101033,10 @@ class TestBasicInformation : public TestCommandBridge { ChipLogProgress(chipTool, " ***** Test Step 17 : Restore initial LocalConfigDisabled value\n"); err = TestRestoreInitialLocalConfigDisabledValue_17(); break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Read the ProductApppearance value\n"); + err = TestReadTheProductApppearanceValue_18(); + break; } if (CHIP_NO_ERROR != err) { @@ -101098,6 +101102,9 @@ class TestBasicInformation : public TestCommandBridge { case 17: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; } // Go on to the next test. @@ -101111,7 +101118,7 @@ class TestBasicInformation : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; + const uint16_t mTestCount = 19; chip::Optional mNodeId; chip::Optional mCluster; @@ -101228,7 +101235,7 @@ class TestBasicInformation : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(25))); + VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(26))); VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); VerifyOrReturn(CheckValue("", actualValue[2], 2UL)); @@ -101249,11 +101256,12 @@ class TestBasicInformation : public TestCommandBridge { VerifyOrReturn(CheckValue("", actualValue[17], 17UL)); VerifyOrReturn(CheckValue("", actualValue[18], 18UL)); VerifyOrReturn(CheckValue("", actualValue[19], 19UL)); - VerifyOrReturn(CheckValue("", actualValue[20], 65528UL)); - VerifyOrReturn(CheckValue("", actualValue[21], 65529UL)); - VerifyOrReturn(CheckValue("", actualValue[22], 65531UL)); - VerifyOrReturn(CheckValue("", actualValue[23], 65532UL)); - VerifyOrReturn(CheckValue("", actualValue[24], 65533UL)); + VerifyOrReturn(CheckValue("", actualValue[20], 20UL)); + VerifyOrReturn(CheckValue("", actualValue[21], 65528UL)); + VerifyOrReturn(CheckValue("", actualValue[22], 65529UL)); + VerifyOrReturn(CheckValue("", actualValue[23], 65531UL)); + VerifyOrReturn(CheckValue("", actualValue[24], 65532UL)); + VerifyOrReturn(CheckValue("", actualValue[25], 65533UL)); } NextTest(); @@ -101498,6 +101506,35 @@ class TestBasicInformation : public TestCommandBridge { return CHIP_NO_ERROR; } + + CHIP_ERROR TestReadTheProductApppearanceValue_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeProductAppearanceWithCompletion:^( + MTRBasicInformationClusterProductAppearanceStruct * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read the ProductApppearance value Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn( + CheckValue("Finish", ((MTRBasicInformationClusterProductAppearanceStruct *) actualValue).finish, 2U)); + VerifyOrReturn(CheckValueNonNull( + "PrimaryColor", ((MTRBasicInformationClusterProductAppearanceStruct *) actualValue).primaryColor)); + VerifyOrReturn(CheckValue( + "PrimaryColor", ((MTRBasicInformationClusterProductAppearanceStruct *) actualValue).primaryColor, 5U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } }; class TestFabricRemovalWhileSubscribed : public TestCommandBridge { From 246188c4609503284f38835902cb9169d1330e26 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 2 May 2023 10:47:03 -0400 Subject: [PATCH 068/200] Stop generating attribute accessors for AttributeAccessInterface-only attributes. (#26279) Those accessors can't work correctly and are just a bug waiting to happen if someone tries to use them. The code in the Infineon examples that did ManufacturingDate::Set was not really doing anything useful, since the attribute value is read from GetDeviceInstanceInfoProvider()->GetManufacturingDate() in the Basic Information cluster implementation anyway, ignoring the attribute store. --- .../infineon/cyw30739/src/ZclCallbacks.cpp | 14 - .../infineon/cyw30739/src/ZclCallbacks.cpp | 14 - .../infineon/cyw30739/src/ZclCallbacks.cpp | 14 - .../docker/images/chip-cert-bins/Dockerfile | 2 +- scripts/setup/zap.json | 2 +- scripts/tools/zap/zap_execution.py | 2 +- .../app/attributes/Accessors-src.zapt | 6 +- .../templates/app/attributes/Accessors.zapt | 5 +- .../zcl/zcl-with-test-extensions.json | 6 +- src/app/zap-templates/zcl/zcl.json | 6 +- .../zap-generated/attributes/Accessors.cpp | 7564 ++++------------- .../zap-generated/attributes/Accessors.h | 673 -- 12 files changed, 1605 insertions(+), 6703 deletions(-) diff --git a/examples/light-switch-app/infineon/cyw30739/src/ZclCallbacks.cpp b/examples/light-switch-app/infineon/cyw30739/src/ZclCallbacks.cpp index 84ca0d61fb8895..852295fffcd23b 100644 --- a/examples/light-switch-app/infineon/cyw30739/src/ZclCallbacks.cpp +++ b/examples/light-switch-app/infineon/cyw30739/src/ZclCallbacks.cpp @@ -24,20 +24,6 @@ using namespace chip; using namespace chip::app::Clusters; using namespace chip::DeviceLayer; -void emberAfBasicInformationClusterInitCallback(EndpointId endpoint) -{ - uint16_t year; - uint8_t month; - uint8_t dayOfMonth; - char cString[16] = "00000000"; - - if (GetDeviceInstanceInfoProvider()->GetManufacturingDate(year, month, dayOfMonth) == CHIP_NO_ERROR) - { - snprintf(cString, sizeof(cString), "%04u%02u%02u", year, month, dayOfMonth); - } - BasicInformation::Attributes::ManufacturingDate::Set(endpoint, CharSpan(cString)); -} - void MatterPostAttributeChangeCallback(const app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value) { diff --git a/examples/lighting-app/infineon/cyw30739/src/ZclCallbacks.cpp b/examples/lighting-app/infineon/cyw30739/src/ZclCallbacks.cpp index fc07d131340dbd..4f0222ca740ca3 100644 --- a/examples/lighting-app/infineon/cyw30739/src/ZclCallbacks.cpp +++ b/examples/lighting-app/infineon/cyw30739/src/ZclCallbacks.cpp @@ -26,20 +26,6 @@ using namespace chip; using namespace chip::app::Clusters; using namespace chip::DeviceLayer; -void emberAfBasicInformationClusterInitCallback(EndpointId endpoint) -{ - uint16_t year; - uint8_t month; - uint8_t dayOfMonth; - char cString[16] = "00000000"; - - if (GetDeviceInstanceInfoProvider()->GetManufacturingDate(year, month, dayOfMonth) == CHIP_NO_ERROR) - { - snprintf(cString, sizeof(cString), "%04u%02u%02u", year, month, dayOfMonth); - } - BasicInformation::Attributes::ManufacturingDate::Set(endpoint, CharSpan(cString)); -} - void MatterPostAttributeChangeCallback(const app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value) diff --git a/examples/lock-app/infineon/cyw30739/src/ZclCallbacks.cpp b/examples/lock-app/infineon/cyw30739/src/ZclCallbacks.cpp index d1efc819761bf4..7d3eeed7bcf1b6 100644 --- a/examples/lock-app/infineon/cyw30739/src/ZclCallbacks.cpp +++ b/examples/lock-app/infineon/cyw30739/src/ZclCallbacks.cpp @@ -27,20 +27,6 @@ using namespace chip; using namespace chip::app::Clusters; using namespace chip::DeviceLayer; -void emberAfBasicInformationClusterInitCallback(EndpointId endpoint) -{ - uint16_t year; - uint8_t month; - uint8_t dayOfMonth; - char cString[16] = "00000000"; - - if (GetDeviceInstanceInfoProvider()->GetManufacturingDate(year, month, dayOfMonth) == CHIP_NO_ERROR) - { - snprintf(cString, sizeof(cString), "%04u%02u%02u", year, month, dayOfMonth); - } - BasicInformation::Attributes::ManufacturingDate::Set(endpoint, CharSpan(cString)); -} - void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value) { diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile index 218438bb81ec79..3c096c3ac33e2c 100644 --- a/integrations/docker/images/chip-cert-bins/Dockerfile +++ b/integrations/docker/images/chip-cert-bins/Dockerfile @@ -7,7 +7,7 @@ ARG COMMITHASH=7b99e6399c6069037c613782d78132c69b9dcabb # ZAP Development install, so that it runs on both x64 and arm64 # Generally this should match with the ZAP version that is used for codegen within the # specified SHA -ARG ZAP_VERSION=v2023.04.21-nightly +ARG ZAP_VERSION=v2023.04.27-nightly # Ensure TARGETPLATFORM is set RUN case ${TARGETPLATFORM} in \ diff --git a/scripts/setup/zap.json b/scripts/setup/zap.json index df3f76ff5b5d0f..5877f6395570e0 100644 --- a/scripts/setup/zap.json +++ b/scripts/setup/zap.json @@ -8,7 +8,7 @@ "mac-arm64", "windows-amd64" ], - "tags": ["version:2@v2023.04.21-nightly.1"] + "tags": ["version:2@v2023.04.27-nightly.1"] } ] } diff --git a/scripts/tools/zap/zap_execution.py b/scripts/tools/zap/zap_execution.py index 3fdeeab5a1da93..7ada169c086eb4 100644 --- a/scripts/tools/zap/zap_execution.py +++ b/scripts/tools/zap/zap_execution.py @@ -23,7 +23,7 @@ # Use scripts/tools/zap/version_update.py to manage ZAP versioning as many # files may need updating for versions # -MIN_ZAP_VERSION = '2023.4.21' +MIN_ZAP_VERSION = '2023.4.27' class ZapTool: diff --git a/src/app/zap-templates/templates/app/attributes/Accessors-src.zapt b/src/app/zap-templates/templates/app/attributes/Accessors-src.zapt index 31af3168b9998c..8406cdeb989927 100644 --- a/src/app/zap-templates/templates/app/attributes/Accessors-src.zapt +++ b/src/app/zap-templates/templates/app/attributes/Accessors-src.zapt @@ -25,8 +25,10 @@ namespace {{asUpperCamelCase parent.label}} { namespace Attributes { {{/first}} +{{#unless (isStrEqual storagePolicy "attributeAccessInterface")}} {{#if_is_struct type}} -{{else if (canHaveSimpleAccessors this)}} +#error Attribute "{{name}}" in cluster "{{../name}}" is struct-typed and must be added to the attributeAccessInterfaceAttributes object in src/app/zap-templates/zcl/zcl.json and src/app/zap-templates/zcl/zcl-with-test-extensions.json +{{/if_is_struct}} namespace {{asUpperCamelCase label}} { {{#*inline "clusterId"}}Clusters::{{asUpperCamelCase parent.label}}::Id{{/inline}} @@ -133,7 +135,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, {{zapTypeToEncodableClusterObjectTy } // namespace {{asUpperCamelCase label}} -{{/if_is_struct}} +{{/unless}} {{#last}} } // namespace Attributes } // {{asUpperCamelCase parent.label}} diff --git a/src/app/zap-templates/templates/app/attributes/Accessors.zapt b/src/app/zap-templates/templates/app/attributes/Accessors.zapt index 8854633c99d33b..cd149524f5448c 100644 --- a/src/app/zap-templates/templates/app/attributes/Accessors.zapt +++ b/src/app/zap-templates/templates/app/attributes/Accessors.zapt @@ -23,8 +23,7 @@ namespace {{asUpperCamelCase parent.label}} { namespace Attributes { {{/first}} -{{#if_is_struct type}} -{{else if (canHaveSimpleAccessors this)}} +{{#unless (isStrEqual storagePolicy "attributeAccessInterface")}} namespace {{asUpperCamelCase label}} { EmberAfStatus Get(chip::EndpointId endpoint, {{accessorGetterType this}} value); // {{type}} EmberAfStatus Set(chip::EndpointId endpoint, {{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotNullable=true forceNotOptional=true}} value); @@ -34,7 +33,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, {{zapTypeToEncodableClusterObjectTy {{/if}} } // namespace {{asUpperCamelCase label}} -{{/if_is_struct}} +{{/unless}} {{#last}} } // namespace Attributes } // {{asUpperCamelCase parent.label}} diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index 0630b770710483..6a40f87300463b 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -270,7 +270,11 @@ "PacketUnicastTxCount", "CurrentMaxRate", "OverrunCount" - ] + ], + "Channel": ["Lineup", "CurrentChannel"], + "Media Playback": ["SampledPosition"], + "Application Launcher": ["CurrentApp"], + "Application Basic": ["Application"] }, "defaultReportingPolicy": "mandatory", "ZCLDataTypes": ["ARRAY", "BITMAP", "ENUM", "NUMBER", "STRING", "STRUCT"], diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index a4908975f74213..d5bd43109c7b96 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -268,7 +268,11 @@ "PacketUnicastTxCount", "CurrentMaxRate", "OverrunCount" - ] + ], + "Channel": ["Lineup", "CurrentChannel"], + "Media Playback": ["SampledPosition"], + "Application Launcher": ["CurrentApp"], + "Application Basic": ["Application"] }, "defaultReportingPolicy": "mandatory", "ZCLDataTypes": ["ARRAY", "BITMAP", "ENUM", "NUMBER", "STRING", "STRUCT"], diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index ebd102aded5e53..6dd1d09dfa0a55 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -2101,99 +2101,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) namespace AccessControl { namespace Attributes { -namespace SubjectsPerAccessControlEntry { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::AccessControl::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::AccessControl::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace SubjectsPerAccessControlEntry - -namespace TargetsPerAccessControlEntry { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::AccessControl::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::AccessControl::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace TargetsPerAccessControlEntry - -namespace AccessControlEntriesPerFabric { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::AccessControl::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::AccessControl::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace AccessControlEntriesPerFabric - namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) @@ -2360,38 +2267,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) namespace BasicInformation { namespace Attributes { -namespace DataModelRevision { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace DataModelRevision - -namespace VendorName { +namespace NodeLabel { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { @@ -2419,13 +2295,13 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -} // namespace VendorName +} // namespace NodeLabel -namespace VendorID { +namespace LocalConfigDisabled { -EmberAfStatus Get(chip::EndpointId endpoint, chip::VendorId * value) +EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, readable, sizeof(temp)); @@ -2437,9 +2313,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::VendorId * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::VendorId value) +EmberAfStatus Set(chip::EndpointId endpoint, bool value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -2447,46 +2323,16 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::VendorId value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, writable, ZCL_VENDOR_ID_ATTRIBUTE_TYPE); -} - -} // namespace VendorID - -namespace ProductName { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) -{ - uint8_t zclString[32 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 32); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace ProductName +} // namespace LocalConfigDisabled -namespace ProductID { +namespace Reachable { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, readable, sizeof(temp)); @@ -2498,9 +2344,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) +EmberAfStatus Set(chip::EndpointId endpoint, bool value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -2508,72 +2354,43 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace ProductID +} // namespace Reachable -namespace NodeLabel { +namespace FeatureMap { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - uint8_t zclString[32 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, sizeof(zclString)); + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 32); - value.reduce_size(length); + *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); -} - -} // namespace NodeLabel - -namespace Location { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - uint8_t zclString[2 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - - VerifyOrReturnError(value.size() == 2, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 2); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(2 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 2, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[2 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } -} // namespace Location +} // namespace FeatureMap -namespace HardwareVersion { +namespace ClusterRevision { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { @@ -2602,46 +2419,53 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace HardwareVersion +} // namespace ClusterRevision -namespace HardwareVersionString { +} // namespace Attributes +} // namespace BasicInformation -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +namespace OtaSoftwareUpdateProvider { +namespace Attributes { + +namespace FeatureMap { + +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - uint8_t zclString[64 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, sizeof(zclString)); + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateProvider::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - - VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 64); - value.reduce_size(length); + *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - static_assert(64 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[64 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateProvider::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } -} // namespace HardwareVersionString +} // namespace FeatureMap -namespace SoftwareVersion { +namespace ClusterRevision { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateProvider::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -2650,9 +2474,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -2660,199 +2484,140 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateProvider::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace SoftwareVersion +} // namespace ClusterRevision -namespace SoftwareVersionString { +} // namespace Attributes +} // namespace OtaSoftwareUpdateProvider -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +namespace OtaSoftwareUpdateRequestor { +namespace Attributes { + +namespace UpdatePossible { + +EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - uint8_t zclString[64 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, sizeof(zclString)); + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - - VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 64); - value.reduce_size(length); + *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(64 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[64 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); -} - -} // namespace SoftwareVersionString - -namespace ManufacturingDate { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +EmberAfStatus Set(chip::EndpointId endpoint, bool value) { - uint8_t zclString[16 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 16); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(16 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[16 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace ManufacturingDate +} // namespace UpdatePossible -namespace PartNumber { +namespace UpdateState { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum * value) { - uint8_t zclString[32 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, sizeof(zclString)); + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 32); - value.reduce_size(length); + *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum value) { - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -} // namespace PartNumber +} // namespace UpdateState -namespace ProductURL { +namespace UpdateStateProgress { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - uint8_t zclString[256 + 2]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, sizeof(zclString)); + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfLongStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - - VerifyOrReturnError(value.size() == 256, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[2], 256); - value.reduce_size(length); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(256 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 256, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[256 + 2]; - emberAfCopyInt16u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[2], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, ZCL_LONG_CHAR_STRING_ATTRIBUTE_TYPE); -} - -} // namespace ProductURL - -namespace ProductLabel { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { - uint8_t zclString[64 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - - VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 64); - value.reduce_size(length); - return status; + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) + +EmberAfStatus SetNull(chip::EndpointId endpoint) { - static_assert(64 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[64 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } -} // namespace ProductLabel - -namespace SerialNumber { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) { - uint8_t zclString[32 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + if (value.IsNull()) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + return SetNull(endpoint); } - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 32); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + return Set(endpoint, value.Value()); } -} // namespace SerialNumber +} // namespace UpdateStateProgress -namespace LocalConfigDisabled { +namespace FeatureMap { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -2861,9 +2626,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, bool * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, bool value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -2871,19 +2636,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } -} // namespace LocalConfigDisabled +} // namespace FeatureMap -namespace Reachable { +namespace ClusterRevision { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -2892,9 +2657,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, bool * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, bool value) +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -2902,17 +2667,24 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace Reachable +} // namespace ClusterRevision -namespace UniqueID { +} // namespace Attributes +} // namespace OtaSoftwareUpdateRequestor + +namespace LocalizationConfiguration { +namespace Attributes { + +namespace ActiveLocale { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - uint8_t zclString[32 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, sizeof(zclString)); + uint8_t zclString[35 + 1]; + EmberAfStatus status = + emberAfReadAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, zclString, sizeof(zclString)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); size_t length = emberAfStringLength(zclString); if (length == NumericAttributeTraits::kNullValue) @@ -2920,22 +2692,22 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 32); + VerifyOrReturnError(value.size() == 35, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 35); value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; + static_assert(35 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 35, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[35 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -} // namespace UniqueID +} // namespace ActiveLocale namespace FeatureMap { @@ -2944,7 +2716,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -2963,7 +2735,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } } // namespace FeatureMap @@ -2975,7 +2747,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BasicInformation::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -2994,25 +2766,25 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BasicInformation::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } } // namespace ClusterRevision } // namespace Attributes -} // namespace BasicInformation +} // namespace LocalizationConfiguration -namespace OtaSoftwareUpdateProvider { +namespace TimeFormatLocalization { namespace Attributes { -namespace FeatureMap { +namespace HourFormat { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::TimeFormatLocalization::HourFormatEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateProvider::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3021,9 +2793,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeFormatLocalization::HourFormatEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3031,19 +2803,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateProvider::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -} // namespace FeatureMap +} // namespace HourFormat -namespace ClusterRevision { +namespace ActiveCalendarType { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::TimeFormatLocalization::CalendarTypeEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateProvider::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3052,9 +2824,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeFormatLocalization::CalendarTypeEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3062,25 +2834,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateProvider::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace OtaSoftwareUpdateProvider - -namespace OtaSoftwareUpdateRequestor { -namespace Attributes { +} // namespace ActiveCalendarType -namespace UpdatePossible { +namespace FeatureMap { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3089,9 +2855,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, bool * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, bool value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3099,19 +2865,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } -} // namespace UpdatePossible +} // namespace FeatureMap -namespace UpdateState { +namespace ClusterRevision { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3120,9 +2886,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::OtaSoftwareUpd *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3130,63 +2896,47 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::OtaSoftwareUpd Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace UpdateState +} // namespace ClusterRevision -namespace UpdateStateProgress { +} // namespace Attributes +} // namespace TimeFormatLocalization -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +namespace UnitLocalization { +namespace Attributes { + +namespace TemperatureUnit { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::UnitLocalization::TempUnitEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::UnitLocalization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { - value.SetNonNull() = Traits::StorageToWorking(temp); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } + *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::UnitLocalization::TempUnitEnum value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); + return emberAfWriteAttribute(endpoint, Clusters::UnitLocalization::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -} // namespace UpdateStateProgress +} // namespace TemperatureUnit namespace FeatureMap { @@ -3195,7 +2945,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::UnitLocalization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3214,7 +2964,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::UnitLocalization::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } } // namespace FeatureMap @@ -3226,7 +2976,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::UnitLocalization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3245,48 +2995,17 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::UnitLocalization::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } } // namespace ClusterRevision } // namespace Attributes -} // namespace OtaSoftwareUpdateRequestor +} // namespace UnitLocalization -namespace LocalizationConfiguration { +namespace PowerSourceConfiguration { namespace Attributes { -namespace ActiveLocale { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) -{ - uint8_t zclString[35 + 1]; - EmberAfStatus status = - emberAfReadAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - - VerifyOrReturnError(value.size() == 35, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 35); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(35 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 35, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[35 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); -} - -} // namespace ActiveLocale - namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) @@ -3294,7 +3013,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSourceConfiguration::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3313,7 +3032,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSourceConfiguration::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } } // namespace FeatureMap @@ -3325,7 +3044,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSourceConfiguration::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3344,25 +3063,25 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSourceConfiguration::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } } // namespace ClusterRevision } // namespace Attributes -} // namespace LocalizationConfiguration +} // namespace PowerSourceConfiguration -namespace TimeFormatLocalization { +namespace PowerSource { namespace Attributes { -namespace HourFormat { +namespace Status { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::TimeFormatLocalization::HourFormatEnum * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::PowerSourceStatusEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3371,9 +3090,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::TimeFormatLoca *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeFormatLocalization::HourFormatEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::PowerSourceStatusEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3381,19 +3100,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeFormatLoca Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -} // namespace HourFormat +} // namespace Status -namespace ActiveCalendarType { +namespace Order { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::TimeFormatLocalization::CalendarTypeEnum * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3402,9 +3121,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::TimeFormatLoca *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeFormatLocalization::CalendarTypeEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3412,87 +3131,155 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeFormatLoca Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } -} // namespace ActiveCalendarType +} // namespace Order -namespace FeatureMap { +namespace Description { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +{ + uint8_t zclString[60 + 1]; + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + + VerifyOrReturnError(value.size() == 60, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 60); + value.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +{ + static_assert(60 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 60, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[60 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); +} + +} // namespace Description + +namespace WiredAssessedInputVoltage { + +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); } -} // namespace FeatureMap +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); +} -namespace ClusterRevision { +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) + return Set(endpoint, value.Value()); +} + +} // namespace WiredAssessedInputVoltage + +namespace WiredAssessedInputFrequency { + +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeFormatLocalization::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace ClusterRevision +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); +} -} // namespace Attributes -} // namespace TimeFormatLocalization +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } -namespace UnitLocalization { -namespace Attributes { + return Set(endpoint, value.Value()); +} -namespace TemperatureUnit { +} // namespace WiredAssessedInputFrequency -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::UnitLocalization::TempUnitEnum * value) +namespace WiredCurrentType { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::WiredCurrentTypeEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::UnitLocalization::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3501,9 +3288,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::UnitLocalizati *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::UnitLocalization::TempUnitEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::WiredCurrentTypeEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3511,50 +3298,72 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::UnitLocalizati Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::UnitLocalization::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -} // namespace TemperatureUnit +} // namespace WiredCurrentType -namespace FeatureMap { +namespace WiredAssessedCurrent { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::UnitLocalization::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::UnitLocalization::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); } -} // namespace FeatureMap +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); +} -namespace ClusterRevision { +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) + return Set(endpoint, value.Value()); +} + +} // namespace WiredAssessedCurrent + +namespace WiredNominalVoltage { + +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::UnitLocalization::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3563,9 +3372,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3573,25 +3382,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::UnitLocalization::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); } -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace UnitLocalization - -namespace PowerSourceConfiguration { -namespace Attributes { +} // namespace WiredNominalVoltage -namespace FeatureMap { +namespace WiredMaximumCurrent { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSourceConfiguration::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3610,19 +3413,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSourceConfiguration::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); } -} // namespace FeatureMap +} // namespace WiredMaximumCurrent -namespace ClusterRevision { +namespace WiredPresent { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSourceConfiguration::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -3631,9 +3434,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) +EmberAfStatus Set(chip::EndpointId endpoint, bool value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3641,114 +3444,69 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSourceConfiguration::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace PowerSourceConfiguration - -namespace PowerSource { -namespace Attributes { +} // namespace WiredPresent -namespace Status { +namespace BatVoltage { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::PowerSourceStatusEnum * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::PowerSourceStatusEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); } -} // namespace Status - -namespace Order { - -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +EmberAfStatus SetNull(chip::EndpointId endpoint) { - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); } -} // namespace Order - -namespace Description { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) { - uint8_t zclString[60 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + if (value.IsNull()) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + return SetNull(endpoint); } - VerifyOrReturnError(value.size() == 60, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 60); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(60 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 60, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[60 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + return Set(endpoint, value.Value()); } -} // namespace Description +} // namespace BatVoltage -namespace WiredAssessedInputVoltage { +namespace BatPercentRemaining { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); @@ -3763,9 +3521,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & val } return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3773,19 +3531,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } EmberAfStatus SetNull(chip::EndpointId endpoint) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType value; Traits::SetNull(value); uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) { if (value.IsNull()) { @@ -3795,13 +3553,13 @@ EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullabl return Set(endpoint, value.Value()); } -} // namespace WiredAssessedInputVoltage +} // namespace BatPercentRemaining -namespace WiredAssessedInputFrequency { +namespace BatTimeRemaining { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); @@ -3816,9 +3574,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & val } return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3826,19 +3584,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); } EmberAfStatus SetNull(chip::EndpointId endpoint) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType value; Traits::SetNull(value); uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); } -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) { if (value.IsNull()) { @@ -3848,13 +3606,13 @@ EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullabl return Set(endpoint, value.Value()); } -} // namespace WiredAssessedInputFrequency +} // namespace BatTimeRemaining -namespace WiredCurrentType { +namespace BatChargeLevel { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::WiredCurrentTypeEnum * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatChargeLevelEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); @@ -3866,9 +3624,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::W *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::WiredCurrentTypeEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatChargeLevelEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3879,66 +3637,44 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::W return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -} // namespace WiredCurrentType +} // namespace BatChargeLevel -namespace WiredAssessedCurrent { +namespace BatReplacementNeeded { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { - value.SetNonNull() = Traits::StorageToWorking(temp); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } + *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, bool value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace WiredAssessedCurrent +} // namespace BatReplacementNeeded -namespace WiredNominalVoltage { +namespace BatReplaceability { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatReplaceabilityEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); @@ -3950,9 +3686,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatReplaceabilityEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3960,16 +3696,16 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -} // namespace WiredNominalVoltage +} // namespace BatReplaceability -namespace WiredMaximumCurrent { +namespace BatPresent { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); @@ -3981,9 +3717,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, bool value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -3991,149 +3727,257 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace WiredMaximumCurrent +} // namespace BatPresent -namespace WiredPresent { +namespace BatReplacementDescription { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + uint8_t zclString[60 + 1]; + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, sizeof(zclString)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - *value = Traits::StorageToWorking(temp); + + VerifyOrReturnError(value.size() == 60, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 60); + value.reduce_size(length); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, bool value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + static_assert(60 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 60, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[60 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -} // namespace WiredPresent +} // namespace BatReplacementDescription -namespace BatVoltage { +namespace BatCommonDesignation { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatCommonDesignationEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { - value.SetNonNull() = Traits::StorageToWorking(temp); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } + *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatCommonDesignationEnum value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM16_ATTRIBUTE_TYPE); } -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} +} // namespace BatCommonDesignation -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +namespace BatANSIDesignation { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - if (value.IsNull()) - { - return SetNull(endpoint); + uint8_t zclString[20 + 1]; + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - return Set(endpoint, value.Value()); + VerifyOrReturnError(value.size() == 20, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 20); + value.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +{ + static_assert(20 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 20, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[20 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -} // namespace BatVoltage +} // namespace BatANSIDesignation -namespace BatPercentRemaining { +namespace BatIECDesignation { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - using Traits = NumericAttributeTraits; + uint8_t zclString[20 + 1]; + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + + VerifyOrReturnError(value.size() == 20, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 20); + value.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +{ + static_assert(20 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 20, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[20 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); +} + +} // namespace BatIECDesignation + +namespace BatApprovedChemistry { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatApprovedChemistryEnum * value) +{ + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { - value.SetNull(); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - else + *value = Traits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatApprovedChemistryEnum value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { - value.SetNonNull() = Traits::StorageToWorking(temp); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM16_ATTRIBUTE_TYPE); +} + +} // namespace BatApprovedChemistry + +namespace BatCapacity { + +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } + *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); } -EmberAfStatus SetNull(chip::EndpointId endpoint) +} // namespace BatCapacity + +namespace BatQuantity { + +EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + *value = Traits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +} // namespace BatQuantity + +namespace BatChargeState { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatChargeStateEnum * value) { - if (value.IsNull()) + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { - return SetNull(endpoint); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - - return Set(endpoint, value.Value()); + *value = Traits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatChargeStateEnum value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -} // namespace BatPercentRemaining +} // namespace BatChargeState -namespace BatTimeRemaining { +namespace BatTimeToFullCharge { EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { @@ -4184,13 +4028,13 @@ EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullabl return Set(endpoint, value.Value()); } -} // namespace BatTimeRemaining +} // namespace BatTimeToFullCharge -namespace BatChargeLevel { +namespace BatFunctionalWhileCharging { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatChargeLevelEnum * value) +EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); @@ -4202,9 +4046,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::B *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatChargeLevelEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, bool value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4212,47 +4056,69 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::B Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace BatChargeLevel +} // namespace BatFunctionalWhileCharging -namespace BatReplacementNeeded { +namespace BatChargingCurrent { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, bool value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); } -} // namespace BatReplacementNeeded +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); +} -namespace BatReplaceability { +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatReplaceabilityEnum * value) + return Set(endpoint, value.Value()); +} + +} // namespace BatChargingCurrent + +namespace FeatureMap { + +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); @@ -4264,9 +4130,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::B *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatReplaceabilityEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4274,16 +4140,16 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::B Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } -} // namespace BatReplaceability +} // namespace FeatureMap -namespace BatPresent { +namespace ClusterRevision { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); @@ -4295,9 +4161,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, bool * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, bool value) +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4305,49 +4171,25 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace BatPresent - -namespace BatReplacementDescription { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) -{ - uint8_t zclString[60 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } +} // namespace ClusterRevision - VerifyOrReturnError(value.size() == 60, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 60); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(60 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 60, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[60 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); -} +} // namespace Attributes +} // namespace PowerSource -} // namespace BatReplacementDescription +namespace GeneralCommissioning { +namespace Attributes { -namespace BatCommonDesignation { +namespace Breadcrumb { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatCommonDesignationEnum * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4356,9 +4198,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::B *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatCommonDesignationEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4366,79 +4208,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::B Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM16_ATTRIBUTE_TYPE); -} - -} // namespace BatCommonDesignation - -namespace BatANSIDesignation { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) -{ - uint8_t zclString[20 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - - VerifyOrReturnError(value.size() == 20, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 20); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(20 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 20, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[20 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); -} - -} // namespace BatANSIDesignation - -namespace BatIECDesignation { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) -{ - uint8_t zclString[20 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - - VerifyOrReturnError(value.size() == 20, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 20); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(20 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 20, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[20 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); } -} // namespace BatIECDesignation +} // namespace Breadcrumb -namespace BatApprovedChemistry { +namespace FeatureMap { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatApprovedChemistryEnum * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4447,9 +4229,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::B *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatApprovedChemistryEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4457,19 +4239,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::B Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM16_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } -} // namespace BatApprovedChemistry +} // namespace FeatureMap -namespace BatCapacity { +namespace ClusterRevision { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4478,9 +4260,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4488,19 +4270,25 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace BatCapacity +} // namespace ClusterRevision -namespace BatQuantity { +} // namespace Attributes +} // namespace GeneralCommissioning + +namespace NetworkCommissioning { +namespace Attributes { + +namespace MaxNetworks { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4519,19 +4307,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } -} // namespace BatQuantity +} // namespace MaxNetworks -namespace BatChargeState { +namespace ScanMaxTimeSeconds { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatChargeStateEnum * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4540,9 +4328,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::B *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::BatChargeStateEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4550,72 +4338,50 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::PowerSource::B Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } -} // namespace BatChargeState +} // namespace ScanMaxTimeSeconds -namespace BatTimeToFullCharge { +namespace ConnectMaxTimeSeconds { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { - value.SetNonNull() = Traits::StorageToWorking(temp); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } + *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); + return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } -} // namespace BatTimeToFullCharge +} // namespace ConnectMaxTimeSeconds -namespace BatFunctionalWhileCharging { +namespace InterfaceEnabled { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4634,19 +4400,20 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace BatFunctionalWhileCharging +} // namespace InterfaceEnabled -namespace BatChargingCurrent { +namespace LastNetworkingStatus { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +EmberAfStatus Get(chip::EndpointId endpoint, + DataModel::Nullable & value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (Traits::IsNullValue(temp)) { @@ -4658,9 +4425,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & val } return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::NetworkCommissioning::NetworkCommissioningStatus value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4668,19 +4435,21 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } EmberAfStatus SetNull(chip::EndpointId endpoint) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType value; Traits::SetNull(value); uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +EmberAfStatus +Set(chip::EndpointId endpoint, + const chip::app::DataModel::Nullable & value) { if (value.IsNull()) { @@ -4690,47 +4459,117 @@ EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullabl return Set(endpoint, value.Value()); } -} // namespace BatChargingCurrent +} // namespace LastNetworkingStatus -namespace FeatureMap { +namespace LastNetworkID { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - using Traits = NumericAttributeTraits; - Traits::StorageType temp; + uint8_t zclString[32 + 1]; + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) + { + value.SetNull(); + return EMBER_ZCL_STATUS_SUCCESS; + } + auto & span = value.SetNonNull(); + + VerifyOrReturnError(span.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(span.data(), &zclString[1], 32); + span.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) +{ + static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[32 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); +} + +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + uint8_t zclString[1] = { 0xFF }; + return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); +} + +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); +} + +} // namespace LastNetworkID + +namespace LastConnectErrorValue { + +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, int32_t value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_INT32S_ATTRIBUTE_TYPE); } -} // namespace FeatureMap +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_INT32S_ATTRIBUTE_TYPE); +} -namespace ClusterRevision { +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) + return Set(endpoint, value.Value()); +} + +} // namespace LastConnectErrorValue + +namespace FeatureMap { + +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::PowerSource::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4739,9 +4578,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4749,25 +4588,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::PowerSource::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace PowerSource - -namespace GeneralCommissioning { -namespace Attributes { +} // namespace FeatureMap -namespace Breadcrumb { +namespace ClusterRevision { -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4776,9 +4609,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4786,19 +4619,25 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace Breadcrumb +} // namespace ClusterRevision -namespace RegulatoryConfig { +} // namespace Attributes +} // namespace NetworkCommissioning + +namespace DiagnosticLogs { +namespace Attributes { + +namespace FeatureMap { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::DiagnosticLogs::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4807,9 +4646,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::GeneralCommiss *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4817,19 +4656,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::GeneralCommiss Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::DiagnosticLogs::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } -} // namespace RegulatoryConfig +} // namespace FeatureMap -namespace LocationCapability { +namespace ClusterRevision { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::DiagnosticLogs::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4838,9 +4677,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::GeneralCommiss *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType value) +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4848,19 +4687,25 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::GeneralCommiss Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::DiagnosticLogs::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace LocationCapability +} // namespace ClusterRevision + +} // namespace Attributes +} // namespace DiagnosticLogs + +namespace GeneralDiagnostics { +namespace Attributes { -namespace SupportsConcurrentConnection { +namespace TestEventTriggersEnabled { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4879,10 +4724,10 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace SupportsConcurrentConnection +} // namespace TestEventTriggersEnabled namespace FeatureMap { @@ -4891,7 +4736,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4910,7 +4755,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } } // namespace FeatureMap @@ -4922,7 +4767,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4941,25 +4786,25 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } } // namespace ClusterRevision } // namespace Attributes -} // namespace GeneralCommissioning +} // namespace GeneralDiagnostics -namespace NetworkCommissioning { +namespace SoftwareDiagnostics { namespace Attributes { -namespace MaxNetworks { +namespace FeatureMap { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4968,9 +4813,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -4978,19 +4823,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } -} // namespace MaxNetworks +} // namespace FeatureMap -namespace ScanMaxTimeSeconds { +namespace ClusterRevision { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -4999,9 +4844,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -5009,19 +4854,25 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace ScanMaxTimeSeconds +} // namespace ClusterRevision -namespace ConnectMaxTimeSeconds { +} // namespace Attributes +} // namespace SoftwareDiagnostics -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +namespace ThreadNetworkDiagnostics { +namespace Attributes { + +namespace FeatureMap { + +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -5030,9 +4881,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -5040,19 +4891,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } -} // namespace ConnectMaxTimeSeconds +} // namespace FeatureMap -namespace InterfaceEnabled { +namespace ClusterRevision { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -5061,9 +4912,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, bool * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, bool value) +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -5071,176 +4922,25 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace InterfaceEnabled +} // namespace ClusterRevision -namespace LastNetworkingStatus { +} // namespace Attributes +} // namespace ThreadNetworkDiagnostics -EmberAfStatus Get(chip::EndpointId endpoint, - DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::NetworkCommissioning::NetworkCommissioningStatus value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -EmberAfStatus -Set(chip::EndpointId endpoint, - const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace LastNetworkingStatus - -namespace LastNetworkID { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - uint8_t zclString[32 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - value.SetNull(); - return EMBER_ZCL_STATUS_SUCCESS; - } - auto & span = value.SetNonNull(); - - VerifyOrReturnError(span.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(span.data(), &zclString[1], 32); - span.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) -{ - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - uint8_t zclString[1] = { 0xFF }; - return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace LastNetworkID - -namespace LastConnectErrorValue { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, int32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_INT32S_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_INT32S_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace LastConnectErrorValue - -namespace FeatureMap { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +namespace WiFiNetworkDiagnostics { +namespace Attributes { + +namespace FeatureMap { + +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -5259,7 +4959,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } } // namespace FeatureMap @@ -5271,7 +4971,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -5290,15 +4990,15 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::NetworkCommissioning::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } } // namespace ClusterRevision } // namespace Attributes -} // namespace NetworkCommissioning +} // namespace WiFiNetworkDiagnostics -namespace DiagnosticLogs { +namespace EthernetNetworkDiagnostics { namespace Attributes { namespace FeatureMap { @@ -5308,7 +5008,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::DiagnosticLogs::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -5327,7 +5027,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::DiagnosticLogs::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } } // namespace FeatureMap @@ -5339,7 +5039,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::DiagnosticLogs::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -5358,87 +5058,78 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::DiagnosticLogs::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } } // namespace ClusterRevision } // namespace Attributes -} // namespace DiagnosticLogs +} // namespace EthernetNetworkDiagnostics -namespace GeneralDiagnostics { +namespace TimeSynchronization { namespace Attributes { -namespace RebootCount { +namespace UTCTime { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_EPOCH_US_ATTRIBUTE_TYPE); } -} // namespace RebootCount - -namespace UpTime { - -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) +EmberAfStatus SetNull(chip::EndpointId endpoint) { using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_EPOCH_US_ATTRIBUTE_TYPE); } -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) + +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + if (value.IsNull()) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + return SetNull(endpoint); } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); + + return Set(endpoint, value.Value()); } -} // namespace UpTime +} // namespace UTCTime -namespace TotalOperationalHours { +namespace Granularity { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchronization::GranularityEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -5447,9 +5138,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchronization::GranularityEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -5457,19 +5148,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -} // namespace TotalOperationalHours +} // namespace Granularity -namespace BootReason { +namespace TimeSource { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::GeneralDiagnostics::BootReasonEnum * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchronization::TimeSourceEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -5478,9 +5169,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::GeneralDiagnos *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::GeneralDiagnostics::BootReasonEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchronization::TimeSourceEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -5488,4467 +5179,173 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::GeneralDiagnos Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -} // namespace BootReason - -namespace TestEventTriggersEnabled { - -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, bool value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); -} - -} // namespace TestEventTriggersEnabled - -namespace FeatureMap { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); -} - -} // namespace FeatureMap - -namespace ClusterRevision { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GeneralDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace GeneralDiagnostics - -namespace SoftwareDiagnostics { -namespace Attributes { - -namespace CurrentHeapFree { - -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -} // namespace CurrentHeapFree - -namespace CurrentHeapUsed { - -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -} // namespace CurrentHeapUsed - -namespace CurrentHeapHighWatermark { - -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -} // namespace CurrentHeapHighWatermark - -namespace FeatureMap { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); -} - -} // namespace FeatureMap - -namespace ClusterRevision { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::SoftwareDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace SoftwareDiagnostics - -namespace ThreadNetworkDiagnostics { -namespace Attributes { - -namespace Channel { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace Channel - -namespace RoutingRole { - -EmberAfStatus Get(chip::EndpointId endpoint, - DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::ThreadNetworkDiagnostics::RoutingRole value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, - const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace RoutingRole - -namespace NetworkName { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - uint8_t zclString[16 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - value.SetNull(); - return EMBER_ZCL_STATUS_SUCCESS; - } - auto & span = value.SetNonNull(); - - VerifyOrReturnError(span.size() == 16, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(span.data(), &zclString[1], 16); - span.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(16 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[16 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - uint8_t zclString[1] = { 0xFF }; - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace NetworkName - -namespace PanId { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace PanId - -namespace ExtendedPanId { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace ExtendedPanId - -namespace MeshLocalPrefix { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - uint8_t zclString[17 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - value.SetNull(); - return EMBER_ZCL_STATUS_SUCCESS; - } - auto & span = value.SetNonNull(); - - VerifyOrReturnError(span.size() == 17, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(span.data(), &zclString[1], 17); - span.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) -{ - static_assert(17 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 17, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[17 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - uint8_t zclString[1] = { 0xFF }; - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace MeshLocalPrefix - -namespace OverrunCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -} // namespace OverrunCount - -namespace PartitionId { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace PartitionId - -namespace Weighting { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace Weighting - -namespace DataVersion { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace DataVersion - -namespace StableDataVersion { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace StableDataVersion - -namespace LeaderRouterId { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace LeaderRouterId - -namespace DetachedRoleCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace DetachedRoleCount - -namespace ChildRoleCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace ChildRoleCount - -namespace RouterRoleCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace RouterRoleCount - -namespace LeaderRoleCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace LeaderRoleCount - -namespace AttachAttemptCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace AttachAttemptCount - -namespace PartitionIdChangeCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace PartitionIdChangeCount - -namespace BetterPartitionAttachAttemptCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace BetterPartitionAttachAttemptCount - -namespace ParentChangeCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace ParentChangeCount - -namespace TxTotalCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxTotalCount - -namespace TxUnicastCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxUnicastCount - -namespace TxBroadcastCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxBroadcastCount - -namespace TxAckRequestedCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxAckRequestedCount - -namespace TxAckedCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxAckedCount - -namespace TxNoAckRequestedCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxNoAckRequestedCount - -namespace TxDataCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxDataCount - -namespace TxDataPollCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxDataPollCount - -namespace TxBeaconCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxBeaconCount - -namespace TxBeaconRequestCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxBeaconRequestCount - -namespace TxOtherCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxOtherCount - -namespace TxRetryCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxRetryCount - -namespace TxDirectMaxRetryExpiryCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxDirectMaxRetryExpiryCount - -namespace TxIndirectMaxRetryExpiryCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxIndirectMaxRetryExpiryCount - -namespace TxErrCcaCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxErrCcaCount - -namespace TxErrAbortCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxErrAbortCount - -namespace TxErrBusyChannelCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace TxErrBusyChannelCount - -namespace RxTotalCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxTotalCount - -namespace RxUnicastCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxUnicastCount - -namespace RxBroadcastCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxBroadcastCount - -namespace RxDataCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxDataCount - -namespace RxDataPollCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxDataPollCount - -namespace RxBeaconCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxBeaconCount - -namespace RxBeaconRequestCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxBeaconRequestCount - -namespace RxOtherCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxOtherCount - -namespace RxAddressFilteredCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxAddressFilteredCount - -namespace RxDestAddrFilteredCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxDestAddrFilteredCount - -namespace RxDuplicatedCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxDuplicatedCount - -namespace RxErrNoFrameCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxErrNoFrameCount - -namespace RxErrUnknownNeighborCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxErrUnknownNeighborCount - -namespace RxErrInvalidSrcAddrCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxErrInvalidSrcAddrCount - -namespace RxErrSecCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxErrSecCount - -namespace RxErrFcsCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxErrFcsCount - -namespace RxErrOtherCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -} // namespace RxErrOtherCount - -namespace ActiveTimestamp { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace ActiveTimestamp - -namespace PendingTimestamp { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace PendingTimestamp - -namespace Delay { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace Delay - -namespace ChannelPage0Mask { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - uint8_t zclString[4 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - value.SetNull(); - return EMBER_ZCL_STATUS_SUCCESS; - } - auto & span = value.SetNonNull(); - - VerifyOrReturnError(span.size() == 4, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(span.data(), &zclString[1], 4); - span.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) -{ - static_assert(4 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 4, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[4 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - uint8_t zclString[1] = { 0xFF }; - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace ChannelPage0Mask - -namespace FeatureMap { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); -} - -} // namespace FeatureMap - -namespace ClusterRevision { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::ThreadNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace ThreadNetworkDiagnostics - -namespace WiFiNetworkDiagnostics { -namespace Attributes { - -namespace Bssid { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - uint8_t zclString[6 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - value.SetNull(); - return EMBER_ZCL_STATUS_SUCCESS; - } - auto & span = value.SetNonNull(); - - VerifyOrReturnError(span.size() == 6, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(span.data(), &zclString[1], 6); - span.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) -{ - static_assert(6 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 6, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[6 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - uint8_t zclString[1] = { 0xFF }; - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace Bssid - -namespace SecurityType { - -EmberAfStatus Get(chip::EndpointId endpoint, - DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, - const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace SecurityType - -namespace WiFiVersion { - -EmberAfStatus Get(chip::EndpointId endpoint, - DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, - const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace WiFiVersion - -namespace ChannelNumber { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace ChannelNumber - -namespace Rssi { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, int8_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT8S_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT8S_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace Rssi - -namespace BeaconLostCount { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace BeaconLostCount - -namespace BeaconRxCount { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace BeaconRxCount - -namespace PacketMulticastRxCount { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace PacketMulticastRxCount - -namespace PacketMulticastTxCount { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace PacketMulticastTxCount - -namespace PacketUnicastRxCount { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace PacketUnicastRxCount - -namespace PacketUnicastTxCount { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace PacketUnicastTxCount - -namespace CurrentMaxRate { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace CurrentMaxRate - -namespace OverrunCount { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace OverrunCount - -namespace FeatureMap { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); -} - -} // namespace FeatureMap - -namespace ClusterRevision { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::WiFiNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace WiFiNetworkDiagnostics - -namespace EthernetNetworkDiagnostics { -namespace Attributes { - -namespace PHYRate { - -EmberAfStatus Get(chip::EndpointId endpoint, - DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, - const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace PHYRate - -namespace FullDuplex { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, bool value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace FullDuplex - -namespace PacketRxCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -} // namespace PacketRxCount - -namespace PacketTxCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -} // namespace PacketTxCount - -namespace TxErrCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -} // namespace TxErrCount - -namespace CollisionCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -} // namespace CollisionCount - -namespace OverrunCount { - -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -} // namespace OverrunCount - -namespace CarrierDetect { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, bool value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace CarrierDetect - -namespace TimeSinceReset { - -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_INT64U_ATTRIBUTE_TYPE); -} - -} // namespace TimeSinceReset - -namespace FeatureMap { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); -} - -} // namespace FeatureMap - -namespace ClusterRevision { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace EthernetNetworkDiagnostics - -namespace TimeSynchronization { -namespace Attributes { - -namespace UTCTime { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_EPOCH_US_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_EPOCH_US_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace UTCTime - -namespace Granularity { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchronization::GranularityEnum * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchronization::GranularityEnum value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -} // namespace Granularity - -namespace TimeSource { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchronization::TimeSourceEnum * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchronization::TimeSourceEnum value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -} // namespace TimeSource - -namespace TrustedTimeNodeId { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::NodeId value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_NODE_ID_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_NODE_ID_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace TrustedTimeNodeId - -namespace DefaultNtp { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - uint8_t zclString[128 + 1]; - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - value.SetNull(); - return EMBER_ZCL_STATUS_SUCCESS; - } - auto & span = value.SetNonNull(); - - VerifyOrReturnError(span.size() == 128, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(span.data(), &zclString[1], 128); - span.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(128 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 128, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[128 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - uint8_t zclString[1] = { 0xFF }; - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace DefaultNtp - -namespace LocalTime { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_EPOCH_US_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_EPOCH_US_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace LocalTime - -namespace TimeZoneDatabase { - -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, bool value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); -} - -} // namespace TimeZoneDatabase - -namespace NtpServerPort { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace NtpServerPort - -namespace FeatureMap { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); -} - -} // namespace FeatureMap - -namespace ClusterRevision { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace TimeSynchronization - -namespace BridgedDeviceBasicInformation { -namespace Attributes { - -namespace VendorName { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) -{ - uint8_t zclString[32 + 1]; - EmberAfStatus status = - emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 32); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, - ZCL_CHAR_STRING_ATTRIBUTE_TYPE); -} - -} // namespace VendorName - -namespace VendorID { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::VendorId * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::VendorId value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, writable, ZCL_VENDOR_ID_ATTRIBUTE_TYPE); -} - -} // namespace VendorID - -namespace ProductName { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) -{ - uint8_t zclString[32 + 1]; - EmberAfStatus status = - emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 32); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, - ZCL_CHAR_STRING_ATTRIBUTE_TYPE); -} - -} // namespace ProductName - -namespace NodeLabel { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) -{ - uint8_t zclString[32 + 1]; - EmberAfStatus status = - emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 32); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, - ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -} // namespace NodeLabel +} // namespace TimeSource -namespace HardwareVersion { +namespace TrustedTimeNodeId { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace HardwareVersion - -namespace HardwareVersionString { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) -{ - uint8_t zclString[64 + 1]; - EmberAfStatus status = - emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); } - - VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 64); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(64 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[64 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, - ZCL_CHAR_STRING_ATTRIBUTE_TYPE); -} - -} // namespace HardwareVersionString - -namespace SoftwareVersion { - -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + else { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::NodeId value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_NODE_ID_ATTRIBUTE_TYPE); } -} // namespace SoftwareVersion - -namespace SoftwareVersionString { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) -{ - uint8_t zclString[64 + 1]; - EmberAfStatus status = - emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - - VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 64); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +EmberAfStatus SetNull(chip::EndpointId endpoint) { - static_assert(64 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[64 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, - ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_NODE_ID_ATTRIBUTE_TYPE); } -} // namespace SoftwareVersionString - -namespace ManufacturingDate { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) { - uint8_t zclString[16 + 1]; - EmberAfStatus status = - emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + if (value.IsNull()) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + return SetNull(endpoint); } - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 16); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) -{ - static_assert(16 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[16 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, - ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + return Set(endpoint, value.Value()); } -} // namespace ManufacturingDate +} // namespace TrustedTimeNodeId -namespace PartNumber { +namespace DefaultNtp { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - uint8_t zclString[32 + 1]; - EmberAfStatus status = - emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); + uint8_t zclString[128 + 1]; + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, zclString, sizeof(zclString)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); size_t length = emberAfStringLength(zclString); if (length == NumericAttributeTraits::kNullValue) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + return EMBER_ZCL_STATUS_SUCCESS; } + auto & span = value.SetNonNull(); - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 32); - value.reduce_size(length); + VerifyOrReturnError(span.size() == 128, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(span.data(), &zclString[1], 128); + span.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; + static_assert(128 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 128, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[128 + 1]; emberAfCopyInt8u(zclString, 0, static_cast(value.size())); memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, - ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -} // namespace PartNumber - -namespace ProductURL { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) -{ - uint8_t zclString[256 + 2]; - EmberAfStatus status = - emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfLongStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - - VerifyOrReturnError(value.size() == 256, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[2], 256); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +EmberAfStatus SetNull(chip::EndpointId endpoint) { - static_assert(256 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 256, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[256 + 2]; - emberAfCopyInt16u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[2], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, - ZCL_LONG_CHAR_STRING_ATTRIBUTE_TYPE); + uint8_t zclString[1] = { 0xFF }; + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -} // namespace ProductURL - -namespace ProductLabel { - -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) -{ - uint8_t zclString[64 + 1]; - EmberAfStatus status = - emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - - VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 64); - value.reduce_size(length); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) { - static_assert(64 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[64 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, - ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); } -} // namespace ProductLabel +} // namespace DefaultNtp -namespace SerialNumber { +namespace LocalTime { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - uint8_t zclString[32 + 1]; - EmberAfStatus status = - emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + if (Traits::IsNullValue(temp)) + { + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); + } + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_EPOCH_US_ATTRIBUTE_TYPE); +} - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 32); - value.reduce_size(length); - return status; +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_EPOCH_US_ATTRIBUTE_TYPE); } -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) + +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) { - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, - ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); } -} // namespace SerialNumber +} // namespace LocalTime -namespace Reachable { +namespace TimeZoneDatabase { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -9967,42 +5364,63 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace Reachable +} // namespace TimeZoneDatabase -namespace UniqueID { +namespace NtpServerPort { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { - uint8_t zclString[32 + 1]; - EmberAfStatus status = - emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + if (Traits::IsNullValue(temp)) + { + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); + } + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); +} - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 32); - value.reduce_size(length); - return status; +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) + +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) { - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, - ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); } -} // namespace UniqueID +} // namespace NtpServerPort namespace FeatureMap { @@ -10011,7 +5429,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10030,7 +5448,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } } // namespace FeatureMap @@ -10042,7 +5460,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10061,25 +5479,57 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } } // namespace ClusterRevision } // namespace Attributes -} // namespace BridgedDeviceBasicInformation +} // namespace TimeSynchronization -namespace Switch { +namespace BridgedDeviceBasicInformation { namespace Attributes { -namespace NumberOfPositions { +namespace VendorName { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - using Traits = NumericAttributeTraits; + uint8_t zclString[32 + 1]; + EmberAfStatus status = + emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 32); + value.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +{ + static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[32 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, + ZCL_CHAR_STRING_ATTRIBUTE_TYPE); +} + +} // namespace VendorName + +namespace VendorID { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::VendorId * value) +{ + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::Switch::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10088,9 +5538,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::VendorId value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -10098,19 +5548,83 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::Switch::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, writable, ZCL_VENDOR_ID_ATTRIBUTE_TYPE); +} + +} // namespace VendorID + +namespace ProductName { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +{ + uint8_t zclString[32 + 1]; + EmberAfStatus status = + emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 32); + value.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +{ + static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[32 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, + ZCL_CHAR_STRING_ATTRIBUTE_TYPE); +} + +} // namespace ProductName + +namespace NodeLabel { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +{ + uint8_t zclString[32 + 1]; + EmberAfStatus status = + emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 32); + value.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +{ + static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[32 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, + ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -} // namespace NumberOfPositions +} // namespace NodeLabel -namespace CurrentPosition { +namespace HardwareVersion { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::Switch::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10119,9 +5633,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -10129,50 +5643,51 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::Switch::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace CurrentPosition +} // namespace HardwareVersion -namespace MultiPressMax { +namespace HardwareVersionString { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::Switch::Id, Id, readable, sizeof(temp)); + uint8_t zclString[64 + 1]; + EmberAfStatus status = + emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - *value = Traits::StorageToWorking(temp); + + VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 64); + value.reduce_size(length); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::Switch::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); + static_assert(64 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[64 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, + ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -} // namespace MultiPressMax +} // namespace HardwareVersionString -namespace FeatureMap { +namespace SoftwareVersion { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::Switch::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10191,184 +5706,265 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::Switch::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); } -} // namespace FeatureMap +} // namespace SoftwareVersion -namespace ClusterRevision { +namespace SoftwareVersionString { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::Switch::Id, Id, readable, sizeof(temp)); + uint8_t zclString[64 + 1]; + EmberAfStatus status = + emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - *value = Traits::StorageToWorking(temp); + + VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 64); + value.reduce_size(length); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::Switch::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + static_assert(64 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[64 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, + ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace Switch - -namespace AdministratorCommissioning { -namespace Attributes { +} // namespace SoftwareVersionString -namespace WindowStatus { +namespace ManufacturingDate { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, readable, sizeof(temp)); + uint8_t zclString[16 + 1]; + EmberAfStatus status = + emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - *value = Traits::StorageToWorking(temp); + + VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 16); + value.reduce_size(length); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + static_assert(16 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[16 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, + ZCL_CHAR_STRING_ATTRIBUTE_TYPE); +} + +} // namespace ManufacturingDate + +namespace PartNumber { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +{ + uint8_t zclString[32 + 1]; + EmberAfStatus status = + emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); + + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 32); + value.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +{ + static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[32 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, + ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -} // namespace WindowStatus +} // namespace PartNumber -namespace AdminFabricIndex { +namespace ProductURL { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, readable, sizeof(temp)); + uint8_t zclString[256 + 2]; + EmberAfStatus status = + emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else + size_t length = emberAfLongStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) { - value.SetNonNull() = Traits::StorageToWorking(temp); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } + + VerifyOrReturnError(value.size() == 256, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[2], 256); + value.reduce_size(length); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::FabricIndex value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) + static_assert(256 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 256, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[256 + 2]; + emberAfCopyInt16u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[2], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, + ZCL_LONG_CHAR_STRING_ATTRIBUTE_TYPE); +} + +} // namespace ProductURL + +namespace ProductLabel { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +{ + uint8_t zclString[64 + 1]; + EmberAfStatus status = + emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, writable, ZCL_FABRIC_IDX_ATTRIBUTE_TYPE); -} -EmberAfStatus SetNull(chip::EndpointId endpoint) + VerifyOrReturnError(value.size() == 64, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 64); + value.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, writable, ZCL_FABRIC_IDX_ATTRIBUTE_TYPE); + static_assert(64 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 64, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[64 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, + ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +} // namespace ProductLabel + +namespace SerialNumber { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - if (value.IsNull()) + uint8_t zclString[32 + 1]; + EmberAfStatus status = + emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) { - return SetNull(endpoint); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - return Set(endpoint, value.Value()); + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 32); + value.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +{ + static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[32 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, + ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -} // namespace AdminFabricIndex +} // namespace SerialNumber -namespace AdminVendorId { +namespace Reachable { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { - value.SetNonNull() = Traits::StorageToWorking(temp); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } + *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) +EmberAfStatus Set(chip::EndpointId endpoint, bool value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} +} // namespace Reachable -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +namespace UniqueID { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) { - if (value.IsNull()) + uint8_t zclString[32 + 1]; + EmberAfStatus status = + emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) { - return SetNull(endpoint); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - return Set(endpoint, value.Value()); + VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 32); + value.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +{ + static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[32 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, zclString, + ZCL_CHAR_STRING_ATTRIBUTE_TYPE); } -} // namespace AdminVendorId +} // namespace UniqueID namespace FeatureMap { @@ -10377,7 +5973,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10396,7 +5992,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } } // namespace FeatureMap @@ -10408,7 +6004,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10427,25 +6023,25 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::BridgedDeviceBasicInformation::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } } // namespace ClusterRevision } // namespace Attributes -} // namespace AdministratorCommissioning +} // namespace BridgedDeviceBasicInformation -namespace OperationalCredentials { +namespace Switch { namespace Attributes { -namespace SupportedFabrics { +namespace NumberOfPositions { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::Switch::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10464,19 +6060,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::Switch::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } -} // namespace SupportedFabrics +} // namespace NumberOfPositions -namespace CommissionedFabrics { +namespace CurrentPosition { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::Switch::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10495,19 +6091,19 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::Switch::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } -} // namespace CommissionedFabrics +} // namespace CurrentPosition -namespace CurrentFabricIndex { +namespace MultiPressMax { EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::Switch::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10526,10 +6122,10 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::Switch::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } -} // namespace CurrentFabricIndex +} // namespace MultiPressMax namespace FeatureMap { @@ -10538,7 +6134,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::Switch::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10557,7 +6153,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::Switch::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } } // namespace FeatureMap @@ -10569,7 +6165,7 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::Switch::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10588,25 +6184,56 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::Switch::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } } // namespace ClusterRevision } // namespace Attributes -} // namespace OperationalCredentials +} // namespace Switch -namespace GroupKeyManagement { +namespace AdministratorCommissioning { namespace Attributes { -namespace MaxGroupsPerFabric { +namespace FeatureMap { + +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + *value = Traits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); +} + +} // namespace FeatureMap + +namespace ClusterRevision { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GroupKeyManagement::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10625,19 +6252,56 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GroupKeyManagement::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::AdministratorCommissioning::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); +} + +} // namespace ClusterRevision + +} // namespace Attributes +} // namespace AdministratorCommissioning + +namespace OperationalCredentials { +namespace Attributes { + +namespace FeatureMap { + +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + *value = Traits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); } -} // namespace MaxGroupsPerFabric +} // namespace FeatureMap -namespace MaxGroupKeysPerFabric { +namespace ClusterRevision { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::GroupKeyManagement::Id, Id, readable, sizeof(temp)); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { @@ -10656,10 +6320,16 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::GroupKeyManagement::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::OperationalCredentials::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } -} // namespace MaxGroupKeysPerFabric +} // namespace ClusterRevision + +} // namespace Attributes +} // namespace OperationalCredentials + +namespace GroupKeyManagement { +namespace Attributes { namespace FeatureMap { @@ -28955,68 +24625,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) } // namespace TimedWriteBoolean -namespace GeneralErrorBoolean { - -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::UnitTesting::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, bool value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::UnitTesting::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); -} - -} // namespace GeneralErrorBoolean - -namespace ClusterErrorBoolean { - -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::UnitTesting::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = Traits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, bool value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::UnitTesting::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); -} - -} // namespace ClusterErrorBoolean - namespace Unsupported { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index 510d8bd4cc582b..2d919d595c757b 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -410,21 +410,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace AccessControl { namespace Attributes { -namespace SubjectsPerAccessControlEntry { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace SubjectsPerAccessControlEntry - -namespace TargetsPerAccessControlEntry { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace TargetsPerAccessControlEntry - -namespace AccessControlEntriesPerFabric { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace AccessControlEntriesPerFabric - namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); @@ -462,86 +447,11 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace BasicInformation { namespace Attributes { -namespace DataModelRevision { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace DataModelRevision - -namespace VendorName { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // char_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); -} // namespace VendorName - -namespace VendorID { -EmberAfStatus Get(chip::EndpointId endpoint, chip::VendorId * value); // vendor_id -EmberAfStatus Set(chip::EndpointId endpoint, chip::VendorId value); -} // namespace VendorID - -namespace ProductName { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // char_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); -} // namespace ProductName - -namespace ProductID { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace ProductID - namespace NodeLabel { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // char_string EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); } // namespace NodeLabel -namespace Location { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // char_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); -} // namespace Location - -namespace HardwareVersion { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace HardwareVersion - -namespace HardwareVersionString { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // char_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); -} // namespace HardwareVersionString - -namespace SoftwareVersion { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace SoftwareVersion - -namespace SoftwareVersionString { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // char_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); -} // namespace SoftwareVersionString - -namespace ManufacturingDate { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // char_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); -} // namespace ManufacturingDate - -namespace PartNumber { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // char_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); -} // namespace PartNumber - -namespace ProductURL { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // long_char_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); -} // namespace ProductURL - -namespace ProductLabel { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // char_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); -} // namespace ProductLabel - -namespace SerialNumber { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // char_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); -} // namespace SerialNumber - namespace LocalConfigDisabled { EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean EmberAfStatus Set(chip::EndpointId endpoint, bool value); @@ -552,11 +462,6 @@ EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean EmberAfStatus Set(chip::EndpointId endpoint, bool value); } // namespace Reachable -namespace UniqueID { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // char_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); -} // namespace UniqueID - namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); @@ -890,23 +795,6 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); } // namespace Breadcrumb -namespace RegulatoryConfig { -EmberAfStatus Get(chip::EndpointId endpoint, - chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType * value); // RegulatoryLocationType -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType value); -} // namespace RegulatoryConfig - -namespace LocationCapability { -EmberAfStatus Get(chip::EndpointId endpoint, - chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType * value); // RegulatoryLocationType -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType value); -} // namespace LocationCapability - -namespace SupportsConcurrentConnection { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean -EmberAfStatus Set(chip::EndpointId endpoint, bool value); -} // namespace SupportsConcurrentConnection - namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); @@ -1000,26 +888,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace GeneralDiagnostics { namespace Attributes { -namespace RebootCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace RebootCount - -namespace UpTime { -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -} // namespace UpTime - -namespace TotalOperationalHours { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TotalOperationalHours - -namespace BootReason { -EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::GeneralDiagnostics::BootReasonEnum * value); // BootReasonEnum -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::GeneralDiagnostics::BootReasonEnum value); -} // namespace BootReason - namespace TestEventTriggersEnabled { EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean EmberAfStatus Set(chip::EndpointId endpoint, bool value); @@ -1041,21 +909,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace SoftwareDiagnostics { namespace Attributes { -namespace CurrentHeapFree { -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -} // namespace CurrentHeapFree - -namespace CurrentHeapUsed { -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -} // namespace CurrentHeapUsed - -namespace CurrentHeapHighWatermark { -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -} // namespace CurrentHeapHighWatermark - namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); @@ -1072,328 +925,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace ThreadNetworkDiagnostics { namespace Attributes { -namespace Channel { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace Channel - -namespace RoutingRole { -EmberAfStatus Get(chip::EndpointId endpoint, - DataModel::Nullable & value); // RoutingRole -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::ThreadNetworkDiagnostics::RoutingRole value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, - const chip::app::DataModel::Nullable & value); -} // namespace RoutingRole - -namespace NetworkName { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // char_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace NetworkName - -namespace PanId { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace PanId - -namespace ExtendedPanId { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace ExtendedPanId - -namespace MeshLocalPrefix { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // octet_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace MeshLocalPrefix - -namespace OverrunCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -} // namespace OverrunCount - -namespace PartitionId { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace PartitionId - -namespace Weighting { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int8u -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace Weighting - -namespace DataVersion { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int8u -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace DataVersion - -namespace StableDataVersion { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int8u -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace StableDataVersion - -namespace LeaderRouterId { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int8u -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace LeaderRouterId - -namespace DetachedRoleCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace DetachedRoleCount - -namespace ChildRoleCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace ChildRoleCount - -namespace RouterRoleCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace RouterRoleCount - -namespace LeaderRoleCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace LeaderRoleCount - -namespace AttachAttemptCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace AttachAttemptCount - -namespace PartitionIdChangeCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace PartitionIdChangeCount - -namespace BetterPartitionAttachAttemptCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace BetterPartitionAttachAttemptCount - -namespace ParentChangeCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace ParentChangeCount - -namespace TxTotalCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxTotalCount - -namespace TxUnicastCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxUnicastCount - -namespace TxBroadcastCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxBroadcastCount - -namespace TxAckRequestedCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxAckRequestedCount - -namespace TxAckedCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxAckedCount - -namespace TxNoAckRequestedCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxNoAckRequestedCount - -namespace TxDataCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxDataCount - -namespace TxDataPollCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxDataPollCount - -namespace TxBeaconCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxBeaconCount - -namespace TxBeaconRequestCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxBeaconRequestCount - -namespace TxOtherCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxOtherCount - -namespace TxRetryCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxRetryCount - -namespace TxDirectMaxRetryExpiryCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxDirectMaxRetryExpiryCount - -namespace TxIndirectMaxRetryExpiryCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxIndirectMaxRetryExpiryCount - -namespace TxErrCcaCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxErrCcaCount - -namespace TxErrAbortCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxErrAbortCount - -namespace TxErrBusyChannelCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace TxErrBusyChannelCount - -namespace RxTotalCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxTotalCount - -namespace RxUnicastCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxUnicastCount - -namespace RxBroadcastCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxBroadcastCount - -namespace RxDataCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxDataCount - -namespace RxDataPollCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxDataPollCount - -namespace RxBeaconCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxBeaconCount - -namespace RxBeaconRequestCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxBeaconRequestCount - -namespace RxOtherCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxOtherCount - -namespace RxAddressFilteredCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxAddressFilteredCount - -namespace RxDestAddrFilteredCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxDestAddrFilteredCount - -namespace RxDuplicatedCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxDuplicatedCount - -namespace RxErrNoFrameCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxErrNoFrameCount - -namespace RxErrUnknownNeighborCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxErrUnknownNeighborCount - -namespace RxErrInvalidSrcAddrCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxErrInvalidSrcAddrCount - -namespace RxErrSecCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxErrSecCount - -namespace RxErrFcsCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxErrFcsCount - -namespace RxErrOtherCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -} // namespace RxErrOtherCount - -namespace ActiveTimestamp { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace ActiveTimestamp - -namespace PendingTimestamp { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace PendingTimestamp - -namespace Delay { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace Delay - -namespace ChannelPage0Mask { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // octet_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace ChannelPage0Mask - namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); @@ -1410,101 +941,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace WiFiNetworkDiagnostics { namespace Attributes { -namespace Bssid { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // octet_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace Bssid - -namespace SecurityType { -EmberAfStatus Get(chip::EndpointId endpoint, - DataModel::Nullable & value); // SecurityTypeEnum -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, - const chip::app::DataModel::Nullable & value); -} // namespace SecurityType - -namespace WiFiVersion { -EmberAfStatus Get(chip::EndpointId endpoint, - DataModel::Nullable & value); // WiFiVersionEnum -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, - const chip::app::DataModel::Nullable & value); -} // namespace WiFiVersion - -namespace ChannelNumber { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace ChannelNumber - -namespace Rssi { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int8s -EmberAfStatus Set(chip::EndpointId endpoint, int8_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace Rssi - -namespace BeaconLostCount { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace BeaconLostCount - -namespace BeaconRxCount { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace BeaconRxCount - -namespace PacketMulticastRxCount { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace PacketMulticastRxCount - -namespace PacketMulticastTxCount { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace PacketMulticastTxCount - -namespace PacketUnicastRxCount { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace PacketUnicastRxCount - -namespace PacketUnicastTxCount { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int32u -EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace PacketUnicastTxCount - -namespace CurrentMaxRate { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace CurrentMaxRate - -namespace OverrunCount { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace OverrunCount - namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); @@ -1521,59 +957,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace EthernetNetworkDiagnostics { namespace Attributes { -namespace PHYRate { -EmberAfStatus Get(chip::EndpointId endpoint, - DataModel::Nullable & value); // PHYRateEnum -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, - const chip::app::DataModel::Nullable & value); -} // namespace PHYRate - -namespace FullDuplex { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // boolean -EmberAfStatus Set(chip::EndpointId endpoint, bool value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace FullDuplex - -namespace PacketRxCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -} // namespace PacketRxCount - -namespace PacketTxCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -} // namespace PacketTxCount - -namespace TxErrCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -} // namespace TxErrCount - -namespace CollisionCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -} // namespace CollisionCount - -namespace OverrunCount { -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -} // namespace OverrunCount - -namespace CarrierDetect { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // boolean -EmberAfStatus Set(chip::EndpointId endpoint, bool value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace CarrierDetect - -namespace TimeSinceReset { -EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u -EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); -} // namespace TimeSinceReset - namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); @@ -1778,27 +1161,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace AdministratorCommissioning { namespace Attributes { -namespace WindowStatus { -EmberAfStatus -Get(chip::EndpointId endpoint, - chip::app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum * value); // CommissioningWindowStatusEnum -EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum value); -} // namespace WindowStatus - -namespace AdminFabricIndex { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // fabric_idx -EmberAfStatus Set(chip::EndpointId endpoint, chip::FabricIndex value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace AdminFabricIndex - -namespace AdminVendorId { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace AdminVendorId - namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); @@ -1815,21 +1177,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace OperationalCredentials { namespace Attributes { -namespace SupportedFabrics { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // int8u -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); -} // namespace SupportedFabrics - -namespace CommissionedFabrics { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // int8u -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); -} // namespace CommissionedFabrics - -namespace CurrentFabricIndex { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // int8u -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); -} // namespace CurrentFabricIndex - namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); @@ -1846,16 +1193,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace GroupKeyManagement { namespace Attributes { -namespace MaxGroupsPerFabric { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace MaxGroupsPerFabric - -namespace MaxGroupKeysPerFabric { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace MaxGroupKeysPerFabric - namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); @@ -4892,16 +4229,6 @@ EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean EmberAfStatus Set(chip::EndpointId endpoint, bool value); } // namespace TimedWriteBoolean -namespace GeneralErrorBoolean { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean -EmberAfStatus Set(chip::EndpointId endpoint, bool value); -} // namespace GeneralErrorBoolean - -namespace ClusterErrorBoolean { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean -EmberAfStatus Set(chip::EndpointId endpoint, bool value); -} // namespace ClusterErrorBoolean - namespace Unsupported { EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean EmberAfStatus Set(chip::EndpointId endpoint, bool value); From 34b2a8040ce4305064cfff740fafeeec3032c030 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Tue, 2 May 2023 17:07:49 +0200 Subject: [PATCH 069/200] Add some options to dump the message expected by the Test Harness (#26054) --- .../matter_yamltests/hooks.py | 21 ++++-- .../matter_yamltests/parser.py | 8 ++- .../matter_yamltests/runner.py | 8 +-- .../matter_yamltests/yaml_loader.py | 6 +- .../py_matter_yamltests/test_yaml_loader.py | 49 +++++++------- scripts/tests/yaml/chiptool.py | 1 + scripts/tests/yaml/runner.py | 14 ++-- scripts/tests/yaml/tests_logger.py | 64 ++++++++++++++++--- 8 files changed, 120 insertions(+), 51 deletions(-) diff --git a/scripts/py_matter_yamltests/matter_yamltests/hooks.py b/scripts/py_matter_yamltests/matter_yamltests/hooks.py index f471af83408589..7e779420759e6c 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/hooks.py +++ b/scripts/py_matter_yamltests/matter_yamltests/hooks.py @@ -98,12 +98,15 @@ def stop(self, duration: int): """ pass - def test_start(self, name: str, count: int): + def test_start(self, filename: str, name: str, count: int): """ This method is called when the runner starts running a single test. Parameters ---------- + filename: str + The name of the file containing the test that is starting. + name: str The name of the test that is starting. @@ -126,7 +129,7 @@ def test_stop(self, exception: Exception, duration: int): """ pass - def step_skipped(self, name: str): + def step_skipped(self, name: str, expression: str): """ This method is called when running a step is skipped. @@ -134,6 +137,9 @@ def step_skipped(self, name: str): ---------- name: str The name of the test step that is skipped. + + expression: str + The PICS expression that results in the test step being skipped. """ pass @@ -148,7 +154,7 @@ def step_start(self, name: str): """ pass - def step_success(self, logger, logs, duration: int): + def step_success(self, logger, logs, duration: int, request): """ This method is called when running a step succeeds. @@ -162,10 +168,13 @@ def step_success(self, logger, logs, duration: int): duration: int How long it took to run the test step, in milliseconds. + + request: + The original request as defined by the test step. """ pass - def step_failure(self, logger, logs, duration: int, expected, received): + def step_failure(self, logger, logs, duration: int, request, received): """ This method is called when running a step fails. @@ -180,8 +189,8 @@ def step_failure(self, logger, logs, duration: int, expected, received): duration: int How long it took to run the test step, in milliseconds. - expected: - The expected response as defined by the test step. + request: + The original request as defined by the test step. received: The received response. diff --git a/scripts/py_matter_yamltests/matter_yamltests/parser.py b/scripts/py_matter_yamltests/matter_yamltests/parser.py index 8f9b38a85f63f8..1affdf21fd6564 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/parser.py +++ b/scripts/py_matter_yamltests/matter_yamltests/parser.py @@ -180,6 +180,7 @@ def __init__(self, test: dict, config: dict, definitions: SpecDefinitions, pics_ self.attribute = _value_or_none(test, 'attribute') self.event = _value_or_none(test, 'event') self.endpoint = _value_or_config(test, 'endpoint', config) + self.pics = _value_or_none(test, 'PICS') self.is_pics_enabled = pics_checker.check(_value_or_none(test, 'PICS')) self.identity = _value_or_none(test, 'identity') @@ -565,6 +566,10 @@ def wait_for(self): def event_number(self): return self._test.event_number + @property + def pics(self): + return self._test.pics + def post_process_response(self, received_responses): result = PostProcessResponseResult() @@ -955,11 +960,12 @@ class TestParserConfig: class TestParser: def __init__(self, test_file: str, parser_config: TestParserConfig = TestParserConfig()): yaml_loader = YamlLoader() - name, pics, config, tests = yaml_loader.load(test_file) + filename, name, pics, config, tests = yaml_loader.load(test_file) self.__apply_config_override(config, parser_config.config_override) self.__apply_legacy_config(config) + self.filename = filename self.name = name self.PICS = pics self.tests = YamlTests( diff --git a/scripts/py_matter_yamltests/matter_yamltests/runner.py b/scripts/py_matter_yamltests/matter_yamltests/runner.py index 4c5db7a9d2b8d8..884d2c249467df 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/runner.py +++ b/scripts/py_matter_yamltests/matter_yamltests/runner.py @@ -157,12 +157,12 @@ async def _run(self, parser: TestParser, config: TestRunnerConfig): await self.start() hooks = config.hooks - hooks.test_start(parser.name, parser.tests.count) + hooks.test_start(parser.filename, parser.name, parser.tests.count) test_duration = 0 for idx, request in enumerate(parser.tests): if not request.is_pics_enabled: - hooks.step_skipped(request.label) + hooks.step_skipped(request.label, request.pics) continue elif not config.adapter: hooks.step_start(request.label) @@ -185,9 +185,9 @@ async def _run(self, parser: TestParser, config: TestRunnerConfig): if logger.is_failure(): hooks.step_failure(logger, logs, duration, - request.responses, responses) + request, responses) else: - hooks.step_success(logger, logs, duration) + hooks.step_success(logger, logs, duration, request) if logger.is_failure() and config.options.stop_on_error: status = False diff --git a/scripts/py_matter_yamltests/matter_yamltests/yaml_loader.py b/scripts/py_matter_yamltests/matter_yamltests/yaml_loader.py index 543de252dc3820..2332419c0d10ee 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/yaml_loader.py +++ b/scripts/py_matter_yamltests/matter_yamltests/yaml_loader.py @@ -25,6 +25,8 @@ except: from yaml import SafeLoader +import os + import yaml @@ -32,12 +34,14 @@ class YamlLoader: """This class loads a file from the disk and validates that the content is a well formed yaml test.""" def load(self, yaml_file: str) -> tuple[str, Union[list, str], dict, list]: + filename = '' name = '' pics = None config = {} tests = [] if yaml_file: + filename = os.path.splitext(os.path.basename(yaml_file))[0] with open(yaml_file) as f: loader = SafeLoader add_yaml_support_for_scientific_notation_without_dot(loader) @@ -50,7 +54,7 @@ def load(self, yaml_file: str) -> tuple[str, Union[list, str], dict, list]: config = content.get('config', {}) tests = content.get('tests', []) - return (name, pics, config, tests) + return (filename, name, pics, config, tests) def __check_content(self, content): schema = { diff --git a/scripts/py_matter_yamltests/test_yaml_loader.py b/scripts/py_matter_yamltests/test_yaml_loader.py index d67dd062667ba1..1e748e317a3082 100644 --- a/scripts/py_matter_yamltests/test_yaml_loader.py +++ b/scripts/py_matter_yamltests/test_yaml_loader.py @@ -66,7 +66,8 @@ def test_missing_file(self): content = None - name, pics, config, tests = load(content) + filename, name, pics, config, tests = load(content) + self.assertEqual(filename, '') self.assertEqual(name, '') self.assertEqual(pics, None) self.assertEqual(config, {}) @@ -77,7 +78,8 @@ def test_empty_file(self): content = '' - name, pics, config, tests = load(content) + filename, name, pics, config, tests = load(content) + self.assertEqual(name, '') self.assertEqual(name, '') self.assertEqual(pics, None) self.assertEqual(config, {}) @@ -99,7 +101,7 @@ def test_key_name(self): name: Test Name ''' - name, _, _, _ = load(content) + _, name, _, _, _ = load(content) self.assertEqual(name, 'Test Name') def test_key_name_wrong_values(self): @@ -117,7 +119,7 @@ def test_key_pics_string(self): PICS: OO.S ''' - _, pics, _, _ = load(content) + _, _, pics, _, _ = load(content) self.assertEqual(pics, 'OO.S') def test_key_pics_list(self): @@ -129,7 +131,7 @@ def test_key_pics_list(self): - OO.C ''' - _, pics, _, _ = load(content) + _, _, pics, _, _ = load(content) self.assertEqual(pics, ['OO.S', 'OO.C']) def test_key_pics_wrong_values(self): @@ -149,7 +151,7 @@ def test_key_config(self): name2: value2 ''' - _, _, config, _ = load(content) + _, _, _, config, _ = load(content) self.assertEqual(config, {'name': 'value', 'name2': 'value2'}) def test_key_config_wrong_values(self): @@ -169,7 +171,7 @@ def test_key_tests(self): - label: Test2 ''' - _, _, _, tests = load(content) + _, _, _, _, tests = load(content) self.assertEqual(tests, [{'label': 'Test1'}, {'label': 'Test2'}]) def test_key_tests_wrong_values(self): @@ -202,7 +204,7 @@ def test_key_tests_step_bool_keys(self): wrong_values = self._get_wrong_values([bool], spaces=6) for key in keys: - _, _, _, tests = load(content.format(key=key, value=True)) + _, _, _, _, tests = load(content.format(key=key, value=True)) self.assertEqual(tests, [{key: True}]) for value in wrong_values: @@ -232,7 +234,7 @@ def test_key_tests_step_str_keys(self): wrong_values = self._get_wrong_values([str], spaces=6) for key in keys: - _, _, _, tests = load(content.format(key=key, value='a string')) + _, _, _, _, tests = load(content.format(key=key, value='a string')) self.assertEqual(tests, [{key: 'a string'}]) for value in wrong_values: @@ -256,7 +258,7 @@ def test_key_tests_step_int_keys(self): wrong_values = self._get_wrong_values([int], spaces=6) for key in keys: - _, _, _, tests = load(content.format(key=key, value=1)) + _, _, _, _, tests = load(content.format(key=key, value=1)) self.assertEqual(tests, [{key: 1}]) for value in wrong_values: @@ -276,7 +278,8 @@ def test_key_tests_step_dict_keys(self): ' value: True\n') wrong_values = self._get_wrong_values([dict], spaces=6) for key in keys: - _, _, _, tests = load(content.format(key=key, value=valid_value)) + _, _, _, _, tests = load( + content.format(key=key, value=valid_value)) self.assertEqual(tests, [{key: {'value': True}}]) for value in wrong_values: @@ -291,12 +294,12 @@ def test_key_tests_step_response_key(self): value = ('\n' ' value: True\n') - _, _, _, tests = load(content.format(value=value)) + _, _, _, _, tests = load(content.format(value=value)) self.assertEqual(tests, [{'response': {'value': True}}]) value = ('\n' ' - value: True\n') - _, _, _, tests = load(content.format(value=value)) + _, _, _, _, tests = load(content.format(value=value)) self.assertEqual(tests, [{'response': [{'value': True}]}]) wrong_values = self._get_wrong_values([dict, list], spaces=6) @@ -310,10 +313,10 @@ def test_key_tests_step_event_number_key(self): content = ('tests:\n' ' - eventNumber: {value}') - _, _, _, tests = load(content.format(value=1)) + _, _, _, _, tests = load(content.format(value=1)) self.assertEqual(tests, [{'eventNumber': 1}]) - _, _, _, tests = load(content.format(value='TestKey')) + _, _, _, _, tests = load(content.format(value='TestKey')) self.assertEqual(tests, [{'eventNumber': 'TestKey'}]) wrong_values = self._get_wrong_values([str, int], spaces=6) @@ -328,7 +331,7 @@ def test_key_tests_step_verification_key(self): ' - verification: {value}\n' ' disabled: true') - _, _, _, tests = load(content.format(value='Test Sentence')) + _, _, _, _, tests = load(content.format(value='Test Sentence')) self.assertEqual( tests, [{'verification': 'Test Sentence', 'disabled': True}]) @@ -392,7 +395,7 @@ def test_key_tests_step_rule_step_with_verification_should_be_disabled_or_intera disabled: true ''' - _, _, _, tests = load(content) + _, _, _, _, tests = load(content) self.assertEqual(tests, [ {'label': 'A Test Name', 'verification': 'A verification sentence', 'disabled': True}]) @@ -412,7 +415,7 @@ def test_key_tests_step_rule_step_with_verification_should_be_disabled_or_intera command: UserPrompt ''' - _, _, _, tests = load(content) + _, _, _, _, tests = load(content) self.assertEqual(tests, [ {'label': 'A Test Name', 'verification': 'A verification sentence', 'command': 'UserPrompt'}]) @@ -427,7 +430,7 @@ def test_key_tests_step_response_key_values_key(self): ' - response:\n' ' values: {value}') - _, _, _, tests = load(content.format(value=[])) + _, _, _, _, tests = load(content.format(value=[])) self.assertEqual(tests, [{'response': {'values': []}}]) wrong_values = self._get_wrong_values([list], spaces=8) @@ -442,7 +445,7 @@ def test_key_tests_step_response_key_error_key(self): ' - response:\n' ' error: {value}') - _, _, _, tests = load(content.format(value='AnError')) + _, _, _, _, tests = load(content.format(value='AnError')) self.assertEqual(tests, [{'response': {'error': 'AnError'}}]) wrong_values = self._get_wrong_values([str], spaces=8) @@ -457,7 +460,7 @@ def test_key_tests_step_response_key_cluster_error_key(self): ' - response:\n' ' clusterError: {value}') - _, _, _, tests = load(content.format(value=1)) + _, _, _, _, tests = load(content.format(value=1)) self.assertEqual(tests, [{'response': {'clusterError': 1}}]) wrong_values = self._get_wrong_values([int], spaces=8) @@ -472,7 +475,7 @@ def test_key_tests_step_response_key_constraints_key(self): ' - response:\n' ' constraints: {value}') - _, _, _, tests = load(content.format(value={})) + _, _, _, _, tests = load(content.format(value={})) self.assertEqual(tests, [{'response': {'constraints': {}}}]) wrong_values = self._get_wrong_values([dict], spaces=8) @@ -487,7 +490,7 @@ def test_key_tests_step_response_key_save_as_key(self): ' - response:\n' ' saveAs: {value}') - _, _, _, tests = load(content.format(value='AKey')) + _, _, _, _, tests = load(content.format(value='AKey')) self.assertEqual(tests, [{'response': {'saveAs': 'AKey'}}]) wrong_values = self._get_wrong_values([str], spaces=8) diff --git a/scripts/tests/yaml/chiptool.py b/scripts/tests/yaml/chiptool.py index c5d6724b1459cd..d47a4d22d32882 100755 --- a/scripts/tests/yaml/chiptool.py +++ b/scripts/tests/yaml/chiptool.py @@ -85,6 +85,7 @@ def chiptool_runner_options(f): CONTEXT_SETTINGS['ignore_unknown_options'] = True +CONTEXT_SETTINGS['default_map']['chiptool']['use_test_harness_log_format'] = True @click.command(context_settings=CONTEXT_SETTINGS) diff --git a/scripts/tests/yaml/runner.py b/scripts/tests/yaml/runner.py index 9889976cf9e002..7ccc6cf50253ea 100755 --- a/scripts/tests/yaml/runner.py +++ b/scripts/tests/yaml/runner.py @@ -71,6 +71,8 @@ def test_runner_options(f): help='Show additional logs provided by the adapter.')(f) f = click.option('--show_adapter_logs_on_error', type=bool, default=True, show_default=True, help='Show additional logs provided by the adapter on error.')(f) + f = click.option('--use_test_harness_log_format', type=bool, default=False, show_default=True, + help='Use the test harness log format.')(f) return f @@ -261,11 +263,11 @@ def dry_run(parser_group: ParserGroup): @runner_base.command() @test_runner_options @pass_parser_group -def run(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop_on_warning: bool, stop_at_number: int, show_adapter_logs: bool, show_adapter_logs_on_error: bool): +def run(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop_on_warning: bool, stop_at_number: int, show_adapter_logs: bool, show_adapter_logs_on_error: bool, use_test_harness_log_format: bool): """Run the test suite.""" adapter = __import__(adapter, fromlist=[None]).Adapter(parser_group.builder_config.parser_config.definitions) runner_options = TestRunnerOptions(stop_on_error, stop_on_warning, stop_at_number) - runner_hooks = TestRunnerLogger(show_adapter_logs, show_adapter_logs_on_error) + runner_hooks = TestRunnerLogger(show_adapter_logs, show_adapter_logs_on_error, use_test_harness_log_format) runner_config = TestRunnerConfig(adapter, parser_group.pseudo_clusters, runner_options, runner_hooks) runner = TestRunner() @@ -276,11 +278,11 @@ def run(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop_on_wa @test_runner_options @websocket_runner_options @pass_parser_group -def websocket(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop_on_warning: bool, stop_at_number: int, show_adapter_logs: bool, show_adapter_logs_on_error: bool, server_address: str, server_port: int, server_path: str, server_name: str, server_arguments: str): +def websocket(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop_on_warning: bool, stop_at_number: int, show_adapter_logs: bool, show_adapter_logs_on_error: bool, use_test_harness_log_format: bool, server_address: str, server_port: int, server_path: str, server_name: str, server_arguments: str): """Run the test suite using websockets.""" adapter = __import__(adapter, fromlist=[None]).Adapter(parser_group.builder_config.parser_config.definitions) runner_options = TestRunnerOptions(stop_on_error, stop_on_warning, stop_at_number) - runner_hooks = TestRunnerLogger(show_adapter_logs, show_adapter_logs_on_error) + runner_hooks = TestRunnerLogger(show_adapter_logs, show_adapter_logs_on_error, use_test_harness_log_format) runner_config = TestRunnerConfig(adapter, parser_group.pseudo_clusters, runner_options, runner_hooks) if server_path is None and server_name: @@ -299,11 +301,11 @@ def websocket(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop @test_runner_options @chip_repl_runner_options @pass_parser_group -def chip_repl(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop_on_warning: bool, stop_at_number: int, show_adapter_logs: bool, show_adapter_logs_on_error: bool, runner: str, repl_storage_path: str, commission_on_network_dut: bool): +def chip_repl(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop_on_warning: bool, stop_at_number: int, show_adapter_logs: bool, show_adapter_logs_on_error: bool, use_test_harness_log_format: bool, runner: str, repl_storage_path: str, commission_on_network_dut: bool): """Run the test suite using chip-repl.""" adapter = __import__(adapter, fromlist=[None]).Adapter(parser_group.builder_config.parser_config.definitions) runner_options = TestRunnerOptions(stop_on_error, stop_on_warning, stop_at_number) - runner_hooks = TestRunnerLogger(show_adapter_logs, show_adapter_logs_on_error) + runner_hooks = TestRunnerLogger(show_adapter_logs, show_adapter_logs_on_error, use_test_harness_log_format) runner_config = TestRunnerConfig(adapter, parser_group.pseudo_clusters, runner_options, runner_hooks) runner = __import__(runner, fromlist=[None]).Runner(repl_storage_path, commission_on_network_dut) diff --git a/scripts/tests/yaml/tests_logger.py b/scripts/tests/yaml/tests_logger.py index 4a0bd553a03047..bdfed70030fd83 100755 --- a/scripts/tests/yaml/tests_logger.py +++ b/scripts/tests/yaml/tests_logger.py @@ -128,11 +128,23 @@ class RunnerStrings: error_header = click.style('\t\t Error at step {index}:', fg='white', bold=True) error_line = click.style('\t\t {error_line}', fg='white') + test_harness_test_start = '\t\t***** Test Start : {filename}' + test_harness_test_stop_success = '\t\t***** Test Complete: {filename}' + test_harness_step_skipped = '\t\t**** Skipping: {expression} == false' + test_harness_step_start = '\t\t***** Test Step {index} : {name}' + test_harness_step_failure = '\t\t***** Test Failure : {message}' + test_harness_setup_device_connection_success = '\t\t**** Test Setup: Device Connected' + test_harness_setup_device_connection_failure = '\t\t**** Test Setup: Device Connection Failure [deviceId={deviceId}. Error {message}]' + log = '\t\t{message}' + user_prompt = '\t\tUSER_PROMPT: {message}' + class TestRunnerLogger(TestRunnerHooks): - def __init__(self, show_adapter_logs: bool = False, show_adapter_logs_on_error: bool = True): + def __init__(self, show_adapter_logs: bool = False, show_adapter_logs_on_error: bool = True, use_test_harness_log_format: bool = False): self.__show_adapter_logs = show_adapter_logs self.__show_adapter_logs_on_error = show_adapter_logs_on_error + self.__use_test_harness_log_format = use_test_harness_log_format + self.__filename = None self.__index = 1 self.__successes = 0 self.__warnings = 0 @@ -144,14 +156,17 @@ def __init__(self, show_adapter_logs: bool = False, show_adapter_logs_on_error: def start(self, count: int): print(self.__strings.start) - pass def stop(self, duration: int): print(self.__strings.stop.format(runned=self.__runned, skipped=self.__skipped, duration=duration)) - def test_start(self, name: str, count: int): + def test_start(self, filename: str, name: str, count: int): print(self.__strings.test_start.format(name=click.style(name, bold=True), count=click.style(count, bold=True))) + if self.__use_test_harness_log_format: + self.__filename = filename + print(self.__strings.test_harness_test_start.format(filename=filename)) + def test_stop(self, duration: int): if self.__errors: state = _FAILURE @@ -160,18 +175,27 @@ def test_stop(self, duration: int): else: state = _SUCCESS + if self.__use_test_harness_log_format and (state == _SUCCESS or state == _WARNING): + print(self.__strings.test_harness_test_stop_success.format(filename=self.__filename)) + successes = click.style(self.__successes, bold=True) errors = click.style(self.__errors, bold=True) warnings = click.style(self.__warnings, bold=True) print(self.__strings.test_stop.format(state=state, successes=successes, errors=errors, warnings=warnings, duration=duration)) - def step_skipped(self, name: str): + def step_skipped(self, name: str, expression: str): print(self.__strings.step_skipped.format(index=self.__index, name=_strikethrough(name))) self.__index += 1 self.__skipped += 1 + if self.__use_test_harness_log_format: + print(self.__strings.test_harness_step_skipped.format(expression=expression)) + def step_start(self, name: str): + if self.__use_test_harness_log_format: + print(self.__strings.test_harness_step_start.format(index=self.__index, name=name)) + print(self.__strings.step_start.format(index=self.__index, name=click.style(name, bold=True)), end='') # flushing stdout such that the previous print statement is visible on the screen for long running tasks. sys.stdout.flush() @@ -183,10 +207,19 @@ def step_unknown(self): self.__runned += 1 - def step_success(self, logger, logs, duration: int): + def step_success(self, logger, logs, duration: int, request): print(self.__strings.step_result.format(state=_SUCCESS, duration=duration)) self.__print_results(logger) + if self.__use_test_harness_log_format: + if request.command == 'WaitForCommissionee': + print(self.__strings.test_harness_setup_device_connection_success) + elif request.command == 'Log': + message = request.arguments['values'][0]['value'] + print(self.__strings.log.format(message=f'{message}')) + elif request.command == 'UserPrompt': + message = request.arguments['values'][0]['value'] + print(self.__strings.user_prompt.format(message=f'{message}')) if self.__show_adapter_logs: self.__log_printer.print(logs) @@ -196,7 +229,7 @@ def step_success(self, logger, logs, duration: int): self.__errors += logger.errors self.__runned += 1 - def step_failure(self, logger, logs, duration: int, expected, received): + def step_failure(self, logger, logs, duration: int, request, received): print(self.__strings.step_result.format(state=_FAILURE, duration=duration)) self.__print_results(logger) @@ -217,13 +250,24 @@ def step_failure(self, logger, logs, duration: int, expected, received): has_failures_without_exception = True if has_failures_without_exception: - self.__print_failure(expected, received) + self.__print_failure(request.responses, received) self.__successes += logger.successes self.__warnings += logger.warnings self.__errors += logger.errors self.__runned += 1 + if self.__use_test_harness_log_format: + message = '' + for entry in logger.entries: + if entry.is_error(): + message = entry.message + print(self.__strings.test_harness_step_failure.format(message=message)) + break + + if request.command == 'WaitForCommissionee': + print(self.__strings.test_harness_setup_device_connection_failure.format(deviceId=request.node_id, message=message)) + def __print_step_exception(self, exception: TestStepError): if exception.context is None: return @@ -348,7 +392,7 @@ def parser(): @simulate.command() def runner(): """Simulate running tests.""" - runner_logger = TestRunnerLogger() + runner_logger = TestRunnerLogger(use_test_harness_log_format=True) class TestLogger: def __init__(self, entries=[], successes=0, warnings=0, errors=0): @@ -378,12 +422,12 @@ def __init__(self, message, module='CTL', level='Others'): ] runner_logger.start(99) - runner_logger.test_start('test.yaml', 23) + runner_logger.test_start('Test_File', 'A test with multiple steps', 23) runner_logger.step_start('First Step') runner_logger.step_success(success_logger, empty_logs, 1234) runner_logger.step_start('Second Step') runner_logger.step_failure(error_logger, other_logs, 4321, expected_response, received_response) - runner_logger.step_skipped('Third Step') + runner_logger.step_skipped('Third Step', 'SHOULD_RUN') runner_logger.step_start('Fourth Step') runner_logger.step_unknown() runner_logger.test_stop(1234 + 4321) From 7be19548393d78b622c42d1ca98e880156bc8743 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 2 May 2023 11:45:45 -0400 Subject: [PATCH 070/200] Add ProductAppearance on Bridged Device Basic Information to the list of forced-attribute-access attributes. (#26334) This fixes a merge issue between the ProductAppearance PR and the "don't generate accessors for things where they do not make sense" PR. --- src/app/zap-templates/zcl/zcl-with-test-extensions.json | 1 + src/app/zap-templates/zcl/zcl.json | 1 + 2 files changed, 2 insertions(+) diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index 6a40f87300463b..8399e4a3dfe139 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -142,6 +142,7 @@ "CapabilityMinima", "ProductAppearance" ], + "Bridged Device Basic Information": ["ProductAppearance"], "Descriptor": ["ClusterRevision"], "Ethernet Network Diagnostics": [ "PHYRate", diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index d5bd43109c7b96..f63ef856fce8ac 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -140,6 +140,7 @@ "CapabilityMinima", "ProductAppearance" ], + "Bridged Device Basic Information": ["ProductAppearance"], "Descriptor": ["ClusterRevision"], "Ethernet Network Diagnostics": [ "PHYRate", From 991a4a33b22220f77d1c35ed797b39569f15949d Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Tue, 2 May 2023 13:36:46 -0400 Subject: [PATCH 071/200] Fix segfault when rpc client disconnects on linux app (#26320) --- examples/platform/linux/system_rpc_server.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/platform/linux/system_rpc_server.cc b/examples/platform/linux/system_rpc_server.cc index ff8e52ec94d65e..3a24525d0514ec 100644 --- a/examples/platform/linux/system_rpc_server.cc +++ b/examples/platform/linux/system_rpc_server.cc @@ -92,6 +92,8 @@ Status Start() // An out of range status indicates the remote end has disconnected. // Start to serve the connection again, which will allow another // remote to connect. + socket_stream.Close(); + server_socket.Close(); PW_CHECK_OK(server_socket.Listen(socket_port)); auto accept_result = server_socket.Accept(); PW_CHECK_OK(accept_result.status()); From f264e1cbf8ddc65ef4264f80ee22dfd4761c7c82 Mon Sep 17 00:00:00 2001 From: LeelaKumarPS-silabs <114213294+LeelakumarPS@users.noreply.github.com> Date: Tue, 2 May 2023 23:24:03 +0530 Subject: [PATCH 072/200] [Silabs]-WF200_MG24, Adds fix to the firmware error 15 (#26323) reduced the spi-bitrate from 16MHz to 10MHz --- examples/platform/silabs/efr32/spi_multiplex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/platform/silabs/efr32/spi_multiplex.h b/examples/platform/silabs/efr32/spi_multiplex.h index 29835962a4dd85..537061f09f9006 100644 --- a/examples/platform/silabs/efr32/spi_multiplex.h +++ b/examples/platform/silabs/efr32/spi_multiplex.h @@ -29,7 +29,7 @@ extern "C" { #define SL_BIT_RATE_LCD 1100000 #define SL_BIT_RATE_EXP_HDR 16000000 -#define SL_BIT_RATE_SPI_FLASH 16000000 +#define SL_BIT_RATE_SPI_FLASH 10000000 #define SL_BIT_RATE_UART_CONSOLE 16000000 extern SemaphoreHandle_t spi_sem_sync_hdl; From 8f66f4215bc0708efc8cc73bda80620e67d8955f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Michalak-Szmaci=C5=84ski?= Date: Tue, 2 May 2023 19:55:30 +0200 Subject: [PATCH 073/200] [ linux cirque ] Add flake8 to workflow and fix python files (part #25193) (#25245) * [linux-cirque] Add flake8 to workflow and fix python files in linux cirque test * rebase * Restyled by autopep8 --------- Co-authored-by: Restyled.io Co-authored-by: Arkadiusz Bokowy --- .flake8 | 1 - .../CommissioningFailureOnReportTest.py | 12 +++++---- .../linux-cirque/CommissioningFailureTest.py | 9 ++++--- .../linux-cirque/CommissioningTest.py | 15 ++++++----- .../linux-cirque/CommissioningWindowTest.py | 9 ++++--- .../linux-cirque/EchoOverTcpTest.py | 7 ++--- src/test_driver/linux-cirque/EchoTest.py | 1 - src/test_driver/linux-cirque/FailsafeTest.py | 9 ++++--- .../linux-cirque/InteractionModelTest.py | 1 - src/test_driver/linux-cirque/ManualTest.py | 2 +- .../linux-cirque/MobileDeviceTest.py | 12 +++++---- .../linux-cirque/OnOffClusterTest.py | 7 +++-- .../linux-cirque/PythonCommissioningTest.py | 2 -- .../linux-cirque/SplitCommissioningTest.py | 11 ++++---- .../linux-cirque/helper/CHIPTestBase.py | 26 ++++++++++--------- 15 files changed, 68 insertions(+), 56 deletions(-) diff --git a/.flake8 b/.flake8 index fe0075bf560c49..9ea57bd941d574 100644 --- a/.flake8 +++ b/.flake8 @@ -9,7 +9,6 @@ exclude = third_party # TODO: Remove the paths below when all bugs are fixed src/tools/chip-cert/* src/test_driver/mbed/* - src/test_driver/linux-cirque/* build/chip/java/tests/* build/chip/linux/* build/config/linux/* diff --git a/src/test_driver/linux-cirque/CommissioningFailureOnReportTest.py b/src/test_driver/linux-cirque/CommissioningFailureOnReportTest.py index 4f657235af1a53..b4c346bf3e45eb 100755 --- a/src/test_driver/linux-cirque/CommissioningFailureOnReportTest.py +++ b/src/test_driver/linux-cirque/CommissioningFailureOnReportTest.py @@ -17,9 +17,7 @@ import logging import os -import pprint import sys -import time from helper.CHIPTestBase import CHIPVirtualHome @@ -83,8 +81,11 @@ def run_controller_test(self): if device['type'] == 'MobileDevice'] for server in server_ids: - self.execute_device_cmd(server, "CHIPCirqueDaemon.py -- run gdb -return-child-result -q -ex \"set pagination off\" -ex run -ex \"bt 25\" --args {} --thread --discriminator {}".format( - os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"), TEST_DISCRIMINATOR)) + self.execute_device_cmd( + server, + ("CHIPCirqueDaemon.py -- run gdb -return-child-result -q -ex \"set pagination off\" " + "-ex run -ex \"bt 25\" --args {} --thread --discriminator {}").format( + os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"), TEST_DISCRIMINATOR)) self.reset_thread_devices(server_ids) @@ -97,7 +98,8 @@ def run_controller_test(self): self.execute_device_cmd(req_device_id, "pip3 install {}".format(os.path.join( CHIP_REPO, "out/debug/linux_x64_gcc/controller/python/chip_repl-0.0-py3-none-any.whl"))) - command = "gdb -return-child-result -q -ex run -ex bt --args python3 {} -t 150 -a {} --paa-trust-store-path {} --fail-on-report".format( + command = ("gdb -return-child-result -q -ex run -ex bt --args python3 " + "{} -t 150 -a {} --paa-trust-store-path {} --fail-on-report").format( os.path.join( CHIP_REPO, "src/controller/python/test/test_scripts/commissioning_failure_test.py"), ethernet_ip, os.path.join(CHIP_REPO, MATTER_DEVELOPMENT_PAA_ROOT_CERTS)) diff --git a/src/test_driver/linux-cirque/CommissioningFailureTest.py b/src/test_driver/linux-cirque/CommissioningFailureTest.py index 8cabb4deba54cc..dbb8dfebc09838 100755 --- a/src/test_driver/linux-cirque/CommissioningFailureTest.py +++ b/src/test_driver/linux-cirque/CommissioningFailureTest.py @@ -17,9 +17,7 @@ import logging import os -import pprint import sys -import time from helper.CHIPTestBase import CHIPVirtualHome @@ -83,8 +81,11 @@ def run_controller_test(self): if device['type'] == 'MobileDevice'] for server in server_ids: - self.execute_device_cmd(server, "CHIPCirqueDaemon.py -- run gdb -return-child-result -q -ex \"set pagination off\" -ex run -ex \"bt 25\" --args {} --thread --discriminator {}".format( - os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"), TEST_DISCRIMINATOR)) + self.execute_device_cmd( + server, + ("CHIPCirqueDaemon.py -- run gdb -return-child-result -q -ex \"set pagination off\" " + "-ex run -ex \"bt 25\" --args {} --thread --discriminator {}").format( + os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"), TEST_DISCRIMINATOR)) self.reset_thread_devices(server_ids) diff --git a/src/test_driver/linux-cirque/CommissioningTest.py b/src/test_driver/linux-cirque/CommissioningTest.py index b2c3a654deb505..adc6c21656dc53 100755 --- a/src/test_driver/linux-cirque/CommissioningTest.py +++ b/src/test_driver/linux-cirque/CommissioningTest.py @@ -17,9 +17,7 @@ import logging import os -import pprint import sys -import time from helper.CHIPTestBase import CHIPVirtualHome @@ -99,8 +97,11 @@ def run_controller_test(self): servers[1]['nodeid'] = 2 for server in servers: - self.execute_device_cmd(server['id'], "CHIPCirqueDaemon.py -- run gdb -return-child-result -q -ex \"set pagination off\" -ex run -ex \"bt 25\" --args {} --thread --discriminator {}".format( - os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"), server['discriminator'])) + self.execute_device_cmd( + server['id'], + ("CHIPCirqueDaemon.py -- run gdb -return-child-result -q -ex \"set pagination off\" " + "-ex run -ex \"bt 25\" --args {} --thread --discriminator {}").format( + os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"), server['discriminator'])) self.reset_thread_devices([server['id'] for server in servers]) @@ -113,7 +114,8 @@ def run_controller_test(self): self.execute_device_cmd(req_device_id, "pip3 install {}".format(os.path.join( CHIP_REPO, "out/debug/linux_x64_gcc/controller/python/chip_repl-0.0-py3-none-any.whl"))) - command = "gdb -return-child-result -q -ex run -ex bt --args python3 {} -t 150 -a {} --paa-trust-store-path {} --discriminator {} --nodeid {}".format( + command = ("gdb -return-child-result -q -ex run -ex bt --args python3 " + "{} -t 150 -a {} --paa-trust-store-path {} --discriminator {} --nodeid {}").format( os.path.join( CHIP_REPO, "src/controller/python/test/test_scripts/commissioning_test.py"), servers[0]['ip'], @@ -125,7 +127,8 @@ def run_controller_test(self): self.assertEqual(ret['return_code'], '0', "Test failed: non-zero return code") - command = "gdb -return-child-result -q -ex run -ex bt --args python3 {} -t 150 --paa-trust-store-path {} --discriminator {} --setup-payload {} --nodeid {}".format( + command = ("gdb -return-child-result -q -ex run -ex bt --args python3 " + "{} -t 150 --paa-trust-store-path {} --discriminator {} --setup-payload {} --nodeid {}").format( os.path.join( CHIP_REPO, "src/controller/python/test/test_scripts/commissioning_test.py"), os.path.join(CHIP_REPO, MATTER_DEVELOPMENT_PAA_ROOT_CERTS), diff --git a/src/test_driver/linux-cirque/CommissioningWindowTest.py b/src/test_driver/linux-cirque/CommissioningWindowTest.py index 16fad7ebdff8bd..7c1a646c58c52e 100755 --- a/src/test_driver/linux-cirque/CommissioningWindowTest.py +++ b/src/test_driver/linux-cirque/CommissioningWindowTest.py @@ -17,9 +17,7 @@ import logging import os -import pprint import sys -import time from helper.CHIPTestBase import CHIPVirtualHome @@ -88,7 +86,9 @@ def run_controller_test(self): servers[0]['nodeid'] = 1 for server in servers: - self.execute_device_cmd(server['id'], "CHIPCirqueDaemon.py -- run gdb -return-child-result -q -ex \"set pagination off\" -ex run -ex \"bt 25\" --args {} --thread --discriminator {}".format( + self.execute_device_cmd(server['id'], + ("CHIPCirqueDaemon.py -- run gdb -return-child-result -q -ex \"set pagination off\" " + "-ex run -ex \"bt 25\" --args {} --thread --discriminator {}").format( os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"), server['discriminator'])) self.reset_thread_devices([server['id'] for server in servers]) @@ -102,7 +102,8 @@ def run_controller_test(self): self.execute_device_cmd(req_device_id, "pip3 install {}".format(os.path.join( CHIP_REPO, "out/debug/linux_x64_gcc/controller/python/chip_repl-0.0-py3-none-any.whl"))) - command = "gdb -return-child-result -q -ex run -ex bt --args python3 {} -t 150 --address {} --paa-trust-store-path {}".format( + command = ("gdb -return-child-result -q -ex run -ex bt " + "--args python3 {} -t 150 --address {} --paa-trust-store-path {}").format( os.path.join( CHIP_REPO, "src/controller/python/test/test_scripts/commissioning_window_test.py"), servers[0]['ip'], diff --git a/src/test_driver/linux-cirque/EchoOverTcpTest.py b/src/test_driver/linux-cirque/EchoOverTcpTest.py index 5cb0c0b1c7a111..b5a3a2471a9e48 100755 --- a/src/test_driver/linux-cirque/EchoOverTcpTest.py +++ b/src/test_driver/linux-cirque/EchoOverTcpTest.py @@ -18,7 +18,6 @@ import logging import os import sys -import time from helper.CHIPTestBase import CHIPVirtualHome @@ -83,8 +82,10 @@ def run_data_model_test(self): req_device_id = req_ids[0] for id in resp_ids: - self.execute_device_cmd(id, "CHIPCirqueDaemon.py -- run gdb -batch -return-child-result -q -ex run -ex bt --args {}".format( - os.path.join(CHIP_REPO, "out/debug/linux_x64_gcc/chip-echo-responder --tcp"))) + self.execute_device_cmd( + id, + "CHIPCirqueDaemon.py -- run gdb -batch -return-child-result -q -ex run -ex bt --args {}".format( + os.path.join(CHIP_REPO, "out/debug/linux_x64_gcc/chip-echo-responder --tcp"))) command = "gdb -return-child-result -q -ex run -ex bt --args " + \ os.path.join( diff --git a/src/test_driver/linux-cirque/EchoTest.py b/src/test_driver/linux-cirque/EchoTest.py index 4f13027958591a..b76812dbf3aa4f 100755 --- a/src/test_driver/linux-cirque/EchoTest.py +++ b/src/test_driver/linux-cirque/EchoTest.py @@ -18,7 +18,6 @@ import logging import os import sys -import time from helper.CHIPTestBase import CHIPVirtualHome diff --git a/src/test_driver/linux-cirque/FailsafeTest.py b/src/test_driver/linux-cirque/FailsafeTest.py index dbcddda426849e..3f75873cd5d683 100755 --- a/src/test_driver/linux-cirque/FailsafeTest.py +++ b/src/test_driver/linux-cirque/FailsafeTest.py @@ -17,9 +17,7 @@ import logging import os -import pprint import sys -import time from helper.CHIPTestBase import CHIPVirtualHome @@ -83,8 +81,11 @@ def run_controller_test(self): if device['type'] == 'MobileDevice'] for server in server_ids: - self.execute_device_cmd(server, "CHIPCirqueDaemon.py -- run gdb -return-child-result -q -ex \"set pagination off\" -ex run -ex \"bt 25\" --args {} --thread --discriminator {}".format( - os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"), TEST_DISCRIMINATOR)) + self.execute_device_cmd( + server, + ("CHIPCirqueDaemon.py -- run gdb -return-child-result -q -ex \"set pagination off\" " + "-ex run -ex \"bt 25\" --args {} --thread --discriminator {}").format( + os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"), TEST_DISCRIMINATOR)) self.reset_thread_devices(server_ids) diff --git a/src/test_driver/linux-cirque/InteractionModelTest.py b/src/test_driver/linux-cirque/InteractionModelTest.py index fe0848d1bc76f1..3884f0a125cd36 100755 --- a/src/test_driver/linux-cirque/InteractionModelTest.py +++ b/src/test_driver/linux-cirque/InteractionModelTest.py @@ -18,7 +18,6 @@ import logging import os import sys -import time from helper.CHIPTestBase import CHIPVirtualHome diff --git a/src/test_driver/linux-cirque/ManualTest.py b/src/test_driver/linux-cirque/ManualTest.py index 0032df00b8ff2f..ba71b0fa8c9080 100755 --- a/src/test_driver/linux-cirque/ManualTest.py +++ b/src/test_driver/linux-cirque/ManualTest.py @@ -20,7 +20,7 @@ import os import sys import time -from optparse import OptionParser, OptionValueError +from optparse import OptionParser from helper.CHIPTestBase import CHIPVirtualHome diff --git a/src/test_driver/linux-cirque/MobileDeviceTest.py b/src/test_driver/linux-cirque/MobileDeviceTest.py index c5d29a1c2feff0..84ab53b9c15514 100755 --- a/src/test_driver/linux-cirque/MobileDeviceTest.py +++ b/src/test_driver/linux-cirque/MobileDeviceTest.py @@ -17,9 +17,7 @@ import logging import os -import pprint import sys -import time from helper.CHIPTestBase import CHIPVirtualHome @@ -83,8 +81,11 @@ def run_controller_test(self): if device['type'] == 'MobileDevice'] for server in server_ids: - self.execute_device_cmd(server, "CHIPCirqueDaemon.py -- run gdb -batch -return-child-result -q -ex \"set pagination off\" -ex run -ex \"thread apply all bt\" --args {} --thread --discriminator {}".format( - os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"), TEST_DISCRIMINATOR)) + self.execute_device_cmd( + server, + ("CHIPCirqueDaemon.py -- run gdb -batch -return-child-result -q -ex \"set pagination off\" " + "-ex run -ex \"thread apply all bt\" --args {} --thread --discriminator {}").format( + os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"), TEST_DISCRIMINATOR)) self.reset_thread_devices(server_ids) @@ -97,7 +98,8 @@ def run_controller_test(self): self.execute_device_cmd(req_device_id, "pip3 install {}".format(os.path.join( CHIP_REPO, "out/debug/linux_x64_gcc/controller/python/chip_repl-0.0-py3-none-any.whl"))) - command = "gdb -batch -return-child-result -q -ex run -ex \"thread apply all bt\" --args python3 {} -t 240 -a {} --paa-trust-store-path {}".format( + command = ("gdb -batch -return-child-result -q -ex run -ex \"thread apply all bt\" " + "--args python3 {} -t 240 -a {} --paa-trust-store-path {}").format( os.path.join( CHIP_REPO, "src/controller/python/test/test_scripts/mobile-device-test.py"), ethernet_ip, os.path.join(CHIP_REPO, MATTER_DEVELOPMENT_PAA_ROOT_CERTS)) diff --git a/src/test_driver/linux-cirque/OnOffClusterTest.py b/src/test_driver/linux-cirque/OnOffClusterTest.py index 701bd80dfaea81..0bd78f2c8a5246 100755 --- a/src/test_driver/linux-cirque/OnOffClusterTest.py +++ b/src/test_driver/linux-cirque/OnOffClusterTest.py @@ -115,8 +115,11 @@ def run_data_model_test(self): for device_id in server_ids: self.logger.info("checking device log for {}".format( self.get_device_pretty_id(device_id))) - self.assertTrue(self.sequenceMatch(self.get_device_log(device_id).decode('utf-8'), ["Thread initialized.", "LightingManager::InitiateAction(ON_ACTION)", "LightingManager::InitiateAction(OFF_ACTION)"]), - "Datamodel test failed: cannot find matching string from device {}".format(device_id)) + self.assertTrue(self.sequenceMatch(self.get_device_log(device_id).decode('utf-8'), [ + "Thread initialized.", + "LightingManager::InitiateAction(ON_ACTION)", + "LightingManager::InitiateAction(OFF_ACTION)" + ]), "Datamodel test failed: cannot find matching string from device {}".format(device_id)) if __name__ == "__main__": diff --git a/src/test_driver/linux-cirque/PythonCommissioningTest.py b/src/test_driver/linux-cirque/PythonCommissioningTest.py index 052474a48c8f47..c3f70c85760bac 100755 --- a/src/test_driver/linux-cirque/PythonCommissioningTest.py +++ b/src/test_driver/linux-cirque/PythonCommissioningTest.py @@ -17,9 +17,7 @@ import logging import os -import pprint import sys -import time from helper.CHIPTestBase import CHIPVirtualHome diff --git a/src/test_driver/linux-cirque/SplitCommissioningTest.py b/src/test_driver/linux-cirque/SplitCommissioningTest.py index 623e4355dee79d..ad4475fd92437d 100755 --- a/src/test_driver/linux-cirque/SplitCommissioningTest.py +++ b/src/test_driver/linux-cirque/SplitCommissioningTest.py @@ -17,9 +17,7 @@ import logging import os -import pprint import sys -import time from helper.CHIPTestBase import CHIPVirtualHome @@ -91,8 +89,10 @@ def run_controller_test(self): if device['type'] == 'MobileDevice'] for server in server_ids: - self.execute_device_cmd(server, "CHIPCirqueDaemon.py -- run gdb -return-child-result -q -ex \"set pagination off\" -ex run -ex \"bt 25\" --args {} --thread".format( - os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"))) + self.execute_device_cmd(server, + ("CHIPCirqueDaemon.py -- run gdb -return-child-result -q -ex " + "\"set pagination off\" -ex run -ex \"bt 25\" --args {} --thread").format( + os.path.join(CHIP_REPO, "out/debug/standalone/chip-all-clusters-app"))) self.reset_thread_devices(server_ids) @@ -105,7 +105,8 @@ def run_controller_test(self): self.execute_device_cmd(req_device_id, "pip3 install {}".format(os.path.join( CHIP_REPO, "out/debug/linux_x64_gcc/controller/python/chip_repl-0.0-py3-none-any.whl"))) - command = "gdb -return-child-result -q -ex run -ex bt --args python3 {} -t 150 --address1 {} --address2 {} --paa-trust-store-path {}".format( + command = ("gdb -return-child-result -q -ex run -ex bt --args python3 " + "{} -t 150 --address1 {} --address2 {} --paa-trust-store-path {}").format( os.path.join( CHIP_REPO, "src/controller/python/test/test_scripts/split_commissioning_test.py"), ethernet_ips[0], ethernet_ips[1], os.path.join(CHIP_REPO, MATTER_DEVELOPMENT_PAA_ROOT_CERTS)) diff --git a/src/test_driver/linux-cirque/helper/CHIPTestBase.py b/src/test_driver/linux-cirque/helper/CHIPTestBase.py index 957c9187aa465f..62489b24bfc360 100644 --- a/src/test_driver/linux-cirque/helper/CHIPTestBase.py +++ b/src/test_driver/linux-cirque/helper/CHIPTestBase.py @@ -17,7 +17,6 @@ import ipaddress import json -import logging import os import re import sys @@ -74,12 +73,12 @@ def run_test(self, save_logs=True): if save_logs: try: self.save_device_logs() - except: + except Exception: test_ret = TestResult.SYSTEM_FAILURE traceback.print_exc(file=sys.stderr) try: self.destroy_home() - except: + except requests.exceptions.RequestException: test_ret = TestResult.SYSTEM_FAILURE traceback.print_exc(file=sys.stderr) return test_ret @@ -101,7 +100,7 @@ def execute_device_cmd(self, device_id, cmd, stream=False): ret_struct = ret.json() command_ret_code = ret_struct.get('return_code', None) - if command_ret_code == None: + if command_ret_code is None: # could be 0 self.logger.error("cannot get command return code") raise Exception("cannot get command return code") @@ -110,7 +109,7 @@ def execute_device_cmd(self, device_id, cmd, stream=False): ret_struct.get('return_code', 'Unknown')) ) command_output = ret_struct.get('output', None) - if command_output == None: + if command_output is None: # could be empty string self.logger.error("cannot get command output") raise Exception("cannot get command output") @@ -213,7 +212,9 @@ def connect_to_thread_network(self): otInitCommands = [ "ot-ctl thread stop", "ot-ctl ifconfig down", - "ot-ctl dataset set active 0e080000000000010000000300000d35060004001fffe00208dead00beef00cafe0708fd01234567890abc051000112233445566778899aabbccddeeff030a4f70656e546872656164010212340410ad463152f9622c7297ec6c6c543a63e70c0302a0ff", + ("ot-ctl dataset set active 0e080000000000010000000300000d35060004001fffe00208d" + "ead00beef00cafe0708fd01234567890abc051000112233445566778899aabbccddeeff030a4f" + "70656e546872656164010212340410ad463152f9622c7297ec6c6c543a63e70c0302a0ff"), "ot-ctl ifconfig up", "ot-ctl thread start", "ot-ctl dataset active", # Emit @@ -264,7 +265,8 @@ def get_device_thread_ip(self, device_id): continue if not ipaddr.is_private: continue - if re.match("fd[0-9a-f]{2}:[0-9a-f]{4}:[0-9a-f]{4}:[0-9a-f]{4}:0000:00ff:fe00:[0-9a-f]{4}", ipaddr.exploded) != None: + if re.match(("fd[0-9a-f]{2}:[0-9a-f]{4}:[0-9a-f]" + "{4}:[0-9a-f]{4}:0000:00ff:fe00:[0-9a-f]{4}"), ipaddr.exploded) is not None: continue self.logger.info("Get Mesh-Local EID: {}".format(ipstr)) return str(ipaddr) @@ -293,19 +295,19 @@ def assertTrue(self, exp, note=None): assert(Not)Equal python unittest style functions that raise exceptions when condition not met ''' - if not exp == True: + if not (exp is True): if note: self.logger.error(note) raise AssertionError def assertFalse(self, exp, note=None): - if not exp == False: + if not (exp is False): if note: self.logger.error(note) raise AssertionError def assertEqual(self, val1, val2, note=None): - if not val1 == val2: + if not (val1 == val2): if note: self.logger.error(note) raise AssertionError @@ -366,7 +368,7 @@ def initialize_home(self): def save_device_logs(self): timestamp = int(time.time()) log_dir = os.environ.get("DEVICE_LOG_DIR", None) - if log_dir != None and not os.path.exists(log_dir): + if log_dir is not None and not os.path.exists(log_dir): os.makedirs("logs") for device in self.non_ap_devices: @@ -409,7 +411,7 @@ def kill_existing_wpa_supplicant(self, device_id): def get_device_pretty_name(self, device_id): device_obj = self.device_config.get(device_id, None) - if device_obj != None: + if device_obj is not None: return device_obj['type'] return "" From 328c5532d981daea6e2666f234e2fe9bfcc6fea5 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Tue, 2 May 2023 16:03:52 -0400 Subject: [PATCH 074/200] Use stack buffer when tokenizing smaller buffers (#26336) * Only allocate logging buffer when required buffer size is larger than 32 bytes * Fix CI issue * Fix compiler warning --- src/lib/support/logging/CHIPLogging.cpp | 40 +++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/src/lib/support/logging/CHIPLogging.cpp b/src/lib/support/logging/CHIPLogging.cpp index fae093cd9cca5c..a1eac1324e6b3b 100644 --- a/src/lib/support/logging/CHIPLogging.cpp +++ b/src/lib/support/logging/CHIPLogging.cpp @@ -62,19 +62,41 @@ void HandleTokenizedLog(uint32_t levels, pw_tokenizer_Token token, pw_tokenizer_ pw_tokenizer_EncodeArgs(types, args, encoded_message + sizeof(token), sizeof(encoded_message) - sizeof(token)); va_end(args); - uint8_t log_category = levels >> 8 & 0xFF; - uint8_t log_module = levels & 0xFF; - char * buffer = (char *) chip::Platform::MemoryAlloc(2 * encoded_size + 1); + uint8_t log_category = levels >> 8 & 0xFF; + uint8_t log_module = levels & 0xFF; + char * logging_buffer = nullptr; - if (buffer) + // To reduce the number of alloc/free that is happening we will use a stack + // buffer when buffer required to log is small. + char stack_buffer[32]; + char * allocated_buffer = nullptr; + size_t required_buffer_size = 2 * encoded_size + 1; + + if (required_buffer_size > sizeof(stack_buffer)) { - for (int i = 0; i < encoded_size; i++) + allocated_buffer = (char *) chip::Platform::MemoryAlloc(required_buffer_size); + if (allocated_buffer) { - sprintf(buffer + 2 * i, "%02x", encoded_message[i]); + logging_buffer = allocated_buffer; } - buffer[2 * encoded_size] = '\0'; - Log(log_module, log_category, "%s", buffer); - chip::Platform::MemoryFree(buffer); + } + else + { + logging_buffer = stack_buffer; + } + + if (logging_buffer) + { + for (size_t i = 0; i < encoded_size; i++) + { + sprintf(logging_buffer + 2 * i, "%02x", encoded_message[i]); + } + logging_buffer[2 * encoded_size] = '\0'; + Log(log_module, log_category, "%s", logging_buffer); + } + if (allocated_buffer) + { + chip::Platform::MemoryFree(allocated_buffer); } } From 084eb3ca109de8bd20921ea5bffb49d0922f46d1 Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Tue, 2 May 2023 22:45:10 -0400 Subject: [PATCH 075/200] [ICD] Initial Client Monitoring Cluster xml update (#26302) * update cm cluster xml * change hex to decimal representation * Apply suggestions from code review Co-authored-by: Boris Zbarsky * disable CM cluster generation and tests * generated files * disable cm cluster table * Disable java cm table * disable cm cluster in descriptor test * generated files * disable cm cluster for esp32 * restyler * comment out cm table sources * ifdef out cm table code for esp32 * restyle * disable cm cluster yaml for repl * removed acess modifier --------- Co-authored-by: Boris Zbarsky --- .../all-clusters-app.matter | 45 -- .../all-clusters-common/all-clusters-app.zap | 228 +--------- .../esp32/main/CMakeLists.txt | 4 +- .../light-switch-common/light-switch-app.zap | 222 ---------- scripts/tests/chiptest/__init__.py | 1 + src/app/chip_data_model.cmake | 4 +- src/app/chip_data_model.gni | 7 +- src/app/tests/BUILD.gn | 32 +- .../tests/suites/TestDescriptorCluster.yaml | 4 +- src/app/tests/suites/ciTests.json | 3 +- .../ClientMonitoringRegistrationTable.cpp | 4 + .../util/ClientMonitoringRegistrationTable.h | 4 + .../chip/client-monitoring-cluster.xml | 45 +- src/controller/data_model/BUILD.gn | 7 +- .../data_model/controller-clusters.matter | 38 -- .../data_model/controller-clusters.zap | 232 +---------- .../devicecontroller/ClusterReadMapping.java | 148 ------- .../devicecontroller/ClusterWriteMapping.java | 2 - .../CHIPAttributeTLVValueDecoder.cpp | 238 ----------- .../CHIPEventTLVValueDecoder.cpp | 10 - .../java/zap-generated/CHIPReadCallbacks.cpp | 390 ------------------ .../chip/devicecontroller/ChipClusters.java | 248 ----------- .../chip/devicecontroller/ChipIdLookup.java | 39 -- .../chip/devicecontroller/ChipStructs.java | 30 -- .../devicecontroller/ClusterInfoMapping.java | 182 -------- .../python/chip/clusters/CHIPClusters.py | 86 ---- .../python/chip/clusters/Objects.py | 72 +++- .../zap-generated/attributes/Accessors.cpp | 31 ++ .../zap-generated/attributes/Accessors.h | 5 + .../zap-generated/cluster-objects.cpp | 93 ++++- .../zap-generated/cluster-objects.h | 97 +++-- .../app-common/zap-generated/ids/Attributes.h | 4 + .../app-common/zap-generated/ids/Commands.h | 8 +- .../zap-generated/cluster/Commands.h | 34 +- .../cluster/ComplexArgumentParser.cpp | 32 +- .../cluster/ComplexArgumentParser.h | 5 +- .../cluster/logging/DataModelLogger.cpp | 68 +-- .../cluster/logging/DataModelLogger.h | 5 +- .../chip-tool/zap-generated/test/Commands.h | 199 +-------- .../zap-generated/test/Commands.h | 5 +- .../zap-generated/CHIPClientCallbacks.h | 12 - .../zap-generated/CHIPClusters.h | 9 - .../zap-generated/endpoint_config.h | 17 +- .../zap-generated/gen_config.h | 5 - 44 files changed, 383 insertions(+), 2571 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 0cf14341ac4d1f..23ea23057166d5 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -4225,39 +4225,6 @@ server cluster ElectricalMeasurement = 2820 { readonly attribute int16u clusterRevision = 65533; } -/** Client Monitoring allows for ensuring that listed clients meet the required monitoring conditions on the server. */ -server cluster ClientMonitoring = 4166 { - fabric_scoped struct MonitoringRegistration { - node_id clientNodeId = 1; - int64u ICid = 2; - fabric_idx fabricIndex = 254; - } - - readonly attribute int32u idleModeInterval = 0; - readonly attribute int32u activeModeInterval = 1; - readonly attribute int16u activeModeThreshold = 2; - readonly attribute MonitoringRegistration expectedClients[] = 3; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; - - request struct RegisterClientMonitoringRequest { - node_id clientNodeId = 0; - INT64U ICid = 1; - } - - request struct UnregisterClientMonitoringRequest { - node_id clientNodeId = 0; - INT64U ICid = 1; - } - - command access(invoke: manage) RegisterClientMonitoring(RegisterClientMonitoringRequest): DefaultSuccess = 0; - command access(invoke: manage) UnregisterClientMonitoring(UnregisterClientMonitoringRequest): DefaultSuccess = 1; -} - /** The Test Cluster is meant to validate the generated code */ server cluster UnitTesting = 4294048773 { enum SimpleEnum : ENUM8 { @@ -4951,18 +4918,6 @@ endpoint 0 { ram attribute clusterRevision default = 3; } - server cluster ClientMonitoring { - ram attribute idleModeInterval default = 0x12C; - ram attribute activeModeInterval default = 0x12C; - ram attribute activeModeThreshold default = 0xFA0; - callback attribute expectedClients; - callback attribute generatedCommandList; - callback attribute acceptedCommandList; - callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - } - server cluster FaultInjection { callback attribute generatedCommandList; callback attribute acceptedCommandList; diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 8c645de17c904b..399ac119c1f433 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 96, "creator": "zap", "keyValuePairs": [ { @@ -16,6 +16,12 @@ } ], "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + }, { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/zcl/zcl-with-test-extensions.json", @@ -23,12 +29,6 @@ "category": "matter", "version": 1, "description": "Matter SDK ZCL data with some extensions" - }, - { - "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", - "version": "chip-v1" } ], "endpointTypes": [ @@ -8194,220 +8194,6 @@ } ] }, - { - "name": "Client Monitoring", - "code": 4166, - "mfgCode": null, - "define": "CLIENT_MONITORING_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "RegisterClientMonitoring", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "UnregisterClientMonitoring", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "client", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - }, - { - "name": "Client Monitoring", - "code": 4166, - "mfgCode": null, - "define": "CLIENT_MONITORING_CLUSTER", - "side": "server", - "enabled": 1, - "attributes": [ - { - "name": "IdleModeInterval", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x12C", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ActiveModeInterval", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x12C", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ActiveModeThreshold", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0xFA0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ExpectedClients", - "code": 3, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "GeneratedCommandList", - "code": 65528, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "AcceptedCommandList", - "code": 65529, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "AttributeList", - "code": 65531, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - }, { "name": "Unit Testing", "code": 4294048773, diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 70f17774c00d77..c004e3f5dffb42 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -77,7 +77,9 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic-information" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/bindings" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/client-monitoring-server" + # Disable Client Monitoring cluster until update is done + # https://github.com/project-chip/connectedhomeip/issues/24425 + # "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/client-monitoring-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/diagnostic-logs-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/door-lock-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server" diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.zap b/examples/light-switch-app/light-switch-common/light-switch-app.zap index e38ff2637a6ad9..a5c77707454345 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.zap +++ b/examples/light-switch-app/light-switch-common/light-switch-app.zap @@ -5363,228 +5363,6 @@ "reportableChange": 0 } ] - }, - { - "name": "Client Monitoring", - "code": 4166, - "mfgCode": null, - "define": "CLIENT_MONITORING_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "RegisterClientMonitoring", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "UnregisterClientMonitoring", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "StayAwakeRequest", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 0 - } - ], - "attributes": [ - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "client", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - }, - { - "name": "Client Monitoring", - "code": 4166, - "mfgCode": null, - "define": "CLIENT_MONITORING_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ - { - "name": "IdleModeInterval", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x12C", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ActiveModeInterval", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x12C", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ActiveModeThreshold", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0xFA0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ExpectedClients", - "code": 3, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "GeneratedCommandList", - "code": 65528, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 0, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "AcceptedCommandList", - "code": 65529, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 0, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "AttributeList", - "code": 65531, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 0, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] } ] }, diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py index 9ddbc0ef8f2d21..b537f681091781 100644 --- a/scripts/tests/chiptest/__init__.py +++ b/scripts/tests/chiptest/__init__.py @@ -135,6 +135,7 @@ def _GetInDevelopmentTests() -> Set[str]: """ return { "Test_AddNewFabricFromExistingFabric.yaml", # chip-repl does not support GetCommissionerRootCertificate and IssueNocChain command + "TestClientMonitoringCluster.yaml" # Client Monitoring Tests need a rework after the XML update } diff --git a/src/app/chip_data_model.cmake b/src/app/chip_data_model.cmake index e5b19626f52710..e27e8509bfeddb 100644 --- a/src/app/chip_data_model.cmake +++ b/src/app/chip_data_model.cmake @@ -134,7 +134,9 @@ function(chip_configure_data_model APP_TARGET) ${CHIP_APP_BASE_DIR}/util/attribute-storage.cpp ${CHIP_APP_BASE_DIR}/util/attribute-table.cpp ${CHIP_APP_BASE_DIR}/util/binding-table.cpp - ${CHIP_APP_BASE_DIR}/util/ClientMonitoringRegistrationTable.cpp + # Disable CM cluster table tests until update is done + # https://github.com/project-chip/connectedhomeip/issues/24425 + # ${CHIP_APP_BASE_DIR}/util/ClientMonitoringRegistrationTable.cpp ${CHIP_APP_BASE_DIR}/util/DataModelHandler.cpp ${CHIP_APP_BASE_DIR}/util/ember-compatibility-functions.cpp ${CHIP_APP_BASE_DIR}/util/ember-print.cpp diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 39b6f1869ae1dc..8b85c353ec7bc2 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -171,8 +171,11 @@ template("chip_data_model") { "${_app_root}/clusters/scenes/SceneTableImpl.h", "${_app_root}/clusters/scenes/scenes-tokens.h", "${_app_root}/clusters/scenes/scenes.h", - "${_app_root}/util/ClientMonitoringRegistrationTable.cpp", - "${_app_root}/util/ClientMonitoringRegistrationTable.h", + + # Disable CM cluster table tests until update is done + # https://github.com/project-chip/connectedhomeip/issues/24425 + # "${_app_root}/util/ClientMonitoringRegistrationTable.cpp", + # "${_app_root}/util/ClientMonitoringRegistrationTable.h", "${_app_root}/util/DataModelHandler.cpp", "${_app_root}/util/attribute-size-util.cpp", "${_app_root}/util/attribute-storage.cpp", diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn index f64f0f58fe5154..b4da7f9f6af015 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -54,17 +54,17 @@ source_set("binding-test-srcs") { ] } -source_set("client-monitoring-test-srcs") { - sources = [ - "${chip_root}/src/app/util/ClientMonitoringRegistrationTable.cpp", - "${chip_root}/src/app/util/ClientMonitoringRegistrationTable.h", - ] - - public_deps = [ - "${chip_root}/src/app/common:cluster-objects", - "${chip_root}/src/lib/core", - ] -} +# source_set("client-monitoring-test-srcs") { +# sources = [ +# "${chip_root}/src/app/util/ClientMonitoringRegistrationTable.cpp", +# "${chip_root}/src/app/util/ClientMonitoringRegistrationTable.h", +# ] + +# public_deps = [ +# "${chip_root}/src/app/common:cluster-objects", +# "${chip_root}/src/lib/core", +# ] +# } source_set("ota-requestor-test-srcs") { sources = [ @@ -108,7 +108,10 @@ chip_test_suite("tests") { "TestAttributeValueEncoder.cpp", "TestBindingTable.cpp", "TestBuilderParser.cpp", - "TestClientMonitoringRegistrationTable.cpp", + + # Disable CM cluster table tests until update is done + # https://github.com/project-chip/connectedhomeip/issues/24425 + # "TestClientMonitoringRegistrationTable.cpp", "TestClusterInfo.cpp", "TestCommandInteraction.cpp", "TestCommandPathParams.cpp", @@ -159,7 +162,10 @@ chip_test_suite("tests") { public_deps = [ ":binding-test-srcs", - ":client-monitoring-test-srcs", + + # Disable CM cluster table tests until update is done + #https://github.com/project-chip/connectedhomeip/issues/24425 + # ":client-monitoring-test-srcs", ":ota-requestor-test-srcs", ":scenes-table-test-srcs", "${chip_root}/src/app", diff --git a/src/app/tests/suites/TestDescriptorCluster.yaml b/src/app/tests/suites/TestDescriptorCluster.yaml index a0ac7ee099d5c9..803f8507b92f1d 100644 --- a/src/app/tests/suites/TestDescriptorCluster.yaml +++ b/src/app/tests/suites/TestDescriptorCluster.yaml @@ -65,7 +65,9 @@ tests: 0x0040, # Fixed Label 0x0041, # User Label 0x0405, # Relative Humidity Measurement (why on EP0?) - 0x1046, # Client Monitoring + # Disable CM cluster table tests until update is done + # https://github.com/project-chip/connectedhomeip/issues/24425 + # 0x1046, # Client Monitoring 0xFFF1FC06, # Fault Injection ] diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index deb6fce3dd5ba4..64bcf3908c2169 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -238,8 +238,7 @@ "TestAccessControlConstraints", "TestLevelControlWithOnOffDependency", "TestCommissioningWindow", - "TestCommissionerNodeId", - "TestClientMonitoringCluster" + "TestCommissionerNodeId" ], "MultiAdmin": ["TestMultiAdmin"], "SoftwareDiagnostics": ["Test_TC_DGSW_1_1"], diff --git a/src/app/util/ClientMonitoringRegistrationTable.cpp b/src/app/util/ClientMonitoringRegistrationTable.cpp index b996c925faab53..bfe81a7ddf77d9 100644 --- a/src/app/util/ClientMonitoringRegistrationTable.cpp +++ b/src/app/util/ClientMonitoringRegistrationTable.cpp @@ -15,6 +15,9 @@ * limitations under the License. */ +// Disable CM cluster table until update is done +// https://github.com/project-chip/connectedhomeip/issues/24425 +#if 0 #include "ClientMonitoringRegistrationTable.h" #include @@ -77,3 +80,4 @@ bool ClientMonitoringRegistrationTable::HasValueForFabric(FabricIndex fabric) } } // namespace chip +#endif diff --git a/src/app/util/ClientMonitoringRegistrationTable.h b/src/app/util/ClientMonitoringRegistrationTable.h index 18545ddad51fa2..51886e8527e34a 100644 --- a/src/app/util/ClientMonitoringRegistrationTable.h +++ b/src/app/util/ClientMonitoringRegistrationTable.h @@ -15,6 +15,9 @@ * limitations under the License. */ +// Disable CM cluster table until update is done +// https://github.com/project-chip/connectedhomeip/issues/24425 +#if 0 #pragma once #include @@ -96,3 +99,4 @@ class ClientMonitoringRegistrationTable }; } // namespace chip +#endif diff --git a/src/app/zap-templates/zcl/data-model/chip/client-monitoring-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/client-monitoring-cluster.xml index 7b7a5fbdcbe0b2..7b9fdae8a919cf 100644 --- a/src/app/zap-templates/zcl/data-model/chip/client-monitoring-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/client-monitoring-cluster.xml @@ -18,10 +18,10 @@ limitations under the License. - + - - + + @@ -29,29 +29,42 @@ limitations under the License. Client Monitoring 0x1046 CLIENT_MONITORING_CLUSTER - Client Monitoring allows for ensuring that listed clients meet the required monitoring conditions on the server. - IdleModeInterval - ActiveModeInterval - ActiveModeThreshold + Client Monitoring allows servers to ensure that listed clients are notified when a server is available for communication. + IdleModeInterval + ActiveModeInterval + ActiveModeThreshold - - ExpectedClients + + ExpectedClients + + - + + ICDCounter + + + + + Register a client to the end device - - + + - + + RegisterClientMonitoring response command + + + + + Unregister a client from an end device - - + - + Request the end device to stay in Active Mode for an additional ActiveModeThreshold diff --git a/src/controller/data_model/BUILD.gn b/src/controller/data_model/BUILD.gn index 1fd8d3e99f7f5c..3a2f40e4961e9d 100644 --- a/src/controller/data_model/BUILD.gn +++ b/src/controller/data_model/BUILD.gn @@ -174,8 +174,11 @@ if (current_os == "android" || build_java_matter_controller) { "jni/ElectricalMeasurementClient-InvokeSubscribeImpl.cpp", "jni/UnitTestingClient-ReadImpl.cpp", "jni/UnitTestingClient-InvokeSubscribeImpl.cpp", - "jni/ClientMonitoringClient-ReadImpl.cpp", - "jni/ClientMonitoringClient-InvokeSubscribeImpl.cpp", + + # Disable CM cluster table tests until update is done + # https://github.com/project-chip/connectedhomeip/issues/24425 + #"jni/ClientMonitoringClient-ReadImpl.cpp", + #"jni/ClientMonitoringClient-InvokeSubscribeImpl.cpp", ] deps = [ diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index cf47d784ff7407..bb426017d5b79d 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -4970,43 +4970,6 @@ client cluster ElectricalMeasurement = 2820 { command GetMeasurementProfileCommand(GetMeasurementProfileCommandRequest): DefaultSuccess = 1; } -/** Client Monitoring allows for ensuring that listed clients meet the required monitoring conditions on the server. */ -client cluster ClientMonitoring = 4166 { - fabric_scoped struct MonitoringRegistration { - node_id clientNodeId = 1; - int64u ICid = 2; - fabric_idx fabricIndex = 254; - } - - readonly attribute int32u idleModeInterval = 0; - readonly attribute int32u activeModeInterval = 1; - readonly attribute int16u activeModeThreshold = 2; - readonly attribute MonitoringRegistration expectedClients[] = 3; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; - - request struct RegisterClientMonitoringRequest { - node_id clientNodeId = 0; - INT64U ICid = 1; - } - - request struct UnregisterClientMonitoringRequest { - node_id clientNodeId = 0; - INT64U ICid = 1; - } - - /** Register a client to the end device */ - command access(invoke: manage) RegisterClientMonitoring(RegisterClientMonitoringRequest): DefaultSuccess = 0; - /** Unregister a client from an end device */ - command access(invoke: manage) UnregisterClientMonitoring(UnregisterClientMonitoringRequest): DefaultSuccess = 1; - /** Request the end device to stay in Active Mode for an additional ActiveModeThreshold */ - command access(invoke: manage) StayAwakeRequest(): DefaultSuccess = 2; -} - /** The Test Cluster is meant to validate the generated code */ client cluster UnitTesting = 4294048773 { enum SimpleEnum : ENUM8 { @@ -5519,7 +5482,6 @@ endpoint 1 { binding cluster ApplicationBasic; binding cluster AccountLogin; binding cluster ElectricalMeasurement; - binding cluster ClientMonitoring; binding cluster UnitTesting; } diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index 841e8579296d87..baee7e2a4f6045 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -1,5 +1,5 @@ { - "featureLevel": 94, + "featureLevel": 96, "creator": "zap", "keyValuePairs": [ { @@ -19474,236 +19474,6 @@ } ] }, - { - "name": "Client Monitoring", - "code": 4166, - "mfgCode": null, - "define": "CLIENT_MONITORING_CLUSTER", - "side": "client", - "enabled": 1, - "commands": [ - { - "name": "RegisterClientMonitoring", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "UnregisterClientMonitoring", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "client", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - }, - { - "name": "Client Monitoring", - "code": 4166, - "mfgCode": null, - "define": "CLIENT_MONITORING_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ - { - "name": "IdleModeInterval", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x12C", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ActiveModeInterval", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x12C", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ActiveModeThreshold", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0xFA0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ExpectedClients", - "code": 3, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "GeneratedCommandList", - "code": 65528, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "AcceptedCommandList", - "code": 65529, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "EventList", - "code": 65530, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "AttributeList", - "code": 65531, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - }, { "name": "Unit Testing", "code": 4294048773, diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java index 509b9168a976d7..7f6ec70bd29dc8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java @@ -15312,154 +15312,6 @@ public Map> getReadAttributeMap() { "readClusterRevisionAttribute", readElectricalMeasurementClusterRevisionAttributeInteractionInfo); readAttributeMap.put("electricalMeasurement", readElectricalMeasurementInteractionInfo); - Map readClientMonitoringInteractionInfo = new LinkedHashMap<>(); - Map readClientMonitoringIdleModeIntervalCommandParams = - new LinkedHashMap(); - InteractionInfo readClientMonitoringIdleModeIntervalAttributeInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.ClientMonitoringCluster) cluster) - .readIdleModeIntervalAttribute((ChipClusters.LongAttributeCallback) callback); - }, - () -> new ClusterInfoMapping.DelegatedLongAttributeCallback(), - readClientMonitoringIdleModeIntervalCommandParams); - readClientMonitoringInteractionInfo.put( - "readIdleModeIntervalAttribute", - readClientMonitoringIdleModeIntervalAttributeInteractionInfo); - Map readClientMonitoringActiveModeIntervalCommandParams = - new LinkedHashMap(); - InteractionInfo readClientMonitoringActiveModeIntervalAttributeInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.ClientMonitoringCluster) cluster) - .readActiveModeIntervalAttribute((ChipClusters.LongAttributeCallback) callback); - }, - () -> new ClusterInfoMapping.DelegatedLongAttributeCallback(), - readClientMonitoringActiveModeIntervalCommandParams); - readClientMonitoringInteractionInfo.put( - "readActiveModeIntervalAttribute", - readClientMonitoringActiveModeIntervalAttributeInteractionInfo); - Map readClientMonitoringActiveModeThresholdCommandParams = - new LinkedHashMap(); - InteractionInfo readClientMonitoringActiveModeThresholdAttributeInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.ClientMonitoringCluster) cluster) - .readActiveModeThresholdAttribute( - (ChipClusters.IntegerAttributeCallback) callback); - }, - () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), - readClientMonitoringActiveModeThresholdCommandParams); - readClientMonitoringInteractionInfo.put( - "readActiveModeThresholdAttribute", - readClientMonitoringActiveModeThresholdAttributeInteractionInfo); - Map readClientMonitoringExpectedClientsCommandParams = - new LinkedHashMap(); - InteractionInfo readClientMonitoringExpectedClientsAttributeInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.ClientMonitoringCluster) cluster) - .readExpectedClientsAttribute( - (ChipClusters.ClientMonitoringCluster.ExpectedClientsAttributeCallback) - callback); - }, - () -> - new ClusterInfoMapping - .DelegatedClientMonitoringClusterExpectedClientsAttributeCallback(), - readClientMonitoringExpectedClientsCommandParams); - readClientMonitoringInteractionInfo.put( - "readExpectedClientsAttribute", - readClientMonitoringExpectedClientsAttributeInteractionInfo); - Map readClientMonitoringGeneratedCommandListCommandParams = - new LinkedHashMap(); - InteractionInfo readClientMonitoringGeneratedCommandListAttributeInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.ClientMonitoringCluster) cluster) - .readGeneratedCommandListAttribute( - (ChipClusters.ClientMonitoringCluster.GeneratedCommandListAttributeCallback) - callback); - }, - () -> - new ClusterInfoMapping - .DelegatedClientMonitoringClusterGeneratedCommandListAttributeCallback(), - readClientMonitoringGeneratedCommandListCommandParams); - readClientMonitoringInteractionInfo.put( - "readGeneratedCommandListAttribute", - readClientMonitoringGeneratedCommandListAttributeInteractionInfo); - Map readClientMonitoringAcceptedCommandListCommandParams = - new LinkedHashMap(); - InteractionInfo readClientMonitoringAcceptedCommandListAttributeInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.ClientMonitoringCluster) cluster) - .readAcceptedCommandListAttribute( - (ChipClusters.ClientMonitoringCluster.AcceptedCommandListAttributeCallback) - callback); - }, - () -> - new ClusterInfoMapping - .DelegatedClientMonitoringClusterAcceptedCommandListAttributeCallback(), - readClientMonitoringAcceptedCommandListCommandParams); - readClientMonitoringInteractionInfo.put( - "readAcceptedCommandListAttribute", - readClientMonitoringAcceptedCommandListAttributeInteractionInfo); - Map readClientMonitoringEventListCommandParams = - new LinkedHashMap(); - InteractionInfo readClientMonitoringEventListAttributeInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.ClientMonitoringCluster) cluster) - .readEventListAttribute( - (ChipClusters.ClientMonitoringCluster.EventListAttributeCallback) callback); - }, - () -> - new ClusterInfoMapping.DelegatedClientMonitoringClusterEventListAttributeCallback(), - readClientMonitoringEventListCommandParams); - readClientMonitoringInteractionInfo.put( - "readEventListAttribute", readClientMonitoringEventListAttributeInteractionInfo); - Map readClientMonitoringAttributeListCommandParams = - new LinkedHashMap(); - InteractionInfo readClientMonitoringAttributeListAttributeInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.ClientMonitoringCluster) cluster) - .readAttributeListAttribute( - (ChipClusters.ClientMonitoringCluster.AttributeListAttributeCallback) - callback); - }, - () -> - new ClusterInfoMapping - .DelegatedClientMonitoringClusterAttributeListAttributeCallback(), - readClientMonitoringAttributeListCommandParams); - readClientMonitoringInteractionInfo.put( - "readAttributeListAttribute", readClientMonitoringAttributeListAttributeInteractionInfo); - Map readClientMonitoringFeatureMapCommandParams = - new LinkedHashMap(); - InteractionInfo readClientMonitoringFeatureMapAttributeInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.ClientMonitoringCluster) cluster) - .readFeatureMapAttribute((ChipClusters.LongAttributeCallback) callback); - }, - () -> new ClusterInfoMapping.DelegatedLongAttributeCallback(), - readClientMonitoringFeatureMapCommandParams); - readClientMonitoringInteractionInfo.put( - "readFeatureMapAttribute", readClientMonitoringFeatureMapAttributeInteractionInfo); - Map readClientMonitoringClusterRevisionCommandParams = - new LinkedHashMap(); - InteractionInfo readClientMonitoringClusterRevisionAttributeInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.ClientMonitoringCluster) cluster) - .readClusterRevisionAttribute((ChipClusters.IntegerAttributeCallback) callback); - }, - () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), - readClientMonitoringClusterRevisionCommandParams); - readClientMonitoringInteractionInfo.put( - "readClusterRevisionAttribute", - readClientMonitoringClusterRevisionAttributeInteractionInfo); - readAttributeMap.put("clientMonitoring", readClientMonitoringInteractionInfo); Map readUnitTestingInteractionInfo = new LinkedHashMap<>(); Map readUnitTestingBooleanCommandParams = new LinkedHashMap(); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java index 2dce6dab7f0433..e50aed4bfa0f08 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java @@ -2593,8 +2593,6 @@ public Map> getWriteAttributeMap() { "writeAcOverloadAlarmsMaskAttribute", writeElectricalMeasurementAcOverloadAlarmsMaskAttributeInteractionInfo); writeAttributeMap.put("electricalMeasurement", writeElectricalMeasurementInteractionInfo); - Map writeClientMonitoringInteractionInfo = new LinkedHashMap<>(); - writeAttributeMap.put("clientMonitoring", writeClientMonitoringInteractionInfo); Map writeUnitTestingInteractionInfo = new LinkedHashMap<>(); Map writeUnitTestingBooleanCommandParams = new LinkedHashMap(); diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index e4586c7b7a6a83..9790f0e75b3306 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -21909,244 +21909,6 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } break; } - case app::Clusters::ClientMonitoring::Id: { - using namespace app::Clusters::ClientMonitoring; - switch (aPath.mAttributeId) - { - case Attributes::IdleModeInterval::Id: { - using TypeInfo = Attributes::IdleModeInterval::TypeInfo; - TypeInfo::DecodableType cppValue; - *aError = app::DataModel::Decode(aReader, cppValue); - if (*aError != CHIP_NO_ERROR) - { - return nullptr; - } - jobject value; - std::string valueClassName = "java/lang/Long"; - std::string valueCtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - cppValue, value); - return value; - } - case Attributes::ActiveModeInterval::Id: { - using TypeInfo = Attributes::ActiveModeInterval::TypeInfo; - TypeInfo::DecodableType cppValue; - *aError = app::DataModel::Decode(aReader, cppValue); - if (*aError != CHIP_NO_ERROR) - { - return nullptr; - } - jobject value; - std::string valueClassName = "java/lang/Long"; - std::string valueCtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - cppValue, value); - return value; - } - case Attributes::ActiveModeThreshold::Id: { - using TypeInfo = Attributes::ActiveModeThreshold::TypeInfo; - TypeInfo::DecodableType cppValue; - *aError = app::DataModel::Decode(aReader, cppValue); - if (*aError != CHIP_NO_ERROR) - { - return nullptr; - } - jobject value; - std::string valueClassName = "java/lang/Integer"; - std::string valueCtorSignature = "(I)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - cppValue, value); - return value; - } - case Attributes::ExpectedClients::Id: { - using TypeInfo = Attributes::ExpectedClients::TypeInfo; - TypeInfo::DecodableType cppValue; - *aError = app::DataModel::Decode(aReader, cppValue); - if (*aError != CHIP_NO_ERROR) - { - return nullptr; - } - jobject value; - chip::JniReferences::GetInstance().CreateArrayList(value); - - auto iter_value_0 = cppValue.begin(); - while (iter_value_0.Next()) - { - auto & entry_0 = iter_value_0.GetValue(); - jobject newElement_0; - jobject newElement_0_clientNodeId; - std::string newElement_0_clientNodeIdClassName = "java/lang/Long"; - std::string newElement_0_clientNodeIdCtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_clientNodeIdClassName.c_str(), - newElement_0_clientNodeIdCtorSignature.c_str(), - entry_0.clientNodeId, newElement_0_clientNodeId); - jobject newElement_0_ICid; - std::string newElement_0_ICidClassName = "java/lang/Long"; - std::string newElement_0_ICidCtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_ICidClassName.c_str(), newElement_0_ICidCtorSignature.c_str(), entry_0.ICid, newElement_0_ICid); - jobject newElement_0_fabricIndex; - std::string newElement_0_fabricIndexClassName = "java/lang/Integer"; - std::string newElement_0_fabricIndexCtorSignature = "(I)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_fabricIndexClassName.c_str(), - newElement_0_fabricIndexCtorSignature.c_str(), - entry_0.fabricIndex, newElement_0_fabricIndex); - - jclass monitoringRegistrationStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ClientMonitoringClusterMonitoringRegistration", - monitoringRegistrationStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ClientMonitoringClusterMonitoringRegistration"); - return nullptr; - } - jmethodID monitoringRegistrationStructCtor_1 = env->GetMethodID( - monitoringRegistrationStructClass_1, "", "(Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Integer;)V"); - if (monitoringRegistrationStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ClientMonitoringClusterMonitoringRegistration constructor"); - return nullptr; - } - - newElement_0 = env->NewObject(monitoringRegistrationStructClass_1, monitoringRegistrationStructCtor_1, - newElement_0_clientNodeId, newElement_0_ICid, newElement_0_fabricIndex); - chip::JniReferences::GetInstance().AddToList(value, newElement_0); - } - return value; - } - case Attributes::GeneratedCommandList::Id: { - using TypeInfo = Attributes::GeneratedCommandList::TypeInfo; - TypeInfo::DecodableType cppValue; - *aError = app::DataModel::Decode(aReader, cppValue); - if (*aError != CHIP_NO_ERROR) - { - return nullptr; - } - jobject value; - chip::JniReferences::GetInstance().CreateArrayList(value); - - auto iter_value_0 = cppValue.begin(); - while (iter_value_0.Next()) - { - auto & entry_0 = iter_value_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Long"; - std::string newElement_0CtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), entry_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(value, newElement_0); - } - return value; - } - case Attributes::AcceptedCommandList::Id: { - using TypeInfo = Attributes::AcceptedCommandList::TypeInfo; - TypeInfo::DecodableType cppValue; - *aError = app::DataModel::Decode(aReader, cppValue); - if (*aError != CHIP_NO_ERROR) - { - return nullptr; - } - jobject value; - chip::JniReferences::GetInstance().CreateArrayList(value); - - auto iter_value_0 = cppValue.begin(); - while (iter_value_0.Next()) - { - auto & entry_0 = iter_value_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Long"; - std::string newElement_0CtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), entry_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(value, newElement_0); - } - return value; - } - case Attributes::EventList::Id: { - using TypeInfo = Attributes::EventList::TypeInfo; - TypeInfo::DecodableType cppValue; - *aError = app::DataModel::Decode(aReader, cppValue); - if (*aError != CHIP_NO_ERROR) - { - return nullptr; - } - jobject value; - chip::JniReferences::GetInstance().CreateArrayList(value); - - auto iter_value_0 = cppValue.begin(); - while (iter_value_0.Next()) - { - auto & entry_0 = iter_value_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Long"; - std::string newElement_0CtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), entry_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(value, newElement_0); - } - return value; - } - case Attributes::AttributeList::Id: { - using TypeInfo = Attributes::AttributeList::TypeInfo; - TypeInfo::DecodableType cppValue; - *aError = app::DataModel::Decode(aReader, cppValue); - if (*aError != CHIP_NO_ERROR) - { - return nullptr; - } - jobject value; - chip::JniReferences::GetInstance().CreateArrayList(value); - - auto iter_value_0 = cppValue.begin(); - while (iter_value_0.Next()) - { - auto & entry_0 = iter_value_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Long"; - std::string newElement_0CtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), entry_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(value, newElement_0); - } - return value; - } - case Attributes::FeatureMap::Id: { - using TypeInfo = Attributes::FeatureMap::TypeInfo; - TypeInfo::DecodableType cppValue; - *aError = app::DataModel::Decode(aReader, cppValue); - if (*aError != CHIP_NO_ERROR) - { - return nullptr; - } - jobject value; - std::string valueClassName = "java/lang/Long"; - std::string valueCtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - cppValue, value); - return value; - } - case Attributes::ClusterRevision::Id: { - using TypeInfo = Attributes::ClusterRevision::TypeInfo; - TypeInfo::DecodableType cppValue; - *aError = app::DataModel::Decode(aReader, cppValue); - if (*aError != CHIP_NO_ERROR) - { - return nullptr; - } - jobject value; - std::string valueClassName = "java/lang/Integer"; - std::string valueCtorSignature = "(I)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - cppValue, value); - return value; - } - default: - *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; - break; - } - break; - } case app::Clusters::UnitTesting::Id: { using namespace app::Clusters::UnitTesting; switch (aPath.mAttributeId) diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index 066d36bdd1f4d2..71c20ae30036fe 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -3436,16 +3436,6 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } break; } - case app::Clusters::ClientMonitoring::Id: { - using namespace app::Clusters::ClientMonitoring; - switch (aPath.mEventId) - { - default: - *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; - break; - } - break; - } case app::Clusters::UnitTesting::Id: { using namespace app::Clusters::UnitTesting; switch (aPath.mEventId) diff --git a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp index caf86b14ed9214..198aa3b31806bc 100644 --- a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp @@ -31913,396 +31913,6 @@ void CHIPElectricalMeasurementAttributeListAttributeCallback::CallbackFn( env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); } -CHIPClientMonitoringExpectedClientsAttributeCallback::CHIPClientMonitoringExpectedClientsAttributeCallback(jobject javaCallback, - bool keepAlive) : - chip::Callback::Callback(CallbackFn, this), - keepAlive(keepAlive) -{ - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPClientMonitoringExpectedClientsAttributeCallback::~CHIPClientMonitoringExpectedClientsAttributeCallback() -{ - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -} - -void CHIPClientMonitoringExpectedClientsAttributeCallback::CallbackFn( - void * context, - const chip::app::DataModel::DecodableList< - chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType> & list) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); - - std::unique_ptr cppCallback( - reinterpret_cast(context), maybeDestroy); - - // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. - javaCallbackRef = cppCallback.get()->javaCallbackRef; - VerifyOrReturn(javaCallbackRef != nullptr, - ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); - - jmethodID javaMethod; - err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); - - jobject arrayListObj; - chip::JniReferences::GetInstance().CreateArrayList(arrayListObj); - - auto iter_arrayListObj_0 = list.begin(); - while (iter_arrayListObj_0.Next()) - { - auto & entry_0 = iter_arrayListObj_0.GetValue(); - jobject newElement_0; - jobject newElement_0_clientNodeId; - std::string newElement_0_clientNodeIdClassName = "java/lang/Long"; - std::string newElement_0_clientNodeIdCtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_clientNodeIdClassName.c_str(), - newElement_0_clientNodeIdCtorSignature.c_str(), - entry_0.clientNodeId, newElement_0_clientNodeId); - jobject newElement_0_ICid; - std::string newElement_0_ICidClassName = "java/lang/Long"; - std::string newElement_0_ICidCtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_0_ICidClassName.c_str(), newElement_0_ICidCtorSignature.c_str(), entry_0.ICid, newElement_0_ICid); - jobject newElement_0_fabricIndex; - std::string newElement_0_fabricIndexClassName = "java/lang/Integer"; - std::string newElement_0_fabricIndexCtorSignature = "(I)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_fabricIndexClassName.c_str(), - newElement_0_fabricIndexCtorSignature.c_str(), - entry_0.fabricIndex, newElement_0_fabricIndex); - - jclass monitoringRegistrationStructClass_1; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$ClientMonitoringClusterMonitoringRegistration", - monitoringRegistrationStructClass_1); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$ClientMonitoringClusterMonitoringRegistration"); - return; - } - jmethodID monitoringRegistrationStructCtor_1 = env->GetMethodID(monitoringRegistrationStructClass_1, "", - "(Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Integer;)V"); - if (monitoringRegistrationStructCtor_1 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$ClientMonitoringClusterMonitoringRegistration constructor"); - return; - } - - newElement_0 = env->NewObject(monitoringRegistrationStructClass_1, monitoringRegistrationStructCtor_1, - newElement_0_clientNodeId, newElement_0_ICid, newElement_0_fabricIndex); - chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); - } - - env->ExceptionClear(); - env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); -} - -CHIPClientMonitoringGeneratedCommandListAttributeCallback::CHIPClientMonitoringGeneratedCommandListAttributeCallback( - jobject javaCallback, bool keepAlive) : - chip::Callback::Callback(CallbackFn, this), - keepAlive(keepAlive) -{ - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPClientMonitoringGeneratedCommandListAttributeCallback::~CHIPClientMonitoringGeneratedCommandListAttributeCallback() -{ - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -} - -void CHIPClientMonitoringGeneratedCommandListAttributeCallback::CallbackFn( - void * context, const chip::app::DataModel::DecodableList & list) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); - - std::unique_ptr cppCallback( - reinterpret_cast(context), maybeDestroy); - - // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. - javaCallbackRef = cppCallback.get()->javaCallbackRef; - VerifyOrReturn(javaCallbackRef != nullptr, - ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); - - jmethodID javaMethod; - err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); - - jobject arrayListObj; - chip::JniReferences::GetInstance().CreateArrayList(arrayListObj); - - auto iter_arrayListObj_0 = list.begin(); - while (iter_arrayListObj_0.Next()) - { - auto & entry_0 = iter_arrayListObj_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Long"; - std::string newElement_0CtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), - newElement_0CtorSignature.c_str(), entry_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); - } - - env->ExceptionClear(); - env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); -} - -CHIPClientMonitoringAcceptedCommandListAttributeCallback::CHIPClientMonitoringAcceptedCommandListAttributeCallback( - jobject javaCallback, bool keepAlive) : - chip::Callback::Callback(CallbackFn, this), - keepAlive(keepAlive) -{ - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPClientMonitoringAcceptedCommandListAttributeCallback::~CHIPClientMonitoringAcceptedCommandListAttributeCallback() -{ - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -} - -void CHIPClientMonitoringAcceptedCommandListAttributeCallback::CallbackFn( - void * context, const chip::app::DataModel::DecodableList & list) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); - - std::unique_ptr cppCallback( - reinterpret_cast(context), maybeDestroy); - - // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. - javaCallbackRef = cppCallback.get()->javaCallbackRef; - VerifyOrReturn(javaCallbackRef != nullptr, - ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); - - jmethodID javaMethod; - err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); - - jobject arrayListObj; - chip::JniReferences::GetInstance().CreateArrayList(arrayListObj); - - auto iter_arrayListObj_0 = list.begin(); - while (iter_arrayListObj_0.Next()) - { - auto & entry_0 = iter_arrayListObj_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Long"; - std::string newElement_0CtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), - newElement_0CtorSignature.c_str(), entry_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); - } - - env->ExceptionClear(); - env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); -} - -CHIPClientMonitoringEventListAttributeCallback::CHIPClientMonitoringEventListAttributeCallback(jobject javaCallback, - bool keepAlive) : - chip::Callback::Callback(CallbackFn, this), - keepAlive(keepAlive) -{ - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPClientMonitoringEventListAttributeCallback::~CHIPClientMonitoringEventListAttributeCallback() -{ - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -} - -void CHIPClientMonitoringEventListAttributeCallback::CallbackFn(void * context, - const chip::app::DataModel::DecodableList & list) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); - - std::unique_ptr cppCallback( - reinterpret_cast(context), maybeDestroy); - - // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. - javaCallbackRef = cppCallback.get()->javaCallbackRef; - VerifyOrReturn(javaCallbackRef != nullptr, - ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); - - jmethodID javaMethod; - err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); - - jobject arrayListObj; - chip::JniReferences::GetInstance().CreateArrayList(arrayListObj); - - auto iter_arrayListObj_0 = list.begin(); - while (iter_arrayListObj_0.Next()) - { - auto & entry_0 = iter_arrayListObj_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Long"; - std::string newElement_0CtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), - newElement_0CtorSignature.c_str(), entry_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); - } - - env->ExceptionClear(); - env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); -} - -CHIPClientMonitoringAttributeListAttributeCallback::CHIPClientMonitoringAttributeListAttributeCallback(jobject javaCallback, - bool keepAlive) : - chip::Callback::Callback(CallbackFn, this), - keepAlive(keepAlive) -{ - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - return; - } - - javaCallbackRef = env->NewGlobalRef(javaCallback); - if (javaCallbackRef == nullptr) - { - ChipLogError(Zcl, "Could not create global reference for Java callback"); - } -} - -CHIPClientMonitoringAttributeListAttributeCallback::~CHIPClientMonitoringAttributeListAttributeCallback() -{ - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - if (env == nullptr) - { - ChipLogError(Zcl, "Could not delete global reference for Java callback"); - return; - } - env->DeleteGlobalRef(javaCallbackRef); -} - -void CHIPClientMonitoringAttributeListAttributeCallback::CallbackFn( - void * context, const chip::app::DataModel::DecodableList & list) -{ - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject javaCallbackRef; - - VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); - - std::unique_ptr cppCallback( - reinterpret_cast(context), maybeDestroy); - - // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. - javaCallbackRef = cppCallback.get()->javaCallbackRef; - VerifyOrReturn(javaCallbackRef != nullptr, - ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); - - jmethodID javaMethod; - err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); - VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); - - jobject arrayListObj; - chip::JniReferences::GetInstance().CreateArrayList(arrayListObj); - - auto iter_arrayListObj_0 = list.begin(); - while (iter_arrayListObj_0.Next()) - { - auto & entry_0 = iter_arrayListObj_0.GetValue(); - jobject newElement_0; - std::string newElement_0ClassName = "java/lang/Long"; - std::string newElement_0CtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), - newElement_0CtorSignature.c_str(), entry_0, newElement_0); - chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); - } - - env->ExceptionClear(); - env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); -} - CHIPUnitTestingListInt8uAttributeCallback::CHIPUnitTestingListInt8uAttributeCallback(jobject javaCallback, bool keepAlive) : chip::Callback::Callback(CallbackFn, this), keepAlive(keepAlive) { diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java index 68cadaf318e3e4..9bf694f16f5f5a 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java @@ -27560,254 +27560,6 @@ private native void subscribeClusterRevisionAttribute( long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval); } - public static class ClientMonitoringCluster extends BaseChipCluster { - public static final long CLUSTER_ID = 4166L; - - public ClientMonitoringCluster(long devicePtr, int endpointId) { - super(devicePtr, endpointId); - } - - @Override - public native long initWithDevice(long devicePtr, int endpointId); - - public void registerClientMonitoring( - DefaultClusterCallback callback, Long clientNodeId, Long ICid) { - registerClientMonitoring(chipClusterPtr, callback, clientNodeId, ICid, null); - } - - public void registerClientMonitoring( - DefaultClusterCallback callback, Long clientNodeId, Long ICid, int timedInvokeTimeoutMs) { - registerClientMonitoring(chipClusterPtr, callback, clientNodeId, ICid, timedInvokeTimeoutMs); - } - - public void unregisterClientMonitoring( - DefaultClusterCallback callback, Long clientNodeId, Long ICid) { - unregisterClientMonitoring(chipClusterPtr, callback, clientNodeId, ICid, null); - } - - public void unregisterClientMonitoring( - DefaultClusterCallback callback, Long clientNodeId, Long ICid, int timedInvokeTimeoutMs) { - unregisterClientMonitoring( - chipClusterPtr, callback, clientNodeId, ICid, timedInvokeTimeoutMs); - } - - private native void registerClientMonitoring( - long chipClusterPtr, - DefaultClusterCallback Callback, - Long clientNodeId, - Long ICid, - @Nullable Integer timedInvokeTimeoutMs); - - private native void unregisterClientMonitoring( - long chipClusterPtr, - DefaultClusterCallback Callback, - Long clientNodeId, - Long ICid, - @Nullable Integer timedInvokeTimeoutMs); - - public interface ExpectedClientsAttributeCallback { - void onSuccess(List valueList); - - void onError(Exception ex); - - default void onSubscriptionEstablished(long subscriptionId) {} - } - - public interface GeneratedCommandListAttributeCallback { - void onSuccess(List valueList); - - void onError(Exception ex); - - default void onSubscriptionEstablished(long subscriptionId) {} - } - - public interface AcceptedCommandListAttributeCallback { - void onSuccess(List valueList); - - void onError(Exception ex); - - default void onSubscriptionEstablished(long subscriptionId) {} - } - - public interface EventListAttributeCallback { - void onSuccess(List valueList); - - void onError(Exception ex); - - default void onSubscriptionEstablished(long subscriptionId) {} - } - - public interface AttributeListAttributeCallback { - void onSuccess(List valueList); - - void onError(Exception ex); - - default void onSubscriptionEstablished(long subscriptionId) {} - } - - public void readIdleModeIntervalAttribute(LongAttributeCallback callback) { - readIdleModeIntervalAttribute(chipClusterPtr, callback); - } - - public void subscribeIdleModeIntervalAttribute( - LongAttributeCallback callback, int minInterval, int maxInterval) { - subscribeIdleModeIntervalAttribute(chipClusterPtr, callback, minInterval, maxInterval); - } - - public void readActiveModeIntervalAttribute(LongAttributeCallback callback) { - readActiveModeIntervalAttribute(chipClusterPtr, callback); - } - - public void subscribeActiveModeIntervalAttribute( - LongAttributeCallback callback, int minInterval, int maxInterval) { - subscribeActiveModeIntervalAttribute(chipClusterPtr, callback, minInterval, maxInterval); - } - - public void readActiveModeThresholdAttribute(IntegerAttributeCallback callback) { - readActiveModeThresholdAttribute(chipClusterPtr, callback); - } - - public void subscribeActiveModeThresholdAttribute( - IntegerAttributeCallback callback, int minInterval, int maxInterval) { - subscribeActiveModeThresholdAttribute(chipClusterPtr, callback, minInterval, maxInterval); - } - - public void readExpectedClientsAttribute(ExpectedClientsAttributeCallback callback) { - readExpectedClientsAttribute(chipClusterPtr, callback); - } - - public void subscribeExpectedClientsAttribute( - ExpectedClientsAttributeCallback callback, int minInterval, int maxInterval) { - subscribeExpectedClientsAttribute(chipClusterPtr, callback, minInterval, maxInterval); - } - - public void readGeneratedCommandListAttribute(GeneratedCommandListAttributeCallback callback) { - readGeneratedCommandListAttribute(chipClusterPtr, callback); - } - - public void subscribeGeneratedCommandListAttribute( - GeneratedCommandListAttributeCallback callback, int minInterval, int maxInterval) { - subscribeGeneratedCommandListAttribute(chipClusterPtr, callback, minInterval, maxInterval); - } - - public void readAcceptedCommandListAttribute(AcceptedCommandListAttributeCallback callback) { - readAcceptedCommandListAttribute(chipClusterPtr, callback); - } - - public void subscribeAcceptedCommandListAttribute( - AcceptedCommandListAttributeCallback callback, int minInterval, int maxInterval) { - subscribeAcceptedCommandListAttribute(chipClusterPtr, callback, minInterval, maxInterval); - } - - public void readEventListAttribute(EventListAttributeCallback callback) { - readEventListAttribute(chipClusterPtr, callback); - } - - public void subscribeEventListAttribute( - EventListAttributeCallback callback, int minInterval, int maxInterval) { - subscribeEventListAttribute(chipClusterPtr, callback, minInterval, maxInterval); - } - - public void readAttributeListAttribute(AttributeListAttributeCallback callback) { - readAttributeListAttribute(chipClusterPtr, callback); - } - - public void subscribeAttributeListAttribute( - AttributeListAttributeCallback callback, int minInterval, int maxInterval) { - subscribeAttributeListAttribute(chipClusterPtr, callback, minInterval, maxInterval); - } - - public void readFeatureMapAttribute(LongAttributeCallback callback) { - readFeatureMapAttribute(chipClusterPtr, callback); - } - - public void subscribeFeatureMapAttribute( - LongAttributeCallback callback, int minInterval, int maxInterval) { - subscribeFeatureMapAttribute(chipClusterPtr, callback, minInterval, maxInterval); - } - - public void readClusterRevisionAttribute(IntegerAttributeCallback callback) { - readClusterRevisionAttribute(chipClusterPtr, callback); - } - - public void subscribeClusterRevisionAttribute( - IntegerAttributeCallback callback, int minInterval, int maxInterval) { - subscribeClusterRevisionAttribute(chipClusterPtr, callback, minInterval, maxInterval); - } - - private native void readIdleModeIntervalAttribute( - long chipClusterPtr, LongAttributeCallback callback); - - private native void subscribeIdleModeIntervalAttribute( - long chipClusterPtr, LongAttributeCallback callback, int minInterval, int maxInterval); - - private native void readActiveModeIntervalAttribute( - long chipClusterPtr, LongAttributeCallback callback); - - private native void subscribeActiveModeIntervalAttribute( - long chipClusterPtr, LongAttributeCallback callback, int minInterval, int maxInterval); - - private native void readActiveModeThresholdAttribute( - long chipClusterPtr, IntegerAttributeCallback callback); - - private native void subscribeActiveModeThresholdAttribute( - long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval); - - private native void readExpectedClientsAttribute( - long chipClusterPtr, ExpectedClientsAttributeCallback callback); - - private native void subscribeExpectedClientsAttribute( - long chipClusterPtr, - ExpectedClientsAttributeCallback callback, - int minInterval, - int maxInterval); - - private native void readGeneratedCommandListAttribute( - long chipClusterPtr, GeneratedCommandListAttributeCallback callback); - - private native void subscribeGeneratedCommandListAttribute( - long chipClusterPtr, - GeneratedCommandListAttributeCallback callback, - int minInterval, - int maxInterval); - - private native void readAcceptedCommandListAttribute( - long chipClusterPtr, AcceptedCommandListAttributeCallback callback); - - private native void subscribeAcceptedCommandListAttribute( - long chipClusterPtr, - AcceptedCommandListAttributeCallback callback, - int minInterval, - int maxInterval); - - private native void readEventListAttribute( - long chipClusterPtr, EventListAttributeCallback callback); - - private native void subscribeEventListAttribute( - long chipClusterPtr, EventListAttributeCallback callback, int minInterval, int maxInterval); - - private native void readAttributeListAttribute( - long chipClusterPtr, AttributeListAttributeCallback callback); - - private native void subscribeAttributeListAttribute( - long chipClusterPtr, - AttributeListAttributeCallback callback, - int minInterval, - int maxInterval); - - private native void readFeatureMapAttribute( - long chipClusterPtr, LongAttributeCallback callback); - - private native void subscribeFeatureMapAttribute( - long chipClusterPtr, LongAttributeCallback callback, int minInterval, int maxInterval); - - private native void readClusterRevisionAttribute( - long chipClusterPtr, IntegerAttributeCallback callback); - - private native void subscribeClusterRevisionAttribute( - long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval); - } - public static class UnitTestingCluster extends BaseChipCluster { public static final long CLUSTER_ID = 4294048773L; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java index 3a707bb8a5bad4..b50c4ff62cc48e 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java @@ -217,9 +217,6 @@ public static String clusterIdToName(long clusterId) { if (clusterId == 2820L) { return "ElectricalMeasurement"; } - if (clusterId == 4166L) { - return "ClientMonitoring"; - } if (clusterId == 4294048773L) { return "UnitTesting"; } @@ -3621,39 +3618,6 @@ public static String attributeIdToName(long clusterId, long attributeId) { } return ""; } - if (clusterId == 4166L) { - if (attributeId == 0L) { - return "IdleModeInterval"; - } - if (attributeId == 1L) { - return "ActiveModeInterval"; - } - if (attributeId == 2L) { - return "ActiveModeThreshold"; - } - if (attributeId == 3L) { - return "ExpectedClients"; - } - if (attributeId == 65528L) { - return "GeneratedCommandList"; - } - if (attributeId == 65529L) { - return "AcceptedCommandList"; - } - if (attributeId == 65530L) { - return "EventList"; - } - if (attributeId == 65531L) { - return "AttributeList"; - } - if (attributeId == 65532L) { - return "FeatureMap"; - } - if (attributeId == 65533L) { - return "ClusterRevision"; - } - return ""; - } if (clusterId == 4294048773L) { if (attributeId == 0L) { return "Boolean"; @@ -4295,9 +4259,6 @@ public static String eventIdToName(long clusterId, long eventId) { if (clusterId == 2820L) { return ""; } - if (clusterId == 4166L) { - return ""; - } if (clusterId == 4294048773L) { if (eventId == 1L) { return "TestEvent"; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java index e78e5c00913076..18d55b362c7b68 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java @@ -1880,36 +1880,6 @@ public String toString() { } } - public static class ClientMonitoringClusterMonitoringRegistration { - public Long clientNodeId; - public Long ICid; - public Integer fabricIndex; - - public ClientMonitoringClusterMonitoringRegistration( - Long clientNodeId, Long ICid, Integer fabricIndex) { - this.clientNodeId = clientNodeId; - this.ICid = ICid; - this.fabricIndex = fabricIndex; - } - - @Override - public String toString() { - StringBuilder output = new StringBuilder(); - output.append("ClientMonitoringClusterMonitoringRegistration {\n"); - output.append("\tclientNodeId: "); - output.append(clientNodeId); - output.append("\n"); - output.append("\tICid: "); - output.append(ICid); - output.append("\n"); - output.append("\tfabricIndex: "); - output.append(fabricIndex); - output.append("\n"); - output.append("}\n"); - return output.toString(); - } - } - public static class UnitTestingClusterSimpleStruct { public Integer a; public Boolean b; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java index 68c919e25bb999..8a8a431885d0f2 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java @@ -11897,129 +11897,6 @@ public void onError(Exception ex) { } } - public static class DelegatedClientMonitoringClusterExpectedClientsAttributeCallback - implements ChipClusters.ClientMonitoringCluster.ExpectedClientsAttributeCallback, - DelegatedClusterCallback { - private ClusterCommandCallback callback; - - @Override - public void setCallbackDelegate(ClusterCommandCallback callback) { - this.callback = callback; - } - - @Override - public void onSuccess( - List valueList) { - Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = - new CommandResponseInfo( - "valueList", "List"); - responseValues.put(commandResponseInfo, valueList); - callback.onSuccess(responseValues); - } - - @Override - public void onError(Exception ex) { - callback.onFailure(ex); - } - } - - public static class DelegatedClientMonitoringClusterGeneratedCommandListAttributeCallback - implements ChipClusters.ClientMonitoringCluster.GeneratedCommandListAttributeCallback, - DelegatedClusterCallback { - private ClusterCommandCallback callback; - - @Override - public void setCallbackDelegate(ClusterCommandCallback callback) { - this.callback = callback; - } - - @Override - public void onSuccess(List valueList) { - Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); - responseValues.put(commandResponseInfo, valueList); - callback.onSuccess(responseValues); - } - - @Override - public void onError(Exception ex) { - callback.onFailure(ex); - } - } - - public static class DelegatedClientMonitoringClusterAcceptedCommandListAttributeCallback - implements ChipClusters.ClientMonitoringCluster.AcceptedCommandListAttributeCallback, - DelegatedClusterCallback { - private ClusterCommandCallback callback; - - @Override - public void setCallbackDelegate(ClusterCommandCallback callback) { - this.callback = callback; - } - - @Override - public void onSuccess(List valueList) { - Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); - responseValues.put(commandResponseInfo, valueList); - callback.onSuccess(responseValues); - } - - @Override - public void onError(Exception ex) { - callback.onFailure(ex); - } - } - - public static class DelegatedClientMonitoringClusterEventListAttributeCallback - implements ChipClusters.ClientMonitoringCluster.EventListAttributeCallback, - DelegatedClusterCallback { - private ClusterCommandCallback callback; - - @Override - public void setCallbackDelegate(ClusterCommandCallback callback) { - this.callback = callback; - } - - @Override - public void onSuccess(List valueList) { - Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); - responseValues.put(commandResponseInfo, valueList); - callback.onSuccess(responseValues); - } - - @Override - public void onError(Exception ex) { - callback.onFailure(ex); - } - } - - public static class DelegatedClientMonitoringClusterAttributeListAttributeCallback - implements ChipClusters.ClientMonitoringCluster.AttributeListAttributeCallback, - DelegatedClusterCallback { - private ClusterCommandCallback callback; - - @Override - public void setCallbackDelegate(ClusterCommandCallback callback) { - this.callback = callback; - } - - @Override - public void onSuccess(List valueList) { - Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); - responseValues.put(commandResponseInfo, valueList); - callback.onSuccess(responseValues); - } - - @Override - public void onError(Exception ex) { - callback.onFailure(ex); - } - } - public static class DelegatedUnitTestingClusterTestSpecificResponseCallback implements ChipClusters.UnitTestingCluster.TestSpecificResponseCallback, DelegatedClusterCallback { @@ -13583,11 +13460,6 @@ public Map initializeClusterMap() { (ptr, endpointId) -> new ChipClusters.ElectricalMeasurementCluster(ptr, endpointId), new HashMap<>()); clusterMap.put("electricalMeasurement", electricalMeasurementClusterInfo); - ClusterInfo clientMonitoringClusterInfo = - new ClusterInfo( - (ptr, endpointId) -> new ChipClusters.ClientMonitoringCluster(ptr, endpointId), - new HashMap<>()); - clusterMap.put("clientMonitoring", clientMonitoringClusterInfo); ClusterInfo unitTestingClusterInfo = new ClusterInfo( (ptr, endpointId) -> new ChipClusters.UnitTestingCluster(ptr, endpointId), @@ -13686,7 +13558,6 @@ public void combineCommand( destination.get("applicationBasic").combineCommands(source.get("applicationBasic")); destination.get("accountLogin").combineCommands(source.get("accountLogin")); destination.get("electricalMeasurement").combineCommands(source.get("electricalMeasurement")); - destination.get("clientMonitoring").combineCommands(source.get("clientMonitoring")); destination.get("unitTesting").combineCommands(source.get("unitTesting")); } @@ -17820,59 +17691,6 @@ public Map> getCommandMap() { Map electricalMeasurementClusterInteractionInfoMap = new LinkedHashMap<>(); commandMap.put("electricalMeasurement", electricalMeasurementClusterInteractionInfoMap); - Map clientMonitoringClusterInteractionInfoMap = new LinkedHashMap<>(); - Map clientMonitoringregisterClientMonitoringCommandParams = - new LinkedHashMap(); - CommandParameterInfo clientMonitoringregisterClientMonitoringclientNodeIdCommandParameterInfo = - new CommandParameterInfo("clientNodeId", Long.class, Long.class); - clientMonitoringregisterClientMonitoringCommandParams.put( - "clientNodeId", clientMonitoringregisterClientMonitoringclientNodeIdCommandParameterInfo); - - CommandParameterInfo clientMonitoringregisterClientMonitoringICidCommandParameterInfo = - new CommandParameterInfo("ICid", Long.class, Long.class); - clientMonitoringregisterClientMonitoringCommandParams.put( - "ICid", clientMonitoringregisterClientMonitoringICidCommandParameterInfo); - - InteractionInfo clientMonitoringregisterClientMonitoringInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.ClientMonitoringCluster) cluster) - .registerClientMonitoring( - (DefaultClusterCallback) callback, - (Long) commandArguments.get("clientNodeId"), - (Long) commandArguments.get("ICid")); - }, - () -> new DelegatedDefaultClusterCallback(), - clientMonitoringregisterClientMonitoringCommandParams); - clientMonitoringClusterInteractionInfoMap.put( - "registerClientMonitoring", clientMonitoringregisterClientMonitoringInteractionInfo); - Map clientMonitoringunregisterClientMonitoringCommandParams = - new LinkedHashMap(); - CommandParameterInfo - clientMonitoringunregisterClientMonitoringclientNodeIdCommandParameterInfo = - new CommandParameterInfo("clientNodeId", Long.class, Long.class); - clientMonitoringunregisterClientMonitoringCommandParams.put( - "clientNodeId", clientMonitoringunregisterClientMonitoringclientNodeIdCommandParameterInfo); - - CommandParameterInfo clientMonitoringunregisterClientMonitoringICidCommandParameterInfo = - new CommandParameterInfo("ICid", Long.class, Long.class); - clientMonitoringunregisterClientMonitoringCommandParams.put( - "ICid", clientMonitoringunregisterClientMonitoringICidCommandParameterInfo); - - InteractionInfo clientMonitoringunregisterClientMonitoringInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.ClientMonitoringCluster) cluster) - .unregisterClientMonitoring( - (DefaultClusterCallback) callback, - (Long) commandArguments.get("clientNodeId"), - (Long) commandArguments.get("ICid")); - }, - () -> new DelegatedDefaultClusterCallback(), - clientMonitoringunregisterClientMonitoringCommandParams); - clientMonitoringClusterInteractionInfoMap.put( - "unregisterClientMonitoring", clientMonitoringunregisterClientMonitoringInteractionInfo); - commandMap.put("clientMonitoring", clientMonitoringClusterInteractionInfoMap); Map unitTestingClusterInteractionInfoMap = new LinkedHashMap<>(); Map unitTestingtestCommandParams = new LinkedHashMap(); diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 647fa2721d6ebb..ed20a2b7b89283 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -8379,90 +8379,6 @@ class ChipClusters: }, }, } - _CLIENT_MONITORING_CLUSTER_INFO = { - "clusterName": "ClientMonitoring", - "clusterId": 0x00001046, - "commands": { - 0x00000000: { - "commandId": 0x00000000, - "commandName": "RegisterClientMonitoring", - "args": { - "clientNodeId": "int", - "ICid": "int", - }, - }, - 0x00000001: { - "commandId": 0x00000001, - "commandName": "UnregisterClientMonitoring", - "args": { - "clientNodeId": "int", - "ICid": "int", - }, - }, - }, - "attributes": { - 0x00000000: { - "attributeName": "IdleModeInterval", - "attributeId": 0x00000000, - "type": "int", - "reportable": True, - }, - 0x00000001: { - "attributeName": "ActiveModeInterval", - "attributeId": 0x00000001, - "type": "int", - "reportable": True, - }, - 0x00000002: { - "attributeName": "ActiveModeThreshold", - "attributeId": 0x00000002, - "type": "int", - "reportable": True, - }, - 0x00000003: { - "attributeName": "ExpectedClients", - "attributeId": 0x00000003, - "type": "", - "reportable": True, - }, - 0x0000FFF8: { - "attributeName": "GeneratedCommandList", - "attributeId": 0x0000FFF8, - "type": "int", - "reportable": True, - }, - 0x0000FFF9: { - "attributeName": "AcceptedCommandList", - "attributeId": 0x0000FFF9, - "type": "int", - "reportable": True, - }, - 0x0000FFFA: { - "attributeName": "EventList", - "attributeId": 0x0000FFFA, - "type": "int", - "reportable": True, - }, - 0x0000FFFB: { - "attributeName": "AttributeList", - "attributeId": 0x0000FFFB, - "type": "int", - "reportable": True, - }, - 0x0000FFFC: { - "attributeName": "FeatureMap", - "attributeId": 0x0000FFFC, - "type": "int", - "reportable": True, - }, - 0x0000FFFD: { - "attributeName": "ClusterRevision", - "attributeId": 0x0000FFFD, - "type": "int", - "reportable": True, - }, - }, - } _UNIT_TESTING_CLUSTER_INFO = { "clusterName": "UnitTesting", "clusterId": 0xFFF1FC05, @@ -9307,7 +9223,6 @@ class ChipClusters: 0x0000050D: _APPLICATION_BASIC_CLUSTER_INFO, 0x0000050E: _ACCOUNT_LOGIN_CLUSTER_INFO, 0x00000B04: _ELECTRICAL_MEASUREMENT_CLUSTER_INFO, - 0x00001046: _CLIENT_MONITORING_CLUSTER_INFO, 0xFFF1FC05: _UNIT_TESTING_CLUSTER_INFO, } @@ -9376,7 +9291,6 @@ class ChipClusters: "ApplicationBasic": _APPLICATION_BASIC_CLUSTER_INFO, "AccountLogin": _ACCOUNT_LOGIN_CLUSTER_INFO, "ElectricalMeasurement": _ELECTRICAL_MEASUREMENT_CLUSTER_INFO, - "ClientMonitoring": _CLIENT_MONITORING_CLUSTER_INFO, "UnitTesting": _UNIT_TESTING_CLUSTER_INFO, } diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 224ef39d7564eb..fba181de8c0289 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -29036,7 +29036,8 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="idleModeInterval", Tag=0x00000000, Type=uint), ClusterObjectFieldDescriptor(Label="activeModeInterval", Tag=0x00000001, Type=uint), ClusterObjectFieldDescriptor(Label="activeModeThreshold", Tag=0x00000002, Type=uint), - ClusterObjectFieldDescriptor(Label="expectedClients", Tag=0x00000003, Type=typing.List[ClientMonitoring.Structs.MonitoringRegistration]), + ClusterObjectFieldDescriptor(Label="expectedClients", Tag=0x00000003, Type=typing.List[ClientMonitoring.Structs.MonitoringRegistrationStruct]), + ClusterObjectFieldDescriptor(Label="ICDCounter", Tag=0x00000004, Type=uint), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), @@ -29048,7 +29049,8 @@ def descriptor(cls) -> ClusterObjectDescriptor: idleModeInterval: 'uint' = None activeModeInterval: 'uint' = None activeModeThreshold: 'uint' = None - expectedClients: 'typing.List[ClientMonitoring.Structs.MonitoringRegistration]' = None + expectedClients: 'typing.List[ClientMonitoring.Structs.MonitoringRegistrationStruct]' = None + ICDCounter: 'uint' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None eventList: 'typing.List[uint]' = None @@ -29058,18 +29060,18 @@ def descriptor(cls) -> ClusterObjectDescriptor: class Structs: @dataclass - class MonitoringRegistration(ClusterObject): + class MonitoringRegistrationStruct(ClusterObject): @ChipUtility.classproperty def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="clientNodeId", Tag=1, Type=uint), - ClusterObjectFieldDescriptor(Label="ICid", Tag=2, Type=uint), + ClusterObjectFieldDescriptor(Label="clientNodeID", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="key", Tag=2, Type=bytes), ClusterObjectFieldDescriptor(Label="fabricIndex", Tag=254, Type=uint), ]) - clientNodeId: 'uint' = 0 - ICid: 'uint' = 0 + clientNodeID: 'uint' = 0 + key: 'bytes' = b"" fabricIndex: 'uint' = 0 class Commands: @@ -29078,23 +29080,41 @@ class RegisterClientMonitoring(ClusterCommand): cluster_id: typing.ClassVar[int] = 0x1046 command_id: typing.ClassVar[int] = 0x00000000 is_client: typing.ClassVar[bool] = True + response_type: typing.ClassVar[str] = 'RegisterClientMonitoringResponse' + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="clientNodeID", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="key", Tag=1, Type=bytes), + ]) + + clientNodeID: 'uint' = 0 + key: 'bytes' = b"" + + @dataclass + class RegisterClientMonitoringResponse(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0x1046 + command_id: typing.ClassVar[int] = 0x00000001 + is_client: typing.ClassVar[bool] = False response_type: typing.ClassVar[str] = None @ChipUtility.classproperty def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="clientNodeId", Tag=0, Type=uint), - ClusterObjectFieldDescriptor(Label="ICid", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="status", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="ICDCounter", Tag=1, Type=typing.Union[Nullable, uint]), ]) - clientNodeId: 'uint' = 0 - ICid: 'uint' = 0 + status: 'uint' = 0 + ICDCounter: 'typing.Union[Nullable, uint]' = NullValue @dataclass class UnregisterClientMonitoring(ClusterCommand): cluster_id: typing.ClassVar[int] = 0x1046 - command_id: typing.ClassVar[int] = 0x00000001 + command_id: typing.ClassVar[int] = 0x00000002 is_client: typing.ClassVar[bool] = True response_type: typing.ClassVar[str] = None @@ -29102,17 +29122,15 @@ class UnregisterClientMonitoring(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="clientNodeId", Tag=0, Type=uint), - ClusterObjectFieldDescriptor(Label="ICid", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="clientNodeID", Tag=0, Type=uint), ]) - clientNodeId: 'uint' = 0 - ICid: 'uint' = 0 + clientNodeID: 'uint' = 0 @dataclass class StayAwakeRequest(ClusterCommand): cluster_id: typing.ClassVar[int] = 0x1046 - command_id: typing.ClassVar[int] = 0x00000002 + command_id: typing.ClassVar[int] = 0x00000003 is_client: typing.ClassVar[bool] = True response_type: typing.ClassVar[str] = None @@ -29183,9 +29201,25 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.List[ClientMonitoring.Structs.MonitoringRegistration]) + return ClusterObjectFieldDescriptor(Type=typing.List[ClientMonitoring.Structs.MonitoringRegistrationStruct]) + + value: 'typing.List[ClientMonitoring.Structs.MonitoringRegistrationStruct]' = field(default_factory=lambda: []) + + @dataclass + class ICDCounter(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x1046 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000004 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=uint) - value: 'typing.List[ClientMonitoring.Structs.MonitoringRegistration]' = field(default_factory=lambda: []) + value: 'uint' = 0 @dataclass class GeneratedCommandList(ClusterAttributeDescriptor): diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index 6dd1d09dfa0a55..603fa9be0d4fab 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -23383,6 +23383,37 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) } // namespace ActiveModeThreshold +namespace ICDCounter { + +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ClientMonitoring::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + *value = Traits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::ClientMonitoring::Id, Id, writable, ZCL_INT32U_ATTRIBUTE_TYPE); +} + +} // namespace ICDCounter + namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index 2d919d595c757b..d897fd29993f61 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -4019,6 +4019,11 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); } // namespace ActiveModeThreshold +namespace ICDCounter { +EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // int32u +EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); +} // namespace ICDCounter + namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index d7d8ea5bb57a79..1e9a9aa8a52728 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -18798,7 +18798,7 @@ namespace Events {} // namespace Events } // namespace ElectricalMeasurement namespace ClientMonitoring { namespace Structs { -namespace MonitoringRegistration { +namespace MonitoringRegistrationStruct { CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const { return DoEncode(writer, tag, NullOptional); @@ -18811,10 +18811,17 @@ CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricInde CHIP_ERROR Type::DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const { + bool includeSensitive = !accessingFabricIndex.HasValue() || (accessingFabricIndex.Value() == fabricIndex); TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kClientNodeId), clientNodeId)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kICid), ICid)); + if (includeSensitive) + { + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kClientNodeID), clientNodeID)); + } + if (includeSensitive) + { + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kKey), key)); + } if (accessingFabricIndex.HasValue()) { ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kFabricIndex), fabricIndex)); @@ -18838,11 +18845,11 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } switch (TLV::TagNumFromTag(reader.GetTag())) { - case to_underlying(Fields::kClientNodeId): - ReturnErrorOnFailure(DataModel::Decode(reader, clientNodeId)); + case to_underlying(Fields::kClientNodeID): + ReturnErrorOnFailure(DataModel::Decode(reader, clientNodeID)); break; - case to_underlying(Fields::kICid): - ReturnErrorOnFailure(DataModel::Decode(reader, ICid)); + case to_underlying(Fields::kKey): + ReturnErrorOnFailure(DataModel::Decode(reader, key)); break; case to_underlying(Fields::kFabricIndex): ReturnErrorOnFailure(DataModel::Decode(reader, fabricIndex)); @@ -18858,7 +18865,7 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) return CHIP_NO_ERROR; } -} // namespace MonitoringRegistration +} // namespace MonitoringRegistrationStruct } // namespace Structs namespace Commands { @@ -18867,8 +18874,8 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kClientNodeId), clientNodeId)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kICid), ICid)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kClientNodeID), clientNodeID)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kKey), key)); ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; } @@ -18887,11 +18894,11 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } switch (TLV::TagNumFromTag(reader.GetTag())) { - case to_underlying(Fields::kClientNodeId): - ReturnErrorOnFailure(DataModel::Decode(reader, clientNodeId)); + case to_underlying(Fields::kClientNodeID): + ReturnErrorOnFailure(DataModel::Decode(reader, clientNodeID)); break; - case to_underlying(Fields::kICid): - ReturnErrorOnFailure(DataModel::Decode(reader, ICid)); + case to_underlying(Fields::kKey): + ReturnErrorOnFailure(DataModel::Decode(reader, key)); break; default: break; @@ -18903,13 +18910,13 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) return CHIP_NO_ERROR; } } // namespace RegisterClientMonitoring. -namespace UnregisterClientMonitoring { +namespace RegisterClientMonitoringResponse { CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kClientNodeId), clientNodeId)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kICid), ICid)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kStatus), status)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kICDCounter), ICDCounter)); ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; } @@ -18928,11 +18935,48 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } switch (TLV::TagNumFromTag(reader.GetTag())) { - case to_underlying(Fields::kClientNodeId): - ReturnErrorOnFailure(DataModel::Decode(reader, clientNodeId)); + case to_underlying(Fields::kStatus): + ReturnErrorOnFailure(DataModel::Decode(reader, status)); break; - case to_underlying(Fields::kICid): - ReturnErrorOnFailure(DataModel::Decode(reader, ICid)); + case to_underlying(Fields::kICDCounter): + ReturnErrorOnFailure(DataModel::Decode(reader, ICDCounter)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace RegisterClientMonitoringResponse. +namespace UnregisterClientMonitoring { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kClientNodeID), clientNodeID)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kClientNodeID): + ReturnErrorOnFailure(DataModel::Decode(reader, clientNodeID)); break; default: break; @@ -18996,6 +19040,9 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre case Attributes::ExpectedClients::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, expectedClients)); break; + case Attributes::ICDCounter::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, ICDCounter)); + break; case Attributes::GeneratedCommandList::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, generatedCommandList)); break; @@ -21855,6 +21902,10 @@ bool CommandIsFabricScoped(ClusterId aCluster, CommandId aCommand) case Clusters::ClientMonitoring::Id: { switch (aCommand) { + case Clusters::ClientMonitoring::Commands::RegisterClientMonitoring::Id: + return true; + case Clusters::ClientMonitoring::Commands::UnregisterClientMonitoring::Id: + return true; default: return false; } diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index 68ee013cd179aa..c8b474f334ba13 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -25859,19 +25859,19 @@ struct TypeInfo } // namespace ElectricalMeasurement namespace ClientMonitoring { namespace Structs { -namespace MonitoringRegistration { +namespace MonitoringRegistrationStruct { enum class Fields : uint8_t { - kClientNodeId = 1, - kICid = 2, + kClientNodeID = 1, + kKey = 2, kFabricIndex = 254, }; struct Type { public: - chip::NodeId clientNodeId = static_cast(0); - uint64_t ICid = static_cast(0); + chip::NodeId clientNodeID = static_cast(0); + chip::ByteSpan key; chip::FabricIndex fabricIndex = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); @@ -25891,7 +25891,7 @@ struct Type using DecodableType = Type; -} // namespace MonitoringRegistration +} // namespace MonitoringRegistrationStruct } // namespace Structs namespace Commands { @@ -25902,6 +25902,11 @@ struct Type; struct DecodableType; } // namespace RegisterClientMonitoring +namespace RegisterClientMonitoringResponse { +struct Type; +struct DecodableType; +} // namespace RegisterClientMonitoringResponse + namespace UnregisterClientMonitoring { struct Type; struct DecodableType; @@ -25918,8 +25923,8 @@ namespace Commands { namespace RegisterClientMonitoring { enum class Fields : uint8_t { - kClientNodeId = 0, - kICid = 1, + kClientNodeID = 0, + kKey = 1, }; struct Type @@ -25929,12 +25934,12 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::RegisterClientMonitoring::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ClientMonitoring::Id; } - chip::NodeId clientNodeId = static_cast(0); - uint64_t ICid = static_cast(0); + chip::NodeId clientNodeID = static_cast(0); + chip::ByteSpan key; CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - using ResponseType = DataModel::NullObjectType; + using ResponseType = Clusters::ClientMonitoring::Commands::RegisterClientMonitoringResponse::DecodableType; static constexpr bool MustUseTimedInvoke() { return false; } }; @@ -25945,16 +25950,50 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::RegisterClientMonitoring::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ClientMonitoring::Id; } - chip::NodeId clientNodeId = static_cast(0); - uint64_t ICid = static_cast(0); + chip::NodeId clientNodeID = static_cast(0); + chip::ByteSpan key; CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace RegisterClientMonitoring +namespace RegisterClientMonitoringResponse { +enum class Fields : uint8_t +{ + kStatus = 0, + kICDCounter = 1, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::RegisterClientMonitoringResponse::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::ClientMonitoring::Id; } + + uint8_t status = static_cast(0); + DataModel::Nullable ICDCounter; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; + + using ResponseType = DataModel::NullObjectType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::RegisterClientMonitoringResponse::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::ClientMonitoring::Id; } + + uint8_t status = static_cast(0); + DataModel::Nullable ICDCounter; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace RegisterClientMonitoringResponse namespace UnregisterClientMonitoring { enum class Fields : uint8_t { - kClientNodeId = 0, - kICid = 1, + kClientNodeID = 0, }; struct Type @@ -25964,8 +26003,7 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::UnregisterClientMonitoring::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ClientMonitoring::Id; } - chip::NodeId clientNodeId = static_cast(0); - uint64_t ICid = static_cast(0); + chip::NodeId clientNodeID = static_cast(0); CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; @@ -25980,8 +26018,7 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::UnregisterClientMonitoring::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ClientMonitoring::Id; } - chip::NodeId clientNodeId = static_cast(0); - uint64_t ICid = static_cast(0); + chip::NodeId clientNodeID = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace UnregisterClientMonitoring @@ -26056,17 +26093,30 @@ struct TypeInfo namespace ExpectedClients { struct TypeInfo { - using Type = chip::app::DataModel::List; - using DecodableType = - chip::app::DataModel::DecodableList; + using Type = + chip::app::DataModel::List; + using DecodableType = chip::app::DataModel::DecodableList< + chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistrationStruct::DecodableType>; using DecodableArgType = const chip::app::DataModel::DecodableList< - chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType> &; + chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistrationStruct::DecodableType> &; static constexpr ClusterId GetClusterId() { return Clusters::ClientMonitoring::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::ExpectedClients::Id; } static constexpr bool MustUseTimedWrite() { return false; } }; } // namespace ExpectedClients +namespace ICDCounter { +struct TypeInfo +{ + using Type = uint32_t; + using DecodableType = uint32_t; + using DecodableArgType = uint32_t; + + static constexpr ClusterId GetClusterId() { return Clusters::ClientMonitoring::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::ICDCounter::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace ICDCounter namespace GeneratedCommandList { struct TypeInfo : public Clusters::Globals::Attributes::GeneratedCommandList::TypeInfo { @@ -26116,6 +26166,7 @@ struct TypeInfo Attributes::ActiveModeInterval::TypeInfo::DecodableType activeModeInterval = static_cast(0); Attributes::ActiveModeThreshold::TypeInfo::DecodableType activeModeThreshold = static_cast(0); Attributes::ExpectedClients::TypeInfo::DecodableType expectedClients; + Attributes::ICDCounter::TypeInfo::DecodableType ICDCounter = static_cast(0); Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; Attributes::EventList::TypeInfo::DecodableType eventList; diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h index d141f4e3d8fedf..e658adbe832a81 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h @@ -4912,6 +4912,10 @@ namespace ExpectedClients { static constexpr AttributeId Id = 0x00000003; } // namespace ExpectedClients +namespace ICDCounter { +static constexpr AttributeId Id = 0x00000004; +} // namespace ICDCounter + namespace GeneratedCommandList { static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; } // namespace GeneratedCommandList diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h index 4bf91f56d5eab0..6699a225a48b1f 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h @@ -1098,12 +1098,16 @@ namespace RegisterClientMonitoring { static constexpr CommandId Id = 0x00000000; } // namespace RegisterClientMonitoring -namespace UnregisterClientMonitoring { +namespace RegisterClientMonitoringResponse { static constexpr CommandId Id = 0x00000001; +} // namespace RegisterClientMonitoringResponse + +namespace UnregisterClientMonitoring { +static constexpr CommandId Id = 0x00000002; } // namespace UnregisterClientMonitoring namespace StayAwakeRequest { -static constexpr CommandId Id = 0x00000002; +static constexpr CommandId Id = 0x00000003; } // namespace StayAwakeRequest } // namespace Commands diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 8a0226fa4c76bb..81be7ed1082963 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -7380,14 +7380,15 @@ class ElectricalMeasurementGetMeasurementProfileCommand : public ClusterCommand |------------------------------------------------------------------------------| | Commands: | | | * RegisterClientMonitoring | 0x00 | -| * UnregisterClientMonitoring | 0x01 | -| * StayAwakeRequest | 0x02 | +| * UnregisterClientMonitoring | 0x02 | +| * StayAwakeRequest | 0x03 | |------------------------------------------------------------------------------| | Attributes: | | | * IdleModeInterval | 0x0000 | | * ActiveModeInterval | 0x0001 | | * ActiveModeThreshold | 0x0002 | | * ExpectedClients | 0x0003 | +| * ICDCounter | 0x0004 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -7407,8 +7408,8 @@ class ClientMonitoringRegisterClientMonitoring : public ClusterCommand ClientMonitoringRegisterClientMonitoring(CredentialIssuerCommands * credsIssuerConfig) : ClusterCommand("register-client-monitoring", credsIssuerConfig) { - AddArgument("ClientNodeId", 0, UINT64_MAX, &mRequest.clientNodeId); - AddArgument("ICid", 0, UINT64_MAX, &mRequest.ICid); + AddArgument("ClientNodeID", 0, UINT64_MAX, &mRequest.clientNodeID); + AddArgument("Key", &mRequest.key); ClusterCommand::AddArguments(); } @@ -7439,23 +7440,22 @@ class ClientMonitoringUnregisterClientMonitoring : public ClusterCommand ClientMonitoringUnregisterClientMonitoring(CredentialIssuerCommands * credsIssuerConfig) : ClusterCommand("unregister-client-monitoring", credsIssuerConfig) { - AddArgument("ClientNodeId", 0, UINT64_MAX, &mRequest.clientNodeId); - AddArgument("ICid", 0, UINT64_MAX, &mRequest.ICid); + AddArgument("ClientNodeID", 0, UINT64_MAX, &mRequest.clientNodeID); ClusterCommand::AddArguments(); } CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override { - ChipLogProgress(chipTool, "Sending cluster (0x00001046) command (0x00000001) on endpoint %u", endpointIds.at(0)); + ChipLogProgress(chipTool, "Sending cluster (0x00001046) command (0x00000002) on endpoint %u", endpointIds.at(0)); - return ClusterCommand::SendCommand(device, endpointIds.at(0), 0x00001046, 0x00000001, mRequest); + return ClusterCommand::SendCommand(device, endpointIds.at(0), 0x00001046, 0x00000002, mRequest); } CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) override { - ChipLogProgress(chipTool, "Sending cluster (0x00001046) command (0x00000001) on Group %u", groupId); + ChipLogProgress(chipTool, "Sending cluster (0x00001046) command (0x00000002) on Group %u", groupId); - return ClusterCommand::SendGroupCommand(groupId, fabricIndex, 0x00001046, 0x00000001, mRequest); + return ClusterCommand::SendGroupCommand(groupId, fabricIndex, 0x00001046, 0x00000002, mRequest); } private: @@ -7476,16 +7476,16 @@ class ClientMonitoringStayAwakeRequest : public ClusterCommand CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override { - ChipLogProgress(chipTool, "Sending cluster (0x00001046) command (0x00000002) on endpoint %u", endpointIds.at(0)); + ChipLogProgress(chipTool, "Sending cluster (0x00001046) command (0x00000003) on endpoint %u", endpointIds.at(0)); - return ClusterCommand::SendCommand(device, endpointIds.at(0), 0x00001046, 0x00000002, mRequest); + return ClusterCommand::SendCommand(device, endpointIds.at(0), 0x00001046, 0x00000003, mRequest); } CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) override { - ChipLogProgress(chipTool, "Sending cluster (0x00001046) command (0x00000002) on Group %u", groupId); + ChipLogProgress(chipTool, "Sending cluster (0x00001046) command (0x00000003) on Group %u", groupId); - return ClusterCommand::SendGroupCommand(groupId, fabricIndex, 0x00001046, 0x00000002, mRequest); + return ClusterCommand::SendGroupCommand(groupId, fabricIndex, 0x00001046, 0x00000003, mRequest); } private: @@ -15554,6 +15554,7 @@ void registerClusterClientMonitoring(Commands & commands, CredentialIssuerComman make_unique(Id, "active-mode-interval", Attributes::ActiveModeInterval::Id, credsIssuerConfig), // make_unique(Id, "active-mode-threshold", Attributes::ActiveModeThreshold::Id, credsIssuerConfig), // make_unique(Id, "expected-clients", Attributes::ExpectedClients::Id, credsIssuerConfig), // + make_unique(Id, "icdcounter", Attributes::ICDCounter::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // @@ -15568,8 +15569,10 @@ void registerClusterClientMonitoring(Commands & commands, CredentialIssuerComman make_unique>(Id, "active-mode-threshold", 0, UINT16_MAX, Attributes::ActiveModeThreshold::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( + chip::app::DataModel::List>>( Id, "expected-clients", Attributes::ExpectedClients::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "icdcounter", 0, UINT32_MAX, Attributes::ICDCounter::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // @@ -15588,6 +15591,7 @@ void registerClusterClientMonitoring(Commands & commands, CredentialIssuerComman make_unique(Id, "active-mode-interval", Attributes::ActiveModeInterval::Id, credsIssuerConfig), // make_unique(Id, "active-mode-threshold", Attributes::ActiveModeThreshold::Id, credsIssuerConfig), // make_unique(Id, "expected-clients", Attributes::ExpectedClients::Id, credsIssuerConfig), // + make_unique(Id, "icdcounter", Attributes::ICDCounter::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp index 5594ef89c48bf2..e4aa5a34e4b89d 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp @@ -2347,27 +2347,29 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::ApplicationLauncher::S ComplexArgumentParser::Finalize(request.endpoint); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request, - Json::Value & value) +CHIP_ERROR +ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistrationStruct::Type & request, + Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MonitoringRegistration.clientNodeId", "clientNodeId", - value.isMember("clientNodeId"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MonitoringRegistration.ICid", "ICid", value.isMember("ICid"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MonitoringRegistrationStruct.clientNodeID", "clientNodeID", + value.isMember("clientNodeID"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("MonitoringRegistrationStruct.key", "key", value.isMember("key"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "clientNodeId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.clientNodeId, value["clientNodeId"])); - valueCopy.removeMember("clientNodeId"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "clientNodeID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.clientNodeID, value["clientNodeID"])); + valueCopy.removeMember("clientNodeID"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "ICid"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.ICid, value["ICid"])); - valueCopy.removeMember("ICid"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "key"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.key, value["key"])); + valueCopy.removeMember("key"); if (value.isMember("fabricIndex")) { @@ -2379,10 +2381,10 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistrationStruct::Type & request) { - ComplexArgumentParser::Finalize(request.clientNodeId); - ComplexArgumentParser::Finalize(request.ICid); + ComplexArgumentParser::Finalize(request.clientNodeID); + ComplexArgumentParser::Finalize(request.key); ComplexArgumentParser::Finalize(request.fabricIndex); } diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h index 1827e5cbb930fa..fb84db01015080 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h @@ -290,10 +290,11 @@ static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ApplicationLaun static void Finalize(chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request, +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistrationStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request); +static void Finalize(chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistrationStruct::Type & request); static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request, Json::Value & value); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index 210e152050a010..46ccdd27881a2b 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -2111,22 +2111,22 @@ DataModelLogger::LogValue(const char * label, size_t indent, CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType & value) + const chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistrationStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ClientNodeId", indent + 1, value.clientNodeId); + CHIP_ERROR err = LogValue("ClientNodeID", indent + 1, value.clientNodeID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ClientNodeId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ClientNodeID'"); return err; } } { - CHIP_ERROR err = LogValue("ICid", indent + 1, value.ICid); + CHIP_ERROR err = LogValue("Key", indent + 1, value.key); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ICid'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Key'"); return err; } } @@ -10101,64 +10101,6 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP } break; } - case ClientMonitoring::Id: { - switch (path.mAttributeId) - { - case ClientMonitoring::Attributes::IdleModeInterval::Id: { - uint32_t value; - ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("IdleModeInterval", 1, value); - } - case ClientMonitoring::Attributes::ActiveModeInterval::Id: { - uint32_t value; - ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("ActiveModeInterval", 1, value); - } - case ClientMonitoring::Attributes::ActiveModeThreshold::Id: { - uint16_t value; - ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("ActiveModeThreshold", 1, value); - } - case ClientMonitoring::Attributes::ExpectedClients::Id: { - chip::app::DataModel::DecodableList< - chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType> - value; - ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("ExpectedClients", 1, value); - } - case ClientMonitoring::Attributes::GeneratedCommandList::Id: { - chip::app::DataModel::DecodableList value; - ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("GeneratedCommandList", 1, value); - } - case ClientMonitoring::Attributes::AcceptedCommandList::Id: { - chip::app::DataModel::DecodableList value; - ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("AcceptedCommandList", 1, value); - } - case ClientMonitoring::Attributes::EventList::Id: { - chip::app::DataModel::DecodableList value; - ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("EventList", 1, value); - } - case ClientMonitoring::Attributes::AttributeList::Id: { - chip::app::DataModel::DecodableList value; - ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("AttributeList", 1, value); - } - case ClientMonitoring::Attributes::FeatureMap::Id: { - uint32_t value; - ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("FeatureMap", 1, value); - } - case ClientMonitoring::Attributes::ClusterRevision::Id: { - uint16_t value; - ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("ClusterRevision", 1, value); - } - } - break; - } case UnitTesting::Id: { switch (path.mAttributeId) { diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h index 459c2c13f31cb7..81d723c231777c 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -181,8 +181,9 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType & value); +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistrationStruct::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::UnitTesting::Structs::SimpleStruct::DecodableType & value); diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index a0ab20c57b930e..919fac2e092fd3 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -247,7 +247,6 @@ class TestList : public Command printf("TestLevelControlWithOnOffDependency\n"); printf("TestCommissioningWindow\n"); printf("TestCommissionerNodeId\n"); - printf("TestClientMonitoringCluster\n"); printf("TestMultiAdmin\n"); printf("Test_TC_DGSW_1_1\n"); printf("TestSubscribe_OnOff\n"); @@ -68755,10 +68754,8 @@ class TestDescriptorClusterSuite : public TestCommand VerifyOrReturn(CheckNextListItemDecodes("serverList", iter_0, 25)); VerifyOrReturn(CheckValue("serverList[25]", iter_0.GetValue(), 1029UL)); VerifyOrReturn(CheckNextListItemDecodes("serverList", iter_0, 26)); - VerifyOrReturn(CheckValue("serverList[26]", iter_0.GetValue(), 4166UL)); - VerifyOrReturn(CheckNextListItemDecodes("serverList", iter_0, 27)); - VerifyOrReturn(CheckValue("serverList[27]", iter_0.GetValue(), 4294048774UL)); - VerifyOrReturn(CheckNoMoreListItems("serverList", iter_0, 28)); + VerifyOrReturn(CheckValue("serverList[26]", iter_0.GetValue(), 4294048774UL)); + VerifyOrReturn(CheckNoMoreListItems("serverList", iter_0, 27)); } } break; @@ -74309,197 +74306,6 @@ class TestCommissionerNodeIdSuite : public TestCommand } }; -class TestClientMonitoringClusterSuite : public TestCommand -{ -public: - TestClientMonitoringClusterSuite(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("TestClientMonitoringCluster", 9, credsIssuerConfig) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~TestClientMonitoringClusterSuite() {} - - chip::System::Clock::Timeout GetWaitDuration() const override - { - return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); - } - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::DataModel::DecodableList< - chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType> - value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - { - auto iter_0 = value.begin(); - VerifyOrReturn(CheckNextListItemDecodes("expectedClients", iter_0, 0)); - VerifyOrReturn(CheckValue("expectedClients[0].clientNodeId", iter_0.GetValue().clientNodeId, 10ULL)); - VerifyOrReturn(CheckValue("expectedClients[0].ICid", iter_0.GetValue().ICid, 20ULL)); - VerifyOrReturn(CheckNoMoreListItems("expectedClients", iter_0, 1)); - } - } - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::DataModel::DecodableList< - chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType> - value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - { - auto iter_0 = value.begin(); - VerifyOrReturn(CheckNoMoreListItems("expectedClients", iter_0, 0)); - } - } - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "Wait for the commissioned device to be retrieved"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee(kIdentityAlpha, value); - } - case 1: { - LogStep(1, "Register Client 2 - Invalid"); - ListFreer listFreer; - chip::app::Clusters::ClientMonitoring::Commands::RegisterClientMonitoring::Type value; - value.clientNodeId = 0ULL; - value.ICid = 0ULL; - return SendCommand(kIdentityAlpha, GetEndpoint(0), ClientMonitoring::Id, - ClientMonitoring::Commands::RegisterClientMonitoring::Id, value, chip::NullOptional - - ); - } - case 2: { - LogStep(2, "Register Client 1"); - ListFreer listFreer; - chip::app::Clusters::ClientMonitoring::Commands::RegisterClientMonitoring::Type value; - value.clientNodeId = 10ULL; - value.ICid = 20ULL; - return SendCommand(kIdentityAlpha, GetEndpoint(0), ClientMonitoring::Id, - ClientMonitoring::Commands::RegisterClientMonitoring::Id, value, chip::NullOptional - - ); - } - case 3: { - LogStep(3, "Register Client 2 - Invalid"); - ListFreer listFreer; - chip::app::Clusters::ClientMonitoring::Commands::RegisterClientMonitoring::Type value; - value.clientNodeId = 11ULL; - value.ICid = 21ULL; - return SendCommand(kIdentityAlpha, GetEndpoint(0), ClientMonitoring::Id, - ClientMonitoring::Commands::RegisterClientMonitoring::Id, value, chip::NullOptional - - ); - } - case 4: { - LogStep(4, "Verify Register Client"); - return ReadAttribute(kIdentityAlpha, GetEndpoint(0), ClientMonitoring::Id, - ClientMonitoring::Attributes::ExpectedClients::Id, true, chip::NullOptional); - } - case 5: { - LogStep(5, "Unregister Client - Invalid Client NodeId"); - ListFreer listFreer; - chip::app::Clusters::ClientMonitoring::Commands::UnregisterClientMonitoring::Type value; - value.clientNodeId = 30ULL; - value.ICid = 20ULL; - return SendCommand(kIdentityAlpha, GetEndpoint(0), ClientMonitoring::Id, - ClientMonitoring::Commands::UnregisterClientMonitoring::Id, value, chip::NullOptional - - ); - } - case 6: { - LogStep(6, "Unregister Client - Invalid ICid"); - ListFreer listFreer; - chip::app::Clusters::ClientMonitoring::Commands::UnregisterClientMonitoring::Type value; - value.clientNodeId = 10ULL; - value.ICid = 30ULL; - return SendCommand(kIdentityAlpha, GetEndpoint(0), ClientMonitoring::Id, - ClientMonitoring::Commands::UnregisterClientMonitoring::Id, value, chip::NullOptional - - ); - } - case 7: { - LogStep(7, "Unregister Client - Valid"); - ListFreer listFreer; - chip::app::Clusters::ClientMonitoring::Commands::UnregisterClientMonitoring::Type value; - value.clientNodeId = 10ULL; - value.ICid = 20ULL; - return SendCommand(kIdentityAlpha, GetEndpoint(0), ClientMonitoring::Id, - ClientMonitoring::Commands::UnregisterClientMonitoring::Id, value, chip::NullOptional - - ); - } - case 8: { - LogStep(8, "Verify Register Client - Empty"); - return ReadAttribute(kIdentityAlpha, GetEndpoint(0), ClientMonitoring::Id, - ClientMonitoring::Attributes::ExpectedClients::Id, true, chip::NullOptional); - } - } - return CHIP_NO_ERROR; - } -}; - class TestMultiAdminSuite : public TestCommand { public: @@ -114401,7 +114207,6 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), 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 2ac0dea95d5047..c1486e778f3489 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -100836,7 +100836,7 @@ class TestDescriptorCluster : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("ServerList", [actualValue count], static_cast(28))); + VerifyOrReturn(CheckValue("ServerList", [actualValue count], static_cast(27))); VerifyOrReturn(CheckValue("", actualValue[0], 3UL)); VerifyOrReturn(CheckValue("", actualValue[1], 4UL)); VerifyOrReturn(CheckValue("", actualValue[2], 29UL)); @@ -100863,8 +100863,7 @@ class TestDescriptorCluster : public TestCommandBridge { VerifyOrReturn(CheckValue("", actualValue[23], 64UL)); VerifyOrReturn(CheckValue("", actualValue[24], 65UL)); VerifyOrReturn(CheckValue("", actualValue[25], 1029UL)); - VerifyOrReturn(CheckValue("", actualValue[26], 4166UL)); - VerifyOrReturn(CheckValue("", actualValue[27], 4294048774UL)); + VerifyOrReturn(CheckValue("", actualValue[26], 4294048774UL)); } NextTest(); diff --git a/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClientCallbacks.h b/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClientCallbacks.h index ef6cbd56ee6145..4c52eb1bf23c89 100644 --- a/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClientCallbacks.h @@ -658,18 +658,6 @@ typedef void (*ElectricalMeasurementEventListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); typedef void (*ElectricalMeasurementAttributeListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); -typedef void (*ClientMonitoringExpectedClientsListAttributeCallback)( - void * context, - const chip::app::DataModel::DecodableList< - chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType> & data); -typedef void (*ClientMonitoringGeneratedCommandListListAttributeCallback)( - void * context, const chip::app::DataModel::DecodableList & data); -typedef void (*ClientMonitoringAcceptedCommandListListAttributeCallback)( - void * context, const chip::app::DataModel::DecodableList & data); -typedef void (*ClientMonitoringEventListListAttributeCallback)(void * context, - const chip::app::DataModel::DecodableList & data); -typedef void (*ClientMonitoringAttributeListListAttributeCallback)( - void * context, const chip::app::DataModel::DecodableList & data); typedef void (*UnitTestingListInt8uListAttributeCallback)(void * context, const chip::app::DataModel::DecodableList & data); typedef void (*UnitTestingListOctetStringListAttributeCallback)(void * context, diff --git a/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClusters.h b/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClusters.h index bc03b37dc2ac4a..b08f6b47236de9 100644 --- a/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClusters.h +++ b/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClusters.h @@ -623,15 +623,6 @@ class DLL_EXPORT ElectricalMeasurementCluster : public ClusterBase ~ElectricalMeasurementCluster() {} }; -class DLL_EXPORT ClientMonitoringCluster : public ClusterBase -{ -public: - ClientMonitoringCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : - ClusterBase(exchangeManager, session, endpoint) - {} - ~ClientMonitoringCluster() {} -}; - class DLL_EXPORT UnitTestingCluster : public ClusterBase { public: diff --git a/zzz_generated/darwin/controller-clusters/zap-generated/endpoint_config.h b/zzz_generated/darwin/controller-clusters/zap-generated/endpoint_config.h index 3d74200cb77c4f..7e8e00618681b5 100644 --- a/zzz_generated/darwin/controller-clusters/zap-generated/endpoint_config.h +++ b/zzz_generated/darwin/controller-clusters/zap-generated/endpoint_config.h @@ -59,7 +59,7 @@ #define GENERATED_FUNCTION_ARRAYS // This is an array of EmberAfCluster structures. -#define GENERATED_CLUSTER_COUNT 66 +#define GENERATED_CLUSTER_COUNT 65 // clang-format off #define GENERATED_CLUSTERS { \ { \ @@ -894,19 +894,6 @@ .eventList = nullptr, \ .eventCount = 0, \ },\ - { \ - /* Endpoint: 1, Cluster: Client Monitoring (client) */ \ - .clusterId = 0x00001046, \ - .attributes = ZAP_ATTRIBUTE_INDEX(0), \ - .attributeCount = 0, \ - .clusterSize = 0, \ - .mask = ZAP_CLUSTER_MASK(CLIENT), \ - .functions = NULL, \ - .acceptedCommandList = nullptr, \ - .generatedCommandList = nullptr, \ - .eventList = nullptr, \ - .eventCount = 0, \ - },\ { \ /* Endpoint: 1, Cluster: Unit Testing (client) */ \ .clusterId = 0xFFF1FC05, \ @@ -929,7 +916,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 66, 0 }, \ + { ZAP_CLUSTER_INDEX(0), 65, 0 }, \ } // Largest attribute size is needed for various buffers diff --git a/zzz_generated/darwin/controller-clusters/zap-generated/gen_config.h b/zzz_generated/darwin/controller-clusters/zap-generated/gen_config.h index 9652d781baf6e5..1800d8c39bb740 100644 --- a/zzz_generated/darwin/controller-clusters/zap-generated/gen_config.h +++ b/zzz_generated/darwin/controller-clusters/zap-generated/gen_config.h @@ -85,7 +85,6 @@ #define EMBER_AF_APPLICATION_BASIC_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_ACCOUNT_LOGIN_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_ELECTRICAL_MEASUREMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (1) -#define EMBER_AF_CLIENT_MONITORING_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_UNIT_TESTING_CLUSTER_CLIENT_ENDPOINT_COUNT (1) /**** Cluster Plugins ****/ @@ -346,10 +345,6 @@ #define ZCL_USING_ELECTRICAL_MEASUREMENT_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_ELECTRICAL_MEASUREMENT_CLIENT -// Use this macro to check if the client side of the Client Monitoring cluster is included -#define ZCL_USING_CLIENT_MONITORING_CLUSTER_CLIENT -#define EMBER_AF_PLUGIN_CLIENT_MONITORING_CLIENT - // Use this macro to check if the client side of the Unit Testing cluster is included #define ZCL_USING_UNIT_TESTING_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_UNIT_TESTING_CLIENT From 3902c3593c0f99b8f29575718921cabdf784fbfc Mon Sep 17 00:00:00 2001 From: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> Date: Wed, 3 May 2023 15:41:32 +1200 Subject: [PATCH 076/200] Add configure script to set up a light-weight build environment (#26154) * Add configure script to set up a light-weight build environment ... and optionally configure a GN build from environment variables and command line options. This simplifies building a CHIP app as a component within an existing buildroot style build system. Make the custom_toolchain build arg easier to use by interpreting relative paths as relative to ${build_root}/toolchain. Also move the declare_args statements for the 'custom' toolchain into a gni file so they can be discovered correctly. * Factor out python code into configure.utils.py Ensure //build_overrides/pigweed_environment.gni exists. Install wheel in the venv before installing dependencies. * Add chip-build-minimal docker image and minimal-build workflow The chip-build-minimal contains only the minimal build tools for compiling a CHIP app on Linux (c++ toolchain, python3, gn, ninja) and minimal library dependencies (openssl, glib). * Nits from code review * Update with latest zap version from master --- .github/workflows/minimal-build.yaml | 45 +++ build/config/BUILDCONFIG.gn | 11 +- build/toolchain/custom/BUILD.gn | 12 +- build/toolchain/custom/custom.gni | 27 ++ .../build_overrides/pigweed_environment.gni | 25 +- .../images/chip-build-minimal/Dockerfile | 27 ++ .../docker/images/chip-build-minimal/build.sh | 1 + .../docker/images/chip-build-minimal/run.sh | 1 + .../docker/images/chip-build-minimal/version | 1 + scripts/configure | 276 ++++++++++++++++++ scripts/configure.impl.py | 157 ++++++++++ scripts/setup/requirements.build.txt | 13 + scripts/setup/requirements.txt | 11 +- scripts/setup/zap.version | 1 + scripts/tools/zap/version_update.py | 1 + 15 files changed, 581 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/minimal-build.yaml create mode 100644 build/toolchain/custom/custom.gni create mode 100644 integrations/docker/images/chip-build-minimal/Dockerfile create mode 120000 integrations/docker/images/chip-build-minimal/build.sh create mode 120000 integrations/docker/images/chip-build-minimal/run.sh create mode 120000 integrations/docker/images/chip-build-minimal/version create mode 100755 scripts/configure create mode 100644 scripts/configure.impl.py create mode 100644 scripts/setup/requirements.build.txt create mode 100644 scripts/setup/zap.version diff --git a/.github/workflows/minimal-build.yaml b/.github/workflows/minimal-build.yaml new file mode 100644 index 00000000000000..e6215890be1dda --- /dev/null +++ b/.github/workflows/minimal-build.yaml @@ -0,0 +1,45 @@ +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Minimal Build (Linux / configure) + +on: + push: + pull_request: + merge_group: + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }} + cancel-in-progress: true + +jobs: + minimal: + name: Linux / configure build of all-clusters-app + timeout-minutes: 60 + + if: github.actor != 'restyled-io[bot]' + runs-on: ubuntu-latest + + container: + image: connectedhomeip/chip-build-minimal:0.7.2 + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Checkout submodules + run: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform linux + - name: Configure and build All Clusters App + timeout-minutes: 10 + run: | + CC=gcc CXX=g++ scripts/configure --project=examples/all-clusters-app/linux && ./ninja-build diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 13a13f804c3248..9d2f17d1acf86e 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -57,8 +57,17 @@ if (host_toolchain == "") { } } +_custom_toolchain = { + import("${_build_overrides.build_root}/toolchain/custom/custom.gni") +} + if (_chip_defaults.custom_toolchain != "") { - _default_toolchain = _chip_defaults.custom_toolchain + if (filter_include([ _chip_defaults.custom_toolchain ], [ "/*" ]) == []) { + # Interpret relative toolchain names relative to ${build_root}/toolchain/ + _default_toolchain = "${_build_overrides.build_root}/toolchain/${_chip_defaults.custom_toolchain}" + } else { + _default_toolchain = _chip_defaults.custom_toolchain + } } else if (target_os == "all") { _default_toolchain = "${_pigweed_overrides.dir_pw_toolchain}/default" } else if (target_os == "linux") { diff --git a/build/toolchain/custom/BUILD.gn b/build/toolchain/custom/BUILD.gn index f0ee798e9db194..bb8433ada6a246 100644 --- a/build/toolchain/custom/BUILD.gn +++ b/build/toolchain/custom/BUILD.gn @@ -14,19 +14,9 @@ import("//build_overrides/build.gni") import("${build_root}/config/compiler/compiler.gni") +import("${build_root}/toolchain/custom/custom.gni") import("${build_root}/toolchain/gcc_toolchain.gni") -declare_args() { - # C compiler to use for target build. - target_cc = "" - - # C++ compiler to use for target build. - target_cxx = "" - - # Archive tool to use for target build. - target_ar = "" -} - gcc_toolchain("custom") { if (target_cc == "" || target_cxx == "" || target_ar == "") { assert(false, diff --git a/build/toolchain/custom/custom.gni b/build/toolchain/custom/custom.gni new file mode 100644 index 00000000000000..890801a1c647df --- /dev/null +++ b/build/toolchain/custom/custom.gni @@ -0,0 +1,27 @@ +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # C compiler to use for target build. + # Only relevant with custom_toolchain = "custom". + target_cc = "" + + # C++ compiler to use for target build. + # Only relevant with custom_toolchain = "custom". + target_cxx = "" + + # Archive tool to use for target build. + # Only relevant with custom_toolchain = "custom". + target_ar = "" +} diff --git a/examples/build_overrides/pigweed_environment.gni b/examples/build_overrides/pigweed_environment.gni index 7fc8bb96532351..a35e7843f84885 100644 --- a/examples/build_overrides/pigweed_environment.gni +++ b/examples/build_overrides/pigweed_environment.gni @@ -20,11 +20,20 @@ _bootstrap_root = "//third_party/connectedhomeip" import("${_bootstrap_root}/build_overrides/pigweed_environment.gni") # Rebase paths to our root. -pw_env_setup_CIPD_ARM = - get_path_info("${_bootstrap_root}/${pw_env_setup_CIPD_ARM}", "abspath") -pw_env_setup_CIPD_PIGWEED = - get_path_info("${_bootstrap_root}/${pw_env_setup_CIPD_PIGWEED}", "abspath") -pw_env_setup_CIPD_PYTHON = - get_path_info("${_bootstrap_root}/${pw_env_setup_CIPD_PYTHON}", "abspath") -pw_env_setup_VIRTUAL_ENV = - get_path_info("${_bootstrap_root}/${pw_env_setup_VIRTUAL_ENV}", "abspath") +if (defined(pw_env_setup_CIPD_ARM)) { + pw_env_setup_CIPD_ARM = + get_path_info("${_bootstrap_root}/${pw_env_setup_CIPD_ARM}", "abspath") +} +if (defined(pw_env_setup_CIPD_PIGWEED)) { + pw_env_setup_CIPD_PIGWEED = + get_path_info("${_bootstrap_root}/${pw_env_setup_CIPD_PIGWEED}", + "abspath") +} +if (defined(pw_env_setup_CIPD_PYTHON)) { + pw_env_setup_CIPD_PYTHON = + get_path_info("${_bootstrap_root}/${pw_env_setup_CIPD_PYTHON}", "abspath") +} +if (defined(pw_env_setup_VIRTUAL_ENV)) { + pw_env_setup_VIRTUAL_ENV = + get_path_info("${_bootstrap_root}/${pw_env_setup_VIRTUAL_ENV}", "abspath") +} diff --git a/integrations/docker/images/chip-build-minimal/Dockerfile b/integrations/docker/images/chip-build-minimal/Dockerfile new file mode 100644 index 00000000000000..093943d03a1d3a --- /dev/null +++ b/integrations/docker/images/chip-build-minimal/Dockerfile @@ -0,0 +1,27 @@ +# This minimal build image is intentionally not based on chip-build +FROM ubuntu:focal + +# ARG NINJA_VERSION=v1.11.1 +ARG GN_HASH=5a004f9427a050c6c393c07ddb85cba8ff3849fa + +RUN set -x \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential ca-certificates git pkg-config python3-venv ninja-build \ + && git config --global advice.detachedHead false + +# RUN set -x && cd /var/tmp \ +# && git clone --branch "$NINJA_VERSION" https://github.com/ninja-build/ninja.git \ +# && ( cd ninja && ./configure.py --bootstrap && install -m 0755 ninja /usr/local/bin/ ) \ +# && rm -rf ninja + +RUN set -x && cd /var/tmp \ + && git clone https://gn.googlesource.com/gn \ + && ( cd gn && git checkout "$GN_HASH" && CXX=g++ build/gen.py && ninja -C out && install -m 0755 out/gn /usr/local/bin/ ) \ + && rm -rf gn + +# CHIP build dependencies +RUN set -x \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + libssl-dev libglib2.0-dev diff --git a/integrations/docker/images/chip-build-minimal/build.sh b/integrations/docker/images/chip-build-minimal/build.sh new file mode 120000 index 00000000000000..fcb4d4ee75d531 --- /dev/null +++ b/integrations/docker/images/chip-build-minimal/build.sh @@ -0,0 +1 @@ +../../build.sh \ No newline at end of file diff --git a/integrations/docker/images/chip-build-minimal/run.sh b/integrations/docker/images/chip-build-minimal/run.sh new file mode 120000 index 00000000000000..ccbd3501b330d9 --- /dev/null +++ b/integrations/docker/images/chip-build-minimal/run.sh @@ -0,0 +1 @@ +../../run.sh \ No newline at end of file diff --git a/integrations/docker/images/chip-build-minimal/version b/integrations/docker/images/chip-build-minimal/version new file mode 120000 index 00000000000000..a4280acd348e7f --- /dev/null +++ b/integrations/docker/images/chip-build-minimal/version @@ -0,0 +1 @@ +../chip-build/version \ No newline at end of file diff --git a/scripts/configure b/scripts/configure new file mode 100755 index 00000000000000..84203e71043b3e --- /dev/null +++ b/scripts/configure @@ -0,0 +1,276 @@ +#!/bin/bash -e + +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Usage: configure [OPTIONS] [--project=... [PROJECT OPTIONS]] +# +# Configures a stand-alone build for a CHIP application in the current +# directory and creates a `ninja-build` wrapper script to build it. Should +# generally be run from an empty build directory (i.e. out-of-tree). +# +# This is intended to be used in the context of an external build system and +# represents a light-weight alternative to bootstrapping the full Pigweed build +# environment (via scripts/activate.sh). The pigweed git sub-module must still +# be present though. +# +# External tool dependencies: bash, python3, gn, ninja +# +# The zap-cli code generator and a small number of Python modules are +# downloaded if necessary (see scripts/setup/requirements.build.txt) and +# installed in a build environment directory. By default this is local to +# the build directory, but an external directory can be specified using the +# --build-env-dir option. The build environment directory can be shared by any +# number of build directories, independently of target / tool chain. +# +# Project options can be passed in the usual GNU configure style (--enable-foo, +# --foo-bar=value) and are translated into GN build arguments. By default, +# configure will override the toolchain for the GN build using a 'custom' +# toolchain assembled from the usual environment variables (CC, CXX, AR, CFLAGS, +# CXXFLAGS, ...). + +function usage() { + info "Usage: $0 [OPTIONS] [--project=... [PROJECT OPTIONS]]" + info "Options:" + info " --build-env-dir=DIR Directory to create (host) build environment in" + info " --project=DIR Sub-directory to build, e.g. examples/lighting-app/linux" + exit 0 +} + +function main() { # ... + set -o pipefail + CHIP_ROOT=$(cd "$(dirname "$0")/.." && pwd) + BUILD_ENV_DEPS=( + "${CHIP_ROOT}/scripts/setup/requirements.build.txt" + "${CHIP_ROOT}/scripts/setup/constraints.txt" + "${CHIP_ROOT}/scripts/setup/zap.version" + ) + + if [[ "$PWD" == "$CHIP_ROOT" ]]; then + BUILD_DIR="out/configured" + BUILD_ROOT="${CHIP_ROOT}/${BUILD_DIR}" + BUILD_ENV_DIR=".venv" + info "Configuring in-tree, will build in $BUILD_DIR using environment $BUILD_ENV_DIR" + else + BUILD_DIR="." + BUILD_ROOT="$PWD" + BUILD_ENV_DIR="build-env" + fi + PROJECT= + + # Parse main options but leave project options in $@ + while [[ $# -gt 0 && -z "$PROJECT" ]]; do + case "$1" in + --help) usage ;; + --build-env-dir=*) BUILD_ENV_DIR="${1#*=}" ;; + --project=*) PROJECT="${1#*=}" ;; + *) fail "Invalid argument: '$1'" ;; + esac + shift + done + + if [[ -n "$PROJECT" ]]; then + local subdir="$(cd "${CHIP_ROOT}/${PROJECT}" 2>/dev/null && pwd)" + [[ -n "$subdir" && -r "${subdir}/.gn" ]] || fail "Invalid project '${PROJECT}'" + PROJECT="${subdir#${CHIP_ROOT}/}" + [[ "$subdir" == "${CHIP_ROOT}/${PROJECT}" ]] || fail "Unable to determine project path" + fi + + check_binary gn GN + check_binary ninja NINJA + if ! activate_build_env; then + check_python + configure_python_env + if ! check_binary zap-cli; then + download_zap + fi + finalize_build_env + fi + + if [[ -z "$PROJECT" ]]; then + info "Build environment created. (Specify --project=DIR to configure a build.)" + return + fi + + create_empty_pw_env + gn_generate "$@" + create_ninja_wrapper + info "You can now run ./ninja-build" +} + +function create_empty_pw_env() { + # The Pigweed environment ("//build_overrides/pigweed_environment.gni") is + # imported unconditionally in various build files, so ensure it exists. + local gni="build_overrides/pigweed_environment.gni" + if [[ -d "${CHIP_ROOT}/$(dirname "$gni")" ]]; then + if safe_to_clobber "$gni"; then + info "Creating empty $gni in source tree" + echo "# ${CONFIGURE_MARKER}" >"${CHIP_ROOT}/${gni}" + else + info "Warning: Leaving existing $gni in place, this might affect the build configuration." + fi + fi +} + +function gn_generate() { # [project options] + mkdir -p "${BUILD_ROOT}" + ensure_no_clobber "${BUILD_ROOT}/args.gn" + ( + cd "${CHIP_ROOT}/${PROJECT}" # --root= doesn't work for gn args! + + # Run gn gen with an empty args.gn first so we can list all arguments + info "Configuring gn build arguments (see $BUILD_DIR/args.configured for full list)" + echo "# ${CONFIGURE_MARKER}" >"${BUILD_ROOT}/args.gn" + gn -q gen "$BUILD_ROOT" + + # Use the argument list to drive the mapping of our command line options to GN args + call_impl process_project_args <(gn args "$BUILD_ROOT" --list --json) "$@" >>"${BUILD_ROOT}/args.gn" + gn args "$BUILD_ROOT" --list >"${BUILD_ROOT}/args.configured" + + # Now gn gen with the arguments we have configured. + info "Running gn gen to generate ninja files" + gn -q gen "$BUILD_ROOT" + ) +} + +function create_ninja_wrapper() { + # Note: "." != $BUILD_DIR for in-tree builds + local wrapper="ninja-build" + ensure_no_clobber "$wrapper" + cat >"$wrapper" <"${BUILD_ENV_DIR}/.cksum" + source "${BUILD_ENV_DIR}/bin/activate" + PYTHON="python" +} + +function download_zap() { + local version platform + read -r version <"${CHIP_ROOT}/scripts/setup/zap.version" + case "$OSTYPE" in + linux*) platform=linux ;; + darwin*) platform=mac ;; + *) fail "Unable to determine zap platform for OSTYPE='$OSTYPE'" ;; + esac + local url="https://github.com/project-chip/zap/releases/download/${version}/zap-${platform}.zip" + + progress "Installing zap-cli from $url" + call_impl download_and_extract_zip "$url" "${BUILD_ENV_DIR}/bin" zap-cli + chmod a+x "${BUILD_ENV_DIR}/bin/zap-cli" # ZipFile.extract() does not handle permissions + info "ok" +} + +function call_impl() { # func ... + "$PYTHON" "${CHIP_ROOT}/scripts/configure.impl.py" "$@" +} + +function check_python() { + progress "Checking for Python 3" + if have_binary python3; then + PYTHON="$(hash -t python3)" + elif have_binary python; then + PYTHON="$(hash -t python)" + local ver="$("$PYTHON" --version)" + if [[ "$ver" != "Python 3."* ]]; then + info "need Python 3 but found $ver" + return 1 + fi + else + info "not found" + return 1 + fi + info "$PYTHON" +} + +function check_binary() { # binary [VAR] + progress "Checking for $1" + if ! have_binary "$1"; then + info "not found" + return 1 + fi + local path="$(hash -t "$1")" + [[ -n "$2" ]] && eval "$2=\$path" + info "$path" +} + +function have_binary() { # binary + hash "$1" 2>/dev/null +} + +function ensure_no_clobber() { # file + safe_to_clobber "$1" || fail "Won't overwrite file not generated by configure: $1" +} + +function safe_to_clobber() { # file + CONFIGURE_MARKER="Auto-generated by configure, do not edit" + [[ -s "$1" ]] || return 0 + read -r -n 512 -d '' <"$1" || true + [[ "${REPLY/$CONFIGURE_MARKER/}" != "$REPLY" ]] && return 0 + return 1 +} + +function info() { # message + echo "$*" >&2 +} + +function progress() { # message + echo -n "$*... " >&2 +} + +function fail() { # message + echo "Error: $*" >&2 + exit 1 +} + +main "$@" diff --git a/scripts/configure.impl.py b/scripts/configure.impl.py new file mode 100644 index 00000000000000..b51e40fa00cf55 --- /dev/null +++ b/scripts/configure.impl.py @@ -0,0 +1,157 @@ +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file contains private utilities for use by the `configure` script. +# It is self-contained and depends only on the Python 3 standard library. + +import collections +import json +import os +import re +import sys +import urllib.request +import zipfile + + +def download_and_extract_zip(url, dest_dir, *member_names): + file, *_ = urllib.request.urlretrieve(url) + with zipfile.ZipFile(file) as zip: + for member in zip.infolist(): + if member.filename in member_names: + zip.extract(member, dest_dir) + + +def process_project_args(gn_args_json_file, *params): + processor = ProjectArgProcessor(gn_args_json_file) + processor.process_defaults() + processor.process_env() + processor.process_parameters(params) + for arg, value in processor.args.items(): + info(" - %s = %s" % (arg, value)) + print("%s = %s" % (arg, value)) + + +class ProjectArgProcessor: + # Prefixes to try when mapping parameters to GN arguments + BOOL_ARG_PREFIXES = ('is_', 'enable_', 'use_', 'chip_', 'chip_enable', 'chip_use_', 'chip_config_') + GENERIC_ARG_PREFIXES = ('chip_', 'chip_config_') + + gn_args = {} # GN arg -> type ('s'tring, 'b'ool, 'i'integer, '[' list, '{' struct) + args = collections.OrderedDict() # collected arguments + + def __init__(self, gn_args_json_file): + # Parse `gn args --list --json` output and derive arg types from default values + argtype = str.maketrans('"tf0123456789', 'sbbiiiiiiiiii') + with open(gn_args_json_file) as fh: + for arg in json.load(fh): + self.gn_args[arg['name']] = arg['default']['value'][0].translate(argtype) + + def process_defaults(self): + self.add_default('custom_toolchain', 'custom') + + def process_env(self): + self.add_env_arg('target_cc', 'CC', 'cc') + self.add_env_arg('target_cxx', 'CXX', 'cxx') + self.add_env_arg('target_ar', 'AR', 'ar') + self.add_env_arg('target_cflags', 'CPPFLAGS', list=True) + self.add_env_arg('target_cflags_c', 'CFLAGS', list=True) + self.add_env_arg('target_cflags_cc', 'CXXFLAGS', list=True) + self.add_env_arg('target_cflags_objc', 'OBJCFLAGS', list=True) + self.add_env_arg('target_ldflags', 'LDFLAGS', list=True) + + def add_arg(self, arg, value): + # format strings and booleans as JSON, otherwise pass through as is + self.args[arg] = (json.dumps(value) if self.gn_args.get(arg, 's') in 'sb' else value) + + def add_default(self, arg, value): + """Add an argument, if supported by the GN build""" + if arg in self.gn_args: + self.add_arg(arg, value) + + def add_env_arg(self, arg, envvar, default=None, list=False): + """Add an argument from an environment variable""" + value = os.environ.get(envvar, default) + if not value: + return + if not (type := self.gn_args.get(arg, None)): + info("Warning: Not propagating %s, project has no build arg '%s'" % (envvar, arg)) + return + self.args[arg] = json.dumps(value if type != '[' else value.split() if list else [value]) + + def gn_arg(self, name, prefixes=(), type=None): + """Finds the GN argument corresponding to a parameter name""" + arg = name.translate(str.maketrans('-', '_')) + candidates = [p + arg for p in (('',) + prefixes) if (p + arg) in self.gn_args] + preferred = [c for c in candidates if self.gn_args[c] == type] if type else [] + if not (match := next(iter(preferred + candidates), None)): + info("Warning: Project has no build arg '%s'" % arg) + return match + + def process_triplet_parameter(self, name, value): + if value is None: + fail("Project option --%s requires an argument" % name) + triplet = value.split('-') + if len(triplet) not in (2, 3, 4): + fail("Project option --%s argument must be a cpu-vendor-os[-abi] triplet" % name) + prefix = 'host_' if name == 'build' else 'target_' # "host" has different meanings in GNU and GN! + self.add_arg(prefix + 'cpu', triplet[0]) + self.add_arg(prefix + 'os', triplet[1 if len(triplet) == 2 else 2]) + + def process_enable_parameter(self, name, value): + if not (arg := self.gn_arg(name[len('enable-'):], self.BOOL_ARG_PREFIXES, 'b')): + return + if self.gn_args[arg] != 'b': + fail("Project build arg '%s' is not a boolean" % arg) + if value != 'no' and value is not None: + fail("Invalid argument for --%s, must be absent or 'no'" % name) + self.add_arg(arg, value is None) + + def process_generic_parameter(self, name, value): + if not (arg := self.gn_arg(name, self.GENERIC_ARG_PREFIXES)): + return + if self.gn_args[arg] == 'b': + fail("Project build arg '%s' is a boolean, use --enable-..." % arg) + if value is None: + fail("Project option --%s requires an argument" % name) + self.add_arg(arg, value) + + def process_parameter(self, name, value): + if name in ('build', 'host', 'target'): + self.process_triplet_parameter(name, value) + elif name.startswith('enable-'): + self.process_enable_parameter(name, value) + else: + self.process_generic_parameter(name, value) + + def process_parameters(self, args): + """Process GNU-style configure command line parameters""" + for arg in args: + if not (m := re.fullmatch(r'--([a-z][a-z0-9-]*)(?:=(.*))?', arg)): + fail("Invalid argument: '%s'" % arg) + self.process_parameter(m.group(1), m.group(2)) + + +def info(message): + print(message, file=sys.stderr) + + +def fail(message): + info("Error: " + message) + sys.exit(1) + + +# `configure` invokes the top-level functions in this file by +# passing the function name and arguments on the command line. +[_, func, *args] = sys.argv +globals()[func](*args) diff --git a/scripts/setup/requirements.build.txt b/scripts/setup/requirements.build.txt new file mode 100644 index 00000000000000..82fe4cc08cea50 --- /dev/null +++ b/scripts/setup/requirements.build.txt @@ -0,0 +1,13 @@ +# Minimal requirements for building stand-alone CHIP applications. +# +# The list of Python packages required to perform a minimal CHIP +# application build should be kept as small as possible. Ideally, +# core build scripts should depend only on the standard library. + +# scripts/build +click + +# scripts/py_matter_idl/matter_idl +jinja2 +lark +stringcase diff --git a/scripts/setup/requirements.txt b/scripts/setup/requirements.txt index 53d0037d6634f3..2a5c57c1eef574 100644 --- a/scripts/setup/requirements.txt +++ b/scripts/setup/requirements.txt @@ -1,6 +1,9 @@ pip-tools virtualenv +# core build requirements +-r requirements.build.txt + # esp-idf -c constraints.esp32.txt -r requirements.esp32.txt @@ -67,14 +70,6 @@ ghapi pandas ; platform_machine != 'aarch64' and platform_machine != 'arm64' tabulate -# scripts/build -click - -# scripts/py_matter_idl/matter_idl -lark -# scripts/py_matter_idl/matter_idl and scripts/py_matter_yamtests/matter_yamltests -stringcase - cryptography # python unit tests diff --git a/scripts/setup/zap.version b/scripts/setup/zap.version new file mode 100644 index 00000000000000..70fb1c57a67ad8 --- /dev/null +++ b/scripts/setup/zap.version @@ -0,0 +1 @@ +v2023.04.27-nightly diff --git a/scripts/tools/zap/version_update.py b/scripts/tools/zap/version_update.py index 394e2048b17646..ba40ca575c53f2 100755 --- a/scripts/tools/zap/version_update.py +++ b/scripts/tools/zap/version_update.py @@ -51,6 +51,7 @@ USAGE_FILES_DEPENDING_ON_ZAP_VERSION = [ 'integrations/docker/images/chip-cert-bins/Dockerfile', 'scripts/setup/zap.json', + 'scripts/setup/zap.version', ] From 6ddc6f9be228d1c20ff1c8f95584f7084a5736f5 Mon Sep 17 00:00:00 2001 From: Jean-Francois Penven <67962328+jepenven-silabs@users.noreply.github.com> Date: Wed, 3 May 2023 08:36:35 -0400 Subject: [PATCH 077/200] Use a common main files accross All examples (#26342) --- examples/chef/efr32/include/AppTask.h | 2 +- examples/chef/efr32/src/AppTask.cpp | 16 ++-- examples/chef/efr32/src/main.cpp | 84 ----------------- .../light-switch-app/silabs/SiWx917/BUILD.gn | 2 +- .../silabs/SiWx917/include/AppConfig.h | 2 + .../silabs/SiWx917/src/AppTask.cpp | 5 + .../silabs/SiWx917/src/main.cpp | 87 ------------------ .../light-switch-app/silabs/efr32/BUILD.gn | 2 +- .../silabs/efr32/include/AppConfig.h | 2 + .../silabs/efr32/include/AppTask.h | 2 +- .../silabs/efr32/src/AppTask.cpp | 18 ++-- .../silabs/efr32/src/main.cpp | 84 ----------------- examples/lighting-app/silabs/SiWx917/BUILD.gn | 2 +- .../silabs/SiWx917/include/AppConfig.h | 2 + examples/lighting-app/silabs/efr32/BUILD.gn | 2 +- .../silabs/efr32/include/AppConfig.h | 2 + .../silabs/efr32/include/AppTask.h | 2 +- .../lighting-app/silabs/efr32/src/AppTask.cpp | 25 ++--- .../lighting-app/silabs/efr32/src/main.cpp | 91 ------------------- examples/lock-app/silabs/SiWx917/BUILD.gn | 2 +- .../silabs/SiWx917/include/AppConfig.h | 2 + .../lock-app/silabs/SiWx917/src/AppTask.cpp | 4 + examples/lock-app/silabs/SiWx917/src/main.cpp | 85 ----------------- examples/lock-app/silabs/efr32/BUILD.gn | 2 +- .../lock-app/silabs/efr32/include/AppConfig.h | 2 + .../lock-app/silabs/efr32/include/AppTask.h | 2 +- .../lock-app/silabs/efr32/src/AppTask.cpp | 19 ++-- examples/lock-app/silabs/efr32/src/main.cpp | 84 ----------------- examples/platform/silabs/Rpc.cpp | 2 +- .../platform/silabs/efr32/BaseApplication.cpp | 2 +- .../platform/silabs/efr32/BaseApplication.h | 12 --- .../SiWx917/src => platform/silabs}/main.cpp | 27 ++---- examples/thermostat/silabs/efr32/BUILD.gn | 2 +- .../silabs/efr32/include/AppConfig.h | 2 + .../thermostat/silabs/efr32/include/AppTask.h | 2 +- .../thermostat/silabs/efr32/src/AppTask.cpp | 16 ++-- examples/thermostat/silabs/efr32/src/main.cpp | 84 ----------------- .../silabs/efr32/include/WindowAppImpl.h | 4 +- .../silabs/efr32/src/WindowAppImpl.cpp | 14 ++- .../silabs/platformAbstraction/GsdkSpam.cpp | 34 +++++++ .../platformAbstraction/SilabsPlatform.h | 6 ++ .../platformAbstraction/SilabsPlatformBase.h | 5 + .../platformAbstraction/WiseMcuSpam.cpp | 22 +++++ 43 files changed, 170 insertions(+), 698 deletions(-) delete mode 100644 examples/chef/efr32/src/main.cpp delete mode 100644 examples/light-switch-app/silabs/SiWx917/src/main.cpp delete mode 100644 examples/light-switch-app/silabs/efr32/src/main.cpp delete mode 100644 examples/lighting-app/silabs/efr32/src/main.cpp delete mode 100644 examples/lock-app/silabs/SiWx917/src/main.cpp delete mode 100644 examples/lock-app/silabs/efr32/src/main.cpp rename examples/{lighting-app/silabs/SiWx917/src => platform/silabs}/main.cpp (81%) delete mode 100644 examples/thermostat/silabs/efr32/src/main.cpp diff --git a/examples/chef/efr32/include/AppTask.h b/examples/chef/efr32/include/AppTask.h index a8e186083c23f6..afa323b2d277f1 100644 --- a/examples/chef/efr32/include/AppTask.h +++ b/examples/chef/efr32/include/AppTask.h @@ -77,7 +77,7 @@ class AppTask : public BaseApplication * @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED, * SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED */ - void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override; + static void ButtonEventHandler(uint8_t button, uint8_t btnAction) override; /** * @brief Callback called by the identify-server when an identify command is received diff --git a/examples/chef/efr32/src/AppTask.cpp b/examples/chef/efr32/src/AppTask.cpp index 397fab5d482f7d..04355d98fd2035 100644 --- a/examples/chef/efr32/src/AppTask.cpp +++ b/examples/chef/efr32/src/AppTask.cpp @@ -41,6 +41,8 @@ #include +#include + #include #include @@ -49,7 +51,7 @@ #include #define SYSTEM_STATE_LED 0 -#define APP_FUNCTION_BUTTON &sl_button_btn0 +#define APP_FUNCTION_BUTTON 0 using namespace chip; using namespace ::chip::DeviceLayer; @@ -123,6 +125,9 @@ AppTask AppTask::sAppTask; CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT + chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler); +#endif err = BaseApplication::Init(&gIdentify); if (err != CHIP_NO_ERROR) @@ -164,18 +169,13 @@ void AppTask::AppTaskMain(void * pvParameter) } } -void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) +void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction) { - if (buttonHandle == NULL) - { - return; - } - AppEvent button_event = {}; button_event.Type = AppEvent::kEventType_Button; button_event.ButtonEvent.Action = btnAction; - if (buttonHandle == APP_FUNCTION_BUTTON) + if (button == APP_FUNCTION_BUTTON) { button_event.Handler = BaseApplication::ButtonHandler; sAppTask.PostEvent(&button_event); diff --git a/examples/chef/efr32/src/main.cpp b/examples/chef/efr32/src/main.cpp deleted file mode 100644 index f1aa92f95935d8..00000000000000 --- a/examples/chef/efr32/src/main.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "AppConfig.h" -#include "init_efrPlatform.h" -#include "sl_simple_button_instances.h" -#include "sl_system_kernel.h" -#include -#include -#include -#include -#ifdef SILABS_ATTESTATION_CREDENTIALS -#include -#else -#include -#endif - -#define BLE_DEV_NAME "SiLabs-Chef-App" -using namespace ::chip; -using namespace ::chip::Inet; -using namespace ::chip::DeviceLayer; -using namespace ::chip::Credentials; - -#define UNUSED_PARAMETER(a) (a = a) - -volatile int apperror_cnt; -static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; - -// ================================================================================ -// Main Code -// ================================================================================ -int main(void) -{ - init_efrPlatform(); - if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); - chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); - - chip::DeviceLayer::PlatformMgr().LockChipStack(); - // Initialize device attestation config -#ifdef SILABS_ATTESTATION_CREDENTIALS - SetDeviceAttestationCredentialsProvider(EFR32::GetEFR32DacProvider()); -#else - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); -#endif - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - SILABS_LOG("Starting App Task"); - if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - SILABS_LOG("Starting FreeRTOS scheduler"); - sl_system_kernel_start(); - - // Should never get here. - chip::Platform::MemoryShutdown(); - SILABS_LOG("vTaskStartScheduler() failed"); - appError(CHIP_ERROR_INTERNAL); -} - -void sl_button_on_change(const sl_button_t * handle) -{ - AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle)); -} diff --git a/examples/light-switch-app/silabs/SiWx917/BUILD.gn b/examples/light-switch-app/silabs/SiWx917/BUILD.gn index 2d41d77fc50ab6..62ddb969e9b594 100644 --- a/examples/light-switch-app/silabs/SiWx917/BUILD.gn +++ b/examples/light-switch-app/silabs/SiWx917/BUILD.gn @@ -73,9 +73,9 @@ silabs_executable("light_switch_app") { sources = [ "${chip_root}/examples/light-switch-app/silabs/common/BindingHandler.cpp", "${chip_root}/examples/light-switch-app/silabs/common/LightSwitchMgr.cpp", + "${examples_common_plat_dir}/main.cpp", "src/AppTask.cpp", "src/ZclCallbacks.cpp", - "src/main.cpp", ] deps = [ diff --git a/examples/light-switch-app/silabs/SiWx917/include/AppConfig.h b/examples/light-switch-app/silabs/SiWx917/include/AppConfig.h index a936fe1d8abaeb..b20cbf8fc20d55 100644 --- a/examples/light-switch-app/silabs/SiWx917/include/AppConfig.h +++ b/examples/light-switch-app/silabs/SiWx917/include/AppConfig.h @@ -23,6 +23,8 @@ #define APP_TASK_NAME "Lit" +#define BLE_DEV_NAME "SiLabs-Light-Switch" + // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 10 diff --git a/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp b/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp index d53505b3374775..3cf6d9a034cae7 100644 --- a/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp @@ -52,6 +52,8 @@ #include +#include + /********************************************************** * Defines and Constants *********************************************************/ @@ -152,6 +154,9 @@ AppTask AppTask::sAppTask; CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; + + chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler); + #ifdef DISPLAY_ENABLED GetLCD().Init((uint8_t *) "Light Switch"); #endif diff --git a/examples/light-switch-app/silabs/SiWx917/src/main.cpp b/examples/light-switch-app/silabs/SiWx917/src/main.cpp deleted file mode 100644 index bdafdfbf61cb08..00000000000000 --- a/examples/light-switch-app/silabs/SiWx917/src/main.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "AppConfig.h" -#include "init_ccpPlatform.h" -#include -#include -#include -#include -#ifdef SILABS_ATTESTATION_CREDENTIALS -#include -#else -#include -#endif - -#define BLE_DEV_NAME "SiLabs-Light-Switch" - -extern "C" void sl_button_on_change(uint8_t btn, uint8_t btnAction); - -using namespace ::chip; -using namespace ::chip::Inet; -using namespace ::chip::DeviceLayer; -using namespace ::chip::Credentials; - -#define UNUSED_PARAMETER(a) (a = a) - -volatile int apperror_cnt; -static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; - -// ================================================================================ -// Main Code -// ================================================================================ -int main(void) -{ - init_ccpPlatform(); - if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) - { - appError(CHIP_ERROR_INTERNAL); - } - - gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); - chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); - - chip::DeviceLayer::PlatformMgr().LockChipStack(); - // Initialize device attestation config -#ifdef SILABS_ATTESTATION_CREDENTIALS - SetDeviceAttestationCredentialsProvider(SIWx917::GetSIWx917DacProvider()); -#else - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); -#endif - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - SILABS_LOG("Starting App Task"); - if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - SILABS_LOG("Starting FreeRTOS scheduler"); - vTaskStartScheduler(); - - // Should never get here. - chip::Platform::MemoryShutdown(); - SILABS_LOG("vTaskStartScheduler() failed"); - appError(CHIP_ERROR_INTERNAL); -} - -void sl_button_on_change(uint8_t btn, uint8_t btnAction) -{ - AppTask::GetAppTask().ButtonEventHandler(btn, btnAction); -} diff --git a/examples/light-switch-app/silabs/efr32/BUILD.gn b/examples/light-switch-app/silabs/efr32/BUILD.gn index a0e4d707e7c6cd..e989008ba0efb6 100644 --- a/examples/light-switch-app/silabs/efr32/BUILD.gn +++ b/examples/light-switch-app/silabs/efr32/BUILD.gn @@ -91,9 +91,9 @@ silabs_executable("light_switch_app") { sources = [ "${chip_root}/examples/light-switch-app/silabs/common/BindingHandler.cpp", "${chip_root}/examples/light-switch-app/silabs/common/LightSwitchMgr.cpp", + "${examples_common_plat_dir}/main.cpp", "src/AppTask.cpp", "src/ZclCallbacks.cpp", - "src/main.cpp", ] deps = [ diff --git a/examples/light-switch-app/silabs/efr32/include/AppConfig.h b/examples/light-switch-app/silabs/efr32/include/AppConfig.h index 5b0d0a461072d5..6d61bd11840cb6 100644 --- a/examples/light-switch-app/silabs/efr32/include/AppConfig.h +++ b/examples/light-switch-app/silabs/efr32/include/AppConfig.h @@ -23,6 +23,8 @@ #define APP_TASK_NAME "Lit" +#define BLE_DEV_NAME "SiLabs-Light-Switch" + // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 10 diff --git a/examples/light-switch-app/silabs/efr32/include/AppTask.h b/examples/light-switch-app/silabs/efr32/include/AppTask.h index a8e186083c23f6..20ced3fb49a323 100644 --- a/examples/light-switch-app/silabs/efr32/include/AppTask.h +++ b/examples/light-switch-app/silabs/efr32/include/AppTask.h @@ -77,7 +77,7 @@ class AppTask : public BaseApplication * @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED, * SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED */ - void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override; + static void ButtonEventHandler(uint8_t button, uint8_t btnAction); /** * @brief Callback called by the identify-server when an identify command is received diff --git a/examples/light-switch-app/silabs/efr32/src/AppTask.cpp b/examples/light-switch-app/silabs/efr32/src/AppTask.cpp index fab53ca052baf6..257104fb427568 100644 --- a/examples/light-switch-app/silabs/efr32/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/efr32/src/AppTask.cpp @@ -48,14 +48,16 @@ #include +#include + /********************************************************** * Defines and Constants *********************************************************/ #define SYSTEM_STATE_LED &sl_led_led0 -#define APP_FUNCTION_BUTTON &sl_button_btn0 -#define APP_LIGHT_SWITCH &sl_button_btn1 +#define APP_FUNCTION_BUTTON 0 +#define APP_LIGHT_SWITCH 1 namespace { @@ -151,6 +153,10 @@ AppTask AppTask::sAppTask; CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT + chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler); +#endif + #ifdef DISPLAY_ENABLED GetLCD().Init((uint8_t *) "Light Switch"); #endif @@ -248,20 +254,18 @@ void AppTask::SwitchActionEventHandler(AppEvent * aEvent) } } -void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) +void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction) { - VerifyOrReturn(buttonHandle != NULL); - AppEvent button_event = {}; button_event.Type = AppEvent::kEventType_Button; button_event.ButtonEvent.Action = btnAction; - if (buttonHandle == APP_LIGHT_SWITCH) + if (button == APP_LIGHT_SWITCH) { button_event.Handler = SwitchActionEventHandler; sAppTask.PostEvent(&button_event); } - else if (buttonHandle == APP_FUNCTION_BUTTON) + else if (button == APP_FUNCTION_BUTTON) { button_event.Handler = BaseApplication::ButtonHandler; sAppTask.PostEvent(&button_event); diff --git a/examples/light-switch-app/silabs/efr32/src/main.cpp b/examples/light-switch-app/silabs/efr32/src/main.cpp deleted file mode 100644 index cd16d5f31b0ac2..00000000000000 --- a/examples/light-switch-app/silabs/efr32/src/main.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "AppConfig.h" -#include "init_efrPlatform.h" -#include "sl_simple_button_instances.h" -#include "sl_system_kernel.h" -#include -#include -#include -#include -#ifdef SILABS_ATTESTATION_CREDENTIALS -#include -#else -#include -#endif - -#define BLE_DEV_NAME "SiLabs-Light-Switch" -using namespace ::chip; -using namespace ::chip::Inet; -using namespace ::chip::DeviceLayer; -using namespace ::chip::Credentials; - -#define UNUSED_PARAMETER(a) (a = a) - -volatile int apperror_cnt; -static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; - -// ================================================================================ -// Main Code -// ================================================================================ -int main(void) -{ - init_efrPlatform(); - if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); - chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); - - chip::DeviceLayer::PlatformMgr().LockChipStack(); - // Initialize device attestation config -#ifdef SILABS_ATTESTATION_CREDENTIALS - SetDeviceAttestationCredentialsProvider(Silabs::GetSilabsDacProvider()); -#else - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); -#endif - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - SILABS_LOG("Starting App Task"); - if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - SILABS_LOG("Starting FreeRTOS scheduler"); - sl_system_kernel_start(); - - // Should never get here. - chip::Platform::MemoryShutdown(); - SILABS_LOG("vTaskStartScheduler() failed"); - appError(CHIP_ERROR_INTERNAL); -} - -void sl_button_on_change(const sl_button_t * handle) -{ - AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle)); -} diff --git a/examples/lighting-app/silabs/SiWx917/BUILD.gn b/examples/lighting-app/silabs/SiWx917/BUILD.gn index 05c1caaa3e72e6..b0bcf56032f81a 100644 --- a/examples/lighting-app/silabs/SiWx917/BUILD.gn +++ b/examples/lighting-app/silabs/SiWx917/BUILD.gn @@ -70,10 +70,10 @@ silabs_executable("lighting_app") { defines = [] sources = [ + "${examples_common_plat_dir}/main.cpp", "src/AppTask.cpp", "src/LightingManager.cpp", "src/ZclCallbacks.cpp", - "src/main.cpp", ] deps = [ diff --git a/examples/lighting-app/silabs/SiWx917/include/AppConfig.h b/examples/lighting-app/silabs/SiWx917/include/AppConfig.h index b86af8b22c2213..0b916a32f8452c 100644 --- a/examples/lighting-app/silabs/SiWx917/include/AppConfig.h +++ b/examples/lighting-app/silabs/SiWx917/include/AppConfig.h @@ -25,6 +25,8 @@ #define APP_TASK_NAME "Lit" +#define BLE_DEV_NAME "SiLabs-Light" + // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 10 diff --git a/examples/lighting-app/silabs/efr32/BUILD.gn b/examples/lighting-app/silabs/efr32/BUILD.gn index 5656bbf53db9ab..391226a9fc7bb9 100644 --- a/examples/lighting-app/silabs/efr32/BUILD.gn +++ b/examples/lighting-app/silabs/efr32/BUILD.gn @@ -107,10 +107,10 @@ silabs_executable("lighting_app") { } sources = [ + "${examples_common_plat_dir}/main.cpp", "src/AppTask.cpp", "src/LightingManager.cpp", "src/ZclCallbacks.cpp", - "src/main.cpp", ] deps = [ diff --git a/examples/lighting-app/silabs/efr32/include/AppConfig.h b/examples/lighting-app/silabs/efr32/include/AppConfig.h index 349f28d7c466d6..1cb27c78ae654c 100644 --- a/examples/lighting-app/silabs/efr32/include/AppConfig.h +++ b/examples/lighting-app/silabs/efr32/include/AppConfig.h @@ -25,6 +25,8 @@ #define APP_TASK_NAME "Lit" +#define BLE_DEV_NAME "SiLabs-Light" + // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 10 diff --git a/examples/lighting-app/silabs/efr32/include/AppTask.h b/examples/lighting-app/silabs/efr32/include/AppTask.h index cc76b02e8b293d..e80d6bf75a9276 100644 --- a/examples/lighting-app/silabs/efr32/include/AppTask.h +++ b/examples/lighting-app/silabs/efr32/include/AppTask.h @@ -80,7 +80,7 @@ class AppTask : public BaseApplication * @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED, * SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED */ - void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override; + static void ButtonEventHandler(uint8_t button, uint8_t btnAction); #endif /** * @brief Callback called by the identify-server when an identify command is received diff --git a/examples/lighting-app/silabs/efr32/src/AppTask.cpp b/examples/lighting-app/silabs/efr32/src/AppTask.cpp index 58197087f4b2cb..a1fc21b66fa4a1 100755 --- a/examples/lighting-app/silabs/efr32/src/AppTask.cpp +++ b/examples/lighting-app/silabs/efr32/src/AppTask.cpp @@ -31,6 +31,8 @@ #include +#include + #include #include @@ -46,8 +48,8 @@ #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT -#define APP_FUNCTION_BUTTON &sl_button_btn0 -#define APP_LIGHT_SWITCH &sl_button_btn1 +#define APP_FUNCTION_BUTTON 0 +#define APP_LIGHT_SWITCH 1 #endif using namespace chip; @@ -130,6 +132,10 @@ AppTask AppTask::sAppTask; CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT + chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler); +#endif + #ifdef DISPLAY_ENABLED GetLCD().Init((uint8_t *) "Lighting-App"); #endif @@ -258,26 +264,21 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent) } } #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT -void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) +void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction) { - if (buttonHandle == NULL) - { - return; - } - AppEvent button_event = {}; button_event.Type = AppEvent::kEventType_Button; button_event.ButtonEvent.Action = btnAction; - if (buttonHandle == APP_LIGHT_SWITCH && btnAction == SL_SIMPLE_BUTTON_PRESSED) + if (button == APP_LIGHT_SWITCH && btnAction == SL_SIMPLE_BUTTON_PRESSED) { button_event.Handler = LightActionEventHandler; - sAppTask.PostEvent(&button_event); + AppTask::GetAppTask().PostEvent(&button_event); } - else if (buttonHandle == APP_FUNCTION_BUTTON) + else if (button == APP_FUNCTION_BUTTON) { button_event.Handler = BaseApplication::ButtonHandler; - sAppTask.PostEvent(&button_event); + AppTask::GetAppTask().PostEvent(&button_event); } } diff --git a/examples/lighting-app/silabs/efr32/src/main.cpp b/examples/lighting-app/silabs/efr32/src/main.cpp deleted file mode 100644 index 7bfae98d5b397f..00000000000000 --- a/examples/lighting-app/silabs/efr32/src/main.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "AppConfig.h" -#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT -#include "sl_simple_button_instances.h" -#endif -#include "sl_system_kernel.h" -#include -#include -#include -#include -#ifdef SILABS_ATTESTATION_CREDENTIALS -#include -#else -#include -#endif - -#include - -#define BLE_DEV_NAME "SiLabs-Light" -using namespace ::chip; -using namespace ::chip::Inet; -using namespace ::chip::DeviceLayer; -using namespace ::chip::Credentials; -using namespace chip::DeviceLayer::Silabs; - -#define UNUSED_PARAMETER(a) (a = a) - -volatile int apperror_cnt; -static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; - -// ================================================================================ -// Main Code -// ================================================================================ -int main(void) -{ - GetPlatform().Init(); - - if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - gExampleDeviceInfoProvider.SetStorageDelegate(&chip::Server::GetInstance().GetPersistentStorage()); - chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); - - chip::DeviceLayer::PlatformMgr().LockChipStack(); - // Initialize device attestation config -#ifdef SILABS_ATTESTATION_CREDENTIALS - SetDeviceAttestationCredentialsProvider(Silabs::GetSilabsDacProvider()); -#else - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); -#endif - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - SILABS_LOG("Starting App Task"); - if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - SILABS_LOG("Starting FreeRTOS scheduler"); - sl_system_kernel_start(); - - // Should never get here. - chip::Platform::MemoryShutdown(); - SILABS_LOG("vTaskStartScheduler() failed"); - appError(CHIP_ERROR_INTERNAL); -} - -#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT -void sl_button_on_change(const sl_button_t * handle) -{ - AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle)); -} -#endif diff --git a/examples/lock-app/silabs/SiWx917/BUILD.gn b/examples/lock-app/silabs/SiWx917/BUILD.gn index 0d6bdcd9781be9..8c531d0ee62608 100644 --- a/examples/lock-app/silabs/SiWx917/BUILD.gn +++ b/examples/lock-app/silabs/SiWx917/BUILD.gn @@ -70,10 +70,10 @@ silabs_executable("lock_app") { defines = [] sources = [ + "${examples_common_plat_dir}/main.cpp", "src/AppTask.cpp", "src/LockManager.cpp", "src/ZclCallbacks.cpp", - "src/main.cpp", ] if (chip_build_libshell) { diff --git a/examples/lock-app/silabs/SiWx917/include/AppConfig.h b/examples/lock-app/silabs/SiWx917/include/AppConfig.h index 3014c5be66479c..f6985596d8993e 100644 --- a/examples/lock-app/silabs/SiWx917/include/AppConfig.h +++ b/examples/lock-app/silabs/SiWx917/include/AppConfig.h @@ -23,6 +23,8 @@ #define APP_TASK_NAME "Lock" +#define BLE_DEV_NAME "SiLabs-Door-Lock" + // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 10 diff --git a/examples/lock-app/silabs/SiWx917/src/AppTask.cpp b/examples/lock-app/silabs/SiWx917/src/AppTask.cpp index a85ac491927d3f..fe1d267e465f02 100644 --- a/examples/lock-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/lock-app/silabs/SiWx917/src/AppTask.cpp @@ -49,6 +49,8 @@ #include +#include + #include #define LOCK_STATE_LED 1 @@ -138,6 +140,8 @@ CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; + chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler); + #ifdef DISPLAY_ENABLED GetLCD().Init((uint8_t *) "Lock-App", true); #endif diff --git a/examples/lock-app/silabs/SiWx917/src/main.cpp b/examples/lock-app/silabs/SiWx917/src/main.cpp deleted file mode 100644 index d28689ff99cfb5..00000000000000 --- a/examples/lock-app/silabs/SiWx917/src/main.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "AppConfig.h" -#include "init_ccpPlatform.h" -#include -#include -#include -#include -#ifdef SILABS_ATTESTATION_CREDENTIALS -#include -#else -#include -#endif - -#define BLE_DEV_NAME "SiLabs-Door-Lock" -extern "C" void sl_button_on_change(uint8_t btn, uint8_t btnAction); - -using namespace ::chip; -using namespace ::chip::Inet; -using namespace ::chip::DeviceLayer; -using namespace ::chip::Credentials; - -#define UNUSED_PARAMETER(a) (a = a) - -volatile int apperror_cnt; -static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; - -// ================================================================================ -// Main Code -// ================================================================================ -int main(void) -{ - init_ccpPlatform(); - - if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); - chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); - - chip::DeviceLayer::PlatformMgr().LockChipStack(); - // Initialize device attestation config -#ifdef SILABS_ATTESTATION_CREDENTIALS - SetDeviceAttestationCredentialsProvider(SI917::GetSI917DacProvider()); -#else - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); -#endif - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - SILABS_LOG("Starting App Task"); - if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - SILABS_LOG("Starting FreeRTOS scheduler"); - vTaskStartScheduler(); - - // Should never get here. - chip::Platform::MemoryShutdown(); - SILABS_LOG("vTaskStartScheduler() failed"); - appError(CHIP_ERROR_INTERNAL); -} - -void sl_button_on_change(uint8_t btn, uint8_t btnAction) -{ - AppTask::GetAppTask().ButtonEventHandler(btn, btnAction); -} diff --git a/examples/lock-app/silabs/efr32/BUILD.gn b/examples/lock-app/silabs/efr32/BUILD.gn index 10ecbfc88f8181..d70726b29d1b70 100644 --- a/examples/lock-app/silabs/efr32/BUILD.gn +++ b/examples/lock-app/silabs/efr32/BUILD.gn @@ -89,10 +89,10 @@ silabs_executable("lock_app") { defines = [] sources = [ + "${examples_common_plat_dir}/main.cpp", "src/AppTask.cpp", "src/LockManager.cpp", "src/ZclCallbacks.cpp", - "src/main.cpp", ] if (chip_build_libshell) { diff --git a/examples/lock-app/silabs/efr32/include/AppConfig.h b/examples/lock-app/silabs/efr32/include/AppConfig.h index 36856b8cb38ed8..405bb4691ad8e5 100644 --- a/examples/lock-app/silabs/efr32/include/AppConfig.h +++ b/examples/lock-app/silabs/efr32/include/AppConfig.h @@ -23,6 +23,8 @@ #define APP_TASK_NAME "Lock" +#define BLE_DEV_NAME "SiLabs-Door-Lock" + // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 10 diff --git a/examples/lock-app/silabs/efr32/include/AppTask.h b/examples/lock-app/silabs/efr32/include/AppTask.h index 0c7723475772be..4205a9b891f2a3 100644 --- a/examples/lock-app/silabs/efr32/include/AppTask.h +++ b/examples/lock-app/silabs/efr32/include/AppTask.h @@ -86,7 +86,7 @@ class AppTask : public BaseApplication * @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED, * SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED */ - void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override; + static void ButtonEventHandler(uint8_t button, uint8_t btnAction); /** * @brief Callback called by the identify-server when an identify command is received diff --git a/examples/lock-app/silabs/efr32/src/AppTask.cpp b/examples/lock-app/silabs/efr32/src/AppTask.cpp index ed1b51df6831d4..93757638519773 100644 --- a/examples/lock-app/silabs/efr32/src/AppTask.cpp +++ b/examples/lock-app/silabs/efr32/src/AppTask.cpp @@ -49,12 +49,14 @@ #include +#include + #include #define SYSTEM_STATE_LED 0 #define LOCK_STATE_LED 1 -#define APP_FUNCTION_BUTTON &sl_button_btn0 -#define APP_LOCK_SWITCH &sl_button_btn1 +#define APP_FUNCTION_BUTTON 0 +#define APP_LOCK_SWITCH 1 using chip::app::Clusters::DoorLock::DlLockState; using chip::app::Clusters::DoorLock::OperationErrorEnum; @@ -141,6 +143,8 @@ CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; + chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler); + #ifdef DISPLAY_ENABLED GetLCD().Init((uint8_t *) "Lock-App", true); #endif @@ -355,23 +359,18 @@ void AppTask::LockActionEventHandler(AppEvent * aEvent) } } -void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) +void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction) { - if (buttonHandle == NULL) - { - return; - } - AppEvent button_event = {}; button_event.Type = AppEvent::kEventType_Button; button_event.ButtonEvent.Action = btnAction; - if (buttonHandle == APP_LOCK_SWITCH && btnAction == SL_SIMPLE_BUTTON_PRESSED) + if (button == APP_LOCK_SWITCH && btnAction == SL_SIMPLE_BUTTON_PRESSED) { button_event.Handler = LockActionEventHandler; sAppTask.PostEvent(&button_event); } - else if (buttonHandle == APP_FUNCTION_BUTTON) + else if (button == APP_FUNCTION_BUTTON) { button_event.Handler = BaseApplication::ButtonHandler; sAppTask.PostEvent(&button_event); diff --git a/examples/lock-app/silabs/efr32/src/main.cpp b/examples/lock-app/silabs/efr32/src/main.cpp deleted file mode 100644 index aef9ed112eb164..00000000000000 --- a/examples/lock-app/silabs/efr32/src/main.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "AppConfig.h" -#include "init_efrPlatform.h" -#include "sl_simple_button_instances.h" -#include "sl_system_kernel.h" -#include -#include -#include -#include -#ifdef SILABS_ATTESTATION_CREDENTIALS -#include -#else -#include -#endif - -#define BLE_DEV_NAME "SiLabs-Door-Lock" -using namespace ::chip; -using namespace ::chip::Inet; -using namespace ::chip::DeviceLayer; -using namespace ::chip::Credentials; - -#define UNUSED_PARAMETER(a) (a = a) - -volatile int apperror_cnt; -static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; - -// ================================================================================ -// Main Code -// ================================================================================ -int main(void) -{ - init_efrPlatform(); - if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); - chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); - - chip::DeviceLayer::PlatformMgr().LockChipStack(); - // Initialize device attestation config -#ifdef SILABS_ATTESTATION_CREDENTIALS - SetDeviceAttestationCredentialsProvider(Silabs::GetSilabsDacProvider()); -#else - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); -#endif - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - SILABS_LOG("Starting App Task"); - if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - SILABS_LOG("Starting FreeRTOS scheduler"); - sl_system_kernel_start(); - - // Should never get here. - chip::Platform::MemoryShutdown(); - SILABS_LOG("vTaskStartScheduler() failed"); - appError(CHIP_ERROR_INTERNAL); -} - -void sl_button_on_change(const sl_button_t * handle) -{ - AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle)); -} diff --git a/examples/platform/silabs/Rpc.cpp b/examples/platform/silabs/Rpc.cpp index e3c1fed77ecf84..5c3462bece6f0e 100644 --- a/examples/platform/silabs/Rpc.cpp +++ b/examples/platform/silabs/Rpc.cpp @@ -82,7 +82,7 @@ class Efr32Button final : public Button public: pw::Status Event(const chip_rpc_ButtonEvent & request, pw_protobuf_Empty & response) override { - AppTask::GetAppTask().ButtonEventHandler(SL_SIMPLE_BUTTON_INSTANCE(request.idx) /* PB 0 or PB 1 */, request.pushed); + AppTask::GetAppTask().ButtonEventHandler(request.idx /* PB 0 or PB 1 */, request.pushed); return pw::OkStatus(); } }; diff --git a/examples/platform/silabs/efr32/BaseApplication.cpp b/examples/platform/silabs/efr32/BaseApplication.cpp index 8d088bd4de3e13..9d096f23353cab 100644 --- a/examples/platform/silabs/efr32/BaseApplication.cpp +++ b/examples/platform/silabs/efr32/BaseApplication.cpp @@ -76,7 +76,7 @@ #define SYSTEM_STATE_LED 0 #endif // ENABLE_WSTK_LEDS #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT -#define APP_FUNCTION_BUTTON &sl_button_btn0 +#define APP_FUNCTION_BUTTON 0 #endif using namespace chip; diff --git a/examples/platform/silabs/efr32/BaseApplication.h b/examples/platform/silabs/efr32/BaseApplication.h index eeb49702099993..191fcba4aaf3f3 100644 --- a/examples/platform/silabs/efr32/BaseApplication.h +++ b/examples/platform/silabs/efr32/BaseApplication.h @@ -93,18 +93,6 @@ class BaseApplication * @brief Return LCD object */ static SilabsLCD & GetLCD(void); -#endif -#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT - /** - * @brief Event handler when a button is pressed - * Function posts an event for button processing - * - * @param buttonHandle APP_LIGHT_SWITCH or APP_FUNCTION_BUTTON - * @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED, - * SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED - */ - virtual void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) = 0; - #endif /** diff --git a/examples/lighting-app/silabs/SiWx917/src/main.cpp b/examples/platform/silabs/main.cpp similarity index 81% rename from examples/lighting-app/silabs/SiWx917/src/main.cpp rename to examples/platform/silabs/main.cpp index ce2ae970887a40..a94696ef08374e 100644 --- a/examples/lighting-app/silabs/SiWx917/src/main.cpp +++ b/examples/platform/silabs/main.cpp @@ -20,7 +20,6 @@ #include #include "AppConfig.h" -#include "init_ccpPlatform.h" #include #include @@ -32,16 +31,12 @@ #include #endif -#define BLE_DEV_NAME "SiLabs-Light" - -extern "C" void sl_button_on_change(uint8_t btn, uint8_t btnAction); +#include using namespace ::chip; -using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; using namespace ::chip::Credentials; - -#define UNUSED_PARAMETER(a) (a = a) +using namespace chip::DeviceLayer::Silabs; volatile int apperror_cnt; static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; @@ -51,11 +46,10 @@ static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; // ================================================================================ int main(void) { - init_ccpPlatform(); + GetPlatform().Init(); + if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) - { appError(CHIP_ERROR_INTERNAL); - } gExampleDeviceInfoProvider.SetStorageDelegate(&chip::Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); @@ -63,7 +57,7 @@ int main(void) chip::DeviceLayer::PlatformMgr().LockChipStack(); // Initialize device attestation config #ifdef SILABS_ATTESTATION_CREDENTIALS - SetDeviceAttestationCredentialsProvider(Silabs::GetSilabsDacProvider()); + SetDeviceAttestationCredentialsProvider(Credentials::Silabs::GetSilabsDacProvider()); #else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif @@ -71,20 +65,13 @@ int main(void) SILABS_LOG("Starting App Task"); if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR) - { appError(CHIP_ERROR_INTERNAL); - } - SILABS_LOG("Starting FreeRTOS scheduler"); - vTaskStartScheduler(); + SILABS_LOG("Starting scheduler"); + GetPlatform().StartScheduler(); // Should never get here. chip::Platform::MemoryShutdown(); SILABS_LOG("vTaskStartScheduler() failed"); appError(CHIP_ERROR_INTERNAL); } - -void sl_button_on_change(uint8_t btn, uint8_t btnAction) -{ - AppTask::GetAppTask().ButtonEventHandler(btn, btnAction); -} diff --git a/examples/thermostat/silabs/efr32/BUILD.gn b/examples/thermostat/silabs/efr32/BUILD.gn index ac33e5624e5987..31485ed1bcdc29 100644 --- a/examples/thermostat/silabs/efr32/BUILD.gn +++ b/examples/thermostat/silabs/efr32/BUILD.gn @@ -105,11 +105,11 @@ silabs_executable("thermostat_app") { defines = [] sources = [ + "${examples_common_plat_dir}/main.cpp", "src/AppTask.cpp", "src/SensorManager.cpp", "src/TemperatureManager.cpp", "src/ZclCallbacks.cpp", - "src/main.cpp", ] if (use_temp_sensor) { diff --git a/examples/thermostat/silabs/efr32/include/AppConfig.h b/examples/thermostat/silabs/efr32/include/AppConfig.h index ed3c7592aa6020..a1561de487da01 100644 --- a/examples/thermostat/silabs/efr32/include/AppConfig.h +++ b/examples/thermostat/silabs/efr32/include/AppConfig.h @@ -23,6 +23,8 @@ #define APP_TASK_NAME "Lit" +#define BLE_DEV_NAME "SiLabs-Thermostat" + // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 10 diff --git a/examples/thermostat/silabs/efr32/include/AppTask.h b/examples/thermostat/silabs/efr32/include/AppTask.h index ce4fa6f0fef43c..8e0458d8a6fdf1 100644 --- a/examples/thermostat/silabs/efr32/include/AppTask.h +++ b/examples/thermostat/silabs/efr32/include/AppTask.h @@ -88,7 +88,7 @@ class AppTask : public BaseApplication * @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED, * SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED */ - void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override; + static void ButtonEventHandler(uint8_t button, uint8_t btnAction); /** * @brief Callback called by the identify-server when an identify command is received diff --git a/examples/thermostat/silabs/efr32/src/AppTask.cpp b/examples/thermostat/silabs/efr32/src/AppTask.cpp index 21cee0c90cc122..f3f8fdecf2e5a2 100644 --- a/examples/thermostat/silabs/efr32/src/AppTask.cpp +++ b/examples/thermostat/silabs/efr32/src/AppTask.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -53,8 +54,8 @@ * Defines and Constants *********************************************************/ -#define APP_FUNCTION_BUTTON &sl_button_btn0 -#define APP_THERMOSTAT &sl_button_btn1 +#define APP_FUNCTION_BUTTON 0 +#define APP_THERMOSTAT 1 #define MODE_TIMER 1000 // 1s timer period @@ -142,6 +143,8 @@ CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; + chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler); + #ifdef DISPLAY_ENABLED GetLCD().Init((uint8_t *) "Thermostat-App"); GetLCD().SetCustomUI(ThermostatUI::DrawUI); @@ -242,18 +245,13 @@ void AppTask::UpdateThermoStatUI() #endif // DISPLAY_ENABLED } -void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) +void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction) { - if (buttonHandle == nullptr) - { - return; - } - AppEvent aEvent = {}; aEvent.Type = AppEvent::kEventType_Button; aEvent.ButtonEvent.Action = btnAction; - if (buttonHandle == APP_FUNCTION_BUTTON) + if (button == APP_FUNCTION_BUTTON) { aEvent.Handler = BaseApplication::ButtonHandler; sAppTask.PostEvent(&aEvent); diff --git a/examples/thermostat/silabs/efr32/src/main.cpp b/examples/thermostat/silabs/efr32/src/main.cpp deleted file mode 100644 index 0af7a99a6a8dd9..00000000000000 --- a/examples/thermostat/silabs/efr32/src/main.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "AppConfig.h" -#include "init_efrPlatform.h" -#include "sl_simple_button_instances.h" -#include "sl_system_kernel.h" -#include -#include -#include -#include -#ifdef SILABS_ATTESTATION_CREDENTIALS -#include -#else -#include -#endif - -#define BLE_DEV_NAME "SiLabs-Thermostat" -using namespace ::chip; -using namespace ::chip::Inet; -using namespace ::chip::DeviceLayer; -using namespace ::chip::Credentials; - -#define UNUSED_PARAMETER(a) (a = a) - -volatile int apperror_cnt; -static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; - -// ================================================================================ -// Main Code -// ================================================================================ -int main(void) -{ - init_efrPlatform(); - if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); - chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); - - chip::DeviceLayer::PlatformMgr().LockChipStack(); - // Initialize device attestation config -#ifdef SILABS_ATTESTATION_CREDENTIALS - SetDeviceAttestationCredentialsProvider(Silabs::GetSilabsDacProvider()); -#else - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); -#endif - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - SILABS_LOG("Starting App Task"); - if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - SILABS_LOG("Starting FreeRTOS scheduler"); - sl_system_kernel_start(); - - // Should never get here. - chip::Platform::MemoryShutdown(); - SILABS_LOG("vTaskStartScheduler() failed"); - appError(CHIP_ERROR_INTERNAL); -} - -void sl_button_on_change(const sl_button_t * handle) -{ - AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle)); -} diff --git a/examples/window-app/silabs/efr32/include/WindowAppImpl.h b/examples/window-app/silabs/efr32/include/WindowAppImpl.h index 27a26dba9a4399..86444574ba0088 100644 --- a/examples/window-app/silabs/efr32/include/WindowAppImpl.h +++ b/examples/window-app/silabs/efr32/include/WindowAppImpl.h @@ -43,7 +43,8 @@ class WindowAppImpl : public WindowApp void Finish() override; void PostEvent(const WindowApp::Event & event) override; void PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId) override; - friend void sl_button_on_change(const sl_button_t * handle); + static void ButtonEventHandler(uint8_t button, uint8_t btnAction); + void OnButtonChange(uint8_t button, uint8_t btnAction); protected: struct Timer : public WindowApp::Timer @@ -67,7 +68,6 @@ class WindowAppImpl : public WindowApp WindowApp::Timer * CreateTimer(const char * name, uint32_t timeoutInMs, WindowApp::Timer::Callback callback, void * context) override; WindowApp::Button * CreateButton(WindowApp::Button::Id id, const char * name) override; - void OnButtonChange(const sl_button_t * handle); void ProcessEvents(); void DispatchEvent(const WindowApp::Event & event) override; void UpdateLEDs(); diff --git a/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp b/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp index e2032125538076..5358344b58ebe7 100644 --- a/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp +++ b/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp @@ -46,6 +46,8 @@ SilabsLCD slLCD; #endif +#include + #define APP_TASK_STACK_SIZE (4096) #define APP_TASK_PRIORITY 2 #define APP_EVENT_QUEUE_SIZE 10 @@ -187,6 +189,8 @@ void WindowAppImpl::OnIconTimeout(WindowApp::Timer & timer) CHIP_ERROR WindowAppImpl::Init() { + chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(WindowAppImpl::ButtonEventHandler); + WindowApp::Init(); // Initialize App Task @@ -510,11 +514,11 @@ void WindowAppImpl::OnMainLoop() //------------------------------------------------------------------------------ WindowAppImpl::Button::Button(WindowApp::Button::Id id, const char * name) : WindowApp::Button(id, name) {} -void WindowAppImpl::OnButtonChange(const sl_button_t * handle) +void WindowAppImpl::OnButtonChange(uint8_t button, uint8_t btnAction) { - WindowApp::Button * btn = static_cast