From 3314bc37e942422c9b446a664c35085c45d7713c Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Tue, 17 Dec 2024 19:47:20 -0800 Subject: [PATCH 1/2] Map the return error from AppendUserLabel to RESOURCE_EXHAUSTED (#36868) * Map the return error from AppendUserLabel to RESOURCE_EXHAUSTED * Restyled by whitespace * Addressed the review comments * Update API comment to algin with implemantion --------- Co-authored-by: Restyled.io --- .../user-label-server/user-label-server.cpp | 9 ++++- .../TestUserLabelClusterConstraints.yaml | 4 +- src/include/platform/DeviceInfoProvider.h | 38 +++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/app/clusters/user-label-server/user-label-server.cpp b/src/app/clusters/user-label-server/user-label-server.cpp index 0030f628097696..47a2c49f4b75a9 100644 --- a/src/app/clusters/user-label-server/user-label-server.cpp +++ b/src/app/clusters/user-label-server/user-label-server.cpp @@ -151,7 +151,14 @@ CHIP_ERROR UserLabelAttrAccess::WriteLabelList(const ConcreteDataAttributePath & ReturnErrorOnFailure(aDecoder.Decode(entry)); VerifyOrReturnError(IsValidLabelEntry(entry), CHIP_IM_GLOBAL_STATUS(ConstraintError)); - return provider->AppendUserLabel(endpoint, entry); + // Append the single user label entry + CHIP_ERROR err = provider->AppendUserLabel(endpoint, entry); + if (err == CHIP_ERROR_NO_MEMORY) + { + return CHIP_IM_GLOBAL_STATUS(ResourceExhausted); + } + + return err; } return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; diff --git a/src/app/tests/suites/TestUserLabelClusterConstraints.yaml b/src/app/tests/suites/TestUserLabelClusterConstraints.yaml index 935fe88c2b662c..ab5a53e5e9c169 100644 --- a/src/app/tests/suites/TestUserLabelClusterConstraints.yaml +++ b/src/app/tests/suites/TestUserLabelClusterConstraints.yaml @@ -85,5 +85,5 @@ tests: ] response: # When the cluster runs out of capacity to store these entries, - # we expect a FAILURE get returned. - error: FAILURE + # we expect a RESOURCE_EXHAUSTED get returned. + error: RESOURCE_EXHAUSTED diff --git a/src/include/platform/DeviceInfoProvider.h b/src/include/platform/DeviceInfoProvider.h index 59920f64d700f7..4bf1e4e0b3a1d4 100644 --- a/src/include/platform/DeviceInfoProvider.h +++ b/src/include/platform/DeviceInfoProvider.h @@ -89,8 +89,46 @@ class DeviceInfoProvider */ void SetStorageDelegate(PersistentStorageDelegate * storage); + /** + * @brief Sets the user label list for a specified endpoint. + * + * Replaces the current user label list with a new list. If the new list is smaller + * than the existing one, excess labels are deleted to free up space. + * + * @param[in] endpoint The endpoint ID associated with the user label list. + * @param[in] labelList The new list of user labels to store. + * + * @return CHIP_NO_ERROR on success. + * @return CHIP_ERROR if an error occurs. + */ CHIP_ERROR SetUserLabelList(EndpointId endpoint, const AttributeList & labelList); + + /** + * @brief Clears the user label list for a specified endpoint. + * + * Deletes all user labels associated with the given endpoint, resetting the list length to zero. + * If no previous list exists, this function has no effect. + * + * @param[in] endpoint The endpoint ID whose user label list will be cleared. + * + * @return CHIP_NO_ERROR on success or if no previous value exists. + * @return CHIP_ERROR if an error occurs during deletion. + */ CHIP_ERROR ClearUserLabelList(EndpointId endpoint); + + /** + * @brief Appends a user label to the user label list for a specified endpoint. + * + * Adds a new label to the end of the existing user label list. The list size must not + * exceed `kMaxUserLabelListLength`. If the list is full, the function returns an error. + * + * @param[in] endpoint The endpoint ID to which the user label will be added. + * @param[in] label The user label to append to the list. + * + * @return CHIP_NO_ERROR on success. + * @return CHIP_ERROR_NO_MEMORY if the list is already at its maximum size. + * @return CHIP_ERROR if an error occurs during storage. + */ CHIP_ERROR AppendUserLabel(EndpointId endpoint, const UserLabelType & label); // Iterators From b0d0614976f0fa4e17f377537023a0db594ac46e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Duda?= Date: Wed, 18 Dec 2024 07:33:44 +0100 Subject: [PATCH 2/2] [nrfconnect] Increase thread stack sizes for pigweed configuration (#36878) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit further increases the stack sizes when Pigweed logger is enabled. Signed-off-by: Ɓukasz Duda --- examples/chef/nrfconnect/rpc.overlay | 6 ++++-- examples/lighting-app/nrfconnect/rpc.overlay | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/chef/nrfconnect/rpc.overlay b/examples/chef/nrfconnect/rpc.overlay index e3b08a0a2a5178..ce776f2e27e000 100644 --- a/examples/chef/nrfconnect/rpc.overlay +++ b/examples/chef/nrfconnect/rpc.overlay @@ -49,6 +49,8 @@ CONFIG_LOG_OUTPUT=y # Increase zephyr tty rx buffer CONFIG_CONSOLE_GETCHAR_BUFSIZE=128 -# Increase BLE thread stack size -CONFIG_BT_RX_STACK_SIZE=2048 +# Increase thread stack sizes +CONFIG_BT_RX_STACK_SIZE=4096 +CONFIG_MAIN_STACK_SIZE=8092 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 diff --git a/examples/lighting-app/nrfconnect/rpc.overlay b/examples/lighting-app/nrfconnect/rpc.overlay index 315349a69555e2..3d74670fe1da6b 100644 --- a/examples/lighting-app/nrfconnect/rpc.overlay +++ b/examples/lighting-app/nrfconnect/rpc.overlay @@ -46,6 +46,8 @@ CONFIG_LOG_OUTPUT=y # Increase zephyr tty rx buffer CONFIG_CONSOLE_GETCHAR_BUFSIZE=128 -# Increase BLE thread stack size -CONFIG_BT_RX_STACK_SIZE=2048 +# Increase thread stack sizes +CONFIG_BT_RX_STACK_SIZE=4096 +CONFIG_MAIN_STACK_SIZE=8092 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048