Use a single MQTT task.

This commit is contained in:
Jason Michalski
2024-05-24 22:50:41 -07:00
parent 077ce6e671
commit 9079bbbcb4
2 changed files with 4 additions and 4 deletions

View File

@@ -18,8 +18,7 @@ async def main(args):
await database.create_tables()
async with asyncio.TaskGroup() as tg:
for topic in args.topic:
tg.create_task(load_database_from_mqtt(topic))
tg.create_task(load_database_from_mqtt(args.topic))
tg.create_task(web.run_server(args.bind, args.port, args.tls_cert))
if args.acme_challenge:
tg.create_task(http.run_server(args.bind, args.acme_challenge))

View File

@@ -26,13 +26,14 @@ def decrypt(packet):
pass
async def get_topic_envelopes(topic):
async def get_topic_envelopes(topics):
while True:
try:
async with aiomqtt.Client(
"mqtt.meshtastic.org", username="meshdev", password="large4cats"
) as client:
await client.subscribe(topic)
for topic in topics:
await client.subscribe(topic)
async for msg in client.messages:
try:
envelope = ServiceEnvelope.FromString(msg.payload)