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>
This commit is contained in:
1 parent
4b42391a46
commit
57182188ba
30 files changed
+2846
-425
No files matched your search
@@ -6,6 +6,8 @@
|
||||
#include <string.h>
|
||||
#include "cJSON.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_random.h"
|
||||
#include "mbedtls/sha256.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
@@ -452,6 +454,43 @@ static esp_err_t ota_post_handler(httpd_req_t *req)
|
||||
return r;
|
||||
}
|
||||
|
||||
cJSON *drv_ota_send(const char *macs, const char *path, const uint8_t *data, size_t len, bool commit, esp_err_t *err)
|
||||
{
|
||||
static target_t ts[MAX_MACS];
|
||||
if (len > MAX_FILE || strlen(path) > MAX_PATH) {
|
||||
*err = ESP_ERR_INVALID_SIZE;
|
||||
return NULL;
|
||||
}
|
||||
if (!s_busy || xSemaphoreTake(s_busy, 0) != pdTRUE) {
|
||||
*err = ESP_ERR_INVALID_STATE;
|
||||
return NULL;
|
||||
}
|
||||
cJSON *out = NULL;
|
||||
int n = parse_targets(macs, ts);
|
||||
if (n <= 0) {
|
||||
*err = n < 0 ? ESP_ERR_INVALID_ARG : ESP_ERR_NOT_FOUND;
|
||||
} else {
|
||||
uint8_t sha[32];
|
||||
mbedtls_sha256(data, len, sha, 0);
|
||||
uint16_t sess = (esp_random() % 0xFFFF) + 1;
|
||||
drain_status();
|
||||
ESP_LOGI(TAG, "%s (%u B) to %d driver(s), session %u", path, (unsigned)len, n, sess);
|
||||
transfer(ts, n, sess, path, sha, data, len);
|
||||
out = results(ts, n, true);
|
||||
if (commit) {
|
||||
uint8_t pkt[4] = { WIRE_MAGIC, OP_COMMIT, sess & 255, sess >> 8 };
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (ts[i].state == C_OK) {
|
||||
command(ts[i].mac, pkt, sizeof(pkt), sess, OP_COMMIT, BEGIN_MS, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
*err = ESP_OK;
|
||||
}
|
||||
xSemaphoreGive(s_busy);
|
||||
return out;
|
||||
}
|
||||
|
||||
esp_err_t drv_ota_register(httpd_handle_t server)
|
||||
{
|
||||
s_status_q = xQueueCreate(16, sizeof(status_t));
|
||||
|
||||
Reference in new issue
Block a user