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.
25 lines
645 B
Python
Executable File
25 lines
645 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Receive LoRa packets on the MeshCore US/Canada channel.
|
|
|
|
Usage:
|
|
python examples/simple_rx.py [PORT]
|
|
"""
|
|
|
|
import sys
|
|
|
|
import donglora as dl
|
|
from _common import MESHCORE_US
|
|
|
|
port = sys.argv[1] if len(sys.argv) > 1 else None
|
|
|
|
with dl.connect(port, config=MESHCORE_US) as d:
|
|
print(f"Listening on {d.config.freq_hz / 1e6:.3f} MHz (Ctrl+C to stop)...\n")
|
|
try:
|
|
for pkt in d.rx():
|
|
print(
|
|
f" RSSI:{pkt.rssi_dbm:6.1f} dBm SNR:{pkt.snr_db:5.1f} dB "
|
|
f"len:{len(pkt.data):3d} {pkt.data.hex()}"
|
|
)
|
|
except KeyboardInterrupt:
|
|
print("\nDone.")
|