meshcore_py/examples/serial_repeater_status.py

33 lines
876 B
Python
Raw Normal View History

2025-03-30 09:00:09 +02:00
#!/usr/bin/python
import asyncio
from meshcore import MeshCore
2025-04-08 22:56:16 -07:00
from meshcore.events import EventType
2025-03-30 09:00:09 +02:00
2025-04-08 22:56:16 -07:00
PORT = "/dev/tty.usbserial-583A0069501"
2025-03-30 09:00:09 +02:00
BAUDRATE = 115200
2025-04-08 22:56:16 -07:00
REPEATER="Orion"
PASSWORD="floopyboopy"
2025-03-30 09:00:09 +02:00
async def main () :
2025-04-08 22:56:16 -07:00
mc = await MeshCore.create_serial(PORT, BAUDRATE)
await mc.commands.get_contacts()
repeater = mc.get_contact_by_name(REPEATER)
2025-04-13 22:19:08 -07:00
if repeater is None:
print(f"Repeater '{REPEATER}' not found in contacts.")
return
await mc.commands.send_login(repeater, PASSWORD)
2025-03-30 09:00:09 +02:00
2025-04-08 22:56:16 -07:00
print("Login sent ... awaiting")
2025-03-30 09:00:09 +02:00
2025-04-08 22:56:16 -07:00
if await mc.wait_for_event(EventType.LOGIN_SUCCESS):
print("Logged in success")
await mc.commands.send_statusreq(bytes.fromhex(repeater["public_key"]))
print("Status request sent ... awaiting")
print(await mc.wait_for_event(EventType.STATUS_RESPONSE))
2025-03-30 09:00:09 +02:00
asyncio.run(main())