39 lines
720 B
Python
Executable File
39 lines
720 B
Python
Executable File
#! /usr/bin/env python3
|
|
|
|
import aiomqtt
|
|
import aioserial
|
|
import asyncio
|
|
import paho
|
|
import uuid
|
|
|
|
from ubxhandler import UBXHandler
|
|
|
|
BAUD = 115200
|
|
|
|
|
|
async def main():
|
|
handler_id = "example-gps"
|
|
mqtt_host = "127.0.0.1"
|
|
mqtt_port = 1883
|
|
|
|
client_id = f"{handler_id}-{uuid.uuid4()}"
|
|
mqtt_client = aiomqtt.Client(
|
|
mqtt_host,
|
|
port=mqtt_port,
|
|
identifier=client_id,
|
|
protocol=paho.mqtt.client.MQTTv5,
|
|
)
|
|
|
|
serial_port = aioserial.AioSerial(
|
|
port="/tmp/ttyV0",
|
|
baudrate=BAUD,
|
|
timeout=0.05, # 50 ms
|
|
)
|
|
|
|
handler = UBXHandler(mqtt_client, "example-gps", serial_port)
|
|
await handler.run()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|