components/esp_matter: add meter_identification cluster in esp_matter

This commit is contained in:
mahesh
2025-11-28 17:55:19 +05:30
parent a192e42299
commit 170bdc7400
7 changed files with 124 additions and 0 deletions
@@ -5351,5 +5351,41 @@ attribute_t *create_forecast_conditions(cluster_t *cluster, uint8_t *value, uint
} /* electrical_grid_conditions */
namespace meter_identification {
namespace attribute {
attribute_t *create_meter_type(cluster_t *cluster, nullable<uint8_t> value)
{
return esp_matter::attribute::create(cluster, MeterIdentification::Attributes::MeterType::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_enum8(value));
}
attribute_t *create_point_of_delivery(cluster_t *cluster, char *value, uint16_t length)
{
return esp_matter::attribute::create(cluster, MeterIdentification::Attributes::PointOfDelivery::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_char_str(value, length));
}
attribute_t *create_meter_serial_number(cluster_t *cluster, char *value, uint16_t length)
{
return esp_matter::attribute::create(cluster, MeterIdentification::Attributes::MeterSerialNumber::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_char_str(value, length));
}
attribute_t *create_protocol_version(cluster_t *cluster, char *value, uint16_t length)
{
return esp_matter::attribute::create(cluster, MeterIdentification::Attributes::ProtocolVersion::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_char_str(value, length));
}
attribute_t *create_power_threshold(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, MeterIdentification::Attributes::PowerThreshold::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
} /* attribute */
} /* meter_identification */
} /* cluster */
} /* esp_matter */
@@ -1385,5 +1385,16 @@ attribute_t *create_forecast_conditions(cluster_t *cluster, uint8_t * value, uin
} /* attribute */
} /* electrical_grid_conditions */
namespace meter_identification {
namespace attribute {
attribute_t *create_meter_type(cluster_t *cluster, nullable<uint8_t> value);
attribute_t *create_point_of_delivery(cluster_t *cluster, char * value, uint16_t length);
attribute_t *create_meter_serial_number(cluster_t *cluster, char * value, uint16_t length);
attribute_t *create_protocol_version(cluster_t *cluster, char * value, uint16_t length);
attribute_t *create_power_threshold(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
} /* attribute */
} /* meter_identification */
} /* cluster */
} /* esp_matter */
@@ -4525,5 +4525,37 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
} /* electrical_grid_conditions */
namespace meter_identification {
const function_generic_t *function_list = NULL;
const int function_flags = CLUSTER_FLAG_NONE;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
{
cluster_t *cluster = esp_matter::cluster::create(endpoint, MeterIdentification::Id, flags);
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, MeterIdentification::Id));
if (flags & CLUSTER_FLAG_SERVER) {
static const auto plugin_server_init_cb = CALL_ONCE(MatterMeterIdentificationPluginServerInitCallback);
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
add_function_list(cluster, function_list, function_flags);
/* Attributes managed internally */
global::attribute::create_feature_map(cluster, 0);
attribute::create_meter_type(cluster, 0);
attribute::create_point_of_delivery(cluster, NULL, 0);
attribute::create_meter_serial_number(cluster, NULL, 0);
/* Attributes not managed internally */
global::attribute::create_cluster_revision(cluster, cluster_revision);
}
if (flags & CLUSTER_FLAG_CLIENT) {
create_default_binding_cluster(endpoint);
}
return cluster;
}
} /* meter_identification */
} /* cluster */
} /* esp_matter */
@@ -1071,5 +1071,11 @@ typedef struct config {
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
} /* electrical_grid_conditions */
namespace meter_identification {
using config_t = common::config_t;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
} /* meter_identification */
} /* cluster */
} /* esp_matter */
@@ -4824,5 +4824,28 @@ esp_err_t add(cluster_t *cluster)
} /* feature */
} /* electrical_grid_conditions */
namespace meter_identification {
namespace feature {
namespace power_threshold {
uint32_t get_id()
{
return static_cast<uint32_t>(MeterIdentification::Feature::kPowerThreshold);
}
esp_err_t add(cluster_t *cluster)
{
VerifyOrReturnError(cluster, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Cluster cannot be NULL"));
update_feature_map(cluster, get_id());
// Attributes
attribute::create_power_threshold(cluster, NULL, 0, 0);
return ESP_OK;
}
} /* power_threshold */
} /* feature */
} /* meter_identification */
} /* cluster */
} /* esp_matter */
@@ -2127,5 +2127,17 @@ esp_err_t add(cluster_t *cluster);
} /* feature */
} /* electrical_grid_conditions */
namespace meter_identification {
namespace feature {
namespace power_threshold {
uint32_t get_id();
esp_err_t add(cluster_t *cluster);
} /* power_threshold */
} /* feature */
} /* meter_identification */
} /* cluster */
} /* esp_matter */
@@ -414,6 +414,10 @@ constexpr uint16_t cluster_revision = 1;
namespace electrical_grid_conditions {
constexpr uint16_t cluster_revision = 1;
} // namespace electrical_grid_conditions
namespace meter_identification {
constexpr uint16_t cluster_revision = 1;
} // namespace meter_identification
} // namespace cluster
} // namespace esp_matter