Add feature development guide and fix ESP-NOW proto generation.

Document UART-to-ESP-NOW flow using Find me; align proto_generate_espnow with uart (python3, -I .).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-19 22:09:24 +02:00
co-authored by Cursor
parent efd6260201
commit 2e88358c53
4 changed files with 367 additions and 7 deletions
+12 -5
View File
@@ -448,11 +448,18 @@ Target: ESP32-S3. Close serial monitor on the UART adapter port before running `
| `proto/*.pb.c/h` | Generated nanopb |
| `CMakeLists.txt` | Sources, `esp_wifi`, drivers, git hash |
## Adding a new UART command
## Adding a new feature (UART → ESP-NOW)
1. Add or extend messages in `uart_messages.proto` and regenerate nanopb.
2. Create `cmd_*.c` with a handler; register with `uart_cmd_register(MessageType_…, handler)`.
3. Decode with `uart_cmd_decode()` / `UART_CMD_REQ()`; reply with `uart_cmd_init_response()` + `uart_cmd_send()`.
4. Extend `goTool` or another host client to send the matching frame.
End-to-end walkthrough (protobuf, master handler, ESP-NOW unicast to slaves, goTool, dashboard) with **Find me** as the worked example:
**[docs/adding-a-feature.md](../docs/adding-a-feature.md)**
Short checklist:
1. Add or extend messages in `uart_messages.proto` (and `esp_now_messages.proto` if slaves are involved); run `make proto_generate` and `make gotool-proto`.
2. Implement device logic in a shared module (e.g. `led_ring.c`), not only in the UART handler.
3. Create `cmd_*.c`, register with `uart_cmd_register()`; decode with `uart_cmd_decode()` / `UART_CMD_REQ()`; reply with `uart_cmd_init_response()` + `uart_cmd_send()`.
4. Master → slave: `esp_now_comm_send_*()` + slave branch in `espnow_recv_cb`.
5. Extend `goTool` (CLI, optional `/api/…` and web UI).
For ESP-NOW-driven PC updates later: map slave state to `ClientInfo` and send `CLIENT_INFO` over UART from the master.