1818
1919#include < lib/support/CodeUtils.h>
2020
21+ #include < array>
22+
2123namespace chip ::app {
2224
25+ namespace {
26+
27+ // Distinct positional tags: sibling endpoints of the same device type under one tree root
28+ // must carry mutually-distinct TagList entries (checked by Descriptor 2.2).
29+ constexpr std::array<EndpointComposition::SemanticTag, 7 > kCabinetTags = { {
30+ { .mfgCode = DataModel::NullNullable, .namespaceID = CommonNamespace::kPositionId ,
31+ .tag = static_cast <uint8_t >(Clusters::Globals::PositionTag::kLeft ) },
32+ { .mfgCode = DataModel::NullNullable, .namespaceID = CommonNamespace::kPositionId ,
33+ .tag = static_cast <uint8_t >(Clusters::Globals::PositionTag::kRight ) },
34+ { .mfgCode = DataModel::NullNullable, .namespaceID = CommonNamespace::kPositionId ,
35+ .tag = static_cast <uint8_t >(Clusters::Globals::PositionTag::kTop ) },
36+ { .mfgCode = DataModel::NullNullable, .namespaceID = CommonNamespace::kPositionId ,
37+ .tag = static_cast <uint8_t >(Clusters::Globals::PositionTag::kBottom ) },
38+ { .mfgCode = DataModel::NullNullable, .namespaceID = CommonNamespace::kPositionId ,
39+ .tag = static_cast <uint8_t >(Clusters::Globals::PositionTag::kMiddle ) },
40+ { .mfgCode = DataModel::NullNullable, .namespaceID = CommonNamespace::kPositionId ,
41+ .tag = static_cast <uint8_t >(Clusters::Globals::PositionTag::kRow ) },
42+ { .mfgCode = DataModel::NullNullable, .namespaceID = CommonNamespace::kPositionId ,
43+ .tag = static_cast <uint8_t >(Clusters::Globals::PositionTag::kColumn ) },
44+ } };
45+
46+ } // namespace
47+
2348LoggingRefrigerator::LoggingRefrigerator (TimerDelegate & timerDelegate) : LoggingRefrigerator(timerDelegate, Config{}) {}
2449
2550LoggingRefrigerator::LoggingRefrigerator (TimerDelegate & timerDelegate, Config config)
@@ -28,6 +53,8 @@ LoggingRefrigerator::LoggingRefrigerator(TimerDelegate & timerDelegate, Config c
2853
2954 // The MA-refrigerator device type requires at least one cabinet endpoint.
3055 VerifyOrDie (config.cabinetCount >= 1 );
56+ // Cabinets beyond one need a distinct positional tag each (see kCabinetTags).
57+ VerifyOrDie (config.cabinetCount <= kCabinetTags .size ());
3158
3259 // Reserve up front: the parts capture the name pointers at construction, so the
3360 // name strings must not move afterwards.
@@ -43,9 +70,17 @@ LoggingRefrigerator::LoggingRefrigerator(TimerDelegate & timerDelegate, Config c
4370
4471CHIP_ERROR LoggingRefrigerator::RegisterParts (EndpointIdAllocator & allocator, CodeDrivenDataModelProvider & provider)
4572{
46- for (auto & cabinet : mCabinets )
73+ // A single cabinet needs no tag; multiple cabinets of the same device type under one
74+ // tree root each need a distinct one.
75+ const bool tagCabinets = mCabinets .size () > 1 ;
76+ for (size_t i = 0 ; i < mCabinets .size (); i++)
4777 {
48- ReturnErrorOnFailure (cabinet->Register (allocator, provider, EndpointComposition::WithParent (GetEndpointId ())));
78+ EndpointComposition composition = EndpointComposition::WithParent (GetEndpointId ());
79+ if (tagCabinets)
80+ {
81+ composition.tagList = Span (&kCabinetTags [i], 1 );
82+ }
83+ ReturnErrorOnFailure (mCabinets [i]->Register (allocator, provider, composition));
4984 }
5085 return CHIP_NO_ERROR ;
5186}
0 commit comments