Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
030280791e
|
||
|
|
222802cf13
|
||
|
|
394acaee6e
|
||
|
|
943f2615f3
|
||
|
|
ae284d571a
|
No files matched your search
@@ -13,13 +13,10 @@ jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Clone donglora (sibling dependency)
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: swaits/donglora
|
||||
path: ../donglora
|
||||
- name: Install system dependencies
|
||||
run: sudo apt-get update && sudo apt-get install -y libudev-dev
|
||||
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
|
||||
@@ -1,5 +1,45 @@
|
||||
# Changelog
|
||||
|
||||
## [0.3.1] - 2026-04-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Sticky mux reconnect.** Once the bridge connects via mux, all subsequent
|
||||
reconnects use mux-only mode (`connect_mux_auto`). Previously, each reconnect
|
||||
re-ran the full mux→USB fallback chain, which could steal the serial port
|
||||
from the mux during a brief disconnect.
|
||||
|
||||
## [0.3.0] - 2026-04-07
|
||||
|
||||
### Changed
|
||||
|
||||
- Upgraded to `donglora-client` 0.2: all connections now auto-validate via
|
||||
ping-on-connect, rejecting non-DongLoRa serial devices within 200ms.
|
||||
- Simplified connection logic — removed manual mux/serial fallback and manual
|
||||
ping; `donglora_client::connect()` handles the full fallback chain and
|
||||
validation internally.
|
||||
- Config negotiation detects mux vs serial via transport type instead of
|
||||
string comparison.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Repository and homepage URLs now point to `github.com/donglora/bridge`
|
||||
(was `swaits/donglora-bridge`).
|
||||
- README links updated to `donglora` GitHub org.
|
||||
|
||||
## [0.2.2] - 2026-04-06
|
||||
|
||||
### Fixed
|
||||
|
||||
- TUI now fits in 80-column terminals (was 86).
|
||||
|
||||
## [0.2.1] - 2026-04-06
|
||||
|
||||
### Fixed
|
||||
|
||||
- CI: removed stale sibling-clone step, added `libudev-dev` dependency,
|
||||
upgraded `actions/checkout` to v5 (Node.js 24).
|
||||
|
||||
## [0.2.0] - 2026-04-06
|
||||
|
||||
### Added
|
||||
|
||||
Generated
+7
-7
@@ -906,7 +906,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "donglora-bridge"
|
||||
version = "0.2.0"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"blake3",
|
||||
@@ -938,9 +938,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "donglora-client"
|
||||
version = "0.1.0"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "162468289ac189a798c4ecd961ed92c5dde2d9c5709d779ae324e0bb9a5ac4dc"
|
||||
checksum = "343d750fe1e5dad94d4b31e6dbbb05214b39e66f3c94a2ff2a29b0031ffd2826"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serialport",
|
||||
@@ -1071,9 +1071,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.4.0"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a043dc74da1e37d6afe657061213aa6f425f855399a11d3463c6ecccc4dfda1f"
|
||||
checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6"
|
||||
|
||||
[[package]]
|
||||
name = "fiat-crypto"
|
||||
@@ -4358,9 +4358,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.25.10+spec-1.1.0"
|
||||
version = "0.25.11+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a82418ca169e235e6c399a84e395ab6debeb3bc90edc959bf0f48647c6a32d1b"
|
||||
checksum = "0b59c4d22ed448339746c59b905d24568fcbb3ab65a500494f7b8c3e97739f2b"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"toml_datetime",
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
[package]
|
||||
name = "donglora-bridge"
|
||||
version = "0.2.0"
|
||||
version = "0.3.1"
|
||||
edition = "2024"
|
||||
authors = ["Stephen Waits <steve@waits.net>"]
|
||||
license = "MIT"
|
||||
description = "Peer-to-peer LoRa bridge using iroh and DongLoRa"
|
||||
repository = "https://github.com/swaits/donglora-bridge"
|
||||
homepage = "https://github.com/swaits/donglora-bridge"
|
||||
repository = "https://github.com/donglora/bridge"
|
||||
homepage = "https://github.com/donglora/bridge"
|
||||
keywords = ["lora", "bridge", "gossip", "p2p", "iot"]
|
||||
categories = ["network-programming", "command-line-utilities"]
|
||||
readme = "README.md"
|
||||
@@ -14,7 +14,7 @@ rust-version = "1.94.1"
|
||||
exclude = [".jj/", ".github/"]
|
||||
|
||||
[dependencies]
|
||||
donglora-client = "0.1"
|
||||
donglora-client = "0.2"
|
||||
iroh = "0.97"
|
||||
iroh-gossip = "0.97"
|
||||
mainline = { version = "6", features = ["async"] }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# donglora-bridge
|
||||
|
||||
[](https://github.com/swaits/donglora-bridge/actions/workflows/ci.yml)
|
||||
[](https://github.com/donglora/bridge/actions/workflows/ci.yml)
|
||||
[](LICENSE)
|
||||

|
||||
|
||||
@@ -25,12 +25,12 @@ through an encrypted peer-to-peer gossip swarm.
|
||||
|
||||
### 1. A DongLoRa radio
|
||||
|
||||
[DongLoRa](https://github.com/swaits/donglora) is open-source firmware that
|
||||
[DongLoRa](https://github.com/donglora/firmware) is open-source firmware that
|
||||
turns a supported LoRa development board (such as a Heltec WiFi LoRa 32 or
|
||||
similar ESP32+SX1262 board) into a USB LoRa dongle. You will need to:
|
||||
|
||||
1. **Get a board** -- any ESP32 board with an SX1262 LoRa radio that DongLoRa
|
||||
supports. See the [DongLoRa README](https://github.com/swaits/donglora) for
|
||||
supports. See the [DongLoRa README](https://github.com/donglora/firmware) for
|
||||
the full list.
|
||||
2. **Flash the DongLoRa firmware** onto the board. Instructions are in the
|
||||
DongLoRa repository.
|
||||
@@ -68,7 +68,7 @@ mise use -g cargo:donglora-bridge
|
||||
Or build from source:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/swaits/donglora-bridge.git
|
||||
git clone https://github.com/donglora/bridge.git
|
||||
cd donglora-bridge
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
@@ -1,60 +1,69 @@
|
||||
# Default: run all checks
|
||||
set shell := ["bash", "-c"]
|
||||
|
||||
default: build
|
||||
|
||||
# Run all checks (fmt, clippy, test)
|
||||
[private]
|
||||
_ensure_tools:
|
||||
@mise trust --yes . 2>/dev/null; mise install --quiet
|
||||
|
||||
# Run the bridge (TUI mode)
|
||||
run *args: _ensure_tools
|
||||
cargo run --release -- {{args}}
|
||||
|
||||
# Run in headless mode
|
||||
run-headless *args: _ensure_tools
|
||||
cargo run --release -- --log-only {{args}}
|
||||
|
||||
# Run the config wizard
|
||||
config: _ensure_tools
|
||||
cargo run --release -- config
|
||||
|
||||
# Run all checks (fmt, clippy, test, audit)
|
||||
check: fmt-check clippy test audit
|
||||
|
||||
# Format code
|
||||
fmt:
|
||||
fmt: _ensure_tools
|
||||
cargo fmt
|
||||
|
||||
# Check formatting without changing files
|
||||
fmt-check:
|
||||
fmt-check: _ensure_tools
|
||||
cargo fmt --check
|
||||
|
||||
# Lint with clippy (pedantic + nursery)
|
||||
clippy:
|
||||
# Lint with clippy
|
||||
clippy: _ensure_tools
|
||||
cargo clippy --all-targets -- -D warnings
|
||||
|
||||
# Build release binary
|
||||
build:
|
||||
cargo build --release
|
||||
|
||||
# Generate docs
|
||||
doc:
|
||||
cargo doc --no-deps --open
|
||||
|
||||
# Run the bridge (TUI mode)
|
||||
run *ARGS:
|
||||
cargo run --release -- {{ARGS}}
|
||||
|
||||
# Run in headless mode
|
||||
run-headless *ARGS:
|
||||
cargo run --release -- --log-only {{ARGS}}
|
||||
|
||||
# Run the config wizard
|
||||
config:
|
||||
cargo run --release -- config
|
||||
|
||||
# Security + license audit
|
||||
audit:
|
||||
cargo deny check
|
||||
|
||||
# Run all tests
|
||||
test: test-unit test-fuzz test-mutants
|
||||
test: test-unit
|
||||
|
||||
# Normal unit tests
|
||||
test-unit:
|
||||
test-unit: _ensure_tools
|
||||
cargo nextest run
|
||||
|
||||
# Mutation testing
|
||||
test-mutants *ARGS:
|
||||
cargo mutants {{ARGS}}
|
||||
test-mutants *args: _ensure_tools
|
||||
cargo mutants {{args}}
|
||||
|
||||
# Fuzz a target (requires nightly)
|
||||
test-fuzz TARGET="fuzz_gossip_frame_decode" DURATION="60":
|
||||
test-fuzz TARGET="fuzz_gossip_frame_decode" DURATION="60": _ensure_tools
|
||||
cargo +nightly fuzz run {{TARGET}} -- -max_total_time={{DURATION}}
|
||||
|
||||
# Security + license audit
|
||||
audit: _ensure_tools
|
||||
cargo deny check
|
||||
|
||||
# Build release binary
|
||||
build: _ensure_tools
|
||||
cargo build --release
|
||||
|
||||
# Generate docs
|
||||
doc: _ensure_tools
|
||||
cargo doc --no-deps --open
|
||||
|
||||
# Check for outdated dependencies
|
||||
outdated: _ensure_tools
|
||||
cargo outdated
|
||||
|
||||
# Clean build artifacts
|
||||
clean:
|
||||
cargo clean
|
||||
+38
-28
@@ -6,7 +6,7 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use donglora_client::{RadioConfig, Response, Transport};
|
||||
use donglora_client::{AnyTransport, RadioConfig, Response, Transport};
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::{debug, error, info, warn};
|
||||
|
||||
@@ -56,15 +56,20 @@ fn radio_loop(
|
||||
let initial_backoff = Duration::from_millis(250);
|
||||
let max_backoff = Duration::from_secs(5);
|
||||
let mut backoff = initial_backoff;
|
||||
let mut use_mux_only = false;
|
||||
|
||||
loop {
|
||||
let started = std::time::Instant::now();
|
||||
match connect_and_run(&config, port.as_deref(), &event_tx, &mut tx_recv) {
|
||||
Ok(()) => {
|
||||
match connect_and_run(&config, port.as_deref(), use_mux_only, &event_tx, &mut tx_recv) {
|
||||
Ok(_was_mux) => {
|
||||
info!("radio thread exiting");
|
||||
return;
|
||||
}
|
||||
Err(e) => {
|
||||
Err((was_mux, e)) => {
|
||||
// Session ended with error. Remember transport type for reconnect.
|
||||
if was_mux {
|
||||
use_mux_only = true;
|
||||
}
|
||||
error!("radio error: {e:#}");
|
||||
let _ = event_tx.blocking_send(RadioEvent::Disconnected);
|
||||
|
||||
@@ -82,42 +87,47 @@ fn radio_loop(
|
||||
}
|
||||
}
|
||||
|
||||
/// Connect to the dongle and run the radio loop.
|
||||
///
|
||||
/// Returns `Ok(was_mux)` on clean exit, `Err((was_mux, error))` on failure.
|
||||
/// The `was_mux` flag lets the caller know which transport was used so it can
|
||||
/// stick to the same transport type on reconnect.
|
||||
fn connect_and_run(
|
||||
config: &RadioConfig,
|
||||
port: Option<&str>,
|
||||
use_mux_only: bool,
|
||||
event_tx: &mpsc::Sender<RadioEvent>,
|
||||
tx_recv: &mut mpsc::Receiver<Vec<u8>>,
|
||||
) -> Result<()> {
|
||||
) -> std::result::Result<bool, (bool, anyhow::Error)> {
|
||||
// Long initial timeout: the mux serializes commands through the dongle,
|
||||
// so our `GetConfig` might have to wait behind other clients' commands.
|
||||
let timeout = Duration::from_secs(10);
|
||||
|
||||
info!("connecting to dongle...");
|
||||
let (mut client, device) = if let Some(port) = port {
|
||||
let c = donglora_client::connect(Some(port), timeout)?;
|
||||
(c, shorten_path(port))
|
||||
} else if let Ok(c) = donglora_client::connect_mux_auto(timeout) {
|
||||
(c, "mux".to_string())
|
||||
let mut client = if use_mux_only {
|
||||
debug!("reconnecting via mux only (previously connected via mux)");
|
||||
donglora_client::connect_mux_auto(timeout).map_err(|e| (true, e))?
|
||||
} else {
|
||||
let port_path = donglora_client::find_port()
|
||||
.ok_or_else(|| anyhow::anyhow!("no mux or USB dongle found"))?;
|
||||
info!("no mux found, connecting to serial port {port_path}");
|
||||
let c = donglora_client::connect(Some(&port_path), timeout)?;
|
||||
(c, shorten_path(&port_path))
|
||||
donglora_client::connect(port, timeout).map_err(|e| (false, e))?
|
||||
};
|
||||
info!("[radio] transport connected: {device}");
|
||||
let is_mux = matches!(client.transport(), AnyTransport::Mux(_));
|
||||
let device = if is_mux { "mux".to_string() } else { port.map_or_else(|| "usb".to_string(), shorten_path) };
|
||||
info!("[radio] connected and validated: {device}");
|
||||
|
||||
info!("[radio] sending ping...");
|
||||
match client.ping() {
|
||||
Ok(()) => info!("[radio] ping OK"),
|
||||
Err(e) => {
|
||||
info!("[radio] ping FAILED: {e:#}");
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
// Run the session. Map Result<()> to include the is_mux flag.
|
||||
run_session(&mut client, config, is_mux, &device, event_tx, tx_recv).map(|()| is_mux).map_err(|e| (is_mux, e))
|
||||
}
|
||||
|
||||
fn run_session(
|
||||
client: &mut donglora_client::Client<AnyTransport>,
|
||||
config: &RadioConfig,
|
||||
is_mux: bool,
|
||||
device: &str,
|
||||
event_tx: &mpsc::Sender<RadioEvent>,
|
||||
tx_recv: &mut mpsc::Receiver<Vec<u8>>,
|
||||
) -> Result<()> {
|
||||
info!("[radio] negotiating config...");
|
||||
let (active_config, config_source) = match negotiate_config(&mut client, config, &device) {
|
||||
let (active_config, config_source) = match negotiate_config(client, config, is_mux) {
|
||||
Ok(result) => {
|
||||
info!("[radio] config negotiated: source={:?}, config={}", result.1, format_radio_config(&result.0));
|
||||
result
|
||||
@@ -137,7 +147,7 @@ fn connect_and_run(
|
||||
}
|
||||
}
|
||||
|
||||
let _ = event_tx.blocking_send(RadioEvent::Connected(active_config, config_source, device));
|
||||
let _ = event_tx.blocking_send(RadioEvent::Connected(active_config, config_source, device.to_string()));
|
||||
|
||||
// Set a short timeout so we can interleave RX and TX.
|
||||
client.transport_mut().set_timeout(Duration::from_millis(100))?;
|
||||
@@ -216,7 +226,7 @@ fn connect_and_run(
|
||||
fn negotiate_config<T: Transport>(
|
||||
client: &mut donglora_client::Client<T>,
|
||||
desired: &RadioConfig,
|
||||
device: &str,
|
||||
is_mux: bool,
|
||||
) -> Result<(RadioConfig, ConfigSource)> {
|
||||
info!("[negotiate] get_config...");
|
||||
match client.get_config() {
|
||||
@@ -224,7 +234,7 @@ fn negotiate_config<T: Transport>(
|
||||
if configs_match(&cfg, desired) {
|
||||
info!("[negotiate] get_config OK (matches desired): {}", format_radio_config(&cfg));
|
||||
Ok((cfg, ConfigSource::Ours))
|
||||
} else if device == "mux" {
|
||||
} else if is_mux {
|
||||
info!("[negotiate] get_config OK (mux config differs, accepting): {}", format_radio_config(&cfg));
|
||||
Ok((cfg, ConfigSource::Mux))
|
||||
} else {
|
||||
|
||||
+3
-3
@@ -245,8 +245,8 @@ fn draw_ui(
|
||||
series: &TimeSeries,
|
||||
) {
|
||||
// Minimum terminal size for the 3-column layout.
|
||||
if area.width < 86 || area.height < 12 {
|
||||
let msg = format!("Terminal too small ({}x{}), need 86x12+", area.width, area.height);
|
||||
if area.width < 80 || area.height < 12 {
|
||||
let msg = format!("Terminal too small ({}x{}), need 80x12+", area.width, area.height);
|
||||
frame.render_widget(
|
||||
Paragraph::new(msg).alignment(Alignment::Center).style(Style::default().fg(C_RATE_DROP)),
|
||||
area,
|
||||
@@ -266,7 +266,7 @@ fn draw_ui(
|
||||
// Packet log columns: Age=5 Hash=8 RF=4 Net=4 Size=6 RSSI=6 SNR=5 Act=5 = 43 + 2 border + 1 pad = 46
|
||||
let cols = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints([Constraint::Length(30), Constraint::Length(46), Constraint::Min(10)])
|
||||
.constraints([Constraint::Length(30), Constraint::Length(46), Constraint::Min(4)])
|
||||
.split(rows[1]);
|
||||
|
||||
// Left column: Network, Radio, Stats stacked.
|
||||
|
||||
Reference in new issue
Block a user