|
12 | 12 | // See the License for the specific language governing permissions and |
13 | 13 | // limitations under the License. |
14 | 14 |
|
| 15 | +#include <esp_matter_data_model.h> |
| 16 | +#include <data_model_provider/esp_matter_data_model_provider.h> |
| 17 | + |
15 | 18 | #include <app/ClusterCallbacks.h> |
16 | 19 | #include <app/clusters/basic-information/BasicInformationCluster.h> |
17 | | -#include <data_model_provider/esp_matter_data_model_provider.h> |
| 20 | +#include <lib/core/DataModelTypes.h> |
18 | 21 |
|
19 | 22 | using namespace chip; |
20 | 23 | using namespace chip::app; |
21 | 24 | using namespace chip::app::Clusters; |
| 25 | +using namespace chip::app::Clusters::BasicInformation::Attributes; |
22 | 26 |
|
23 | 27 | namespace { |
24 | 28 | ServerClusterRegistration gRegistration(BasicInformationCluster::Instance()); |
| 29 | + |
| 30 | +bool IsAttrEnabled(uint32_t attrId) |
| 31 | +{ |
| 32 | + return esp_matter::attribute::get(kRootEndpointId, BasicInformation::Id, attrId); |
| 33 | +} |
| 34 | + |
| 35 | +BasicInformationCluster::OptionalAttributesSet GetOptionalAttrsSet() |
| 36 | +{ |
| 37 | + BasicInformationCluster::OptionalAttributesSet attrsSet; |
| 38 | + return attrsSet.Set<ManufacturingDate::Id>(IsAttrEnabled(ManufacturingDate::Id)) |
| 39 | + .Set<PartNumber::Id>(IsAttrEnabled(PartNumber::Id)) |
| 40 | + .Set<ProductURL::Id>(IsAttrEnabled(ProductURL::Id)) |
| 41 | + .Set<ProductLabel::Id>(IsAttrEnabled(ProductLabel::Id)) |
| 42 | + .Set<SerialNumber::Id>(IsAttrEnabled(SerialNumber::Id)) |
| 43 | + .Set<LocalConfigDisabled::Id>(IsAttrEnabled(LocalConfigDisabled::Id)) |
| 44 | + .Set<Reachable::Id>(IsAttrEnabled(Reachable::Id)) |
| 45 | + .Set<ProductAppearance::Id>(IsAttrEnabled(ProductAppearance::Id)) |
| 46 | + .Set<UniqueID::Id>(IsAttrEnabled(UniqueID::Id)); |
25 | 47 | } |
| 48 | +} // namespace |
26 | 49 |
|
27 | 50 | void ESPMatterBasicInformationClusterServerInitCallback(EndpointId endpoint) |
28 | 51 | { |
29 | 52 | // We implement the cluster as a singleton on the root endpoint. |
30 | 53 | VerifyOrReturn(endpoint == kRootEndpointId); |
31 | 54 |
|
| 55 | + BasicInformationCluster::Instance().OptionalAttributes() = GetOptionalAttrsSet(); |
32 | 56 | CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(gRegistration); |
33 | 57 | if (err != CHIP_NO_ERROR) { |
34 | 58 | ChipLogError(AppServer, "Failed to register BasicInformation - Error %" CHIP_ERROR_FORMAT, err.Format()); |
|
0 commit comments