diff --git a/meshview/models.py b/meshview/models.py index 59d194e..cdbc9b9 100644 --- a/meshview/models.py +++ b/meshview/models.py @@ -17,6 +17,7 @@ class Node(Base): long_name: Mapped[str] short_name: Mapped[str] hw_model: Mapped[str] + role: Mapped[str] = mapped_column(nullable=True) last_lat: Mapped[int] = mapped_column(BigInteger, nullable=True) last_long: Mapped[int] = mapped_column(BigInteger, nullable=True) diff --git a/meshview/store.py b/meshview/store.py index 446342e..4a8eb76 100644 --- a/meshview/store.py +++ b/meshview/store.py @@ -2,6 +2,7 @@ import datetime from sqlalchemy import select +from meshtastic.config_pb2 import Config from meshtastic.portnums_pb2 import PortNum from meshtastic.mesh_pb2 import User, HardwareModel from meshview import database @@ -71,12 +72,17 @@ async def process_envelope(topic, env): hw_model = HardwareModel.Name(user.hw_model) except ValueError: hw_model = "unknown" + try: + role = Config.DeviceConfig.Role.Name(user.role) + except ValueError: + role = "unknown" if node := result.scalar_one_or_none(): node.node_id = node_id node.long_name = user.long_name node.short_name = user.short_name node.hw_model = hw_model + node.role = role else: node = Node( id=user.id, @@ -84,8 +90,9 @@ async def process_envelope(topic, env): long_name=user.long_name, short_name=user.short_name, hw_model=hw_model, + role=role, ) - session.add(node) + session.add(node) if env.packet.decoded.portnum == PortNum.POSITION_APP: position = decode_payload.decode_payload( diff --git a/meshview/templates/node.html b/meshview/templates/node.html index 2cf9e9c..046dfa1 100644 --- a/meshview/templates/node.html +++ b/meshview/templates/node.html @@ -44,6 +44,8 @@