project restructure

This commit is contained in:
Jono Targett 2026-03-18 15:39:27 +10:30
parent 0140c2f9dc
commit e682106f10
10 changed files with 29 additions and 32 deletions

0
README.md Normal file
View File

BIN
docs/dashboard.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

29
main.py
View File

@ -1,29 +0,0 @@
#! /usr/bin/env python3
import aioserial
import asyncio
import socket
import signal
from ubxhandler import UBXHandler
from handler import MQTTConfig
async def main():
handler_id = f"example-gps-{socket.gethostname()}"
mqtt_config = MQTTConfig(host="127.0.0.1", port=1883)
serial_port = aioserial.AioSerial(
port="/tmp/ttyV0",
baudrate=115200,
timeout=0.05, # 50 ms
)
handler = UBXHandler(mqtt_config, handler_id, serial_port)
signal.signal(signal.SIGINT, lambda signum, frame: handler.stop())
await handler.run()
if __name__ == "__main__":
asyncio.run(main())

0
mqtthandler/__init__.py Normal file
View File

View File

@ -6,7 +6,7 @@ import signal
import json
from dataclasses import dataclass
from command import (
from .command import (
Command,
CommandResponse,
CommandArgumentError,

30
ubxhandler.py → ubx.py Normal file → Executable file
View File

@ -1,12 +1,18 @@
#! /usr/bin/env python3
import asyncio
import aioserial
import aiomqtt
import pyubx2
import io
import logging
import aioserial
import asyncio
import socket
import signal
from command import command
from handler import MQTTHandler, task
from mqtthandler.command import command
from mqtthandler.handler import MQTTConfig, MQTTHandler, task
# The pyubx2 library spams the console with errors that aren't errors.
# I don't care if you failed to parse an incomplete buffer.
@ -165,3 +171,23 @@ class UBXHandler(MQTTHandler):
)
num_bytes = await self.serial_port.write_async(message.serialize())
return num_bytes
async def main():
handler_id = f"example-gps-{socket.gethostname()}"
mqtt_config = MQTTConfig(host="127.0.0.1", port=1883)
serial_port = aioserial.AioSerial(
port="/tmp/ttyV0",
baudrate=115200,
timeout=0.05, # 50 ms
)
handler = UBXHandler(mqtt_config, handler_id, serial_port)
signal.signal(signal.SIGINT, lambda signum, frame: handler.stop())
await handler.run()
if __name__ == "__main__":
asyncio.run(main())