diff --git a/clients/rust/LICENSE b/clients/rust/LICENSE new file mode 100644 index 00000000..a4ad6f14 --- /dev/null +++ b/clients/rust/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Stephen Waits + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/clients/rust/README.md b/clients/rust/README.md new file mode 100644 index 00000000..31f2d623 --- /dev/null +++ b/clients/rust/README.md @@ -0,0 +1,37 @@ +# DongLoRa Rust Client + +Rust client library for talking to a DongLoRa device — either directly +over USB or through the [mux daemon](../../mux/). + +## What's in Here + +- `src/protocol.rs` — wire protocol types (`RadioConfig`, `Command`, `Response`, `ErrorCode`) +- `src/codec.rs` — COBS framing, frame accumulator +- `src/discovery.rs` — USB VID:PID device discovery +- `src/transport.rs` — serial and mux socket transports +- `src/client.rs` — high-level `Client` with send/recv +- `src/connect.rs` — auto-detection (mux socket, TCP, direct USB) + +## Usage + +```rust +use donglora_client::*; + +let mut client = connect_default()?; +client.ping()?; +client.set_config(RadioConfig::default())?; +client.start_rx()?; + +loop { + if let Some(Response::RxPacket { rssi, snr, payload }) = client.recv()? { + println!("RX rssi={rssi} snr={snr} len={}", payload.len()); + } +} +``` + +## Dependencies + +- `cobs` — COBS framing +- `serialport` — USB serial communication +- `anyhow` — error handling +- `tracing` — logging diff --git a/mux/rust/LICENSE b/mux/rust/LICENSE new file mode 100644 index 00000000..a4ad6f14 --- /dev/null +++ b/mux/rust/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Stephen Waits + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/mux/rust/README.md b/mux/rust/README.md new file mode 100644 index 00000000..5f2b6d54 --- /dev/null +++ b/mux/rust/README.md @@ -0,0 +1,28 @@ +# DongLoRa Mux (Rust) + +USB multiplexer daemon — lets multiple applications share one DongLoRa +dongle simultaneously. + +## What It Does + +- Owns the USB serial connection exclusively +- Exposes a Unix domain socket (and optional TCP) speaking the same + COBS-framed protocol +- RxPacket frames broadcast to all connected clients +- StartRx/StopRx reference-counted across clients +- SetConfig locked once set (single client can change freely) +- Automatic dongle reconnect on hot-plug +- No panics — enforced by clippy deny lints + +## Running + +```sh +just run # start the mux daemon +just verbose # start with verbose logging +just run -- --tcp 5741 --port /dev/ttyACM0 # with options +``` + +## Depends On + +- [clients/rust](../../clients/rust/) — the `donglora-client` library + (protocol types, COBS framing, device discovery)