mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Merge branch 'feat/add-electrical_grid_conditions-cluster' into 'main'
Add electrical_grid_conditions cluster in esp_matter See merge request app-frameworks/esp-matter!1367
This commit is contained in:
@@ -5327,5 +5327,29 @@ attribute_t *create_maximum_metered_quantities(cluster_t *cluster, nullable<uint
|
||||
|
||||
} /* commodity_metering */
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
namespace attribute {
|
||||
attribute_t *create_local_generation_available(cluster_t *cluster, nullable<bool> value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ElectricalGridConditions::Attributes::LocalGenerationAvailable::Id,
|
||||
ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_bool(value));
|
||||
}
|
||||
|
||||
attribute_t *create_current_conditions(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ElectricalGridConditions::Attributes::CurrentConditions::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
|
||||
}
|
||||
|
||||
attribute_t *create_forecast_conditions(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ElectricalGridConditions::Attributes::ForecastConditions::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY, esp_matter_array(value, length, count));
|
||||
}
|
||||
|
||||
} /* attribute */
|
||||
|
||||
} /* electrical_grid_conditions */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -1376,5 +1376,14 @@ attribute_t *create_maximum_metered_quantities(cluster_t *cluster, nullable<uint
|
||||
} /* attribute */
|
||||
} /* commodity_metering */
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
namespace attribute {
|
||||
|
||||
attribute_t *create_local_generation_available(cluster_t *cluster, nullable<bool> value);
|
||||
attribute_t *create_current_conditions(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
|
||||
attribute_t *create_forecast_conditions(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
|
||||
} /* attribute */
|
||||
} /* electrical_grid_conditions */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -4490,5 +4490,40 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
|
||||
} /* commodity_metering */
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
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, ElectricalGridConditions::Id, flags);
|
||||
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ElectricalGridConditions::Id));
|
||||
if (flags & CLUSTER_FLAG_SERVER) {
|
||||
if (config && config->delegate != nullptr) {
|
||||
static const auto delegate_init_cb = ElectricalGridConditionsDelegateInitCB;
|
||||
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
|
||||
}
|
||||
static const auto plugin_server_init_cb = CALL_ONCE(MatterElectricalGridConditionsPluginServerInitCallback);
|
||||
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_local_generation_available(cluster, false);
|
||||
attribute::create_current_conditions(cluster, NULL, 0, 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;
|
||||
}
|
||||
|
||||
} /* electrical_grid_conditions */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -1062,5 +1062,14 @@ using config_t = common::config_t;
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
} /* commodity_metering */
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
typedef struct config {
|
||||
void *delegate;
|
||||
config() : delegate(nullptr) {}
|
||||
} config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
} /* electrical_grid_conditions */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include <app/clusters/push-av-stream-transport-server/push-av-stream-transport-cluster.h>
|
||||
#include <app/clusters/commodity-tariff-server/commodity-tariff-server.h>
|
||||
#include <app/clusters/commodity-price-server/commodity-price-server.h>
|
||||
#include <app/clusters/electrical-grid-conditions-server/electrical-grid-conditions-server.h>
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace chip::app::Clusters;
|
||||
@@ -606,6 +607,16 @@ void CommodityPriceDelegateInitCB(void *delegate, uint16_t endpoint_id)
|
||||
commodity_price_instance->Init();
|
||||
}
|
||||
|
||||
|
||||
void ElectricalGridConditionsDelegateInitCB(void *delegate, uint16_t endpoint_id)
|
||||
{
|
||||
VerifyOrReturn(delegate != nullptr);
|
||||
ElectricalGridConditions::Delegate *electrical_grid_conditions_delegate = static_cast<ElectricalGridConditions::Delegate*>(delegate);
|
||||
uint32_t feature_map = get_feature_map_value(endpoint_id, ElectricalGridConditions::Id);
|
||||
ElectricalGridConditions::Instance *electrical_grid_conditions_instance = new ElectricalGridConditions::Instance(endpoint_id, *electrical_grid_conditions_delegate, chip::BitMask<ElectricalGridConditions::Feature, uint32_t>(feature_map));
|
||||
electrical_grid_conditions_instance->Init();
|
||||
}
|
||||
|
||||
} // namespace delegate_cb
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
|
||||
@@ -61,6 +61,7 @@ void ClosureDimensionDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
void PushAvStreamTransportDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
void CommodityTariffDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
void CommodityPriceDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
void ElectricalGridConditionsDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
} // namespace delegate_cb
|
||||
|
||||
} // namespace cluster
|
||||
|
||||
@@ -892,5 +892,15 @@ event_t *create_price_change(cluster_t *cluster)
|
||||
} // namespace event
|
||||
} // namespace commodity_price
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
namespace event {
|
||||
event_t *create_current_conditions_changed(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::event::create(cluster, ElectricalGridConditions::Events::CurrentConditionsChanged::Id);
|
||||
}
|
||||
|
||||
} // namespace event
|
||||
} // namespace electrical_grid_conditions
|
||||
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
|
||||
@@ -285,5 +285,11 @@ event_t *create_price_change(cluster_t *cluster);
|
||||
} // namespace event
|
||||
} // namespace commodity_price
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
namespace event {
|
||||
event_t *create_current_conditions_changed(cluster_t *cluster);
|
||||
} // namespace event
|
||||
} // namespace electrical_grid_conditions
|
||||
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
|
||||
@@ -4801,5 +4801,28 @@ esp_err_t add(cluster_t *cluster)
|
||||
} /* feature */
|
||||
} /* commodity_price */
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
namespace feature {
|
||||
namespace forecasting {
|
||||
|
||||
uint32_t get_id()
|
||||
{
|
||||
return static_cast<uint32_t>(ElectricalGridConditions::Feature::kForecasting);
|
||||
}
|
||||
|
||||
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_forecast_conditions(cluster, NULL, 0, 0);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
} /* forecasting */
|
||||
|
||||
} /* feature */
|
||||
} /* electrical_grid_conditions */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -2115,5 +2115,17 @@ esp_err_t add(cluster_t *cluster);
|
||||
} /* feature */
|
||||
} /* commodity_price */
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
namespace feature {
|
||||
|
||||
namespace forecasting {
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
} /* forecasting */
|
||||
|
||||
} /* feature */
|
||||
} /* electrical_grid_conditions */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -410,6 +410,10 @@ constexpr uint16_t cluster_revision = 4;
|
||||
namespace commodity_metering {
|
||||
constexpr uint16_t cluster_revision = 1;
|
||||
} // namespace commodity_metering
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
constexpr uint16_t cluster_revision = 1;
|
||||
} // namespace electrical_grid_conditions
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
|
||||
|
||||
Reference in New Issue
Block a user