# spoonnewman/servo-lora architecture

> Architecture diagram of the GitHub repository spoonnewman/servo-lora, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/spoonnewman/servo-lora
- Repository: https://github.com/spoonnewman/servo-lora

## Overview

This is a single-file LoRa device bridge: it sends periodic telemetry to a base station and receives encrypted messages to dispatch commands, OTA triggers, configuration, and beacon updates. The internal flow covers radio setup, encrypted framing, and message dispatch. Configuration and beacon handling are stubs; OTA currently logs rather than starting an updater. The graph reflects the supplied source only.

Main entry points: [`src/main.rs`](https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs) (Message dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_transport["Radio transport"]
  node_radio["LoRa radio"]
  node_main["Radio main loop<br/>[main.rs]"]
end

subgraph group_messaging["Message handling"]
  node_telemetry["Telemetry task<br/>[main.rs]"]
  node_protocol["Frame and message types<br/>[main.rs]"]
  node_crypto["Encrypted framing<br/>[main.rs]"]
  node_dispatch["Message dispatch<br/>[main.rs]"]
  node_ack["ACK sender<br/>[main.rs]"]
end

subgraph group_actions["Device actions"]
  node_command["Command handler<br/>[main.rs]"]
  node_ota["OTA trigger<br/>[main.rs]"]
  node_config["Config handling<br/>[main.rs]"]
  node_beacon["Beacon handling<br/>[main.rs]"]
end

node_base(("Base station"))
node_control["Local control API"]

node_base -->|"sends packets"| node_radio
node_radio -->|"transmits packets"| node_base
node_main -->|"initializes and polls"| node_radio
node_radio -->|"returns received packet"| node_main
node_main -->|"spawns task"| node_telemetry
node_telemetry -->|"builds telemetry frame"| node_protocol
node_telemetry -->|"sends frame"| node_crypto
node_main -->|"decrypts packet"| node_crypto
node_crypto -->|"returns plaintext"| node_main
node_main -->|"decodes and dispatches"| node_dispatch
node_dispatch -->|"decodes payload types"| node_protocol
node_dispatch -->|"handles command"| node_command
node_dispatch -->|"triggers OTA"| node_ota
node_dispatch -->|"routes config"| node_config
node_dispatch -->|"routes beacon"| node_beacon
node_command -->|"posts action"| node_control
node_dispatch -->|"sends acknowledgement"| node_ack
node_ack -->|"builds ACK frame"| node_protocol
node_ack -->|"encrypts and sends"| node_crypto
node_crypto -->|"transmits encrypted packet"| node_radio

click node_main "https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs"
click node_telemetry "https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs"
click node_protocol "https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs"
click node_crypto "https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs"
click node_dispatch "https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs"
click node_ack "https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs"
click node_command "https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs"
click node_ota "https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs"
click node_config "https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs"
click node_beacon "https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_radio,node_main toneBlue
class node_telemetry,node_protocol,node_crypto,node_dispatch,node_ack toneAmber
class node_command,node_ota,node_config,node_beacon,node_control toneMint
class node_base toneIndigo
```

## Components

### Radio transport

- **LoRa radio**
- [Radio main loop](https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs): `src/main.rs`

### Message handling

- [Telemetry task](https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs): `src/main.rs`
- [Frame and message types](https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs): `src/main.rs`
- [Encrypted framing](https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs): `src/main.rs`
- [Message dispatch](https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs): `src/main.rs`
- [ACK sender](https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs): `src/main.rs`

### Device actions

- [Command handler](https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs): `src/main.rs`
- [OTA trigger](https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs): `src/main.rs`
- [Config handling](https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs): `src/main.rs`
- [Beacon handling](https://github.com/spoonnewman/servo-lora/blob/main/src/main.rs): `src/main.rs`

### Other components

- **Base station**
- **Local control API**

## Connections

- Base station → LoRa radio: sends packets
- LoRa radio → Base station: transmits packets
- Radio main loop → LoRa radio: initializes and polls
- LoRa radio → Radio main loop: returns received packet
- Radio main loop → Telemetry task: spawns task
- Telemetry task → Frame and message types: builds telemetry frame
- Telemetry task → Encrypted framing: sends frame
- Radio main loop → Encrypted framing: decrypts packet
- Encrypted framing → Radio main loop: returns plaintext
- Radio main loop → Message dispatch: decodes and dispatches
- Message dispatch → Frame and message types: decodes payload types
- Message dispatch → Command handler: handles command
- Message dispatch → OTA trigger: triggers OTA
- Message dispatch → Config handling: routes config
- Message dispatch → Beacon handling: routes beacon
- Command handler → Local control API: posts action
- Message dispatch → ACK sender: sends acknowledgement
- ACK sender → Frame and message types: builds ACK frame
- ACK sender → Encrypted framing: encrypts and sends
- Encrypted framing → LoRa radio: transmits encrypted packet
