feat: example scripts (simple_rx, simple_tx, ping_pong) with shared donglora.py helper
This commit is contained in:
9898 files changed
+271434
No files matched your search
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Transmit a single LoRa packet.
|
||||
|
||||
Usage:
|
||||
uv run examples/simple_tx.py [PORT] [MESSAGE]
|
||||
"""
|
||||
# /// script
|
||||
# requires-python = ">=3.10"
|
||||
# dependencies = ["cobs", "pyserial"]
|
||||
# ///
|
||||
|
||||
import sys
|
||||
sys.path.insert(0, __import__("pathlib").Path(__file__).parent.as_posix())
|
||||
import donglora as dl # noqa: E402
|
||||
|
||||
port = None
|
||||
message = "Hello from DongLoRa!"
|
||||
|
||||
args = sys.argv[1:]
|
||||
if args and not args[0].startswith("/dev"):
|
||||
message = " ".join(args)
|
||||
elif args:
|
||||
port = args[0]
|
||||
if len(args) > 1:
|
||||
message = " ".join(args[1:])
|
||||
|
||||
ser = dl.connect(port)
|
||||
print(dl.send(ser, "SetConfig", config=dl.DEFAULT_CONFIG))
|
||||
print(dl.send(ser, "Transmit", payload=message.encode()))
|
||||
print(f"Sent: {message!r}")
|
||||
Reference in new issue
Block a user