Files
swaitsandClaude Opus 4.6 7a9e67ac1c
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
feat!: v0.2.0 — module split, Rust parity, PyPI-ready
Split monolithic __init__.py into six modules matching the Rust client
structure: protocol.py, codec.py, discovery.py, transport.py, connect.py,
client.py. All symbols re-exported from top-level for backwards compat.

New features:
- Ping-on-connect validation (200ms handshake, matches Rust v0.2.0)
- try_connect(), connect_default(), connect_mux_auto(), validate()
- connect() commits to mux when socket exists (no USB fall-through)
- Bandwidth/ErrorCode IntEnums, RadioConfig TypedDict, py.typed marker
- MAX_PAYLOAD, RADIO_CONFIG_SIZE, tag/error constants
- Payload size validation on Transmit
- 46 pytest tests ported from Rust (protocol, codec, client, firmware compat)
- GitHub Actions CI (ruff + pytest on 3.10-3.13 + PyPI publish)
- Strict ruff linting (E, W, F, I, UP, B, C4, ARG, SIM, RUF)

Breaking: package renamed back to donglora (from donglora-python).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 13:33:37 -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://github.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
```