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
+29
-3
@@ -6,6 +6,7 @@
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_app_format.h"
|
||||
#include "esp_system.h"
|
||||
#include <string.h>
|
||||
#include "esp_timer.h"
|
||||
|
||||
static const char *TAG = "ota";
|
||||
@@ -140,14 +141,35 @@ static esp_err_t ota_get_handler(httpd_req_t *req)
|
||||
{
|
||||
const esp_partition_t *run = esp_ota_get_running_partition();
|
||||
const esp_app_desc_t *app = esp_app_get_description();
|
||||
char buf[256];
|
||||
// The build date is only recompiled with its own file, so the ELF hash is what tells two builds apart
|
||||
char sha[17];
|
||||
for (int i = 0; i < 8; i++) {
|
||||
snprintf(sha + 2 * i, 3, "%02x", app->app_elf_sha256[i]);
|
||||
}
|
||||
char buf[288];
|
||||
snprintf(buf, sizeof(buf),
|
||||
"{\"partition\":\"%s\",\"version\":\"%s\",\"built\":\"%s %s\",\"idf\":\"%s\"}",
|
||||
run ? run->label : "?", app->version, app->date, app->time, app->idf_ver);
|
||||
"{\"partition\":\"%s\",\"version\":\"%s\",\"built\":\"%s %s\",\"idf\":\"%s\",\"sha\":\"%s\"}",
|
||||
run ? run->label : "?", app->version, app->date, app->time, app->idf_ver, sha);
|
||||
httpd_resp_set_type(req, "application/json");
|
||||
return httpd_resp_sendstr(req, buf);
|
||||
}
|
||||
|
||||
static esp_err_t reboot_post_handler(httpd_req_t *req)
|
||||
{
|
||||
ESP_LOGI(TAG, "reboot requested");
|
||||
httpd_resp_set_type(req, "application/json");
|
||||
httpd_resp_sendstr(req, "{\"message\":\"rebooting\"}");
|
||||
|
||||
static esp_timer_handle_t t;
|
||||
const esp_timer_create_args_t args = { .callback = reboot_cb, .name = "reboot" };
|
||||
if (esp_timer_create(&args, &t) == ESP_OK) {
|
||||
esp_timer_start_once(t, 500 * 1000);
|
||||
} else {
|
||||
esp_restart();
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t ota_register(httpd_handle_t server)
|
||||
{
|
||||
const httpd_uri_t post = { .uri = "/ota", .method = HTTP_POST, .handler = ota_post_handler };
|
||||
@@ -156,5 +178,9 @@ esp_err_t ota_register(httpd_handle_t server)
|
||||
if (err == ESP_OK) {
|
||||
err = httpd_register_uri_handler(server, &get);
|
||||
}
|
||||
const httpd_uri_t reboot = { .uri = "/reboot", .method = HTTP_POST, .handler = reboot_post_handler };
|
||||
if (err == ESP_OK) {
|
||||
err = httpd_register_uri_handler(server, &reboot);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
Reference in new issue
Block a user