/*
* This file was automatically generated using Avlos.
* https://github.com/tinymovr/avlos
*
* Any changes to this file will be overwritten when
* content is regenerated.
*/

#include <{{ instance.name }}.hpp>

{%- if instance.remote_attributes %}
    {%- for attr in instance.remote_attributes.values() %}
        {%- if attr.remote_attributes %}
        {%- else %}
            {%- if attr.getter_name %}

{{attr.dtype.c_name}} {{ instance.name }}::get_{{attr.name}}(void)
{
    {{attr.dtype.c_name}} value = 0;
    this->send({{attr.ep_id}}, this->_data, 0, true);
    if (this->recv({{attr.ep_id}}, this->_data, &(this->_dlc), RECV_DELAY_US)) 
    {
        read_le(&value, this->_data);
    }
    return value;
}
            {%- endif %}
            {%- if attr.setter_name %}

void {{ instance.name }}::set_{{attr.name}}({{attr.dtype.c_name}} value)
{
    write_le(this->_data, value);
    this->send({{attr.ep_id}}, this->_data, sizeof({{attr.dtype.c_name}}), false);
}
            {%- endif %}
            {%- if attr.caller_name %}
                {%- set comma = joiner(", ") %}

{{attr.dtype.c_name}} {{ instance.name }}::{{attr.name}}({%- for arg in attr.arguments %}{{ comma() }}{{arg.dtype.c_name}} {{ arg.name }} {%- endfor %})
{
    {%- if attr.arguments|length == 0 %}
    this->send({{attr.ep_id}}, this->_data, 0, true);
    {%- else %}
    uint8_t data_len = 0;
        {%- for arg in attr.arguments %}
    write_le(this->_data + data_len, {{ arg.name }});
    data_len += sizeof({{ arg.name }});
        {%- endfor %}

    this->send({{attr.ep_id}}, this->_data, data_len, false);
    {%- endif %}
}
            {%- endif %}
        {%- endif %}
    {%- endfor %}
{%- endif %}


