modjam/modjam/radio/factory.py
Alec Perkins 0f478bf720 Implement test/control stations, simulator, tests
Adds the modjam package: a MeshCore-backed test station service for
Pi (IDLE + RUNNING states, cuesheet-driven), a control station REPL
for the Mac, and a UDP simulator that swaps in for the radio when
SIMULATOR=true (drops cross-config packets and a configurable
fraction of test-payload datagrams to mimic real radio loss).
docker-compose runs three sim stations + control on a bridge net.
TSV log format matches the reference traces.

Pytest suite covers protocol codec, cuesheet builder, TSV logger,
config loader, and UDP radio packet routing/loss; .forgejo/workflows
runs it on push to main and on PRs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 21:27:41 -04:00

15 lines
546 B
Python

from __future__ import annotations
import os
from .base import Radio
def make_radio(station: str, port: str | None = None) -> Radio:
if os.environ.get("SIMULATOR", "").lower() in ("1", "true", "yes"):
from .udp import UDPRadio
peers = [p.strip() for p in os.environ.get("PEERS", "").split(",") if p.strip()]
peers = [p for p in peers if p != station and p.lower() != station.lower()]
return UDPRadio(station=station, peers=peers)
from .meshcore import MeshCoreRadio
return MeshCoreRadio(port=port)