fix communication with new board messages etc
This commit is contained in:
parent
4d21ebb78e
commit
6a35c6767b
5 changed files with 14 additions and 15 deletions
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
<h4>Hardware</h4>
|
<h4>Hardware</h4>
|
||||||
<p>
|
<p>
|
||||||
<strong>Board:</strong> {{ node.last_messages.CONFIG_BOARD.parsed.board.name }}
|
<strong>Board:</strong> {{ node.last_messages.CONFIG_BOARD.parsed.board_config.board.name }}
|
||||||
(with {{ node.last_messages.CONFIG_HARDWARE.parsed.chip.name }} rev{{ node.last_messages.CONFIG_HARDWARE.parsed.revision_major }}.{{ node.last_messages.CONFIG_HARDWARE.parsed.revision_minor }})
|
(with {{ node.last_messages.CONFIG_HARDWARE.parsed.chip.name }} rev{{ node.last_messages.CONFIG_HARDWARE.parsed.revision_major }}.{{ node.last_messages.CONFIG_HARDWARE.parsed.revision_minor }})
|
||||||
|
|
||||||
{% if node.last_messages.CONFIG_BOARD.parsed.led %}
|
{% if node.last_messages.CONFIG_BOARD.parsed.led %}
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{% url "control.mesh.node.detail" pk=node.address %}">{{ node }}</a></td>
|
<td><a href="{% url "control.mesh.node.detail" pk=node.address %}">{{ node }}</a></td>
|
||||||
<td>
|
<td>
|
||||||
{{ node.last_messages.CONFIG_BOARD.parsed.board.name }}
|
{{ node.last_messages.CONFIG_BOARD.parsed.board_config.board.name }}
|
||||||
({{ node.last_messages.CONFIG_HARDWARE.parsed.get_chip_display }} <small>rev{{ node.last_messages.CONFIG_HARDWARE.parsed.revision_major }}.{{ node.last_messages.CONFIG_HARDWARE.parsed.revision_minor }}</small>)
|
({{ node.last_messages.CONFIG_HARDWARE.parsed.get_chip_display }} <small>rev{{ node.last_messages.CONFIG_HARDWARE.parsed.revision_major }}.{{ node.last_messages.CONFIG_HARDWARE.parsed.revision_minor }}</small>)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -86,8 +86,8 @@ class SimpleFormat(BaseFormat):
|
||||||
|
|
||||||
|
|
||||||
class EnumFormat(SimpleFormat):
|
class EnumFormat(SimpleFormat):
|
||||||
def __init__(self, as_hex=False):
|
def __init__(self, fmt="B", *, as_hex=False):
|
||||||
super().__init__("B")
|
super().__init__(fmt)
|
||||||
self.as_hex = as_hex
|
self.as_hex = as_hex
|
||||||
|
|
||||||
def set_field_type(self, field_type):
|
def set_field_type(self, field_type):
|
||||||
|
@ -210,12 +210,11 @@ class VarArrayFormat(BaseVarFormat):
|
||||||
|
|
||||||
|
|
||||||
class VarStrFormat(BaseVarFormat):
|
class VarStrFormat(BaseVarFormat):
|
||||||
|
|
||||||
def get_var_num(self):
|
def get_var_num(self):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def encode(self, value: str) -> bytes:
|
def encode(self, value: str) -> bytes:
|
||||||
return struct.pack(self.num_fmt, len(str)) + value.encode()
|
return struct.pack(self.num_fmt, len(value)) + value.encode()
|
||||||
|
|
||||||
def decode(self, data: bytes) -> tuple[str, bytes]:
|
def decode(self, data: bytes) -> tuple[str, bytes]:
|
||||||
num = struct.unpack(self.num_fmt, data[:self.num_size])[0]
|
num = struct.unpack(self.num_fmt, data[:self.num_size])[0]
|
||||||
|
|
|
@ -90,33 +90,33 @@ class BoardConfig(StructType, union_type_field="board"):
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class CustomBoardConfig(StructType, board=BoardType.CUSTOM):
|
class CustomBoardConfig(BoardConfig, board=BoardType.CUSTOM):
|
||||||
uwb: UWBConfig = field(metadata={"as_definition": True})
|
uwb: UWBConfig = field(metadata={"as_definition": True})
|
||||||
led: LedConfig = field(metadata={"as_definition": True})
|
led: LedConfig = field(metadata={"as_definition": True})
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DevkitMBoardConfig(StructType, board=BoardType.ESP32_C3_DEVKIT_M_1):
|
class DevkitMBoardConfig(BoardConfig, board=BoardType.ESP32_C3_DEVKIT_M_1):
|
||||||
uwb: UWBConfig = field(metadata={"as_definition": True})
|
uwb: UWBConfig = field(metadata={"as_definition": True})
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Esp32SBoardConfig(StructType, board=BoardType.ESP32_C3_32S):
|
class Esp32SBoardConfig(BoardConfig, board=BoardType.ESP32_C3_32S):
|
||||||
uwb: UWBConfig = field(metadata={"as_definition": True})
|
uwb: UWBConfig = field(metadata={"as_definition": True})
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class UwbBoardConfig(StructType, board=BoardType.C3NAV_UWB_BOARD):
|
class UwbBoardConfig(BoardConfig, board=BoardType.C3NAV_UWB_BOARD):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class LocationPCBRev0Dot1BoardConfig(StructType, board=BoardType.C3NAV_LOCATION_PCB_REV_0_1):
|
class LocationPCBRev0Dot1BoardConfig(BoardConfig, board=BoardType.C3NAV_LOCATION_PCB_REV_0_1):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class LocationPCBRev0Dot2BoardConfig(StructType, board=BoardType.C3NAV_LOCATION_PCB_REV_0_2):
|
class LocationPCBRev0Dot2BoardConfig(BoardConfig, board=BoardType.C3NAV_LOCATION_PCB_REV_0_2):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import channels
|
||||||
from asgiref.sync import async_to_sync
|
from asgiref.sync import async_to_sync
|
||||||
|
|
||||||
from c3nav.mesh.baseformats import (BoolFormat, FixedStrFormat, SimpleFormat, StructType, VarArrayFormat, VarStrFormat,
|
from c3nav.mesh.baseformats import (BoolFormat, FixedStrFormat, SimpleFormat, StructType, VarArrayFormat, VarStrFormat,
|
||||||
normalize_name)
|
normalize_name, EnumFormat)
|
||||||
from c3nav.mesh.dataformats import (BoardConfig, FirmwareAppDescription, MacAddressesListFormat, MacAddressFormat,
|
from c3nav.mesh.dataformats import (BoardConfig, FirmwareAppDescription, MacAddressesListFormat, MacAddressFormat,
|
||||||
RangeItemType)
|
RangeItemType)
|
||||||
from c3nav.mesh.utils import get_mesh_comm_group
|
from c3nav.mesh.utils import get_mesh_comm_group
|
||||||
|
@ -207,8 +207,8 @@ class ConfigDumpMessage(MeshMessage, msg_id=MeshMessageType.CONFIG_DUMP):
|
||||||
@dataclass
|
@dataclass
|
||||||
class ConfigHardwareMessage(MeshMessage, msg_id=MeshMessageType.CONFIG_HARDWARE):
|
class ConfigHardwareMessage(MeshMessage, msg_id=MeshMessageType.CONFIG_HARDWARE):
|
||||||
""" respond hardware/chip info """
|
""" respond hardware/chip info """
|
||||||
chip: int = field(metadata={
|
chip: ChipType = field(metadata={
|
||||||
"format": SimpleFormat('H'),
|
"format": EnumFormat("H"),
|
||||||
"c_name": "chip_id",
|
"c_name": "chip_id",
|
||||||
})
|
})
|
||||||
revision_major: int = field(metadata={"format": SimpleFormat('B')})
|
revision_major: int = field(metadata={"format": SimpleFormat('B')})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue