diff --git a/components/esp_matter/data_model_provider/clusters/basic_information_integration.cpp b/components/esp_matter/data_model_provider/clusters/basic_information_integration.cpp index f3c71bbfc..a5528acef 100644 --- a/components/esp_matter/data_model_provider/clusters/basic_information_integration.cpp +++ b/components/esp_matter/data_model_provider/clusters/basic_information_integration.cpp @@ -12,23 +12,47 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include + #include #include -#include +#include using namespace chip; using namespace chip::app; using namespace chip::app::Clusters; +using namespace chip::app::Clusters::BasicInformation::Attributes; namespace { ServerClusterRegistration gRegistration(BasicInformationCluster::Instance()); + +bool IsAttrEnabled(uint32_t attrId) +{ + return esp_matter::attribute::get(kRootEndpointId, BasicInformation::Id, attrId); } +BasicInformationCluster::OptionalAttributesSet GetOptionalAttrsSet() +{ + BasicInformationCluster::OptionalAttributesSet attrsSet; + return attrsSet.Set(IsAttrEnabled(ManufacturingDate::Id)) + .Set(IsAttrEnabled(PartNumber::Id)) + .Set(IsAttrEnabled(ProductURL::Id)) + .Set(IsAttrEnabled(ProductLabel::Id)) + .Set(IsAttrEnabled(SerialNumber::Id)) + .Set(IsAttrEnabled(LocalConfigDisabled::Id)) + .Set(IsAttrEnabled(Reachable::Id)) + .Set(IsAttrEnabled(ProductAppearance::Id)) + .Set(IsAttrEnabled(UniqueID::Id)); +} +} // namespace + void ESPMatterBasicInformationClusterServerInitCallback(EndpointId endpoint) { // We implement the cluster as a singleton on the root endpoint. VerifyOrReturn(endpoint == kRootEndpointId); + BasicInformationCluster::Instance().OptionalAttributes() = GetOptionalAttrsSet(); CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(gRegistration); if (err != CHIP_NO_ERROR) { ChipLogError(AppServer, "Failed to register BasicInformation - Error %" CHIP_ERROR_FORMAT, err.Format());