pretty display for messages, send range request, etc
This commit is contained in:
parent
502e251b54
commit
7dc745c1f0
4 changed files with 44 additions and 8 deletions
|
@ -34,17 +34,31 @@
|
||||||
<td><a href="{% url "control.mesh.node.detail" pk=msg.src_node.address %}">{{ msg.src_node }}</a></td>
|
<td><a href="{% url "control.mesh.node.detail" pk=msg.src_node.address %}">{{ msg.src_node }}</a></td>
|
||||||
<td>{{ msg.get_message_type_display }}</td>
|
<td>{{ msg.get_message_type_display }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if msg.get_message_type_display == "CONFIG_HARDWARE" %}
|
|
||||||
<strong>Chip:</strong> {{ msg.parsed.get_chip_display }} rev{{ msg.parsed.revision_major }}.{{ msg.parsed.revision_minor }}
|
|
||||||
|
|
||||||
{% elif msg.get_message_type_display == "CONFIG_FIRMWARE" %}
|
{% if msg.message_type == "CONFIG_HARDWARE" %}
|
||||||
|
<strong>Chip:</strong> {{ msg.parsed.chip.pretty_name }} rev{{ msg.parsed.revision_major }}.{{ msg.parsed.revision_minor }}
|
||||||
|
|
||||||
|
{% elif msg.message_type == "CONFIG_BOARD" %}
|
||||||
|
<strong>Board:</strong> {{ msg.parsed.board_config.board.pretty_name }}
|
||||||
|
|
||||||
|
{% if msg.parsed.led %}
|
||||||
|
<br>
|
||||||
|
<strong>Status LED:</strong> {{ msg.parsed.led }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if msg.parsed.uwb %}
|
||||||
|
<br>
|
||||||
|
<strong>UWB:</strong> {{ msg.parsed.led }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% elif msg.message_type == "CONFIG_FIRMWARE" %}
|
||||||
<strong>Firmware:</strong> {{ msg.parsed.app_desc.project_name }} {{ msg.parsed.app_desc.version }} (IDF {{ msg.parsed.app_desc.idf_version }})
|
<strong>Firmware:</strong> {{ msg.parsed.app_desc.project_name }} {{ msg.parsed.app_desc.version }} (IDF {{ msg.parsed.app_desc.idf_version }})
|
||||||
<br>
|
<br>
|
||||||
<strong>Compile Date:</strong> {{ msg.parsed.app_desc.compile_date }} {{ msg.parsed.app_desc.compile_time }}
|
<strong>Compile Date:</strong> {{ msg.parsed.app_desc.compile_date }} {{ msg.parsed.app_desc.compile_time }}
|
||||||
<br>
|
<br>
|
||||||
<strong>SHA256:</strong> <small>{{ msg.parsed.app_desc.app_elf_sha256 }}</small>
|
<strong>SHA256:</strong> <small>{{ msg.parsed.app_desc.app_elf_sha256 }}</small>
|
||||||
|
|
||||||
{% elif msg.get_message_type_display == "CONFIG_UPLINK" %}
|
{% elif msg.message_type == "CONFIG_UPLINK" %}
|
||||||
<strong>Enabled:</strong> {{ msg.parsed.enabled }},
|
<strong>Enabled:</strong> {{ msg.parsed.enabled }},
|
||||||
<strong>SSID:</strong> {{ msg.parsed.ssid }},
|
<strong>SSID:</strong> {{ msg.parsed.ssid }},
|
||||||
<strong>Channel:</strong> {{ msg.parsed.channel }}<br>
|
<strong>Channel:</strong> {{ msg.parsed.channel }}<br>
|
||||||
|
@ -53,13 +67,13 @@
|
||||||
<strong>UDP:</strong> {{ msg.parsed.udp }},
|
<strong>UDP:</strong> {{ msg.parsed.udp }},
|
||||||
<strong>SSL:</strong> {{ msg.parsed.ssl }}
|
<strong>SSL:</strong> {{ msg.parsed.ssl }}
|
||||||
|
|
||||||
{% elif msg.get_message_type_display == "CONFIG_LED" %}
|
{% elif msg.message_type == "CONFIG_LED" %}
|
||||||
<strong>LED config:</strong> {{ msg.parsed.led_config }}
|
<strong>LED config:</strong> {{ msg.parsed.led_config }}
|
||||||
|
|
||||||
{% elif msg.get_message_type_display == "CONFIG_POSITION" %}
|
{% elif msg.message_type == "CONFIG_POSITION" %}
|
||||||
<strong>X=</strong>{{ msg.parsed.x_pos }}, <strong>Y=</strong>{{ msg.parsed.y_pos }}, <strong>Z=</strong>{{ msg.parsed.z_pos }}
|
<strong>X=</strong>{{ msg.parsed.x_pos }}, <strong>Y=</strong>{{ msg.parsed.y_pos }}, <strong>Z=</strong>{{ msg.parsed.z_pos }}
|
||||||
|
|
||||||
{% elif msg.get_message_type_display == "MESH_ADD_DESTINATIONS" or msg.get_message_type_display == "MESH_REMOVE_DESTINATIONS" %}
|
{% elif msg.message_type == "MESH_ADD_DESTINATIONS" or msg.message_type == "MESH_REMOVE_DESTINATIONS" %}
|
||||||
<strong>adresses:</strong><br>
|
<strong>adresses:</strong><br>
|
||||||
<ul style="margin: 0;">
|
<ul style="margin: 0;">
|
||||||
{% for address in msg.parsed.addresses %}
|
{% for address in msg.parsed.addresses %}
|
||||||
|
@ -67,6 +81,14 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
{% elif msg.message_type == "LOCATE_RANGE_RESULTS" %}
|
||||||
|
<strong>ranges:</strong><br>
|
||||||
|
<ul style="margin: 0;">
|
||||||
|
{% for range in msg.parsed.ranges %}
|
||||||
|
<li style="margin: 0;">{{ range.address }} - {{ range.distance }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{% for key, value in msg.data.items %}
|
{% for key, value in msg.data.items %}
|
||||||
{% if key != "src" and key != "dst" and key != "msg_type" %}
|
{% if key != "src" and key != "dst" and key != "msg_type" %}
|
||||||
|
|
|
@ -209,6 +209,16 @@ class VarArrayFormat(BaseVarFormat):
|
||||||
result.append(item)
|
result.append(item)
|
||||||
return result, data
|
return result, data
|
||||||
|
|
||||||
|
def fromjson(self, data):
|
||||||
|
return [
|
||||||
|
self.child_type.fromjson(item) for item in data
|
||||||
|
]
|
||||||
|
|
||||||
|
def tojson(self, data):
|
||||||
|
return [
|
||||||
|
item.tojson(item) for item in data
|
||||||
|
]
|
||||||
|
|
||||||
def get_c_parts(self):
|
def get_c_parts(self):
|
||||||
pre, post = self.child_type.get_c_parts()
|
pre, post = self.child_type.get_c_parts()
|
||||||
return super().get_num_c_code() + "\n" + pre, "[0]" + post
|
return super().get_num_c_code() + "\n" + pre, "[0]" + post
|
||||||
|
|
|
@ -262,6 +262,10 @@ class ConfigPositionMessageForm(MeshMessageForm):
|
||||||
z_pos = forms.IntegerField(min_value=0, max_value=2 ** 16 - 1, label=_('Z'))
|
z_pos = forms.IntegerField(min_value=0, max_value=2 ** 16 - 1, label=_('Z'))
|
||||||
|
|
||||||
|
|
||||||
|
class LocateRequestRangeMessageForm(MeshMessageForm):
|
||||||
|
msg_type = MeshMessageType.LOCATE_REQUEST_RANGE
|
||||||
|
|
||||||
|
|
||||||
class MeshNodeForm(forms.ModelForm):
|
class MeshNodeForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = MeshNode
|
model = MeshNode
|
||||||
|
|
|
@ -340,4 +340,4 @@ class LocateRequestRangeMessage(MeshMessage, msg_type=MeshMessageType.LOCATE_REQ
|
||||||
@dataclass
|
@dataclass
|
||||||
class LocateRangeResults(MeshMessage, msg_type=MeshMessageType.LOCATE_RANGE_RESULTS):
|
class LocateRangeResults(MeshMessage, msg_type=MeshMessageType.LOCATE_RANGE_RESULTS):
|
||||||
""" reports distance to given nodes """
|
""" reports distance to given nodes """
|
||||||
ranges: dict[str, int] = field(metadata={"format": VarArrayFormat(RangeItemType)})
|
ranges: list[RangeItemType] = field(metadata={"format": VarArrayFormat(RangeItemType)})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue