mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-28 03:23:07 +00:00
42075d5c75
- data_model/legacy/: moved old data model to this folder - data_model/generated/: contain the automatically generated data model - tools/data_model_gen: contains the script to generate the data model
90 lines
3.0 KiB
Django/Jinja
90 lines
3.0 KiB
Django/Jinja
{% set features = cluster.get_features() %}
|
|
{% if features | length > 0 %}
|
|
namespace feature {
|
|
{% for feature in features %}
|
|
namespace {{ feature.func_name | lower }} {
|
|
uint32_t get_id()
|
|
{
|
|
return {{ feature.chip_name }}::Id;
|
|
}
|
|
|
|
{% set ext_attrs = feature.get_externally_managed_attributes() %}
|
|
{% set has_config = ext_attrs | length > 0 %}
|
|
esp_err_t add(cluster_t *cluster{% if has_config %}, config_t *config{% endif %})
|
|
{
|
|
VerifyOrReturnError(cluster, ESP_ERR_INVALID_ARG);
|
|
{% if has_config %}
|
|
VerifyOrReturnError(config, ESP_ERR_INVALID_ARG);
|
|
{% endif %}
|
|
{% if feature.get_conformance_condition() %}
|
|
{% if "feature" in feature.get_conformance_condition()|string %}
|
|
uint32_t feature_map = get_feature_map_value(cluster);
|
|
{% endif %}
|
|
VerifyOrReturnError({{ feature.get_conformance_condition() }}, ESP_ERR_INVALID_ARG);
|
|
{% endif %}
|
|
update_feature_map(cluster, get_id());
|
|
{# --- Attributes --- #}
|
|
{% set attrs = feature.get_attributes() %}
|
|
{% if attrs | length > 0 %}
|
|
{% filter indent(4, true) %}
|
|
{% include "common.attribute.cpp.jinja" %}
|
|
{% endfilter %}
|
|
{% endif %}
|
|
{# --- Commands --- #}
|
|
{% for command in feature.get_commands() %}
|
|
{% if command.has_special_config() %}
|
|
#if {{ command.get_special_config() }}
|
|
{% endif %}
|
|
command::create_{{ command.func_name }}(cluster);
|
|
{% if command.has_special_config() %}
|
|
#endif // {{ command.get_special_config() }}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{# --- Events --- #}
|
|
{% for event in feature.get_events() %}
|
|
{% if event.has_special_config() %}
|
|
#if {{ event.get_special_config() }}
|
|
{% endif %}
|
|
event::create_{{ event.func_name }}(cluster);
|
|
{% if event.has_special_config() %}
|
|
#endif // {{ event.get_special_config() }}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% set elements = cluster.get_destroyable_elements(feature.func_name) %}
|
|
{% set d_attrs = elements["attributes"] %}
|
|
{% if d_attrs | length > 0 %}
|
|
{% for d_attr in d_attrs %}
|
|
attribute_t *{{ d_attr.func_name }} =
|
|
esp_matter::attribute::get(cluster, attribute::{{ d_attr.chip_name }}::Id);
|
|
if ({{ d_attr.func_name }}) {
|
|
esp_matter::attribute::destroy(cluster, {{ d_attr.func_name }});
|
|
}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% set d_commands = elements["commands"] %}
|
|
{% if d_commands | length > 0 %}
|
|
{% for d_command in d_commands %}
|
|
command_t *{{ d_command.func_name }} = esp_matter::command::get(cluster, command::{{ d_command.chip_name }}::Id, {{ d_command.get_flag() }});
|
|
if ({{ d_command.func_name }}) {
|
|
esp_matter::command::destroy(cluster, {{ d_command.func_name }});
|
|
}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% set d_events = elements["events"] %}
|
|
{% if d_events | length > 0 %}
|
|
{% for d_event in d_events %}
|
|
event_t *{{ d_event.func_name }} = esp_matter::event::get(cluster, event::{{ d_event.chip_name }}::Id);
|
|
if ({{ d_event.func_name }}) {
|
|
esp_matter::event::destroy(cluster, {{ d_event.func_name }});
|
|
}
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
return ESP_OK;
|
|
}
|
|
} /* {{ feature.func_name | lower }} */
|
|
|
|
{% endfor %}
|
|
} /* feature */
|
|
|
|
{% endif %} |