Skip to main content

Crate donglora_client

Crate donglora_client 

Source
Expand description

DongLoRa host library — connect, configure, send/receive LoRa packets.

Implements the DongLoRa Protocol v2 on top of the donglora-protocol wire crate. All I/O is async via tokio; the public surface mirrors the Python client in client-py/.

§Quick start

use donglora_client::{
    connect, LoRaBandwidth, LoRaCodingRate, LoRaConfig, LoRaHeaderMode, Modulation,
};

let dongle = connect().await?;
dongle.set_config(Modulation::LoRa(LoRaConfig {
    freq_hz: 910_525_000,
    sf: 7,
    bw: LoRaBandwidth::Khz62,
    cr: LoRaCodingRate::Cr4_5,
    preamble_len: 16,
    sync_word: 0x1424,
    tx_power_dbm: 20,
    header_mode: LoRaHeaderMode::Explicit,
    payload_crc: true,
    iq_invert: false,
})).await?;
dongle.tx(b"hello world").await?;

§Module layout

Re-exports§

pub use connect::mux_unix_connect;
pub use connect::ConnectOptions;
pub use connect::connect;
pub use connect::connect_mux_auto;
pub use connect::connect_mux_auto_with;
pub use connect::connect_with;
pub use connect::default_socket_path;
pub use connect::find_mux_socket;
pub use connect::mux_tcp_connect;
pub use connect::try_connect;
pub use connect::try_connect_with;
pub use discovery::USB_PID;
pub use discovery::USB_VID;
pub use discovery::find_port;
pub use discovery::wait_for_device;
pub use dongle::Dongle;
pub use dongle::KEEPALIVE_INTERVAL;
pub use dongle::TransportKind;
pub use errors::ClientError;
pub use errors::ClientResult;
pub use retry::RetryPolicy;
pub use retry::TxAttempt;
pub use retry::TxOutcome;
pub use transport::UnixSocketTransport;
pub use transport::AnyTransport;
pub use transport::SerialTransport;
pub use transport::TcpTransport;
pub use transport::Transport;

Modules§

cap
Capability bitmap bit positions (PROTOCOL.md §9).
connect
High-level connect() entry points.
discovery
USB device discovery for DongLoRa dongles.
dongle
The user-facing Dongle — a connected, configured, ready-to-TX radio.
errors
Error taxonomy for donglora-client.
retry
TX retry policy + outcome reporting.
session
Internal session plumbing: tag counter, outstanding-tag correlation, background reader task, async event queue.
transport
Async transport abstractions.

Structs§

FlrcConfig
FLRC configuration payload (13 bytes after modulation_id).
FskConfig
FSK / GFSK configuration payload (PROTOCOL.md §10.2).
Info
GET_INFO response payload.
LoRaConfig
LoRa configuration payload (15 bytes after modulation_id).
LrFhssConfig
LR-FHSS configuration payload (10 bytes after modulation_id).
RxPayload
RX event payload (PROTOCOL.md §6.9). Metadata is the 20-byte prefix; data is the OTA packet body (0..=MAX_OTA_PAYLOAD bytes).
SetConfigResult
Payload of OK in response to SET_CONFIG (PROTOCOL.md §6.3).
TxDonePayload
TX_DONE payload (PROTOCOL.md §6.10).
TxFlags
TX flag byte (PROTOCOL.md §6.4).

Enums§

Command
Host-to-device command.
DeviceMessage
Any device→host message, parsed into its semantic form.
ErrorCode
Wire-level error code.
FlrcBitrate
FLRC bitrate enum (PROTOCOL.md §10.4).
FlrcBt
FLRC Gaussian BT-product enum (PROTOCOL.md §10.4).
FlrcCodingRate
FLRC coding rate enum (PROTOCOL.md §10.4).
FlrcPreambleLen
FLRC preamble length enum (PROTOCOL.md §10.4).
LoRaBandwidth
LoRa signal bandwidth enum (PROTOCOL.md §10.1). The small integer is what goes on the wire, NOT the kHz value.
LoRaCodingRate
LoRa coding rate enum (PROTOCOL.md §10.1).
LoRaHeaderMode
LoRa header mode (PROTOCOL.md §10.1).
LrFhssBandwidth
LR-FHSS occupied-bandwidth enum (PROTOCOL.md §10.3).
LrFhssCodingRate
LR-FHSS coding rate enum (PROTOCOL.md §10.3).
LrFhssGrid
LR-FHSS grid selection (PROTOCOL.md §10.3).
Modulation
Any of the four modulation configs, tagged by ModulationId.
ModulationId
One-byte modulation selector (PROTOCOL.md §10). Prefixes every SET_CONFIG payload.
OkPayload
Payload shape carried by an OK frame.
Owner
SET_CONFIG lock owner (PROTOCOL.md §6.3).
RadioChipId
Radio chip identifier (u16, little-endian on the wire).
RxOrigin
Packet origin — over-the-air vs. local-loopback from another client (PROTOCOL.md §6.9, §13.4). In single-client firmware always Ota.
SetConfigResultCode
SET_CONFIG result code (PROTOCOL.md §6.3).
TxResult
TX_DONE result code (PROTOCOL.md §6.10).