feat!: examples on donglora 1.0 async API with shared _common helpers
Rewrite all scripts against the DongLoRa Protocol v2 async Dongle surface, and extract the shared MeshCore US preset into a single module. * _common.py: MESHCORE_US preset (910.525 MHz / BW 62.5 / SF 7 / CR 4/5 / sync 0x1424 / 20 dBm) plus small helpers, imported by every example. * New: explore.py, which prints the device capabilities and runs a single TX + RX roundtrip for quick hardware validation. * simple_rx.py, simple_tx.py, ping_pong.py, lora_bridge.py all switch to donglora.Dongle and the new Modulation / LoRaConfig types. * all_commands.py removed; it was an index of the old v0.1 command enum that no longer exists after the Protocol v2 split. * justfile: drop stale recipes that referenced removed scripts.
This commit is contained in:
8 files changed
+204
-209
No files matched your search
+5
-11
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Transmit a single LoRa packet.
|
||||
"""Transmit a single LoRa packet on the MeshCore US/Canada channel.
|
||||
|
||||
Usage:
|
||||
python examples/simple_tx.py [PORT] [MESSAGE]
|
||||
@@ -7,9 +7,8 @@ Usage:
|
||||
|
||||
import sys
|
||||
|
||||
import serial
|
||||
|
||||
import donglora as dl
|
||||
from _common import MESHCORE_US
|
||||
|
||||
port = None
|
||||
message = "Hello from DongLoRa!"
|
||||
@@ -22,11 +21,6 @@ elif args:
|
||||
if len(args) > 1:
|
||||
message = " ".join(args[1:])
|
||||
|
||||
try:
|
||||
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}")
|
||||
except serial.SerialException as e:
|
||||
print(f"\nSerial error: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
with dl.connect(port, config=MESHCORE_US) as d:
|
||||
td = d.tx(message.encode())
|
||||
print(f"Sent {message!r} ({td.airtime_us} µs on air)")
|
||||
Reference in new issue
Block a user