Add admin serial settings view

This commit is contained in:
2026-09-07 20:12:33 +02:00
parent c73674cda2
commit 5a2aa0d4d8
20 changed files with 612 additions and 25 deletions
+30
View File
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-3.0-only */
/* Deliberately isolated dependency on the installed IDF HTTPD layout. */
#include "web_httpd_adapter.h"
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "esp_idf_version.h"
@@ -104,3 +105,32 @@ bool web_httpd_unread_body(httpd_req_t *request)
const struct httpd_req_aux *aux = request->aux;
return aux && aux->remaining_len != 0;
}
esp_err_t web_httpd_register_optional_get(httpd_handle_t server, const httpd_uri_t *uri)
{
struct httpd_data *hd = server;
if (!hd || !uri || !uri->uri || !uri->handler || uri->method != HTTP_GET ||
uri->is_websocket || uri->supported_subprotocol || hd->config.uri_match_fn)
return ESP_ERR_INVALID_ARG;
size_t length = 0;
while (length < 128 && uri->uri[length]) ++length;
if (!length || length == 128) return ESP_ERR_INVALID_ARG;
int slot = -1;
for (unsigned i = 0; i < hd->config.max_uri_handlers; ++i) {
if (!hd->hd_calls[i]) { if (slot < 0) slot = (int)i; }
else if (!strcmp(hd->hd_calls[i]->uri, uri->uri) && hd->hd_calls[i]->method == HTTP_GET)
return ESP_ERR_INVALID_STATE;
}
if (slot < 0) return ESP_ERR_NO_MEM;
/* IDF 5.5.0 publishes its descriptor before strdup; strdup failure leaves a
* freed hd_calls entry. Optional registration must leave the table intact. */
httpd_uri_t *copy = malloc(sizeof(*copy));
if (!copy) return ESP_ERR_NO_MEM;
char *name = malloc(length + 1);
if (!name) { free(copy); return ESP_ERR_NO_MEM; }
memcpy(name, uri->uri, length + 1);
*copy = *uri;
copy->uri = name;
hd->hd_calls[slot] = copy;
return ESP_OK;
}