Added the second CFG command

This commit is contained in:
Jono Targett 2026-03-15 19:41:32 +10:30
parent d212bf40fc
commit 641649d964
2 changed files with 43 additions and 3 deletions

View File

@ -6,9 +6,6 @@ import inspect
from paho.mqtt.properties import Properties
from dataclasses import asdict
BAUD = 115200
INTERVAL = 5
class MQTTHandler:
@ -97,6 +94,7 @@ class MQTTHandler:
await self.execute_command(command_name, payload, message.properties)
async def run(self):
INTERVAL = 5
while True:
try:
async with self.mqtt_client as client:

View File

@ -72,6 +72,9 @@ class UBXHandler(MQTTHandler):
topic = f"{self.topic_base}/{message.identity}/{name}"
await self.mqtt_client.publish(topic, value, qos=1, retain=True)
else:
#print("Unexpected response:", message)
pass
@command({"type": "number"}, description="An example command")
async def example_cmd(self, args):
@ -120,3 +123,42 @@ class UBXHandler(MQTTHandler):
)
num_bytes = await self.serial_port.write_async(message.serialize())
return num_bytes
@command(
{
"type": "object",
"properties": {
"measRate": {
"type": "integer",
"minimum": 50,
"maximum": 60000,
"description": "Measurement period in milliseconds",
},
"navRate": {
"type": "integer",
"minimum": 1,
"maximum": 127,
"description": "Number of measurement cycles per navigation solution",
},
"timeRef": {
"type": "integer",
"enum": [0, 1],
"description": "Time reference (0=UTC, 1=GPS)",
},
},
"required": ["measRate", "navRate", "timeRef"],
"additionalProperties": False,
},
description="Reconfigure the rate properties for the UBX device.",
)
async def configure_rate(self, args):
message = pyubx2.UBXMessage(
"CFG",
"CFG-RATE",
pyubx2.ubxtypes_core.SET,
measRate=args["measRate"],
navRate=args["navRate"],
timeRef=args["timeRef"],
)
num_bytes = await self.serial_port.write_async(message.serialize())
return num_bytes