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
54 lines
1.8 KiB
Django/Jinja
54 lines
1.8 KiB
Django/Jinja
{# --- Partition attributes into config-based vs default-based --- #}
|
|
{% set config_attrs = [] %}
|
|
{% set default_attrs = [] %}
|
|
{% for a in attrs %}
|
|
{% set is_config_attr = (
|
|
not a.is_internally_managed
|
|
and not (a.type in ["string", "octstr"] and a.get_default_value() in ["null","NULL"])
|
|
and not (a.type == "list")
|
|
) %}
|
|
{% if is_config_attr %}
|
|
{% do config_attrs.append(a) %}
|
|
{% else %}
|
|
{% do default_attrs.append(a) %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{# --- Config-dependent attributes --- #}
|
|
{% if config_attrs | length > 0 %}
|
|
{% for a in config_attrs %}
|
|
{% if a.has_special_config() %}
|
|
#if {{ a.get_special_config() }}
|
|
{% endif %}
|
|
{% if a.type in ["string", "octstr"] %}
|
|
attribute::create_{{ a.func_name }}(cluster, config->{{ a.func_name }}, sizeof(config->{{ a.func_name }}));
|
|
{% else %}
|
|
attribute::create_{{ a.func_name }}(cluster, config->{{ a.func_name }});
|
|
{% endif %}
|
|
{% if a.has_special_config() %}
|
|
#endif // {{ a.get_special_config() }}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{# --- Default attributes (no config) --- #}
|
|
{% for a in default_attrs %}
|
|
{% if a.has_special_config() %}
|
|
#if {{ a.get_special_config() }}
|
|
{% endif %}
|
|
{% if a.type == "list" %}
|
|
attribute::create_{{ a.func_name }}(cluster, NULL, 0, 0);
|
|
{% elif a.type in ["string", "octstr"] %}
|
|
{% if a.get_default_value() not in ["null","NULL"] %}
|
|
{% if a.is_internally_managed %}
|
|
attribute::create_{{ a.func_name }}(cluster, NULL, 0);
|
|
{% else %}
|
|
attribute::create_{{ a.func_name }}(cluster, "{{ a.get_default_value() }}", sizeof("{{ a.get_default_value() }}"));
|
|
{% endif %}
|
|
{% endif %}
|
|
{% else %}
|
|
attribute::create_{{ a.func_name }}(cluster, {{ a.get_default_value() }});
|
|
{% endif %}
|
|
{% if a.has_special_config() %}
|
|
#endif // {{ a.get_special_config() }}
|
|
{% endif %}
|
|
{% endfor %}
|