#pragma once #include #include #include #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=

&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: {"":{"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);