feat(v2): move web UI into v2, remove legacy MicroPython app
Move the web assets and templates under v2/web, drop the old src/, lib/ and scripts, and update firmware, tools, docs and db files. Add the audio page, LED test scripts and VPN autoconnect script. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6c16998691
commit
71bd320661
193 files changed
+5605
-18860
No files matched your search
@@ -198,6 +198,47 @@ static esp_err_t handle_profile_action(httpd_req_t *req, const char *id, const c
|
||||
return not_implemented(req, action);
|
||||
}
|
||||
|
||||
// Settings a driver keeps in its own settings.json and takes from a device_config message
|
||||
static const char *const DEVICE_CONFIG_KEYS[] = { "max_brightness", "num_leds", "color_order", "startup_mode", "reversed" };
|
||||
|
||||
// The driver settings present in a device update, or NULL when it has none. Caller deletes the result.
|
||||
static cJSON *device_config_from(const cJSON *body)
|
||||
{
|
||||
cJSON *dc = NULL;
|
||||
for (size_t i = 0; i < sizeof(DEVICE_CONFIG_KEYS) / sizeof(DEVICE_CONFIG_KEYS[0]); i++) {
|
||||
const cJSON *v = cJSON_GetObjectItem(body, DEVICE_CONFIG_KEYS[i]);
|
||||
if (!v || cJSON_IsNull(v)) {
|
||||
continue;
|
||||
}
|
||||
if (!dc) {
|
||||
dc = cJSON_CreateObject();
|
||||
}
|
||||
cJSON_AddItemToObject(dc, DEVICE_CONFIG_KEYS[i], cJSON_Duplicate(v, true));
|
||||
}
|
||||
return dc;
|
||||
}
|
||||
|
||||
// Send changed settings to an ESP-NOW driver; takes ownership of dc
|
||||
static esp_err_t push_device_config(const cJSON *dev, cJSON *dc)
|
||||
{
|
||||
const cJSON *tr = cJSON_GetObjectItem(dev, "transport"), *addr = cJSON_GetObjectItem(dev, "address");
|
||||
if (!cJSON_IsString(tr) || strcmp(tr->valuestring, "espnow") || !cJSON_IsString(addr)) {
|
||||
cJSON_Delete(dc);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
cJSON *msg = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(msg, "v", "1");
|
||||
cJSON_AddItemToObject(msg, "device_config", dc);
|
||||
cJSON_AddTrueToObject(msg, "save");
|
||||
cJSON *messages = cJSON_CreateArray(), *targets = cJSON_CreateArray();
|
||||
cJSON_AddItemToArray(messages, msg);
|
||||
cJSON_AddItemToArray(targets, cJSON_CreateString(addr->valuestring));
|
||||
esp_err_t err = engine_push(messages, targets);
|
||||
cJSON_Delete(messages);
|
||||
cJSON_Delete(targets);
|
||||
return err;
|
||||
}
|
||||
|
||||
static esp_err_t collection_handler_inner(httpd_req_t *req)
|
||||
{
|
||||
char seg[3][64];
|
||||
@@ -425,9 +466,13 @@ static esp_err_t collection_handler_inner(httpd_req_t *req)
|
||||
if (!body) {
|
||||
return ESP_OK;
|
||||
}
|
||||
cJSON *dev_cfg = !strcmp(coll, "device") ? device_config_from(body) : NULL;
|
||||
merge(rec, body);
|
||||
cJSON_Delete(body);
|
||||
store_save(coll);
|
||||
if (dev_cfg) {
|
||||
push_device_config(rec, dev_cfg); // before the group resend: a second message right behind another may not be delivered
|
||||
}
|
||||
if (!strcmp(coll, "zone") || !strcmp(coll, "device")) {
|
||||
engine_groups_changed();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user