mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Merge branch 'feat/add-zone_management-cluster' into 'main'
Add zone_management cluster in esp_matter See merge request app-frameworks/esp-matter!1397
This commit is contained in:
@@ -5402,5 +5402,53 @@ attribute_t *create_soil_moisture_measured_value(cluster_t *cluster, nullable<ui
|
||||
|
||||
} /* soil_measurement */
|
||||
|
||||
namespace zone_management {
|
||||
namespace attribute {
|
||||
attribute_t *create_max_user_defined_zones(cluster_t *cluster, uint8_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ZoneManagement::Attributes::MaxUserDefinedZones::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY, esp_matter_uint8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_max_zones(cluster_t *cluster, uint8_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ZoneManagement::Attributes::MaxZones::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY, esp_matter_uint8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_zones(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ZoneManagement::Attributes::Zones::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_array(value, length, count));
|
||||
}
|
||||
|
||||
attribute_t *create_triggers(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ZoneManagement::Attributes::Triggers::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_array(value, length, count));
|
||||
}
|
||||
|
||||
attribute_t *create_sensitivity_max(cluster_t *cluster, uint8_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ZoneManagement::Attributes::SensitivityMax::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY, esp_matter_uint8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_sensitivity(cluster_t *cluster, uint8_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ZoneManagement::Attributes::Sensitivity::Id,
|
||||
ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_two_d_cartesian_max(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ZoneManagement::Attributes::TwoDCartesianMax::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY, esp_matter_array(value, length, count));
|
||||
}
|
||||
|
||||
} /* attribute */
|
||||
|
||||
} /* zone_management */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -1403,5 +1403,18 @@ attribute_t *create_soil_moisture_measured_value(cluster_t *cluster, nullable<ui
|
||||
} /* attribute */
|
||||
} /* soil_measurement */
|
||||
|
||||
namespace zone_management {
|
||||
namespace attribute {
|
||||
|
||||
attribute_t *create_max_user_defined_zones(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_max_zones(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_zones(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
|
||||
attribute_t *create_triggers(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
|
||||
attribute_t *create_sensitivity_max(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_sensitivity(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_two_d_cartesian_max(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
|
||||
} /* attribute */
|
||||
} /* zone_management */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -4552,5 +4552,48 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
|
||||
} /* soil_measurement */
|
||||
|
||||
namespace zone_management {
|
||||
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, ZoneManagement::Id, flags);
|
||||
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ZoneManagement::Id));
|
||||
if (flags & CLUSTER_FLAG_SERVER) {
|
||||
// TODO: Add a delegate initialization callback.
|
||||
// The current esp_matter initialization flow makes this hard to implement cleanly.
|
||||
|
||||
static const auto plugin_server_init_cb = CALL_ONCE(MatterZoneManagementPluginServerInitCallback);
|
||||
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);
|
||||
global::attribute::create_cluster_revision(cluster, 0);
|
||||
attribute::create_max_zones(cluster, 1);
|
||||
attribute::create_zones(cluster, NULL, 0, 0);
|
||||
attribute::create_triggers(cluster, NULL, 0, 0);
|
||||
attribute::create_sensitivity_max(cluster, 0);
|
||||
// if !per_zone_sensitivity, create sensitivity attribute
|
||||
attribute::create_sensitivity(cluster, 0);
|
||||
|
||||
command::create_or_update_trigger(cluster);
|
||||
command::create_remove_trigger(cluster);
|
||||
|
||||
/* Events */
|
||||
event::create_zone_triggered(cluster);
|
||||
event::create_zone_stopped(cluster);
|
||||
}
|
||||
|
||||
if (flags & CLUSTER_FLAG_CLIENT) {
|
||||
create_default_binding_cluster(endpoint);
|
||||
}
|
||||
return cluster;
|
||||
}
|
||||
|
||||
} /* zone_management */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -1061,5 +1061,11 @@ using config_t = common::config_t;
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
} /* soil_measurement */
|
||||
|
||||
namespace zone_management {
|
||||
using config_t = common::config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
} /* zone_management */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -3087,5 +3087,46 @@ command_t *create_get_detailed_forecast_response(cluster_t *cluster)
|
||||
} /* command */
|
||||
} /* commodity_price */
|
||||
|
||||
namespace zone_management {
|
||||
namespace command {
|
||||
command_t *create_two_d_cartesian_zone(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ZoneManagement::Commands::CreateTwoDCartesianZone::Id,
|
||||
COMMAND_FLAG_ACCEPTED, NULL);
|
||||
}
|
||||
|
||||
command_t *create_two_d_cartesian_zone_response(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ZoneManagement::Commands::CreateTwoDCartesianZoneResponse::Id,
|
||||
COMMAND_FLAG_GENERATED, NULL);
|
||||
}
|
||||
|
||||
command_t *create_update_two_d_cartesian_zone(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ZoneManagement::Commands::UpdateTwoDCartesianZone::Id,
|
||||
COMMAND_FLAG_ACCEPTED, NULL);
|
||||
}
|
||||
|
||||
command_t *create_remove_zone(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ZoneManagement::Commands::RemoveZone::Id,
|
||||
COMMAND_FLAG_ACCEPTED, NULL);
|
||||
}
|
||||
|
||||
command_t *create_or_update_trigger(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ZoneManagement::Commands::CreateOrUpdateTrigger::Id,
|
||||
COMMAND_FLAG_ACCEPTED, NULL);
|
||||
}
|
||||
|
||||
command_t *create_remove_trigger(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ZoneManagement::Commands::RemoveTrigger::Id,
|
||||
COMMAND_FLAG_ACCEPTED, NULL);
|
||||
}
|
||||
|
||||
} /* command */
|
||||
} /* zone_management */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -608,5 +608,16 @@ command_t *create_get_detailed_forecast_response(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* commodity_price */
|
||||
|
||||
namespace zone_management {
|
||||
namespace command {
|
||||
command_t *create_two_d_cartesian_zone(cluster_t *cluster);
|
||||
command_t *create_two_d_cartesian_zone_response(cluster_t *cluster);
|
||||
command_t *create_update_two_d_cartesian_zone(cluster_t *cluster);
|
||||
command_t *create_remove_zone(cluster_t *cluster);
|
||||
command_t *create_or_update_trigger(cluster_t *cluster);
|
||||
command_t *create_remove_trigger(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* zone_management */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -902,5 +902,20 @@ event_t *create_current_conditions_changed(cluster_t *cluster)
|
||||
} // namespace event
|
||||
} // namespace electrical_grid_conditions
|
||||
|
||||
namespace zone_management {
|
||||
namespace event {
|
||||
event_t *create_zone_triggered(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::event::create(cluster, ZoneManagement::Events::ZoneTriggered::Id);
|
||||
}
|
||||
|
||||
event_t *create_zone_stopped(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::event::create(cluster, ZoneManagement::Events::ZoneStopped::Id);
|
||||
}
|
||||
|
||||
} // namespace event
|
||||
} // namespace zone_management
|
||||
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
|
||||
@@ -290,5 +290,12 @@ event_t *create_current_conditions_changed(cluster_t *cluster);
|
||||
} // namespace event
|
||||
} // namespace electrical_grid_conditions
|
||||
|
||||
namespace zone_management {
|
||||
namespace event {
|
||||
event_t *create_zone_triggered(cluster_t *cluster);
|
||||
event_t *create_zone_stopped(cluster_t *cluster);
|
||||
} // namespace event
|
||||
} // namespace zone_management
|
||||
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
|
||||
@@ -4852,5 +4852,90 @@ esp_err_t add(cluster_t *cluster)
|
||||
} /* feature */
|
||||
} /* meter_identification */
|
||||
|
||||
namespace zone_management {
|
||||
namespace feature {
|
||||
namespace two_dimensional_cartesian_zone {
|
||||
|
||||
uint32_t get_id()
|
||||
{
|
||||
return static_cast<uint32_t>(ZoneManagement::Feature::kTwoDimensionalCartesianZone);
|
||||
}
|
||||
|
||||
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_two_d_cartesian_max(cluster, NULL, 0, 0);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
} /* two_dimensional_cartesian_zone */
|
||||
|
||||
namespace per_zone_sensitivity {
|
||||
|
||||
uint32_t get_id()
|
||||
{
|
||||
return static_cast<uint32_t>(ZoneManagement::Feature::kPerZoneSensitivity);
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
attribute_t *sensitivity = esp_matter::attribute::get(cluster, ZoneManagement::Attributes::Sensitivity::Id);
|
||||
if (sensitivity) {
|
||||
esp_matter::attribute::destroy(cluster, sensitivity);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
} /* per_zone_sensitivity */
|
||||
|
||||
namespace user_defined {
|
||||
|
||||
uint32_t get_id()
|
||||
{
|
||||
return static_cast<uint32_t>(ZoneManagement::Feature::kUserDefined);
|
||||
}
|
||||
|
||||
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_max_user_defined_zones(cluster, 0);
|
||||
// Commands
|
||||
command::create_remove_zone(cluster);
|
||||
if (get_feature_map_value(cluster) & feature::two_dimensional_cartesian_zone::get_id()) {
|
||||
command::create_two_d_cartesian_zone(cluster);
|
||||
command::create_two_d_cartesian_zone_response(cluster);
|
||||
command::create_update_two_d_cartesian_zone(cluster);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
} /* user_defined */
|
||||
|
||||
namespace focus_zones {
|
||||
|
||||
uint32_t get_id()
|
||||
{
|
||||
return static_cast<uint32_t>(ZoneManagement::Feature::kFocusZones);
|
||||
}
|
||||
|
||||
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());
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
} /* focus_zones */
|
||||
|
||||
} /* feature */
|
||||
} /* zone_management */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -2137,5 +2137,35 @@ esp_err_t add(cluster_t *cluster);
|
||||
} /* feature */
|
||||
} /* meter_identification */
|
||||
|
||||
namespace zone_management {
|
||||
namespace feature {
|
||||
|
||||
namespace two_dimensional_cartesian_zone {
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
} /* two_dimensional_cartesian_zone */
|
||||
|
||||
namespace per_zone_sensitivity {
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
} /* per_zone_sensitivity */
|
||||
|
||||
namespace user_defined {
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
} /* user_defined */
|
||||
|
||||
namespace focus_zones {
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
} /* focus_zones */
|
||||
|
||||
} /* feature */
|
||||
} /* zone_management */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
Reference in New Issue
Block a user