From 88f6797f74e599c35e730d3b805f6b7be2bb25f6 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Wed, 26 Mar 2025 22:38:27 -0700 Subject: [PATCH 01/46] Chef: Add APIs to provide deviceType info on Endpoints. Fix composition initialization in attribute storage. --- examples/chef/common/DataModelUtils.cpp | 60 +++++++++++++ examples/chef/common/DataModelUtils.h | 40 +++++++++ examples/chef/common/stubs.cpp | 109 ++++++++++++++++++++---- examples/chef/linux/BUILD.gn | 1 + examples/chef/nrfconnect/CMakeLists.txt | 1 + src/app/util/attribute-storage.cpp | 30 +++++-- 6 files changed, 215 insertions(+), 26 deletions(-) create mode 100644 examples/chef/common/DataModelUtils.cpp create mode 100644 examples/chef/common/DataModelUtils.h diff --git a/examples/chef/common/DataModelUtils.cpp b/examples/chef/common/DataModelUtils.cpp new file mode 100644 index 00000000000000..3d0ecddf15d261 --- /dev/null +++ b/examples/chef/common/DataModelUtils.cpp @@ -0,0 +1,60 @@ +/* + * + * Copyright (c) 2025 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 +#include + +using namespace chip::app; + +CHIP_ERROR DataModelUtils::isEndpointOfDeviceType(EndpointId endpoint, DeviceTypeId deviceTypeId, bool & isOfDeviceType) +{ + isOfDeviceType = false; + DataModel::ListBuilder deviceTypesList; + ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->DeviceTypes(endpoint, deviceTypesList)); + auto deviceTypes = deviceTypesList.TakeBuffer(); + for (const auto & type : deviceTypes) + { + if (type.deviceTypeId == deviceTypeId) + { + isOfDeviceType = true; + return CHIP_NO_ERROR; + } + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelUtils::getAllEndpointsHavingDeviceType(DeviceTypeId devieType, DataModel::ListBuilder & builder) +{ + + DataModel::ListBuilder endpointsList; + ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->Endpoints(endpointsList)); + auto allEndpoints = endpointsList.TakeBuffer(); + + for (const auto & ep : allEndpoints) + { + bool isOfDeviceType; + ReturnErrorOnFailure(isEndpointOfDeviceType(ep, devieType, isOfDeviceType)); + if (isOfDeviceType) + { + ReturnErrorOnFailure(builder.Append(ep)); + } + } + return CHIP_NO_ERROR; +} diff --git a/examples/chef/common/DataModelUtils.h b/examples/chef/common/DataModelUtils.h new file mode 100644 index 00000000000000..306277ae0e38f8 --- /dev/null +++ b/examples/chef/common/DataModelUtils.h @@ -0,0 +1,40 @@ +/* + * + * Copyright (c) 2025 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 + +namespace chip { +namespace app { +namespace DataModelUtils { + +// Common location to store all device type IDs +constexpr DeviceTypeId COOK_SURFACE_DEVICE_ID = 0x0077; +constexpr DeviceTypeId COOKTOP_DEVICE_ID = 0x0078; +constexpr DeviceTypeId OVEN_DEVICE_ID = 0x007B; +constexpr DeviceTypeId REFRIGERATOR_DEVICE_ID = 0x0070; +constexpr DeviceTypeId TEMPERATURE_CONTROLLED_CABINET_DEVICE_ID = 0x0071; + +// Datamodel Util APIs +CHIP_ERROR isEndpointOfDeviceType(EndpointId endpoint, DeviceTypeId deviceTypeId, bool & isOfDeviceType); +CHIP_ERROR getAllEndpointsHavingDeviceType(DeviceTypeId devieType, DataModel::ListBuilder & builder); + +} // namespace DataModelUtils +} // namespace app +} // namespace chip diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index bacad113512764..3c21d1685d0657 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -46,11 +47,11 @@ constexpr const uint8_t kNamespaceRefrigerator = 0x41; // Refrigerator Namespace: 0x41, tag 0x00 (Refrigerator) constexpr const uint8_t kTagRefrigerator = 0x00; // Refrigerator Namespace: 0x41, tag 0x01 (Freezer) -constexpr const uint8_t kTagFreezer = 0x01; -const Clusters::Descriptor::Structs::SemanticTagStruct::Type refrigeratorTagList[] = { { .namespaceID = kNamespaceRefrigerator, - .tag = kTagRefrigerator } }; -const Clusters::Descriptor::Structs::SemanticTagStruct::Type freezerTagList[] = { { .namespaceID = kNamespaceRefrigerator, - .tag = kTagFreezer } }; +constexpr const uint8_t kTagFreezer = 0x01; +const Clusters::Descriptor::Structs::SemanticTagStruct::Type gRefrigeratorTagList[] = { { .namespaceID = kNamespaceRefrigerator, + .tag = kTagRefrigerator } }; +const Clusters::Descriptor::Structs::SemanticTagStruct::Type gFreezerTagList[] = { { .namespaceID = kNamespaceRefrigerator, + .tag = kTagFreezer } }; } // namespace #endif // MATTER_DM_PLUGIN_REFRIGERATOR_ALARM_SERVER @@ -347,22 +348,96 @@ void emberAfWakeOnLanClusterInitCallback(EndpointId endpoint) } #endif -void ApplicationInit() +/** + * This initializer is for the application having refrigerator on EP1 and child + * temperatureControlledCabinet endpoints on EP2 and EP3. + */ +void RefrigeratorTemperatureControlledCabinetInit() { - ChipLogProgress(NotSpecified, "Chef Application Init !!!"); - -#ifdef MATTER_DM_PLUGIN_REFRIGERATOR_ALARM_SERVER - // set Parent Endpoint and Composition Type for an Endpoint EndpointId kRefEndpointId = 1; EndpointId kColdCabinetEndpointId = 2; EndpointId kFreezeCabinetEndpointId = 3; - SetTreeCompositionForEndpoint(kRefEndpointId); - SetParentEndpointForEndpoint(kColdCabinetEndpointId, kRefEndpointId); - SetParentEndpointForEndpoint(kFreezeCabinetEndpointId, kRefEndpointId); - // set TagList - SetTagList(kColdCabinetEndpointId, Span(refrigeratorTagList)); - SetTagList(kFreezeCabinetEndpointId, Span(freezerTagList)); -#endif // MATTER_DM_PLUGIN_REFRIGERATOR_ALARM_SERVER + bool isRefrigerator; + bool isColdCabinet; + bool isFreezeCabinet; + if ((DataModelUtils::isEndpointOfDeviceType(kRefEndpointId, DataModelUtils::REFRIGERATOR_DEVICE_ID, isRefrigerator) == + CHIP_NO_ERROR) && + isRefrigerator) + { + ChipLogProgress(NotSpecified, "Refrigerator device type on EP: %d", kRefEndpointId); + SetTreeCompositionForEndpoint(kRefEndpointId); + + // Cold Cabinet + if ((DataModelUtils::isEndpointOfDeviceType(kColdCabinetEndpointId, + DataModelUtils::TEMPERATURE_CONTROLLED_CABINET_DEVICE_ID, + isColdCabinet) == CHIP_NO_ERROR) && + isColdCabinet) + { + SetParentEndpointForEndpoint(kColdCabinetEndpointId, kRefEndpointId); + SetTagList(kColdCabinetEndpointId, + Span(gRefrigeratorTagList)); + } + + // Freeze Cabinet + if ((DataModelUtils::isEndpointOfDeviceType(kFreezeCabinetEndpointId, + DataModelUtils::TEMPERATURE_CONTROLLED_CABINET_DEVICE_ID, + isFreezeCabinet) == CHIP_NO_ERROR) && + isFreezeCabinet) + { + SetParentEndpointForEndpoint(kFreezeCabinetEndpointId, kRefEndpointId); + SetTagList(kFreezeCabinetEndpointId, + Span(gFreezerTagList)); + } + } +} + +/** + * This initializer is for the application having oven on EP1 and child endpoints - + * temperatureControlledCabinet on EP2, cooktop on EP3 and cooksurface on EP4. + */ +void OvenTemperatureControlledCabinetCooktopCookSurfaceInit() +{ + EndpointId kOvenEpId = 1; + EndpointId kTemperatureControlledCabinetEpId = 2; + EndpointId kCooktopEpId = 3; + EndpointId kCookSurfaceEpId = 4; + bool isOven; + bool isTemperatureControlledCabinet; + bool isCooktop; + bool isCookSurface; + if ((DataModelUtils::isEndpointOfDeviceType(kOvenEpId, DataModelUtils::OVEN_DEVICE_ID, isOven) == CHIP_NO_ERROR) && isOven) + { + ChipLogProgress(NotSpecified, "Oven device type on EP: %d", kOvenEpId); + SetTreeCompositionForEndpoint(kOvenEpId); + + if ((DataModelUtils::isEndpointOfDeviceType(kTemperatureControlledCabinetEpId, + DataModelUtils::TEMPERATURE_CONTROLLED_CABINET_DEVICE_ID, + isTemperatureControlledCabinet) == CHIP_NO_ERROR) && + isTemperatureControlledCabinet) + { + SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId); + } + + if ((DataModelUtils::isEndpointOfDeviceType(kCooktopEpId, DataModelUtils::COOKTOP_DEVICE_ID, isCooktop) == CHIP_NO_ERROR) && + isCooktop) + { + SetParentEndpointForEndpoint(kCooktopEpId, kOvenEpId); + } + + if ((DataModelUtils::isEndpointOfDeviceType(kCookSurfaceEpId, DataModelUtils::COOK_SURFACE_DEVICE_ID, isCookSurface) == + CHIP_NO_ERROR) && + isCookSurface) + { + SetParentEndpointForEndpoint(kCookSurfaceEpId, kOvenEpId); + } + } +} + +void ApplicationInit() +{ + ChipLogProgress(NotSpecified, "Chef Application Init !!!"); + + RefrigeratorTemperatureControlledCabinetInit(); #ifdef MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER ChipLogProgress(NotSpecified, "Initializing WindowCovering cluster delegate."); diff --git a/examples/chef/linux/BUILD.gn b/examples/chef/linux/BUILD.gn index d70a0423162bf4..d0ff3fe7497a03 100644 --- a/examples/chef/linux/BUILD.gn +++ b/examples/chef/linux/BUILD.gn @@ -40,6 +40,7 @@ chip_data_model("chef-data-model") { executable("${sample_name}") { sources = [ + "${project_dir}/common/DataModelUtils.cpp", "${project_dir}/common/chef-air-quality.cpp", "${project_dir}/common/chef-concentration-measurement.cpp", "${project_dir}/common/chef-dishwasher-alarm-delegate-impl.cpp", diff --git a/examples/chef/nrfconnect/CMakeLists.txt b/examples/chef/nrfconnect/CMakeLists.txt index e1c286f9372d5b..fc8d58e9f468d1 100644 --- a/examples/chef/nrfconnect/CMakeLists.txt +++ b/examples/chef/nrfconnect/CMakeLists.txt @@ -78,6 +78,7 @@ if (CONFIG_CHIP_LIB_SHELL) endif() target_sources(app PRIVATE + ${CHEF}/common/DataModelUtils.cpp ${CHEF}/common/chef-air-quality.cpp ${CHEF}/common/chef-concentration-measurement.cpp ${CHEF}/common/chef-fan-control-manager.cpp diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 1359c59fc5f8de..7f6abeb08abfa5 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -99,18 +99,12 @@ unsigned emberMetadataStructureGeneration = 0; // we need this data block for the defaults #if (defined(GENERATED_DEFAULTS) && GENERATED_DEFAULTS_COUNT) constexpr const uint8_t generatedDefaults[] = GENERATED_DEFAULTS; -#define ZAP_LONG_DEFAULTS_INDEX(index) \ - { \ - &generatedDefaults[index] \ - } +#define ZAP_LONG_DEFAULTS_INDEX(index) { &generatedDefaults[index] } #endif // GENERATED_DEFAULTS #if (defined(GENERATED_MIN_MAX_DEFAULTS) && GENERATED_MIN_MAX_DEFAULT_COUNT) constexpr const EmberAfAttributeMinMaxValue minMaxDefaults[] = GENERATED_MIN_MAX_DEFAULTS; -#define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ - { \ - &minMaxDefaults[index] \ - } +#define ZAP_MIN_MAX_DEFAULTS_INDEX(index) { &minMaxDefaults[index] } #endif // GENERATED_MIN_MAX_DEFAULTS #ifdef GENERATED_FUNCTION_ARRAYS @@ -217,7 +211,25 @@ void emberAfEndpointConfigure() emAfEndpoints[ep].parentEndpointId = fixedParentEndpoints[ep]; emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isEnabled); - emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isFlatComposition); + bool isFlatComposition = false; + for (const auto & deviceType : emAfEndpoints[ep].deviceTypeList) + { + if ((deviceType.deviceTypeId == 0x0016) // Rootnode + || (deviceType.deviceTypeId == 0x000E) // Aggregator + ) + { + isFlatComposition = true; + break; + } + } + if (isFlatComposition) + { + emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isFlatComposition); + } + else + { + emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isTreeComposition); + } // Increment currentDataVersions by 1 (slot) for every server cluster // this endpoint has. From 3441ee15936db09f8c915c15200d70df50a78d59 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Wed, 26 Mar 2025 22:55:04 -0700 Subject: [PATCH 02/46] + --- examples/chef/common/DataModelUtils.cpp | 4 ++-- examples/chef/common/stubs.cpp | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/chef/common/DataModelUtils.cpp b/examples/chef/common/DataModelUtils.cpp index 3d0ecddf15d261..64956254789d31 100644 --- a/examples/chef/common/DataModelUtils.cpp +++ b/examples/chef/common/DataModelUtils.cpp @@ -50,10 +50,10 @@ CHIP_ERROR DataModelUtils::getAllEndpointsHavingDeviceType(DeviceTypeId devieTyp for (const auto & ep : allEndpoints) { bool isOfDeviceType; - ReturnErrorOnFailure(isEndpointOfDeviceType(ep, devieType, isOfDeviceType)); + ReturnErrorOnFailure(isEndpointOfDeviceType(ep.id, devieType, isOfDeviceType)); if (isOfDeviceType) { - ReturnErrorOnFailure(builder.Append(ep)); + ReturnErrorOnFailure(builder.Append(ep.id)); } } return CHIP_NO_ERROR; diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index 3c21d1685d0657..6f4c2143ae7bc0 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -39,7 +39,6 @@ using namespace chip::app::Clusters; #include "refrigerator-and-temperature-controlled-cabinet-mode/tcc-mode.h" #endif // MATTER_DM_PLUGIN_REFRIGERATOR_AND_TEMPERATURE_CONTROLLED_CABINET_MODE_SERVER -#ifdef MATTER_DM_PLUGIN_REFRIGERATOR_ALARM_SERVER namespace { // Please refer to https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces @@ -53,7 +52,6 @@ const Clusters::Descriptor::Structs::SemanticTagStruct::Type gRefrigeratorTagLis const Clusters::Descriptor::Structs::SemanticTagStruct::Type gFreezerTagList[] = { { .namespaceID = kNamespaceRefrigerator, .tag = kTagFreezer } }; } // namespace -#endif // MATTER_DM_PLUGIN_REFRIGERATOR_ALARM_SERVER #ifdef MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER #include "chef-rvc-operational-state-delegate.h" From bf2fde768488bb71bba133a933886d4d43df76ef Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Wed, 26 Mar 2025 23:01:34 -0700 Subject: [PATCH 03/46] + --- examples/chef/common/stubs.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index 6f4c2143ae7bc0..c7bd157d4036af 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -413,12 +413,15 @@ void OvenTemperatureControlledCabinetCooktopCookSurfaceInit() isTemperatureControlledCabinet) == CHIP_NO_ERROR) && isTemperatureControlledCabinet) { + ChipLogProgress(NotSpecified, "Temperature controlled cabinet device type on EP: %d", + kTemperatureControlledCabinetEpId); SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId); } if ((DataModelUtils::isEndpointOfDeviceType(kCooktopEpId, DataModelUtils::COOKTOP_DEVICE_ID, isCooktop) == CHIP_NO_ERROR) && isCooktop) { + ChipLogProgress(NotSpecified, "Cooktop device type on EP: %d", kCooktopEpId); SetParentEndpointForEndpoint(kCooktopEpId, kOvenEpId); } @@ -426,7 +429,8 @@ void OvenTemperatureControlledCabinetCooktopCookSurfaceInit() CHIP_NO_ERROR) && isCookSurface) { - SetParentEndpointForEndpoint(kCookSurfaceEpId, kOvenEpId); + ChipLogProgress(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); + SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); } } } @@ -436,6 +440,7 @@ void ApplicationInit() ChipLogProgress(NotSpecified, "Chef Application Init !!!"); RefrigeratorTemperatureControlledCabinetInit(); + OvenTemperatureControlledCabinetCooktopCookSurfaceInit(); #ifdef MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER ChipLogProgress(NotSpecified, "Initializing WindowCovering cluster delegate."); From 8a441e2eca46d393e41266801daa195e889e58bc Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 01:28:59 -0700 Subject: [PATCH 04/46] Fix: two elements should not have common bits in an enum used as bitmask --- src/app/util/af-types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/util/af-types.h b/src/app/util/af-types.h index 5da5aeb7f5b703..667b93f27849ba 100644 --- a/src/app/util/af-types.h +++ b/src/app/util/af-types.h @@ -195,7 +195,7 @@ enum class EmberAfEndpointOptions : uint8_t { isEnabled = 0x1, isFlatComposition = 0x2, - isTreeComposition = 0x3, + isTreeComposition = 0x4, }; /** From dc03344cab62affe1aa8d90bdfe49b42fae6b464 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 27 Mar 2025 08:34:15 +0000 Subject: [PATCH 05/46] Restyled by clang-format --- src/app/util/attribute-storage.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 7f6abeb08abfa5..ec58032e4e29bb 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -99,12 +99,18 @@ unsigned emberMetadataStructureGeneration = 0; // we need this data block for the defaults #if (defined(GENERATED_DEFAULTS) && GENERATED_DEFAULTS_COUNT) constexpr const uint8_t generatedDefaults[] = GENERATED_DEFAULTS; -#define ZAP_LONG_DEFAULTS_INDEX(index) { &generatedDefaults[index] } +#define ZAP_LONG_DEFAULTS_INDEX(index) \ + { \ + &generatedDefaults[index] \ + } #endif // GENERATED_DEFAULTS #if (defined(GENERATED_MIN_MAX_DEFAULTS) && GENERATED_MIN_MAX_DEFAULT_COUNT) constexpr const EmberAfAttributeMinMaxValue minMaxDefaults[] = GENERATED_MIN_MAX_DEFAULTS; -#define ZAP_MIN_MAX_DEFAULTS_INDEX(index) { &minMaxDefaults[index] } +#define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ + { \ + &minMaxDefaults[index] \ + } #endif // GENERATED_MIN_MAX_DEFAULTS #ifdef GENERATED_FUNCTION_ARRAYS From b2f7220e26b3bc4b35ded13172ad06942b2ba4f6 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 16:43:04 -0700 Subject: [PATCH 06/46] Refactoring --- examples/chef/common/DataModelUtils.cpp | 24 +++--- examples/chef/common/DataModelUtils.h | 21 +++-- examples/chef/common/stubs.cpp | 103 +++++++++++++++--------- src/app/util/attribute-storage.cpp | 29 ++++--- 4 files changed, 101 insertions(+), 76 deletions(-) diff --git a/examples/chef/common/DataModelUtils.cpp b/examples/chef/common/DataModelUtils.cpp index 64956254789d31..c429230e8f9678 100644 --- a/examples/chef/common/DataModelUtils.cpp +++ b/examples/chef/common/DataModelUtils.cpp @@ -21,40 +21,38 @@ #include #include +using namespace chef; using namespace chip::app; -CHIP_ERROR DataModelUtils::isEndpointOfDeviceType(EndpointId endpoint, DeviceTypeId deviceTypeId, bool & isOfDeviceType) +bool DataModelUtils::EndpointHasDeviceType(EndpointId endpoint, DeviceTypeId deviceTypeId) { - isOfDeviceType = false; DataModel::ListBuilder deviceTypesList; - ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->DeviceTypes(endpoint, deviceTypesList)); + InteractionModelEngine::GetInstance()->GetDataModelProvider()->DeviceTypes(endpoint, deviceTypesList); auto deviceTypes = deviceTypesList.TakeBuffer(); for (const auto & type : deviceTypes) { if (type.deviceTypeId == deviceTypeId) { - isOfDeviceType = true; - return CHIP_NO_ERROR; + return true; } } - return CHIP_NO_ERROR; + return false; } -CHIP_ERROR DataModelUtils::getAllEndpointsHavingDeviceType(DeviceTypeId devieType, DataModel::ListBuilder & builder) +DataModel::ListBuilder DataModelUtils::GetAllEndpointsHavingDeviceType(DeviceTypeId devieType) { - DataModel::ListBuilder endpointsList; ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->Endpoints(endpointsList)); auto allEndpoints = endpointsList.TakeBuffer(); + DataModel::ListBuilder endpoints; + for (const auto & ep : allEndpoints) { - bool isOfDeviceType; - ReturnErrorOnFailure(isEndpointOfDeviceType(ep.id, devieType, isOfDeviceType)); - if (isOfDeviceType) + if (EndpointHasDeviceType(ep.id, devieType)) { - ReturnErrorOnFailure(builder.Append(ep.id)); + endpoints.Append(ep.id); } } - return CHIP_NO_ERROR; + return endpoints; } diff --git a/examples/chef/common/DataModelUtils.h b/examples/chef/common/DataModelUtils.h index 306277ae0e38f8..89309dd5391df6 100644 --- a/examples/chef/common/DataModelUtils.h +++ b/examples/chef/common/DataModelUtils.h @@ -17,24 +17,21 @@ */ #include -#include #include -namespace chip { -namespace app { +namespace chef { namespace DataModelUtils { // Common location to store all device type IDs -constexpr DeviceTypeId COOK_SURFACE_DEVICE_ID = 0x0077; -constexpr DeviceTypeId COOKTOP_DEVICE_ID = 0x0078; -constexpr DeviceTypeId OVEN_DEVICE_ID = 0x007B; -constexpr DeviceTypeId REFRIGERATOR_DEVICE_ID = 0x0070; -constexpr DeviceTypeId TEMPERATURE_CONTROLLED_CABINET_DEVICE_ID = 0x0071; +constexpr DeviceTypeId kCookSurfaceDeviceId = 0x0077; +constexpr DeviceTypeId kCooktopDeviceId = 0x0078; +constexpr DeviceTypeId kOvenDeviceId = 0x007B; +constexpr DeviceTypeId kRefrigeratorDeviceId = 0x0070; +constexpr DeviceTypeId kTemperatureControlledCabinetDeviceId = 0x0071; // Datamodel Util APIs -CHIP_ERROR isEndpointOfDeviceType(EndpointId endpoint, DeviceTypeId deviceTypeId, bool & isOfDeviceType); -CHIP_ERROR getAllEndpointsHavingDeviceType(DeviceTypeId devieType, DataModel::ListBuilder & builder); +bool EndpointHasDeviceType(EndpointId endpoint, DeviceTypeId deviceTypeId); +DataModel::ListBuilder GetAllEndpointsHavingDeviceType(DeviceTypeId devieType); } // namespace DataModelUtils -} // namespace app -} // namespace chip +} // namespace chef diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index c7bd157d4036af..e15bf73e60dc81 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -8,6 +8,7 @@ using chip::app::DataModel::Nullable; +using namespace chef; using namespace chip; using namespace chip::app; using namespace chip::app::Clusters; @@ -53,6 +54,17 @@ const Clusters::Descriptor::Structs::SemanticTagStruct::Type gFreezerTagList[] .tag = kTagFreezer } }; } // namespace +namespace PostionSemanticTag { + +constexpr const uint8_t kNamespace = 0x08; // Common Position Namespace +const Clusters::Descriptor::Structs::SemanticTagStruct::Type kLeft = { .namespaceID = kNamespace, .tag = 0x00 }; +const Clusters::Descriptor::Structs::SemanticTagStruct::Type kRight = { .namespaceID = kNamespace, .tag = 0x01 }; +const Clusters::Descriptor::Structs::SemanticTagStruct::Type kTop = { .namespaceID = kNamespace, .tag = 0x02 }; +const Clusters::Descriptor::Structs::SemanticTagStruct::Type kBottom = { .namespaceID = kNamespace, .tag = 0x03 }; +const Clusters::Descriptor::Structs::SemanticTagStruct::Type kMiddle = { .namespaceID = kNamespace, .tag = 0x04 }; + +} // namespace PostionSemanticTag + #ifdef MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER #include "chef-rvc-operational-state-delegate.h" #endif @@ -355,33 +367,24 @@ void RefrigeratorTemperatureControlledCabinetInit() EndpointId kRefEndpointId = 1; EndpointId kColdCabinetEndpointId = 2; EndpointId kFreezeCabinetEndpointId = 3; - bool isRefrigerator; - bool isColdCabinet; - bool isFreezeCabinet; - if ((DataModelUtils::isEndpointOfDeviceType(kRefEndpointId, DataModelUtils::REFRIGERATOR_DEVICE_ID, isRefrigerator) == - CHIP_NO_ERROR) && - isRefrigerator) + if (DataModelUtils::EndpointHasDeviceType(kRefEndpointId, DataModelUtils::kRefrigeratorDeviceId)) { - ChipLogProgress(NotSpecified, "Refrigerator device type on EP: %d", kRefEndpointId); + ChipLogDetail(NotSpecified, "Refrigerator device type on EP: %d", kRefEndpointId); SetTreeCompositionForEndpoint(kRefEndpointId); // Cold Cabinet - if ((DataModelUtils::isEndpointOfDeviceType(kColdCabinetEndpointId, - DataModelUtils::TEMPERATURE_CONTROLLED_CABINET_DEVICE_ID, - isColdCabinet) == CHIP_NO_ERROR) && - isColdCabinet) + if (DataModelUtils::EndpointHasDeviceType(kColdCabinetEndpointId, DataModelUtils::kTemperatureControlledCabinetDeviceId)) { + ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kColdCabinetEndpointId); SetParentEndpointForEndpoint(kColdCabinetEndpointId, kRefEndpointId); SetTagList(kColdCabinetEndpointId, Span(gRefrigeratorTagList)); } // Freeze Cabinet - if ((DataModelUtils::isEndpointOfDeviceType(kFreezeCabinetEndpointId, - DataModelUtils::TEMPERATURE_CONTROLLED_CABINET_DEVICE_ID, - isFreezeCabinet) == CHIP_NO_ERROR) && - isFreezeCabinet) + if (DataModelUtils::EndpointHasDeviceType(kFreezeCabinetEndpointId, DataModelUtils::kTemperatureControlledCabinetDeviceId)) { + ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kFreezeCabinetEndpointId); SetParentEndpointForEndpoint(kFreezeCabinetEndpointId, kRefEndpointId); SetTagList(kFreezeCabinetEndpointId, Span(gFreezerTagList)); @@ -398,39 +401,63 @@ void OvenTemperatureControlledCabinetCooktopCookSurfaceInit() EndpointId kOvenEpId = 1; EndpointId kTemperatureControlledCabinetEpId = 2; EndpointId kCooktopEpId = 3; - EndpointId kCookSurfaceEpId = 4; - bool isOven; - bool isTemperatureControlledCabinet; - bool isCooktop; - bool isCookSurface; - if ((DataModelUtils::isEndpointOfDeviceType(kOvenEpId, DataModelUtils::OVEN_DEVICE_ID, isOven) == CHIP_NO_ERROR) && isOven) + if (DataModelUtils::EndpointHasDeviceType(kOvenEpId, DataModelUtils::kOvenDeviceId)) { - ChipLogProgress(NotSpecified, "Oven device type on EP: %d", kOvenEpId); + ChipLogDetail(NotSpecified, "Oven device type on EP: %d", kOvenEpId); SetTreeCompositionForEndpoint(kOvenEpId); - if ((DataModelUtils::isEndpointOfDeviceType(kTemperatureControlledCabinetEpId, - DataModelUtils::TEMPERATURE_CONTROLLED_CABINET_DEVICE_ID, - isTemperatureControlledCabinet) == CHIP_NO_ERROR) && - isTemperatureControlledCabinet) + if (DataModelUtils::EndpointHasDeviceType(kTemperatureControlledCabinetEpId, + DataModelUtils::kTemperatureControlledCabinetDeviceId)) { - ChipLogProgress(NotSpecified, "Temperature controlled cabinet device type on EP: %d", - kTemperatureControlledCabinetEpId); + ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kTemperatureControlledCabinetEpId); SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId); + SetTagList(kTemperatureControlledCabinetEpId, + Span({ PostionSemanticTag::kTop })); } + CooktopCookSurfaceInit(kCooktopEpId); + } +} - if ((DataModelUtils::isEndpointOfDeviceType(kCooktopEpId, DataModelUtils::COOKTOP_DEVICE_ID, isCooktop) == CHIP_NO_ERROR) && - isCooktop) +/** + * This initializer is for the application having cooktop. The cooktop can be a part of an oven + * or standalone cooktop. + * Standalone Cooktop: Cooktop on EP1 and optional CookSurface on EP2. + * Cooktop part of Oven: Oven on EP1, Cooktop on EP3 and optional CookSurface on EP4. + */ +void CooktopCookSurfaceInit(EndpointId kCooktopEpId) +{ + SetTreeCompositionForEndpoint(kCooktopEpId); + switch (kCooktopEpId) + { + case 1: // Standalone cooktop. + if (DataModelUtils::EndpointHasDeviceType(kCooktopEpId, DataModelUtils::kCooktopDeviceId)) { - ChipLogProgress(NotSpecified, "Cooktop device type on EP: %d", kCooktopEpId); - SetParentEndpointForEndpoint(kCooktopEpId, kOvenEpId); + ChipLogDetail(NotSpecified, "Cooktop device type on EP: %d", kCooktopEpId); + EndpointId kCookSurfaceEpId = 2; + if (DataModelUtils::EndpointHasDeviceType(kCookSurfaceEpId, DataModelUtils::kCookSurfaceDeviceId)) + { + ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); + SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); + SetTagList(kCookSurfaceEpId, + Span({ PostionSemanticTag::kLeft })); + } } - - if ((DataModelUtils::isEndpointOfDeviceType(kCookSurfaceEpId, DataModelUtils::COOK_SURFACE_DEVICE_ID, isCookSurface) == - CHIP_NO_ERROR) && - isCookSurface) + break; + case 3: // Cooktop part of oven. + EndpointId kOvenEpId = 1; + if (DataModelUtils::EndpointHasDeviceType(kCooktopEpId, DataModelUtils::kCooktopDeviceId) && + DataModelUtils::EndpointHasDeviceType(kOvenEpId, DataModelUtils::kOvenDeviceId)) { - ChipLogProgress(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); - SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); + ChipLogDetail(NotSpecified, "Cooktop device type on EP: %d", kCooktopEpId); + SetParentEndpointForEndpoint(kCooktopEpId, kOvenEpId); + EndpointId kCookSurfaceEpId = 4; + if (DataModelUtils::EndpointHasDeviceType(kCookSurfaceEpId, DataModelUtils::kCookSurfaceDeviceId)) + { + ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); + SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); + SetTagList(kCookSurfaceEpId, + Span({ PostionSemanticTag::kLeft })); + } } } } diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index ec58032e4e29bb..f49dd68983d7e9 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -173,6 +173,18 @@ uint16_t emberAfIndexFromEndpointIncludingDisabledEndpoints(EndpointId endpoint) return findIndexFromEndpoint(endpoint, false /* ignoreDisabledEndpoints */); } +constexpr const DeviceTypeId kRootnodeId = 0x0016; +constexpr const DeviceTypeId kAggregatorId = 0x000E; + +bool IsFullFamilyComposition(const EmberAfDeviceType & deviceType) +{ + if ((deviceType.deviceTypeId == kRootnodeId) || (deviceType.deviceTypeId == kAggregatorId)) + { + return true; + } + return false; +} + } // anonymous namespace // Initial configuration @@ -217,25 +229,16 @@ void emberAfEndpointConfigure() emAfEndpoints[ep].parentEndpointId = fixedParentEndpoints[ep]; emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isEnabled); - bool isFlatComposition = false; + EmberAfEndpointOptions defaultComposition = EmberAfEndpointOptions::isTreeComposition; for (const auto & deviceType : emAfEndpoints[ep].deviceTypeList) { - if ((deviceType.deviceTypeId == 0x0016) // Rootnode - || (deviceType.deviceTypeId == 0x000E) // Aggregator - ) + if (IsFullFamilyComposition(deviceType)) { - isFlatComposition = true; + defaultComposition = EmberAfEndpointOptions::isFlatComposition; break; } } - if (isFlatComposition) - { - emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isFlatComposition); - } - else - { - emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isTreeComposition); - } + emAfEndpoints[ep].bitmask.Set(defaultComposition); // Increment currentDataVersions by 1 (slot) for every server cluster // this endpoint has. From 4641c8a69a7bf223f8b9e5c39c9c0e6085dad1b1 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 16:49:46 -0700 Subject: [PATCH 07/46] compilation err --- examples/chef/common/DataModelUtils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/chef/common/DataModelUtils.h b/examples/chef/common/DataModelUtils.h index 89309dd5391df6..0109e36107092a 100644 --- a/examples/chef/common/DataModelUtils.h +++ b/examples/chef/common/DataModelUtils.h @@ -17,6 +17,7 @@ */ #include +#include #include namespace chef { From e2dd9f466dbe964bc62f14e2a6348af66c9cbfe8 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 16:54:41 -0700 Subject: [PATCH 08/46] compilation err --- examples/chef/common/DataModelUtils.cpp | 1 + examples/chef/common/DataModelUtils.h | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/chef/common/DataModelUtils.cpp b/examples/chef/common/DataModelUtils.cpp index c429230e8f9678..16f912aad6894d 100644 --- a/examples/chef/common/DataModelUtils.cpp +++ b/examples/chef/common/DataModelUtils.cpp @@ -22,6 +22,7 @@ #include using namespace chef; +using namespace chip; using namespace chip::app; bool DataModelUtils::EndpointHasDeviceType(EndpointId endpoint, DeviceTypeId deviceTypeId) diff --git a/examples/chef/common/DataModelUtils.h b/examples/chef/common/DataModelUtils.h index 0109e36107092a..62deb5b94855e9 100644 --- a/examples/chef/common/DataModelUtils.h +++ b/examples/chef/common/DataModelUtils.h @@ -24,15 +24,15 @@ namespace chef { namespace DataModelUtils { // Common location to store all device type IDs -constexpr DeviceTypeId kCookSurfaceDeviceId = 0x0077; -constexpr DeviceTypeId kCooktopDeviceId = 0x0078; -constexpr DeviceTypeId kOvenDeviceId = 0x007B; -constexpr DeviceTypeId kRefrigeratorDeviceId = 0x0070; -constexpr DeviceTypeId kTemperatureControlledCabinetDeviceId = 0x0071; +constexpr chip::DeviceTypeId kCookSurfaceDeviceId = 0x0077; +constexpr chip::DeviceTypeId kCooktopDeviceId = 0x0078; +constexpr chip::DeviceTypeId kOvenDeviceId = 0x007B; +constexpr chip::DeviceTypeId kRefrigeratorDeviceId = 0x0070; +constexpr chip::DeviceTypeId kTemperatureControlledCabinetDeviceId = 0x0071; // Datamodel Util APIs -bool EndpointHasDeviceType(EndpointId endpoint, DeviceTypeId deviceTypeId); -DataModel::ListBuilder GetAllEndpointsHavingDeviceType(DeviceTypeId devieType); +bool EndpointHasDeviceType(chip::EndpointId endpoint, chip::DeviceTypeId deviceTypeId); +chip::app::DataModel::ListBuilder GetAllEndpointsHavingDeviceType(chip::DeviceTypeId devieType); } // namespace DataModelUtils } // namespace chef From d8cf98a9c81905a3ed202ae00d7cf75fc1361d59 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 16:54:56 -0700 Subject: [PATCH 09/46] compilation err --- examples/chef/common/DataModelUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/chef/common/DataModelUtils.cpp b/examples/chef/common/DataModelUtils.cpp index 16f912aad6894d..316f5479e1afd4 100644 --- a/examples/chef/common/DataModelUtils.cpp +++ b/examples/chef/common/DataModelUtils.cpp @@ -43,7 +43,7 @@ bool DataModelUtils::EndpointHasDeviceType(EndpointId endpoint, DeviceTypeId dev DataModel::ListBuilder DataModelUtils::GetAllEndpointsHavingDeviceType(DeviceTypeId devieType) { DataModel::ListBuilder endpointsList; - ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetDataModelProvider()->Endpoints(endpointsList)); + InteractionModelEngine::GetInstance()->GetDataModelProvider()->Endpoints(endpointsList); auto allEndpoints = endpointsList.TakeBuffer(); DataModel::ListBuilder endpoints; From 7252e814203e2462ef2f3f04ec58526ae8a54c06 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 17:01:56 -0700 Subject: [PATCH 10/46] compilation err --- examples/chef/common/stubs.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index e15bf73e60dc81..bbd96efbe2a7b9 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -411,8 +411,9 @@ void OvenTemperatureControlledCabinetCooktopCookSurfaceInit() { ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kTemperatureControlledCabinetEpId); SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId); + Clusters::Descriptor::Structs::SemanticTagStruct::Type cabinetPosition[] = { PostionSemanticTag::kTop }; SetTagList(kTemperatureControlledCabinetEpId, - Span({ PostionSemanticTag::kTop })); + Span(cabinetPosition)); } CooktopCookSurfaceInit(kCooktopEpId); } @@ -438,8 +439,9 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) { ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); + Clusters::Descriptor::Structs::SemanticTagStruct::Type cookSurfacePosition[] = { PostionSemanticTag::kLeft }; SetTagList(kCookSurfaceEpId, - Span({ PostionSemanticTag::kLeft })); + Span(cookSurfacePosition)); } } break; @@ -455,8 +457,9 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) { ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); + Clusters::Descriptor::Structs::SemanticTagStruct::Type cookSurfacePosition[] = { PostionSemanticTag::kLeft }; SetTagList(kCookSurfaceEpId, - Span({ PostionSemanticTag::kLeft })); + Span(cookSurfacePosition)); } } } From 5e13d4bc89ef9ec3804057cfbe9e14daee431250 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 17:06:22 -0700 Subject: [PATCH 11/46] compilation err --- examples/chef/common/stubs.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index bbd96efbe2a7b9..817ce6908a95fc 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -411,7 +411,7 @@ void OvenTemperatureControlledCabinetCooktopCookSurfaceInit() { ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kTemperatureControlledCabinetEpId); SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId); - Clusters::Descriptor::Structs::SemanticTagStruct::Type cabinetPosition[] = { PostionSemanticTag::kTop }; + const Clusters::Descriptor::Structs::SemanticTagStruct::Type cabinetPosition[] = { PostionSemanticTag::kTop }; SetTagList(kTemperatureControlledCabinetEpId, Span(cabinetPosition)); } @@ -439,7 +439,7 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) { ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); - Clusters::Descriptor::Structs::SemanticTagStruct::Type cookSurfacePosition[] = { PostionSemanticTag::kLeft }; + const Clusters::Descriptor::Structs::SemanticTagStruct::Type cookSurfacePosition[] = { PostionSemanticTag::kLeft }; SetTagList(kCookSurfaceEpId, Span(cookSurfacePosition)); } @@ -457,7 +457,7 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) { ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); - Clusters::Descriptor::Structs::SemanticTagStruct::Type cookSurfacePosition[] = { PostionSemanticTag::kLeft }; + const Clusters::Descriptor::Structs::SemanticTagStruct::Type cookSurfacePosition[] = { PostionSemanticTag::kLeft }; SetTagList(kCookSurfaceEpId, Span(cookSurfacePosition)); } From e528154136629693f1a7ff07a2888c0ddd0900f0 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 17:08:50 -0700 Subject: [PATCH 12/46] compilation err --- examples/chef/common/stubs.cpp | 54 +++++++++++++++++----------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index 817ce6908a95fc..1fdae771856230 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -392,33 +392,6 @@ void RefrigeratorTemperatureControlledCabinetInit() } } -/** - * This initializer is for the application having oven on EP1 and child endpoints - - * temperatureControlledCabinet on EP2, cooktop on EP3 and cooksurface on EP4. - */ -void OvenTemperatureControlledCabinetCooktopCookSurfaceInit() -{ - EndpointId kOvenEpId = 1; - EndpointId kTemperatureControlledCabinetEpId = 2; - EndpointId kCooktopEpId = 3; - if (DataModelUtils::EndpointHasDeviceType(kOvenEpId, DataModelUtils::kOvenDeviceId)) - { - ChipLogDetail(NotSpecified, "Oven device type on EP: %d", kOvenEpId); - SetTreeCompositionForEndpoint(kOvenEpId); - - if (DataModelUtils::EndpointHasDeviceType(kTemperatureControlledCabinetEpId, - DataModelUtils::kTemperatureControlledCabinetDeviceId)) - { - ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kTemperatureControlledCabinetEpId); - SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId); - const Clusters::Descriptor::Structs::SemanticTagStruct::Type cabinetPosition[] = { PostionSemanticTag::kTop }; - SetTagList(kTemperatureControlledCabinetEpId, - Span(cabinetPosition)); - } - CooktopCookSurfaceInit(kCooktopEpId); - } -} - /** * This initializer is for the application having cooktop. The cooktop can be a part of an oven * or standalone cooktop. @@ -465,6 +438,33 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) } } +/** + * This initializer is for the application having oven on EP1 and child endpoints - + * temperatureControlledCabinet on EP2, cooktop on EP3 and cooksurface on EP4. + */ +void OvenTemperatureControlledCabinetCooktopCookSurfaceInit() +{ + EndpointId kOvenEpId = 1; + EndpointId kTemperatureControlledCabinetEpId = 2; + EndpointId kCooktopEpId = 3; + if (DataModelUtils::EndpointHasDeviceType(kOvenEpId, DataModelUtils::kOvenDeviceId)) + { + ChipLogDetail(NotSpecified, "Oven device type on EP: %d", kOvenEpId); + SetTreeCompositionForEndpoint(kOvenEpId); + + if (DataModelUtils::EndpointHasDeviceType(kTemperatureControlledCabinetEpId, + DataModelUtils::kTemperatureControlledCabinetDeviceId)) + { + ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kTemperatureControlledCabinetEpId); + SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId); + const Clusters::Descriptor::Structs::SemanticTagStruct::Type cabinetPosition[] = { PostionSemanticTag::kTop }; + SetTagList(kTemperatureControlledCabinetEpId, + Span(cabinetPosition)); + } + CooktopCookSurfaceInit(kCooktopEpId); + } +} + void ApplicationInit() { ChipLogProgress(NotSpecified, "Chef Application Init !!!"); From 0a04f6c8ac23d565de2409cfe870b43960403278 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 19:38:39 -0700 Subject: [PATCH 13/46] compilation err --- .../static-supported-temperature-levels.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index 479cf8965251fb..5a5294ad8d9b7e 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -21,6 +21,7 @@ #ifdef MATTER_DM_PLUGIN_TEMPERATURE_CONTROL_SERVER #include "static-supported-temperature-levels.h" #include +#include #include using namespace chip; @@ -32,10 +33,8 @@ app::Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSup CharSpan AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions[] = { "Low"_span, "Medium"_span, "High"_span }; -const AppSupportedTemperatureLevelsDelegate::EndpointPair AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints - [MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT] = { EndpointPair( - 1 /* endpointId */, AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions, - MATTER_ARRAY_SIZE(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions)) }; +const AppSupportedTemperatureLevelsDelegate::EndpointPair + AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; uint8_t AppSupportedTemperatureLevelsDelegate::Size() { @@ -72,7 +71,12 @@ CHIP_ERROR AppSupportedTemperatureLevelsDelegate::Next(MutableCharSpan & item) } void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint) { - static_assert(MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT == 1, "This cluster is only enabled for endpoint 1"); + ChipLogDetail(DeviceLayer, "Initializing TemperatureControl cluster for Endpoint: %d", endpoint); + uint16_t epIndex = emberAfGetClusterServerEndpointIndex(endpoint, TemperatureControl::Id, + MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT); + supportedOptionsByEndpoints[epIndex] = + EndpointPair(endpoint /* endpointId */, AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions, + MATTER_ARRAY_SIZE(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions)); chip::app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate); } From 187407b87e1549d968cd76c39d12bb547cdc1e56 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 19:48:47 -0700 Subject: [PATCH 14/46] compilation err --- .../temperature-control/static-supported-temperature-levels.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index c39bb171c93c58..bfb77bbcf914af 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -34,6 +34,8 @@ class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsI CharSpan * mTemperatureLevels; uint8_t mSize; + EndpointPair() : mEndpointId(kInvalidEndpointId), mTemperatureLevels(NULL), mSize(0) {} + EndpointPair(EndpointId aEndpointId, CharSpan * TemperatureLevels, uint8_t size) : mEndpointId(aEndpointId), mTemperatureLevels(TemperatureLevels), mSize(size) {} From dd52e75e9acf02e745990dfb4fb76536f4f84032 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 19:54:15 -0700 Subject: [PATCH 15/46] compilation err --- .../temperature-control/static-supported-temperature-levels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index 5a5294ad8d9b7e..68feec0e33f367 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -74,7 +74,7 @@ void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint) ChipLogDetail(DeviceLayer, "Initializing TemperatureControl cluster for Endpoint: %d", endpoint); uint16_t epIndex = emberAfGetClusterServerEndpointIndex(endpoint, TemperatureControl::Id, MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT); - supportedOptionsByEndpoints[epIndex] = + AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints[epIndex] = EndpointPair(endpoint /* endpointId */, AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions, MATTER_ARRAY_SIZE(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions)); From a1a87561af97488d44bb0048726e6e091cceae10 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 20:20:57 -0700 Subject: [PATCH 16/46] compilation err --- .../static-supported-temperature-levels.cpp | 8 +++----- .../static-supported-temperature-levels.h | 9 ++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index 68feec0e33f367..0adea3b9d17501 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -33,9 +33,6 @@ app::Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSup CharSpan AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions[] = { "Low"_span, "Medium"_span, "High"_span }; -const AppSupportedTemperatureLevelsDelegate::EndpointPair - AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; - uint8_t AppSupportedTemperatureLevelsDelegate::Size() { for (auto & endpointPair : AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints) @@ -74,9 +71,10 @@ void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint) ChipLogDetail(DeviceLayer, "Initializing TemperatureControl cluster for Endpoint: %d", endpoint); uint16_t epIndex = emberAfGetClusterServerEndpointIndex(endpoint, TemperatureControl::Id, MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT); - AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints[epIndex] = + sAppSupportedTemperatureLevelsDelegate->SetSupportedEndpointPair( + epIndex, EndpointPair(endpoint /* endpointId */, AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions, - MATTER_ARRAY_SIZE(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions)); + MATTER_ARRAY_SIZE(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions))); chip::app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate); } diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index bfb77bbcf914af..7f3f2ab6f1ab65 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -34,21 +34,24 @@ class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsI CharSpan * mTemperatureLevels; uint8_t mSize; - EndpointPair() : mEndpointId(kInvalidEndpointId), mTemperatureLevels(NULL), mSize(0) {} - EndpointPair(EndpointId aEndpointId, CharSpan * TemperatureLevels, uint8_t size) : mEndpointId(aEndpointId), mTemperatureLevels(TemperatureLevels), mSize(size) {} }; static CharSpan temperatureLevelOptions[3]; - static const EndpointPair supportedOptionsByEndpoints[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; + static EndpointPair supportedOptionsByEndpoints[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; public: uint8_t Size() override; CHIP_ERROR Next(MutableCharSpan & item) override; + void SetSupportedEndpointPair(uint16_t index, const EndpointPair & endpointPair) + { + supportedOptionsByEndpoints[index] = endpointPair; + } + ~AppSupportedTemperatureLevelsDelegate() {} }; From 487ce166853a105c006b57514eece27da79f2d8b Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 20:22:29 -0700 Subject: [PATCH 17/46] compilation err --- .../static-supported-temperature-levels.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index 7f3f2ab6f1ab65..8cf5e177a4955f 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -47,10 +47,7 @@ class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsI CHIP_ERROR Next(MutableCharSpan & item) override; - void SetSupportedEndpointPair(uint16_t index, const EndpointPair & endpointPair) - { - supportedOptionsByEndpoints[index] = endpointPair; - } + void SetSupportedEndpointPair(uint16_t index, EndpointPair endpointPair) { supportedOptionsByEndpoints[index] = endpointPair; } ~AppSupportedTemperatureLevelsDelegate() {} }; From 0e1d9052e6ae72c5026a9945d09dd132fd3e6f5f Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 20:36:50 -0700 Subject: [PATCH 18/46] compilation err --- .../static-supported-temperature-levels.cpp | 9 ++++++--- .../static-supported-temperature-levels.h | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index 0adea3b9d17501..932d4f8e416c89 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -31,7 +31,10 @@ using chip::Protocols::InteractionModel::Status; app::Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSupportedTemperatureLevelsDelegate; -CharSpan AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions[] = { "Low"_span, "Medium"_span, "High"_span }; +namespace ChefTemperatureControl { +// Define temperature level options used by chef app +static CharSpan temperatureLevelOptions[] = { "Low"_span, "Medium"_span, "High"_span }; +} // namespace ChefTemperatureControl uint8_t AppSupportedTemperatureLevelsDelegate::Size() { @@ -73,8 +76,8 @@ void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint) MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT); sAppSupportedTemperatureLevelsDelegate->SetSupportedEndpointPair( epIndex, - EndpointPair(endpoint /* endpointId */, AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions, - MATTER_ARRAY_SIZE(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions))); + EndpointPair(endpoint /* endpointId */, ChefTemperatureControl::temperatureLevelOptions, + MATTER_ARRAY_SIZE(ChefTemperatureControl::temperatureLevelOptions))); chip::app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate); } diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index 8cf5e177a4955f..b34b4ffa3735e0 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -39,7 +39,6 @@ class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsI {} }; - static CharSpan temperatureLevelOptions[3]; static EndpointPair supportedOptionsByEndpoints[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; public: From f0fb2b90ffc28166155589549eeadd5198ea8758 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 20:38:18 -0700 Subject: [PATCH 19/46] compilation err --- .../static-supported-temperature-levels.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index 932d4f8e416c89..6b30061e40a4ee 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -76,8 +76,9 @@ void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint) MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT); sAppSupportedTemperatureLevelsDelegate->SetSupportedEndpointPair( epIndex, - EndpointPair(endpoint /* endpointId */, ChefTemperatureControl::temperatureLevelOptions, - MATTER_ARRAY_SIZE(ChefTemperatureControl::temperatureLevelOptions))); + AppSupportedTemperatureLevelsDelegate::EndpointPair(endpoint /* endpointId */, + ChefTemperatureControl::temperatureLevelOptions, + MATTER_ARRAY_SIZE(ChefTemperatureControl::temperatureLevelOptions))); chip::app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate); } From d6a1a8ca6ce3da97ae601b8d4cf17ce30f3fbd54 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 20:54:14 -0700 Subject: [PATCH 20/46] compilation err --- .../static-supported-temperature-levels.cpp | 5 --- .../static-supported-temperature-levels.h | 33 +++++++++++-------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index 6b30061e40a4ee..bfc61f8330174f 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -31,11 +31,6 @@ using chip::Protocols::InteractionModel::Status; app::Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSupportedTemperatureLevelsDelegate; -namespace ChefTemperatureControl { -// Define temperature level options used by chef app -static CharSpan temperatureLevelOptions[] = { "Low"_span, "Medium"_span, "High"_span }; -} // namespace ChefTemperatureControl - uint8_t AppSupportedTemperatureLevelsDelegate::Size() { for (auto & endpointPair : AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index b34b4ffa3735e0..203a89e345bfb7 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -21,6 +21,20 @@ #include #include +namespace ChefTemperatureControl { +struct EndpointPair +{ + EndpointId mEndpointId; + CharSpan * mTemperatureLevels; + uint8_t mSize; + + EndpointPair(EndpointId aEndpointId, CharSpan * TemperatureLevels, uint8_t size) : + mEndpointId(aEndpointId), mTemperatureLevels(TemperatureLevels), mSize(size) + {} +}; +static const CharSpan temperatureLevelOptions[3] = { "Low"_span, "Medium"_span, "High"_span }; +} // namespace ChefTemperatureControl + namespace chip { namespace app { namespace Clusters { @@ -28,25 +42,18 @@ namespace TemperatureControl { class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsIteratorDelegate { - struct EndpointPair - { - EndpointId mEndpointId; - CharSpan * mTemperatureLevels; - uint8_t mSize; - - EndpointPair(EndpointId aEndpointId, CharSpan * TemperatureLevels, uint8_t size) : - mEndpointId(aEndpointId), mTemperatureLevels(TemperatureLevels), mSize(size) - {} - }; - - static EndpointPair supportedOptionsByEndpoints[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; + static ChefTemperatureControl::EndpointPair + supportedOptionsByEndpoints[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; public: uint8_t Size() override; CHIP_ERROR Next(MutableCharSpan & item) override; - void SetSupportedEndpointPair(uint16_t index, EndpointPair endpointPair) { supportedOptionsByEndpoints[index] = endpointPair; } + void SetSupportedEndpointPair(uint16_t index, ChefTemperatureControl::EndpointPair endpointPair) + { + supportedOptionsByEndpoints[index] = endpointPair; + } ~AppSupportedTemperatureLevelsDelegate() {} }; From e0a688aa227f3def210ffc9c37a6b7d56e415364 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 20:58:36 -0700 Subject: [PATCH 21/46] compilation err --- .../static-supported-temperature-levels.cpp | 4 ++++ .../temperature-control/static-supported-temperature-levels.h | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index bfc61f8330174f..413aaa3cdff85a 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -31,6 +31,10 @@ using chip::Protocols::InteractionModel::Status; app::Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSupportedTemperatureLevelsDelegate; +namespace ChefTemperatureControl { +static const CharSpan temperatureLevelOptions[3] = { "Low"_span, "Medium"_span, "High"_span }; +} // namespace ChefTemperatureControl + uint8_t AppSupportedTemperatureLevelsDelegate::Size() { for (auto & endpointPair : AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index 203a89e345bfb7..eb263e0a9a6be6 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -32,7 +32,6 @@ struct EndpointPair mEndpointId(aEndpointId), mTemperatureLevels(TemperatureLevels), mSize(size) {} }; -static const CharSpan temperatureLevelOptions[3] = { "Low"_span, "Medium"_span, "High"_span }; } // namespace ChefTemperatureControl namespace chip { From a95ac8197c66caa02d73a055cf2ff3b0d9258534 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 21:00:46 -0700 Subject: [PATCH 22/46] compilation err --- .../static-supported-temperature-levels.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index eb263e0a9a6be6..c35a0226fc1902 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -24,11 +24,11 @@ namespace ChefTemperatureControl { struct EndpointPair { - EndpointId mEndpointId; - CharSpan * mTemperatureLevels; + chip::EndpointId mEndpointId; + chip::CharSpan * mTemperatureLevels; uint8_t mSize; - EndpointPair(EndpointId aEndpointId, CharSpan * TemperatureLevels, uint8_t size) : + EndpointPair(chip::EndpointId aEndpointId, chip::CharSpan * TemperatureLevels, uint8_t size) : mEndpointId(aEndpointId), mTemperatureLevels(TemperatureLevels), mSize(size) {} }; From 49fb24fcbede6e9db6d49f84c673d6fad32982ac Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 21:02:02 -0700 Subject: [PATCH 23/46] compilation err --- .../static-supported-temperature-levels.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index 413aaa3cdff85a..ac17b798a2599b 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -75,9 +75,8 @@ void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint) MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT); sAppSupportedTemperatureLevelsDelegate->SetSupportedEndpointPair( epIndex, - AppSupportedTemperatureLevelsDelegate::EndpointPair(endpoint /* endpointId */, - ChefTemperatureControl::temperatureLevelOptions, - MATTER_ARRAY_SIZE(ChefTemperatureControl::temperatureLevelOptions))); + ChefTemperatureControl::EndpointPair(endpoint /* endpointId */, ChefTemperatureControl::temperatureLevelOptions, + MATTER_ARRAY_SIZE(ChefTemperatureControl::temperatureLevelOptions))); chip::app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate); } From 81bfbf1f487b9962c54e2f578a9a34a18b7294b3 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 21:03:15 -0700 Subject: [PATCH 24/46] compilation err --- .../temperature-control/static-supported-temperature-levels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index ac17b798a2599b..ac4326cdccd23d 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -73,7 +73,7 @@ void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint) ChipLogDetail(DeviceLayer, "Initializing TemperatureControl cluster for Endpoint: %d", endpoint); uint16_t epIndex = emberAfGetClusterServerEndpointIndex(endpoint, TemperatureControl::Id, MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT); - sAppSupportedTemperatureLevelsDelegate->SetSupportedEndpointPair( + sAppSupportedTemperatureLevelsDelegate.SetSupportedEndpointPair( epIndex, ChefTemperatureControl::EndpointPair(endpoint /* endpointId */, ChefTemperatureControl::temperatureLevelOptions, MATTER_ARRAY_SIZE(ChefTemperatureControl::temperatureLevelOptions))); From af847e1184d21a32a693a20f44b57af40b2f8a54 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 21:05:22 -0700 Subject: [PATCH 25/46] compilation err --- .../temperature-control/static-supported-temperature-levels.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index c35a0226fc1902..578431f4bb2811 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -25,7 +25,7 @@ namespace ChefTemperatureControl { struct EndpointPair { chip::EndpointId mEndpointId; - chip::CharSpan * mTemperatureLevels; + const chip::CharSpan * mTemperatureLevels; uint8_t mSize; EndpointPair(chip::EndpointId aEndpointId, chip::CharSpan * TemperatureLevels, uint8_t size) : From 137cdb0f4eea023f8e4372c69e8b5710c890d46a Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 21:06:45 -0700 Subject: [PATCH 26/46] compilation err --- .../temperature-control/static-supported-temperature-levels.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index 578431f4bb2811..66f79cadb5884f 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -28,7 +28,7 @@ struct EndpointPair const chip::CharSpan * mTemperatureLevels; uint8_t mSize; - EndpointPair(chip::EndpointId aEndpointId, chip::CharSpan * TemperatureLevels, uint8_t size) : + EndpointPair(chip::EndpointId aEndpointId, const chip::CharSpan * TemperatureLevels, uint8_t size) : mEndpointId(aEndpointId), mTemperatureLevels(TemperatureLevels), mSize(size) {} }; From 50c084aee7977f1274bbbfb902c9592967fcef75 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 21:15:17 -0700 Subject: [PATCH 27/46] compilation err --- .../temperature-control/static-supported-temperature-levels.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index 66f79cadb5884f..3aec0d6ce9ddde 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -49,7 +49,7 @@ class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsI CHIP_ERROR Next(MutableCharSpan & item) override; - void SetSupportedEndpointPair(uint16_t index, ChefTemperatureControl::EndpointPair endpointPair) + static void SetSupportedEndpointPair(uint16_t index, ChefTemperatureControl::EndpointPair endpointPair) { supportedOptionsByEndpoints[index] = endpointPair; } From 48cfc55e925854d780e321f73c7d1e0af8568700 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 21:19:19 -0700 Subject: [PATCH 28/46] compilation err --- .../static-supported-temperature-levels.cpp | 3 +++ .../temperature-control/static-supported-temperature-levels.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index ac4326cdccd23d..5e94516380d904 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -35,6 +35,9 @@ namespace ChefTemperatureControl { static const CharSpan temperatureLevelOptions[3] = { "Low"_span, "Medium"_span, "High"_span }; } // namespace ChefTemperatureControl +ChefTemperatureControl::EndpointPair + AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; + uint8_t AppSupportedTemperatureLevelsDelegate::Size() { for (auto & endpointPair : AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index 3aec0d6ce9ddde..0758b3404ad42a 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -28,6 +28,8 @@ struct EndpointPair const chip::CharSpan * mTemperatureLevels; uint8_t mSize; + EndpointPair() : mEndpointId(chip::kInvalidEndpointId), mTemperatureLevels(NULL), mSize(0) {} + EndpointPair(chip::EndpointId aEndpointId, const chip::CharSpan * TemperatureLevels, uint8_t size) : mEndpointId(aEndpointId), mTemperatureLevels(TemperatureLevels), mSize(size) {} From 8426fb2dfdde5f2223bec442c41bf48f9ddbda43 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 21:42:46 -0700 Subject: [PATCH 29/46] compilation err --- examples/chef/telink/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/chef/telink/CMakeLists.txt b/examples/chef/telink/CMakeLists.txt index 364725c34383fc..40dc602107bab3 100755 --- a/examples/chef/telink/CMakeLists.txt +++ b/examples/chef/telink/CMakeLists.txt @@ -72,6 +72,7 @@ target_sources(app PRIVATE ${TELINK_COMMON}/zephyr_ext/zephyr_pwm_pool.c ${TELINK_COMMON}/zephyr_ext/zephyr_ws2812.c ${CHEF}/common/stubs.cpp + ${CHEF}/common/DataModelUtils.cpp ) message(STATUS ${CHEF}/devices/${SAMPLE_NAME}.zap) From 27faf556dbb9e8bc61104363c07465571fbc6ba8 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 27 Mar 2025 22:00:02 -0700 Subject: [PATCH 30/46] compilation err --- examples/chef/common/stubs.cpp | 2 +- examples/chef/telink/CMakeLists.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index 1fdae771856230..e2c7ffd09a1846 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -1,4 +1,4 @@ -#include +#include "DataModelUtils.h" #include #include #include diff --git a/examples/chef/telink/CMakeLists.txt b/examples/chef/telink/CMakeLists.txt index 40dc602107bab3..364725c34383fc 100755 --- a/examples/chef/telink/CMakeLists.txt +++ b/examples/chef/telink/CMakeLists.txt @@ -72,7 +72,6 @@ target_sources(app PRIVATE ${TELINK_COMMON}/zephyr_ext/zephyr_pwm_pool.c ${TELINK_COMMON}/zephyr_ext/zephyr_ws2812.c ${CHEF}/common/stubs.cpp - ${CHEF}/common/DataModelUtils.cpp ) message(STATUS ${CHEF}/devices/${SAMPLE_NAME}.zap) From fbed38a62abca96ce4b50597ec551fec9120a50b Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Fri, 28 Mar 2025 11:22:00 -0700 Subject: [PATCH 31/46] + --- examples/chef/common/DataModelUtils.cpp | 4 ++-- examples/chef/common/DataModelUtils.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/chef/common/DataModelUtils.cpp b/examples/chef/common/DataModelUtils.cpp index 316f5479e1afd4..ee734a7e5553c6 100644 --- a/examples/chef/common/DataModelUtils.cpp +++ b/examples/chef/common/DataModelUtils.cpp @@ -40,7 +40,7 @@ bool DataModelUtils::EndpointHasDeviceType(EndpointId endpoint, DeviceTypeId dev return false; } -DataModel::ListBuilder DataModelUtils::GetAllEndpointsHavingDeviceType(DeviceTypeId devieType) +DataModel::ListBuilder DataModelUtils::GetAllEndpointsHavingDeviceType(DeviceTypeId deviceTypeId) { DataModel::ListBuilder endpointsList; InteractionModelEngine::GetInstance()->GetDataModelProvider()->Endpoints(endpointsList); @@ -50,7 +50,7 @@ DataModel::ListBuilder DataModelUtils::GetAllEndpointsHavingDeviceTy for (const auto & ep : allEndpoints) { - if (EndpointHasDeviceType(ep.id, devieType)) + if (EndpointHasDeviceType(ep.id, deviceTypeId)) { endpoints.Append(ep.id); } diff --git a/examples/chef/common/DataModelUtils.h b/examples/chef/common/DataModelUtils.h index 62deb5b94855e9..00fa416c71ef54 100644 --- a/examples/chef/common/DataModelUtils.h +++ b/examples/chef/common/DataModelUtils.h @@ -32,7 +32,7 @@ constexpr chip::DeviceTypeId kTemperatureControlledCabinetDeviceId = 0x0071; // Datamodel Util APIs bool EndpointHasDeviceType(chip::EndpointId endpoint, chip::DeviceTypeId deviceTypeId); -chip::app::DataModel::ListBuilder GetAllEndpointsHavingDeviceType(chip::DeviceTypeId devieType); +chip::app::DataModel::ListBuilder GetAllEndpointsHavingDeviceType(chip::DeviceTypeId deviceTypeId); } // namespace DataModelUtils } // namespace chef From b6fbf5ed705b559a6dd9461270a209875080fd23 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Fri, 28 Mar 2025 13:02:15 -0700 Subject: [PATCH 32/46] Rename DataModelUtils to DeviceTypes --- .../{DataModelUtils.cpp => DeviceTypes.cpp} | 6 ++--- .../{DataModelUtils.h => DeviceTypes.h} | 6 ++--- examples/chef/common/stubs.cpp | 24 +++++++++---------- examples/chef/linux/BUILD.gn | 2 +- examples/chef/nrfconnect/CMakeLists.txt | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) rename examples/chef/common/{DataModelUtils.cpp => DeviceTypes.cpp} (88%) rename examples/chef/common/{DataModelUtils.h => DeviceTypes.h} (94%) diff --git a/examples/chef/common/DataModelUtils.cpp b/examples/chef/common/DeviceTypes.cpp similarity index 88% rename from examples/chef/common/DataModelUtils.cpp rename to examples/chef/common/DeviceTypes.cpp index ee734a7e5553c6..372ca2c2a6df91 100644 --- a/examples/chef/common/DataModelUtils.cpp +++ b/examples/chef/common/DeviceTypes.cpp @@ -16,7 +16,7 @@ * limitations under the License. */ -#include +#include "DeviceTypes.h" #include #include #include @@ -25,7 +25,7 @@ using namespace chef; using namespace chip; using namespace chip::app; -bool DataModelUtils::EndpointHasDeviceType(EndpointId endpoint, DeviceTypeId deviceTypeId) +bool DeviceTypes::EndpointHasDeviceType(EndpointId endpoint, DeviceTypeId deviceTypeId) { DataModel::ListBuilder deviceTypesList; InteractionModelEngine::GetInstance()->GetDataModelProvider()->DeviceTypes(endpoint, deviceTypesList); @@ -40,7 +40,7 @@ bool DataModelUtils::EndpointHasDeviceType(EndpointId endpoint, DeviceTypeId dev return false; } -DataModel::ListBuilder DataModelUtils::GetAllEndpointsHavingDeviceType(DeviceTypeId deviceTypeId) +DataModel::ListBuilder DeviceTypes::GetAllEndpointsHavingDeviceType(DeviceTypeId deviceTypeId) { DataModel::ListBuilder endpointsList; InteractionModelEngine::GetInstance()->GetDataModelProvider()->Endpoints(endpointsList); diff --git a/examples/chef/common/DataModelUtils.h b/examples/chef/common/DeviceTypes.h similarity index 94% rename from examples/chef/common/DataModelUtils.h rename to examples/chef/common/DeviceTypes.h index 00fa416c71ef54..cdef39b3593cb3 100644 --- a/examples/chef/common/DataModelUtils.h +++ b/examples/chef/common/DeviceTypes.h @@ -21,7 +21,7 @@ #include namespace chef { -namespace DataModelUtils { +namespace DeviceTypes { // Common location to store all device type IDs constexpr chip::DeviceTypeId kCookSurfaceDeviceId = 0x0077; @@ -30,9 +30,9 @@ constexpr chip::DeviceTypeId kOvenDeviceId = 0x007B; constexpr chip::DeviceTypeId kRefrigeratorDeviceId = 0x0070; constexpr chip::DeviceTypeId kTemperatureControlledCabinetDeviceId = 0x0071; -// Datamodel Util APIs +// Devicetype APIs bool EndpointHasDeviceType(chip::EndpointId endpoint, chip::DeviceTypeId deviceTypeId); chip::app::DataModel::ListBuilder GetAllEndpointsHavingDeviceType(chip::DeviceTypeId deviceTypeId); -} // namespace DataModelUtils +} // namespace DeviceTypes } // namespace chef diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index e2c7ffd09a1846..87ee5251594310 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -1,4 +1,4 @@ -#include "DataModelUtils.h" +#include "DeviceTypes.h" #include #include #include @@ -367,13 +367,13 @@ void RefrigeratorTemperatureControlledCabinetInit() EndpointId kRefEndpointId = 1; EndpointId kColdCabinetEndpointId = 2; EndpointId kFreezeCabinetEndpointId = 3; - if (DataModelUtils::EndpointHasDeviceType(kRefEndpointId, DataModelUtils::kRefrigeratorDeviceId)) + if (DeviceTypes::EndpointHasDeviceType(kRefEndpointId, DeviceTypes::kRefrigeratorDeviceId)) { ChipLogDetail(NotSpecified, "Refrigerator device type on EP: %d", kRefEndpointId); SetTreeCompositionForEndpoint(kRefEndpointId); // Cold Cabinet - if (DataModelUtils::EndpointHasDeviceType(kColdCabinetEndpointId, DataModelUtils::kTemperatureControlledCabinetDeviceId)) + if (DeviceTypes::EndpointHasDeviceType(kColdCabinetEndpointId, DeviceTypes::kTemperatureControlledCabinetDeviceId)) { ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kColdCabinetEndpointId); SetParentEndpointForEndpoint(kColdCabinetEndpointId, kRefEndpointId); @@ -382,7 +382,7 @@ void RefrigeratorTemperatureControlledCabinetInit() } // Freeze Cabinet - if (DataModelUtils::EndpointHasDeviceType(kFreezeCabinetEndpointId, DataModelUtils::kTemperatureControlledCabinetDeviceId)) + if (DeviceTypes::EndpointHasDeviceType(kFreezeCabinetEndpointId, DeviceTypes::kTemperatureControlledCabinetDeviceId)) { ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kFreezeCabinetEndpointId); SetParentEndpointForEndpoint(kFreezeCabinetEndpointId, kRefEndpointId); @@ -404,11 +404,11 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) switch (kCooktopEpId) { case 1: // Standalone cooktop. - if (DataModelUtils::EndpointHasDeviceType(kCooktopEpId, DataModelUtils::kCooktopDeviceId)) + if (DeviceTypes::EndpointHasDeviceType(kCooktopEpId, DeviceTypes::kCooktopDeviceId)) { ChipLogDetail(NotSpecified, "Cooktop device type on EP: %d", kCooktopEpId); EndpointId kCookSurfaceEpId = 2; - if (DataModelUtils::EndpointHasDeviceType(kCookSurfaceEpId, DataModelUtils::kCookSurfaceDeviceId)) + if (DeviceTypes::EndpointHasDeviceType(kCookSurfaceEpId, DeviceTypes::kCookSurfaceDeviceId)) { ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); @@ -420,13 +420,13 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) break; case 3: // Cooktop part of oven. EndpointId kOvenEpId = 1; - if (DataModelUtils::EndpointHasDeviceType(kCooktopEpId, DataModelUtils::kCooktopDeviceId) && - DataModelUtils::EndpointHasDeviceType(kOvenEpId, DataModelUtils::kOvenDeviceId)) + if (DeviceTypes::EndpointHasDeviceType(kCooktopEpId, DeviceTypes::kCooktopDeviceId) && + DeviceTypes::EndpointHasDeviceType(kOvenEpId, DeviceTypes::kOvenDeviceId)) { ChipLogDetail(NotSpecified, "Cooktop device type on EP: %d", kCooktopEpId); SetParentEndpointForEndpoint(kCooktopEpId, kOvenEpId); EndpointId kCookSurfaceEpId = 4; - if (DataModelUtils::EndpointHasDeviceType(kCookSurfaceEpId, DataModelUtils::kCookSurfaceDeviceId)) + if (DeviceTypes::EndpointHasDeviceType(kCookSurfaceEpId, DeviceTypes::kCookSurfaceDeviceId)) { ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); @@ -447,13 +447,13 @@ void OvenTemperatureControlledCabinetCooktopCookSurfaceInit() EndpointId kOvenEpId = 1; EndpointId kTemperatureControlledCabinetEpId = 2; EndpointId kCooktopEpId = 3; - if (DataModelUtils::EndpointHasDeviceType(kOvenEpId, DataModelUtils::kOvenDeviceId)) + if (DeviceTypes::EndpointHasDeviceType(kOvenEpId, DeviceTypes::kOvenDeviceId)) { ChipLogDetail(NotSpecified, "Oven device type on EP: %d", kOvenEpId); SetTreeCompositionForEndpoint(kOvenEpId); - if (DataModelUtils::EndpointHasDeviceType(kTemperatureControlledCabinetEpId, - DataModelUtils::kTemperatureControlledCabinetDeviceId)) + if (DeviceTypes::EndpointHasDeviceType(kTemperatureControlledCabinetEpId, + DeviceTypes::kTemperatureControlledCabinetDeviceId)) { ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kTemperatureControlledCabinetEpId); SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId); diff --git a/examples/chef/linux/BUILD.gn b/examples/chef/linux/BUILD.gn index d0ff3fe7497a03..3330ff8f7cd9f1 100644 --- a/examples/chef/linux/BUILD.gn +++ b/examples/chef/linux/BUILD.gn @@ -40,7 +40,7 @@ chip_data_model("chef-data-model") { executable("${sample_name}") { sources = [ - "${project_dir}/common/DataModelUtils.cpp", + "${project_dir}/common/DeviceTypes.cpp", "${project_dir}/common/chef-air-quality.cpp", "${project_dir}/common/chef-concentration-measurement.cpp", "${project_dir}/common/chef-dishwasher-alarm-delegate-impl.cpp", diff --git a/examples/chef/nrfconnect/CMakeLists.txt b/examples/chef/nrfconnect/CMakeLists.txt index fc8d58e9f468d1..72eebf484cf44b 100644 --- a/examples/chef/nrfconnect/CMakeLists.txt +++ b/examples/chef/nrfconnect/CMakeLists.txt @@ -78,7 +78,7 @@ if (CONFIG_CHIP_LIB_SHELL) endif() target_sources(app PRIVATE - ${CHEF}/common/DataModelUtils.cpp + ${CHEF}/common/DeviceTypes.cpp ${CHEF}/common/chef-air-quality.cpp ${CHEF}/common/chef-concentration-measurement.cpp ${CHEF}/common/chef-fan-control-manager.cpp From 9a688f7bb8e33891e399550fb5fd5eb4cd717482 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Fri, 28 Mar 2025 13:20:44 -0700 Subject: [PATCH 33/46] Document the new methods --- examples/chef/common/DeviceTypes.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/chef/common/DeviceTypes.h b/examples/chef/common/DeviceTypes.h index cdef39b3593cb3..4ce11fcbd95bc1 100644 --- a/examples/chef/common/DeviceTypes.h +++ b/examples/chef/common/DeviceTypes.h @@ -31,7 +31,17 @@ constexpr chip::DeviceTypeId kRefrigeratorDeviceId = 0x0070; constexpr chip::DeviceTypeId kTemperatureControlledCabinetDeviceId = 0x0071; // Devicetype APIs + +/** + * Returns true if the endpoint has the specified device type in its device types list. + * Device types list for the given endpoint is fetched using DataModelProvider. + */ bool EndpointHasDeviceType(chip::EndpointId endpoint, chip::DeviceTypeId deviceTypeId); + +/** + * Returns a list of all endpoints that have the specified device type in their respective device types list. + * Endpoints list is fetched using DataModelProvider. Device type match is checked using EndpointHasDeviceType. + */ chip::app::DataModel::ListBuilder GetAllEndpointsHavingDeviceType(chip::DeviceTypeId deviceTypeId); } // namespace DeviceTypes From a2089537b1416c95af3726da63f9a091b48a23c7 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Fri, 28 Mar 2025 14:11:37 -0700 Subject: [PATCH 34/46] Fix invalid memory. --- examples/chef/common/stubs.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index 87ee5251594310..a13812920300cc 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -63,6 +63,8 @@ const Clusters::Descriptor::Structs::SemanticTagStruct::Type kTop = { .namesp const Clusters::Descriptor::Structs::SemanticTagStruct::Type kBottom = { .namespaceID = kNamespace, .tag = 0x03 }; const Clusters::Descriptor::Structs::SemanticTagStruct::Type kMiddle = { .namespaceID = kNamespace, .tag = 0x04 }; +const Clusters::Descriptor::Structs::SemanticTagStruct::Type kTopTagList[] = { PostionSemanticTag::kTop }; +const Clusters::Descriptor::Structs::SemanticTagStruct::Type kLeftTagList[] = { PostionSemanticTag::kLeft }; } // namespace PostionSemanticTag #ifdef MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER @@ -412,9 +414,7 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) { ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); - const Clusters::Descriptor::Structs::SemanticTagStruct::Type cookSurfacePosition[] = { PostionSemanticTag::kLeft }; - SetTagList(kCookSurfaceEpId, - Span(cookSurfacePosition)); + SetTagList(kCookSurfaceEpId, PostionSemanticTag::kLeftTagList); } } break; @@ -430,9 +430,7 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) { ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); - const Clusters::Descriptor::Structs::SemanticTagStruct::Type cookSurfacePosition[] = { PostionSemanticTag::kLeft }; - SetTagList(kCookSurfaceEpId, - Span(cookSurfacePosition)); + SetTagList(kCookSurfaceEpId, PostionSemanticTag::kLeftTagList); } } } @@ -457,9 +455,7 @@ void OvenTemperatureControlledCabinetCooktopCookSurfaceInit() { ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kTemperatureControlledCabinetEpId); SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId); - const Clusters::Descriptor::Structs::SemanticTagStruct::Type cabinetPosition[] = { PostionSemanticTag::kTop }; - SetTagList(kTemperatureControlledCabinetEpId, - Span(cabinetPosition)); + SetTagList(kTemperatureControlledCabinetEpId, PostionSemanticTag::kTopTagList); } CooktopCookSurfaceInit(kCooktopEpId); } From fa062ed62d36e845d75d59963d46ee25e0ea24bf Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Fri, 28 Mar 2025 14:15:30 -0700 Subject: [PATCH 35/46] Fix compilation --- examples/chef/common/stubs.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index a13812920300cc..236fbbaadb5f2b 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -414,7 +414,8 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) { ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); - SetTagList(kCookSurfaceEpId, PostionSemanticTag::kLeftTagList); + SetTagList(kCookSurfaceEpId, + Span(PostionSemanticTag::kLeftTagList)); } } break; @@ -430,7 +431,8 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) { ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); SetParentEndpointForEndpoint(kCookSurfaceEpId, kCooktopEpId); - SetTagList(kCookSurfaceEpId, PostionSemanticTag::kLeftTagList); + SetTagList(kCookSurfaceEpId, + Span(PostionSemanticTag::kLeftTagList)); } } } @@ -455,7 +457,8 @@ void OvenTemperatureControlledCabinetCooktopCookSurfaceInit() { ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kTemperatureControlledCabinetEpId); SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId); - SetTagList(kTemperatureControlledCabinetEpId, PostionSemanticTag::kTopTagList); + SetTagList(kTemperatureControlledCabinetEpId, + Span(PostionSemanticTag::kTopTagList)); } CooktopCookSurfaceInit(kCooktopEpId); } From f954b82c9a01abb6e52e608b46d171c217c31d4e Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Fri, 28 Mar 2025 15:14:06 -0700 Subject: [PATCH 36/46] Comments for EndpointPair struct. New chef namespace for cluster configuration. --- .../static-supported-temperature-levels.cpp | 14 ++++++++--- .../static-supported-temperature-levels.h | 25 +++++++++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index 5e94516380d904..f506a8bbfa7783 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -31,9 +31,14 @@ using chip::Protocols::InteractionModel::Status; app::Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSupportedTemperatureLevelsDelegate; -namespace ChefTemperatureControl { +namespace chef { +namespace Configuration { +namespace TemperatureControl { + static const CharSpan temperatureLevelOptions[3] = { "Low"_span, "Medium"_span, "High"_span }; -} // namespace ChefTemperatureControl +} // namespace TemperatureControl +} // namespace Configuration +} // namespace chef ChefTemperatureControl::EndpointPair AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; @@ -78,8 +83,9 @@ void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint) MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT); sAppSupportedTemperatureLevelsDelegate.SetSupportedEndpointPair( epIndex, - ChefTemperatureControl::EndpointPair(endpoint /* endpointId */, ChefTemperatureControl::temperatureLevelOptions, - MATTER_ARRAY_SIZE(ChefTemperatureControl::temperatureLevelOptions))); + ChefTemperatureControl::EndpointPair(endpoint /* endpointId */, + chef::Configuration::TemperatureControl::temperatureLevelOptions, + MATTER_ARRAY_SIZE(chef::Configuration::TemperatureControl::temperatureLevelOptions))); chip::app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate); } diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index 0758b3404ad42a..980f13446b570c 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -21,11 +21,30 @@ #include #include -namespace ChefTemperatureControl { +namespace chef { +namespace Configuration { +namespace TemperatureControl { + +/** + * @brief Endpoint to temperature levels mapping. The endpoint must have a temperature control cluster. + * Represents a pair of endpoints and temperature levels supported by that endpoint. + */ struct EndpointPair { + /** + * @brief An endpoint having temperature control cluster. + */ chip::EndpointId mEndpointId; + + /** + * @brief Temperature levels supported by the temperature control cluster at this endpoint. + * This should point to a const char span array initialized statically. + */ const chip::CharSpan * mTemperatureLevels; + + /** + * @brief Size of the temperature levels array. + */ uint8_t mSize; EndpointPair() : mEndpointId(chip::kInvalidEndpointId), mTemperatureLevels(NULL), mSize(0) {} @@ -34,7 +53,9 @@ struct EndpointPair mEndpointId(aEndpointId), mTemperatureLevels(TemperatureLevels), mSize(size) {} }; -} // namespace ChefTemperatureControl +} // namespace TemperatureControl +} // namespace Configuration +} // namespace chef namespace chip { namespace app { From f731b94050d5f1e659eded5b7bc8c71e8e474fcc Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Fri, 28 Mar 2025 15:18:03 -0700 Subject: [PATCH 37/46] + --- .../static-supported-temperature-levels.cpp | 8 ++++---- .../static-supported-temperature-levels.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index f506a8bbfa7783..85a610f4aff523 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -40,7 +40,7 @@ static const CharSpan temperatureLevelOptions[3] = { "Low"_span, "Medium"_span, } // namespace Configuration } // namespace chef -ChefTemperatureControl::EndpointPair +chef::Configuration::TemperatureControl::EndpointPair AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; uint8_t AppSupportedTemperatureLevelsDelegate::Size() @@ -83,9 +83,9 @@ void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint) MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT); sAppSupportedTemperatureLevelsDelegate.SetSupportedEndpointPair( epIndex, - ChefTemperatureControl::EndpointPair(endpoint /* endpointId */, - chef::Configuration::TemperatureControl::temperatureLevelOptions, - MATTER_ARRAY_SIZE(chef::Configuration::TemperatureControl::temperatureLevelOptions))); + chef::Configuration::TemperatureControl::EndpointPair( + endpoint /* endpointId */, chef::Configuration::TemperatureControl::temperatureLevelOptions, + MATTER_ARRAY_SIZE(chef::Configuration::TemperatureControl::temperatureLevelOptions))); chip::app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate); } diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index 980f13446b570c..4407634b538fb3 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -64,7 +64,7 @@ namespace TemperatureControl { class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsIteratorDelegate { - static ChefTemperatureControl::EndpointPair + static chef::Configuration::TemperatureControl::EndpointPair supportedOptionsByEndpoints[MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; public: @@ -72,7 +72,7 @@ class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsI CHIP_ERROR Next(MutableCharSpan & item) override; - static void SetSupportedEndpointPair(uint16_t index, ChefTemperatureControl::EndpointPair endpointPair) + static void SetSupportedEndpointPair(uint16_t index, chef::Configuration::TemperatureControl::EndpointPair endpointPair) { supportedOptionsByEndpoints[index] = endpointPair; } From 2bb9099afe7e3eb6f6ffb2ef9b8844a9fc69f70b Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 3 Apr 2025 14:52:48 -0700 Subject: [PATCH 38/46] Do not silently ignore CHIP_ERROR return value --- examples/chef/common/DeviceTypes.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/chef/common/DeviceTypes.cpp b/examples/chef/common/DeviceTypes.cpp index 372ca2c2a6df91..2a1d8e17d660d6 100644 --- a/examples/chef/common/DeviceTypes.cpp +++ b/examples/chef/common/DeviceTypes.cpp @@ -28,7 +28,12 @@ using namespace chip::app; bool DeviceTypes::EndpointHasDeviceType(EndpointId endpoint, DeviceTypeId deviceTypeId) { DataModel::ListBuilder deviceTypesList; - InteractionModelEngine::GetInstance()->GetDataModelProvider()->DeviceTypes(endpoint, deviceTypesList); + CHIP_ERROR err = InteractionModelEngine::GetInstance()->GetDataModelProvider()->DeviceTypes(endpoint, deviceTypesList); + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "GetDataModelProvider DeviceTypes returned error: %" CHIP_ERROR_FORMAT, err.Format()); + return false; + } auto deviceTypes = deviceTypesList.TakeBuffer(); for (const auto & type : deviceTypes) { @@ -43,7 +48,12 @@ bool DeviceTypes::EndpointHasDeviceType(EndpointId endpoint, DeviceTypeId device DataModel::ListBuilder DeviceTypes::GetAllEndpointsHavingDeviceType(DeviceTypeId deviceTypeId) { DataModel::ListBuilder endpointsList; - InteractionModelEngine::GetInstance()->GetDataModelProvider()->Endpoints(endpointsList); + CHIP_ERROR err = InteractionModelEngine::GetInstance()->GetDataModelProvider()->Endpoints(endpointsList); + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "GetDataModelProvider Endpoints returned error: %" CHIP_ERROR_FORMAT, err.Format()); + return DataModel::ListBuilder(); + } auto allEndpoints = endpointsList.TakeBuffer(); DataModel::ListBuilder endpoints; From dcc6b0c5c683890091f74712ecbaf2684c2d6157 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 3 Apr 2025 15:25:51 -0700 Subject: [PATCH 39/46] Review suggestion --- examples/chef/common/DeviceTypes.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/chef/common/DeviceTypes.h b/examples/chef/common/DeviceTypes.h index 4ce11fcbd95bc1..8204eaa82a0b4b 100644 --- a/examples/chef/common/DeviceTypes.h +++ b/examples/chef/common/DeviceTypes.h @@ -24,6 +24,9 @@ namespace chef { namespace DeviceTypes { // Common location to store all device type IDs +// Official list is in the spec and a complete copy is in - +// https://github.com/project-chip/connectedhomeip/blob/master/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml +// TODO: Device type IDs must be code generated from matter-devices.xml constexpr chip::DeviceTypeId kCookSurfaceDeviceId = 0x0077; constexpr chip::DeviceTypeId kCooktopDeviceId = 0x0078; constexpr chip::DeviceTypeId kOvenDeviceId = 0x007B; From cdb5c3be36cca15cc028ab65b29190356608cc9e Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 3 Apr 2025 15:28:39 -0700 Subject: [PATCH 40/46] Review suggestion --- .../static-supported-temperature-levels.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index 4407634b538fb3..e709439609e830 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -31,20 +31,14 @@ namespace TemperatureControl { */ struct EndpointPair { - /** - * @brief An endpoint having temperature control cluster. - */ + /// An endpoint having temperature control cluster. chip::EndpointId mEndpointId; - /** - * @brief Temperature levels supported by the temperature control cluster at this endpoint. - * This should point to a const char span array initialized statically. - */ + /// Temperature levels supported by the temperature control cluster at this endpoint. + /// This should point to a const char span array initialized statically. const chip::CharSpan * mTemperatureLevels; - /** - * @brief Size of the temperature levels array. - */ + /// Size of the temperature levels array. uint8_t mSize; EndpointPair() : mEndpointId(chip::kInvalidEndpointId), mTemperatureLevels(NULL), mSize(0) {} From fd556ec578820e6dabc7414e5eaed18298290e86 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 3 Apr 2025 16:23:38 -0700 Subject: [PATCH 41/46] Use Enums for expected endpoint IDs --- examples/chef/common/DeviceTypes.h | 19 +++++++ examples/chef/common/stubs.cpp | 83 +++++++++++++++--------------- 2 files changed, 60 insertions(+), 42 deletions(-) diff --git a/examples/chef/common/DeviceTypes.h b/examples/chef/common/DeviceTypes.h index 8204eaa82a0b4b..67c9631375e87f 100644 --- a/examples/chef/common/DeviceTypes.h +++ b/examples/chef/common/DeviceTypes.h @@ -33,6 +33,25 @@ constexpr chip::DeviceTypeId kOvenDeviceId = 0x007B; constexpr chip::DeviceTypeId kRefrigeratorDeviceId = 0x0070; constexpr chip::DeviceTypeId kTemperatureControlledCabinetDeviceId = 0x0071; +// Expected endpoint IDs for different device types +enum class ExpectedEndpointId : chip::EndpointId +{ + // Oven + kOven = 1, + kTopCabinetPartOfOven = 2, + kCooktopPartOfOven = 3, + kCookSurfacePartOfCooktopOven = 4, + + // Cooktop + kCooktopStandAlone = 1, + kCookSurfacePartOfCooktop = 2, + + // Refrigerator + kRefrigerator = 1, + kColdCabinetPartOfRefrigerator = 2, + kFreezeCabinetPartOfRefrigerator = 3, +}; + // Devicetype APIs /** diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index 236fbbaadb5f2b..046c8bf71205c8 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -366,31 +366,29 @@ void emberAfWakeOnLanClusterInitCallback(EndpointId endpoint) */ void RefrigeratorTemperatureControlledCabinetInit() { - EndpointId kRefEndpointId = 1; - EndpointId kColdCabinetEndpointId = 2; - EndpointId kFreezeCabinetEndpointId = 3; - if (DeviceTypes::EndpointHasDeviceType(kRefEndpointId, DeviceTypes::kRefrigeratorDeviceId)) + EndpointId kRefEndpointId = DeviceTypes::ExpectedEndpointId::kRefrigerator; + EndpointId kColdCabinetEndpointId = DeviceTypes::ExpectedEndpointId::kColdCabinetPartOfRefrigerator; + EndpointId kFreezeCabinetEndpointId = DeviceTypes::ExpectedEndpointId::kFreezeCabinetPartOfRefrigerator; + if (!DeviceTypes::EndpointHasDeviceType(kRefEndpointId, DeviceTypes::kRefrigeratorDeviceId)) { - ChipLogDetail(NotSpecified, "Refrigerator device type on EP: %d", kRefEndpointId); - SetTreeCompositionForEndpoint(kRefEndpointId); + return; + } + ChipLogDetail(NotSpecified, "Refrigerator device type on EP: %d", kRefEndpointId); + SetTreeCompositionForEndpoint(kRefEndpointId); - // Cold Cabinet - if (DeviceTypes::EndpointHasDeviceType(kColdCabinetEndpointId, DeviceTypes::kTemperatureControlledCabinetDeviceId)) - { - ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kColdCabinetEndpointId); - SetParentEndpointForEndpoint(kColdCabinetEndpointId, kRefEndpointId); - SetTagList(kColdCabinetEndpointId, - Span(gRefrigeratorTagList)); - } + if (DeviceTypes::EndpointHasDeviceType(kColdCabinetEndpointId, DeviceTypes::kTemperatureControlledCabinetDeviceId)) + { + ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kColdCabinetEndpointId); + SetParentEndpointForEndpoint(kColdCabinetEndpointId, kRefEndpointId); + SetTagList(kColdCabinetEndpointId, + Span(gRefrigeratorTagList)); + } - // Freeze Cabinet - if (DeviceTypes::EndpointHasDeviceType(kFreezeCabinetEndpointId, DeviceTypes::kTemperatureControlledCabinetDeviceId)) - { - ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kFreezeCabinetEndpointId); - SetParentEndpointForEndpoint(kFreezeCabinetEndpointId, kRefEndpointId); - SetTagList(kFreezeCabinetEndpointId, - Span(gFreezerTagList)); - } + if (DeviceTypes::EndpointHasDeviceType(kFreezeCabinetEndpointId, DeviceTypes::kTemperatureControlledCabinetDeviceId)) + { + ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kFreezeCabinetEndpointId); + SetParentEndpointForEndpoint(kFreezeCabinetEndpointId, kRefEndpointId); + SetTagList(kFreezeCabinetEndpointId, Span(gFreezerTagList)); } } @@ -405,11 +403,11 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) SetTreeCompositionForEndpoint(kCooktopEpId); switch (kCooktopEpId) { - case 1: // Standalone cooktop. + case DeviceTypes::ExpectedEndpointId::kCooktopStandAlone: if (DeviceTypes::EndpointHasDeviceType(kCooktopEpId, DeviceTypes::kCooktopDeviceId)) { ChipLogDetail(NotSpecified, "Cooktop device type on EP: %d", kCooktopEpId); - EndpointId kCookSurfaceEpId = 2; + EndpointId kCookSurfaceEpId = DeviceTypes::ExpectedEndpointId::kCookSurfacePartOfCooktop; if (DeviceTypes::EndpointHasDeviceType(kCookSurfaceEpId, DeviceTypes::kCookSurfaceDeviceId)) { ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); @@ -419,14 +417,14 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) } } break; - case 3: // Cooktop part of oven. - EndpointId kOvenEpId = 1; + case DeviceTypes::ExpectedEndpointId::kCooktopPartOfOven: + EndpointId kOvenEpId = DeviceTypes::ExpectedEndpointId::kOven; if (DeviceTypes::EndpointHasDeviceType(kCooktopEpId, DeviceTypes::kCooktopDeviceId) && DeviceTypes::EndpointHasDeviceType(kOvenEpId, DeviceTypes::kOvenDeviceId)) { ChipLogDetail(NotSpecified, "Cooktop device type on EP: %d", kCooktopEpId); SetParentEndpointForEndpoint(kCooktopEpId, kOvenEpId); - EndpointId kCookSurfaceEpId = 4; + EndpointId kCookSurfaceEpId = DeviceTypes::ExpectedEndpointId::kCookSurfacePartOfCooktopOven; if (DeviceTypes::EndpointHasDeviceType(kCookSurfaceEpId, DeviceTypes::kCookSurfaceDeviceId)) { ChipLogDetail(NotSpecified, "Cook Surface device type on EP: %d", kCookSurfaceEpId); @@ -444,24 +442,25 @@ void CooktopCookSurfaceInit(EndpointId kCooktopEpId) */ void OvenTemperatureControlledCabinetCooktopCookSurfaceInit() { - EndpointId kOvenEpId = 1; - EndpointId kTemperatureControlledCabinetEpId = 2; - EndpointId kCooktopEpId = 3; - if (DeviceTypes::EndpointHasDeviceType(kOvenEpId, DeviceTypes::kOvenDeviceId)) + EndpointId kOvenEpId = DeviceTypes::ExpectedEndpointId::kOven; + EndpointId kTemperatureControlledCabinetEpId = DeviceTypes::ExpectedEndpointId::kTopCabinetPartOfOven; + EndpointId kCooktopEpId = DeviceTypes::ExpectedEndpointId::kCooktopPartOfOven; + if (!DeviceTypes::EndpointHasDeviceType(kOvenEpId, DeviceTypes::kOvenDeviceId)) { - ChipLogDetail(NotSpecified, "Oven device type on EP: %d", kOvenEpId); - SetTreeCompositionForEndpoint(kOvenEpId); + return; + } - if (DeviceTypes::EndpointHasDeviceType(kTemperatureControlledCabinetEpId, - DeviceTypes::kTemperatureControlledCabinetDeviceId)) - { - ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kTemperatureControlledCabinetEpId); - SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId); - SetTagList(kTemperatureControlledCabinetEpId, - Span(PostionSemanticTag::kTopTagList)); - } - CooktopCookSurfaceInit(kCooktopEpId); + ChipLogDetail(NotSpecified, "Oven device type on EP: %d", kOvenEpId); + SetTreeCompositionForEndpoint(kOvenEpId); + + if (DeviceTypes::EndpointHasDeviceType(kTemperatureControlledCabinetEpId, DeviceTypes::kTemperatureControlledCabinetDeviceId)) + { + ChipLogDetail(NotSpecified, "Temperature controlled cabinet device type on EP: %d", kTemperatureControlledCabinetEpId); + SetParentEndpointForEndpoint(kTemperatureControlledCabinetEpId, kOvenEpId); + SetTagList(kTemperatureControlledCabinetEpId, + Span(PostionSemanticTag::kTopTagList)); } + CooktopCookSurfaceInit(kCooktopEpId); } void ApplicationInit() From c348009e842026378ff54f83c5d845ad3044257f Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Thu, 3 Apr 2025 16:34:29 -0700 Subject: [PATCH 42/46] Avoid enums due to casting issue --- examples/chef/common/DeviceTypes.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/examples/chef/common/DeviceTypes.h b/examples/chef/common/DeviceTypes.h index 67c9631375e87f..cf827ac8d4acbd 100644 --- a/examples/chef/common/DeviceTypes.h +++ b/examples/chef/common/DeviceTypes.h @@ -34,23 +34,22 @@ constexpr chip::DeviceTypeId kRefrigeratorDeviceId = 0x0070; constexpr chip::DeviceTypeId kTemperatureControlledCabinetDeviceId = 0x0071; // Expected endpoint IDs for different device types -enum class ExpectedEndpointId : chip::EndpointId -{ - // Oven - kOven = 1, - kTopCabinetPartOfOven = 2, - kCooktopPartOfOven = 3, - kCookSurfacePartOfCooktopOven = 4, +namespace ExpectedEndpointId { +// Oven +constexpr chip::EndpointId kOven = 1; +constexpr chip::EndpointId kTopCabinetPartOfOven = 2; +constexpr chip::EndpointId kCooktopPartOfOven = 3; +constexpr chip::EndpointId kCookSurfacePartOfCooktopOven = 4; - // Cooktop - kCooktopStandAlone = 1, - kCookSurfacePartOfCooktop = 2, +// Cooktop +constexpr chip::EndpointId kCooktopStandAlone = 1; +constexpr chip::EndpointId kCookSurfacePartOfCooktop = 2; - // Refrigerator - kRefrigerator = 1, - kColdCabinetPartOfRefrigerator = 2, - kFreezeCabinetPartOfRefrigerator = 3, -}; +// Refrigerator +constexpr chip::EndpointId kRefrigerator = 1; +constexpr chip::EndpointId kColdCabinetPartOfRefrigerator = 2; +constexpr chip::EndpointId kFreezeCabinetPartOfRefrigerator = 3; +} // namespace ExpectedEndpointId // Devicetype APIs From 01b50ae426d81bff6525ec20393dc5044ea04469 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Fri, 4 Apr 2025 10:44:01 -0700 Subject: [PATCH 43/46] Use Span for temperature levels --- .../static-supported-temperature-levels.cpp | 7 +++---- .../static-supported-temperature-levels.h | 11 ++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index 85a610f4aff523..d49a541e3d2ef3 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -49,7 +49,7 @@ uint8_t AppSupportedTemperatureLevelsDelegate::Size() { if (endpointPair.mEndpointId == mEndpoint) { - return endpointPair.mSize; + return endpointPair.mTemperatureLevels.size(); } } return 0; @@ -61,7 +61,7 @@ CHIP_ERROR AppSupportedTemperatureLevelsDelegate::Next(MutableCharSpan & item) { if (endpointPair.mEndpointId == mEndpoint) { - if (endpointPair.mSize > mIndex) + if (endpointPair.mTemperatureLevels.size() > mIndex) { CHIP_ERROR err = CopyCharSpanToMutableCharSpan(endpointPair.mTemperatureLevels[mIndex], item); if (err != CHIP_NO_ERROR) @@ -84,8 +84,7 @@ void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint) sAppSupportedTemperatureLevelsDelegate.SetSupportedEndpointPair( epIndex, chef::Configuration::TemperatureControl::EndpointPair( - endpoint /* endpointId */, chef::Configuration::TemperatureControl::temperatureLevelOptions, - MATTER_ARRAY_SIZE(chef::Configuration::TemperatureControl::temperatureLevelOptions))); + endpoint /* endpointId */, Span(chef::Configuration::TemperatureControl::temperatureLevelOptions))); chip::app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate); } diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index e709439609e830..1d348ac257f718 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -36,15 +36,12 @@ struct EndpointPair /// Temperature levels supported by the temperature control cluster at this endpoint. /// This should point to a const char span array initialized statically. - const chip::CharSpan * mTemperatureLevels; + const chip::Span mTemperatureLevels; - /// Size of the temperature levels array. - uint8_t mSize; + EndpointPair() : mEndpointId(chip::kInvalidEndpointId), mTemperatureLevels() {} - EndpointPair() : mEndpointId(chip::kInvalidEndpointId), mTemperatureLevels(NULL), mSize(0) {} - - EndpointPair(chip::EndpointId aEndpointId, const chip::CharSpan * TemperatureLevels, uint8_t size) : - mEndpointId(aEndpointId), mTemperatureLevels(TemperatureLevels), mSize(size) + EndpointPair(chip::EndpointId aEndpointId, chip::Span TemperatureLevels) : + mEndpointId(aEndpointId), mTemperatureLevels(TemperatureLevels) {} }; } // namespace TemperatureControl From 3b8200d687b0a51e810ba9d80186654bd6898547 Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Fri, 4 Apr 2025 10:52:51 -0700 Subject: [PATCH 44/46] Use Span for temperature levels --- .../static-supported-temperature-levels.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index 1d348ac257f718..d560831dd4f3e6 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -63,9 +63,10 @@ class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsI CHIP_ERROR Next(MutableCharSpan & item) override; - static void SetSupportedEndpointPair(uint16_t index, chef::Configuration::TemperatureControl::EndpointPair endpointPair) + static void SetSupportedEndpointPair(uint16_t index, EndpointId aEndpointId, const Span TemperatureLevels) { - supportedOptionsByEndpoints[index] = endpointPair; + supportedOptionsByEndpoints[index].mEndpointId = aEndpointId; + supportedOptionsByEndpoints[index].mTemperatureLevels = TemperatureLevels; } ~AppSupportedTemperatureLevelsDelegate() {} From dd544d42906c1565bd24aebd2ab2a2c155dad3ac Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Fri, 4 Apr 2025 10:56:17 -0700 Subject: [PATCH 45/46] Fix compilation --- .../static-supported-temperature-levels.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h index d560831dd4f3e6..84c09a248ca228 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.h @@ -36,7 +36,7 @@ struct EndpointPair /// Temperature levels supported by the temperature control cluster at this endpoint. /// This should point to a const char span array initialized statically. - const chip::Span mTemperatureLevels; + chip::Span mTemperatureLevels; EndpointPair() : mEndpointId(chip::kInvalidEndpointId), mTemperatureLevels() {} @@ -63,10 +63,9 @@ class AppSupportedTemperatureLevelsDelegate : public SupportedTemperatureLevelsI CHIP_ERROR Next(MutableCharSpan & item) override; - static void SetSupportedEndpointPair(uint16_t index, EndpointId aEndpointId, const Span TemperatureLevels) + static void SetSupportedEndpointPair(uint16_t index, chef::Configuration::TemperatureControl::EndpointPair endpointPair) { - supportedOptionsByEndpoints[index].mEndpointId = aEndpointId; - supportedOptionsByEndpoints[index].mTemperatureLevels = TemperatureLevels; + supportedOptionsByEndpoints[index] = endpointPair; } ~AppSupportedTemperatureLevelsDelegate() {} From 69e71f07b4918a297a1d18e263fc6fd0f296a44e Mon Sep 17 00:00:00 2001 From: Shreyas Balakrishna Bhandare Date: Fri, 4 Apr 2025 13:21:50 -0700 Subject: [PATCH 46/46] nit: Rename constant. --- .../static-supported-temperature-levels.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index d49a541e3d2ef3..b09ae5192681fb 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -35,7 +35,7 @@ namespace chef { namespace Configuration { namespace TemperatureControl { -static const CharSpan temperatureLevelOptions[3] = { "Low"_span, "Medium"_span, "High"_span }; +static const CharSpan kTemperatureLevelOptions[3] = { "Low"_span, "Medium"_span, "High"_span }; } // namespace TemperatureControl } // namespace Configuration } // namespace chef @@ -84,7 +84,7 @@ void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint) sAppSupportedTemperatureLevelsDelegate.SetSupportedEndpointPair( epIndex, chef::Configuration::TemperatureControl::EndpointPair( - endpoint /* endpointId */, Span(chef::Configuration::TemperatureControl::temperatureLevelOptions))); + endpoint /* endpointId */, Span(chef::Configuration::TemperatureControl::kTemperatureLevelOptions))); chip::app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate); }