Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/west_commands/cloud_definitions/rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"fields": [
{"name": "id", "type": "uint16_t"},
{"name": "len", "type": "int16_t"},
{"name": "data", "type": "uint8_t", "num": 0}
{"name": "data", "type": "uint8_t", "num": 0, "counted_by": "len"}
]
},
"rpc_struct_kv_store_crc": {
Expand Down Expand Up @@ -98,7 +98,7 @@
{"name": "rssi", "type": "int8_t", "description": "Received signal strength (dBm)"},
{"name": "bssid", "type": "uint8_t", "num": 6, "description": "Basic Service Set Identifier (MAC address)"},
{"name": "ssid_len", "type": "uint8_t", "description": "SSID length"},
{"name": "ssid", "type": "char", "num": 0, "description": "Service Set Identifier (Network Name)"}
{"name": "ssid", "type": "char", "num": 0, "counted_by": "ssid_len", "description": "Service Set Identifier (Network Name)"}
]
},
"rpc_struct_xyz_s16": {
Expand Down
18 changes: 17 additions & 1 deletion scripts/west_commands/templates/rpc_definitions.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,20 @@ class {{ name }}(enum.IntEnum):

{% endif %}
{% endfor -%}

class RPCDefinitionBase:
NAME: str
HELP: str
DESCRIPTION: str
COMMAND_ID: int

{% for command_id, info in commands.items() %}
{% if extensions == info.get('extension', False) %}

class {{ info['name'] }}:
class {{ info['name'] }}(RPCDefinitionBase):
"""{{ info['description'] }}"""

NAME = "{{ info['name'] }}"
HELP = "{{ info['description'] }}"
DESCRIPTION = "{{ info['description'] }}"
COMMAND_ID = {{ command_id }}
Expand Down Expand Up @@ -81,8 +89,16 @@ class {{ info['name'] }}:
{% endif %}
{% endfor -%}

id_type_mapping: dict[int, type[RPCDefinitionBase]] = {
{% for command_id, info in commands.items() %}
{% if extensions == info.get('extension', False) %}
{{ info['name'] | lower }}.COMMAND_ID: {{ info['name'] | lower }},
{% endif %}
{% endfor %}
}

__all__ = [
'id_type_mapping',
{% for name, info in structs.items() %}
{% if extensions == info.get('extension', False) %}
'{{ name }}',
Expand Down