feat!: v0.2.0 — ping-on-connect validation, try_connect, publish polish
- Add ping-on-connect handshake: all connect functions validate the device within 200ms, rejecting non-DongLoRa serial devices immediately - Add try_connect() — non-blocking connect that errors instead of blocking forever when no USB device is present - Add payload size validation in transmit() (max 256 bytes) - Add ErrorCode: impl std::error::Error - Fix drain_rx error handling (no longer swallows original error) - Fix repository URL to github.com/donglora/client-rs - Remove wire-level tag constants from top-level re-exports - Add rust-version (MSRV 1.85), homepage, exclude fields to Cargo.toml - Add examples/ping.rs - Allow clippy unwrap/expect in test modules
This commit is contained in:
11 files changed
+242
-174
No files matched your search
@@ -1,24 +1,21 @@
|
||||
# DongLoRa Rust Client
|
||||
|
||||
Rust client library for talking to a DongLoRa device — either directly
|
||||
over USB or through the [mux daemon](../../mux/).
|
||||
over USB or through a mux daemon.
|
||||
|
||||
## What's in Here
|
||||
## Install
|
||||
|
||||
- `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<T>` with send/recv
|
||||
- `src/connect.rs` — auto-detection (mux socket, TCP, direct USB)
|
||||
```toml
|
||||
[dependencies]
|
||||
donglora-client = "0.2"
|
||||
```
|
||||
|
||||
## Usage
|
||||
## Quick Start
|
||||
|
||||
```rust
|
||||
use donglora_client::*;
|
||||
|
||||
let mut client = connect_default()?;
|
||||
client.ping()?;
|
||||
client.set_config(RadioConfig::default())?;
|
||||
client.start_rx()?;
|
||||
|
||||
@@ -29,6 +26,29 @@ loop {
|
||||
}
|
||||
```
|
||||
|
||||
All `connect` functions automatically validate the device by pinging it,
|
||||
so you'll get a clear error immediately if the port isn't a real DongLoRa.
|
||||
|
||||
## 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<T>` with send/recv
|
||||
- `src/connect.rs` — auto-detection (mux socket, TCP, direct USB)
|
||||
|
||||
## Connection Priority
|
||||
|
||||
[`connect`] and [`try_connect`] try these in order:
|
||||
|
||||
1. **TCP mux** — via `DONGLORA_MUX_TCP` env var
|
||||
2. **Unix socket mux** — checks `$XDG_RUNTIME_DIR/donglora/mux.sock` or `/tmp/donglora-mux.sock`
|
||||
3. **Direct USB serial** — auto-detects by VID:PID
|
||||
|
||||
`try_connect` returns an error immediately if no device is found.
|
||||
`connect` blocks until a USB device appears.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- `ucobs` — COBS framing (same implementation as the firmware)
|
||||
|
||||
Reference in new issue
Block a user