|
4 | 4 | #include <app/data-model/Nullable.h>
|
5 | 5 | #include <app/util/attribute-storage.h>
|
6 | 6 | #include <app/util/config.h>
|
| 7 | +#include <app/util/endpoint-config-api.h> |
7 | 8 | #include <lib/core/DataModelTypes.h>
|
8 | 9 |
|
9 | 10 | using chip::app::DataModel::Nullable;
|
@@ -46,6 +47,40 @@ using namespace chip::app::Clusters;
|
46 | 47 | #endif // MATTER_DM_PLUGIN_ON_OFF_SERVER
|
47 | 48 | #endif // MATTER_DM_PLUGIN_PUMP_CONFIGURATION_AND_CONTROL_SERVER
|
48 | 49 |
|
| 50 | +#if MATTER_DM_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT > 0 |
| 51 | +#include <app/clusters/identify-server/identify-server.h> |
| 52 | + |
| 53 | +namespace { |
| 54 | +// TODO: Move this to a standalone cluster cpp file. |
| 55 | + |
| 56 | +constexpr size_t kIdentifyTableSize = MATTER_DM_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT; |
| 57 | +static_assert(kIdentifyTableSize <= kEmberInvalidEndpointIndex, "Identify table size error"); |
| 58 | +std::unique_ptr<struct Identify> gIdentifyInstanceTable[kIdentifyTableSize]; |
| 59 | + |
| 60 | +void InitIdentifyCluster() |
| 61 | +{ |
| 62 | + const uint16_t endpointCount = emberAfEndpointCount(); |
| 63 | + |
| 64 | + for (uint16_t endpointIndex = 0; endpointIndex < endpointCount; endpointIndex++) |
| 65 | + { |
| 66 | + chip::EndpointId endpointId = emberAfEndpointFromIndex(endpointIndex); |
| 67 | + if (endpointId == kInvalidEndpointId) |
| 68 | + { |
| 69 | + continue; |
| 70 | + } |
| 71 | + |
| 72 | + // Check if endpoint has Identify cluster enabled |
| 73 | + uint16_t epIndex = emberAfGetClusterServerEndpointIndex(endpointId, chip::app::Clusters::Identify::Id, |
| 74 | + MATTER_DM_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT); |
| 75 | + if (epIndex >= kIdentifyTableSize) |
| 76 | + continue; |
| 77 | + |
| 78 | + gIdentifyInstanceTable[epIndex] = |
| 79 | + std::make_unique<struct Identify>(endpointId, nullptr, nullptr, chip::app::Clusters::Identify::IdentifyTypeEnum::kNone); |
| 80 | + } |
| 81 | +} |
| 82 | +} // namespace |
| 83 | +#endif // MATTER_DM_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT |
49 | 84 | namespace {
|
50 | 85 |
|
51 | 86 | // Please refer to https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces
|
@@ -541,6 +576,10 @@ void ApplicationInit()
|
541 | 576 | ChipLogProgress(NotSpecified, "Initializing MicrowaveOvenControl cluster.");
|
542 | 577 | InitChefMicrowaveOvenControlCluster();
|
543 | 578 | #endif // MATTER_DM_PLUGIN_MICROWAVE_OVEN_CONTROL_SERVER
|
| 579 | + |
| 580 | +#if MATTER_DM_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT > 0 |
| 581 | + InitIdentifyCluster(); |
| 582 | +#endif // MATTER_DM_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT |
544 | 583 | }
|
545 | 584 |
|
546 | 585 | void ApplicationShutdown()
|
|
0 commit comments