Skip to content

Commit

Permalink
templates: ping-message-.h: Fix var length
Browse files Browse the repository at this point in the history
* Fix case in external ref to buffer constructor does not take in
  account variable payload sizes like profile length
  • Loading branch information
JoaoMario109 authored and patrickelectric committed Jan 23, 2025
1 parent 0aa6856 commit 03c0615
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/generate/templates/ping-message-.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,23 @@ class {{class_name}} : public ping_message
{
public:
{{class_name}}(const ping_message& msg) : ping_message { msg } {}
{{class_name}}(uint8_t* buf) : ping_message { buf, {{8 + total_payload + 2}} }
{{class_name}}(uint8_t* buf
{%- for payload in m.payload %}
{% if generator.is_vector(payload.type) %},
{% if payload.vector.sizetype -%}
{{generator.get_type_string(payload.vector.sizetype)}} {{payload.name}}_length
{% else -%}
uint16_t {{payload.name}}_length
{%- endif %}
{% endif %}
{% endfor %}{# each payload field #}
) : ping_message { buf, static_cast<uint16_t>({{8 + total_payload + 2}}
{%- for payload in m.payload %}
{% if generator.is_vector(payload.type) %}
+ {{payload.name}}_length
{%- endif %}
{% endfor %}) }{# each payload field #}

{
msgData[0] = 'B';
msgData[1] = 'R';
Expand Down

0 comments on commit 03c0615

Please sign in to comment.