Files
swaits 85cb234442
CI / lint (push) Canceled after 0s
CI / test (3.10) (push) Canceled after 0s
CI / test (3.11) (push) Canceled after 0s
CI / test (3.12) (push) Canceled after 0s
CI / test (3.13) (push) Canceled after 0s
CI / publish (push) Canceled after 0s
chore: repoint remaining links at git.swaits.com
Rewrites lingering github.com / *.sr.ht references to this Gitea instance,
translating GitHub and Sourcehut URL shapes to Gitea's (/blob/<ref>/ and
sr.ht /tree/<ref>/item/ -> /src/branch/<ref>/, /tree/<tag> -> /src/tag/<tag>,
/actions/workflows/X -> /actions?workflow=X, /edit/ -> /_edit/).

Left pointing at the old hosts on purpose: pull-request links (PRs were not
migrated), forks that were never migrated, and GitHub-only surfaces Gitea
lacks. OpenPGP identity proofs are untouched by design.
2026-08-31 18:32:05 -06:00

71 lines
1.7 KiB
Markdown

# DongLoRa Python Client
Python client library for talking to a DongLoRa device — either directly
over USB or through the [mux daemon](https://git.swaits.com/donglora/mux-py).
## Install
```
pip install donglora
```
Or with [uv](https://docs.astral.sh/uv/):
```
uv add donglora
```
## Quick Start
```python
import donglora as dl
ser = dl.connect()
dl.send(ser, "SetConfig", config=dl.DEFAULT_CONFIG)
dl.send(ser, "StartRx")
while True:
pkt = dl.recv(ser)
if pkt:
print(pkt["rssi"], pkt["payload"].hex())
```
## Connection Functions
| Function | Description |
|----------|-------------|
| `connect()` | Auto-detect: TCP mux, Unix socket mux, then USB serial |
| `connect_default()` | Convenience wrapper with default timeout |
| `try_connect()` | Like `connect()` but non-blocking — raises if no device found |
| `connect_mux_auto()` | Mux only — never falls back to USB serial |
| `mux_connect()` | Connect via Unix domain socket |
| `mux_tcp_connect()` | Connect via TCP |
## Module Structure
| Module | Contents |
|--------|----------|
| `donglora.protocol` | Wire types, RadioConfig, encode/decode, constants |
| `donglora.codec` | COBS framing |
| `donglora.discovery` | USB device discovery by VID:PID |
| `donglora.transport` | MuxConnection (socket wrapper) |
| `donglora.connect` | Connection auto-detection and mux helpers |
| `donglora.client` | High-level send/recv/validate |
Everything is re-exported from the top-level `donglora` package.
## Dependencies
- `cobs` — COBS framing
- `pyserial` — USB serial communication
Optional extras: `meshcore` (crypto), `orac` (AI bot).
## Development
```
just check # fmt + lint + test
just fmt # format code
just test # run tests
```