Files
led-controller/main/drv_ota.h
T
jimmyandClaude Opus 5.5 57182188ba feat: port the remaining v1 API to the v2 controller
Profiles seed presets, a default zone and a palette, and clone with their
own copies; deleting a profile removes what it owned. Zones get the v1
list shape, set-current, current, clone and content-fragment. Devices are
keyed by MAC with v1 validation and identify. Patterns: definitions, OTA
file and manifest, upload, driver, and send over ESP-NOW (the led-driver
pattern sources are embedded in the firmware). Pixel outputs get v1
validation and a DDP/Art-Net/sACN test pattern. Sequences, palettes and
settings follow v1 replies and validation, and /ws forwards browser
messages to the drivers.

The resource handlers move out of api.c into res_*.c, patterns.c and
outputs.c. cJSON now allocates from PSRAM: the store had grown enough to
starve internal RAM and abort the mic at boot. /status reports
free_internal.

The Wi-Fi AP and led-tool routes are left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 09:58:17 +13:00

28 lines
1.4 KiB
C

#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "cJSON.h"
#include "esp_err.h"
#include "esp_http_server.h"
// Update led-driver app files (.py) over ESP-NOW. Wire format is documented in
// led-driver/src/espnow_ota.py; tools/driver_ota.py drives a session:
//
// POST /drivers/ota/file?mac=<12hex>[,<12hex>...]|all&sess=<1..65535>&path=<p>&sha=<64hex>
// body: the raw file (0..64 KB). One driver gets the chunks by acked unicast; several get
// one broadcast, then each is asked for its missing chunks and repaired by unicast.
// Reply: {"<mac>":{"result":"same|written|error","code":"...","repaired":n}, ...}
// POST /drivers/ota/commit?mac=...&sess= drivers move their staged files into place and reset
// POST /drivers/ota/abort?mac=...&sess= drivers drop their staged files
//
// mac=all means every ESP-NOW device in the devices collection. One request runs at a time.
esp_err_t drv_ota_register(httpd_handle_t server);
// Send one file the same way from C (macs as above). With commit, drivers that wrote it switch to it
// and reset. Returns the per-driver results (caller owns), or NULL with *err: ESP_ERR_INVALID_STATE
// when an update is running, ESP_ERR_NOT_FOUND with no drivers, ESP_ERR_INVALID_ARG for a bad list,
// ESP_ERR_INVALID_SIZE for a file over 64 KB.
cJSON *drv_ota_send(const char *macs, const char *path, const uint8_t *data, size_t len, bool commit, esp_err_t *err);