From fa81a986c7ece76f36761896ba303c2fd44dddf2 Mon Sep 17 00:00:00 2001 From: Tester23 <85486843+openshwprojects@users.noreply.github.com> Date: Tue, 7 Jan 2025 00:07:35 +0100 Subject: [PATCH] tre --- src/httpserver/http_fns.c | 106 +++++--------------------------------- src/httpserver/new_http.c | 7 +++ 2 files changed, 20 insertions(+), 93 deletions(-) diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index 6b45c93b9..2b0f110ad 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -1146,6 +1146,7 @@ int http_fn_cfg_mqtt_set(http_request_t* request) { return 0; } +#if ENABLE_HTTP_WEBAPP int http_fn_cfg_webapp(http_request_t* request) { http_setup(request, httpMimeTypeHTML); http_html_start(request, "Set Webapp"); @@ -1177,11 +1178,12 @@ int http_fn_cfg_webapp_set(http_request_t* request) { poststr(request, NULL); return 0; } +#endif - +#if ENABLE_HTTP_PING int http_fn_cfg_ping(http_request_t* request) { char tmpA[128]; int bChanged; @@ -1238,6 +1240,7 @@ int http_fn_cfg_ping(http_request_t* request) { poststr(request, NULL); return 0; } +#endif int http_fn_cfg_wifi(http_request_t* request) { // for a test, show password as well... char tmpA[128]; @@ -1367,6 +1370,7 @@ int http_fn_cfg_wifi(http_request_t* request) { poststr(request, NULL); return 0; } +#if ENABLE_HTTP_NAMES int http_fn_cfg_name(http_request_t* request) { // for a test, show password as well... char tmpA[128]; @@ -1404,7 +1408,7 @@ int http_fn_cfg_name(http_request_t* request) { poststr(request, NULL); return 0; } - +#endif int http_fn_cfg_wifi_set(http_request_t* request) { char tmpA[128]; int bChanged; @@ -1536,97 +1540,7 @@ int http_fn_cfg_mac(http_request_t* request) { return 0; } #endif -// -//int http_fn_flash_read_tool(http_request_t* request) { -// int len = 16; -// int ofs = 1970176; -// int res; -// int rem; -// int now; -// int nowOfs; -// int hex; -// int i; -// char tmpA[128]; -// char tmpB[64]; -// -// http_setup(request, httpMimeTypeHTML); -// http_html_start(request, "Flash read"); -// poststr_h4(request, "Flash Read Tool"); -// if (http_getArg(request->url, "hex", tmpA, sizeof(tmpA))) { -// hex = atoi(tmpA); -// } -// else { -// hex = 0; -// } -// -// if (http_getArg(request->url, "offset", tmpA, sizeof(tmpA)) && -// http_getArg(request->url, "len", tmpB, sizeof(tmpB))) { -// unsigned char buffer[128]; -// len = atoi(tmpB); -// ofs = atoi(tmpA); -// hprintf255(request, "Memory at %i with len %i reads: ", ofs, len); -// poststr(request, "
"); -// -// ///res = bekken_hal_flash_read (ofs, buffer,len); -// //sprintf(tmpA,"Result %i",res); -// // strcat(outbuf,tmpA); -// /// strcat(outbuf,"
"); -// -// nowOfs = ofs; -// rem = len; -// while (1) { -// if (rem > sizeof(buffer)) { -// now = sizeof(buffer); -// } -// else { -// now = rem; -// } -//#if PLATFORM_XR809 -// //uint32_t flash_read(uint32_t flash, uint32_t addr,void *buf, uint32_t size) -//#define FLASH_INDEX_XR809 0 -// res = flash_read(FLASH_INDEX_XR809, nowOfs, buffer, now); -//#elif PLATFORM_BL602 -// -//#elif PLATFORM_W600 || PLATFORM_W800 -// -//#else -// res = bekken_hal_flash_read(nowOfs, buffer, now); -//#endif -// for (i = 0; i < now; i++) { -// unsigned char val = buffer[i]; -// if (!hex && isprint(val)) { -// hprintf255(request, "'%c' ", val); -// } -// else { -// hprintf255(request, "%02X ", val); -// } -// } -// rem -= now; -// nowOfs += now; -// if (rem <= 0) { -// break; -// } -// } -// -// poststr(request, "
"); -// } -// poststr(request, "
"); -// -// poststr(request, "
"); -// -// add_label_numeric_field(request, "Offset", "offset", ofs, ""); -// add_label_numeric_field(request, "Length", "len", len, "
"); -// poststr(request, SUBMIT_AND_END_FORM); -// -// poststr(request, htmlFooterReturnToCfgOrMainPage); -// http_html_end(request); -// poststr(request, NULL); -// return 0; -//} + const char* CMD_GetResultString(commandResult_t r) { if (r == CMD_RES_OK) return "OK"; @@ -2498,12 +2412,18 @@ int http_fn_cfg(http_request_t* request) { postFormAction(request, "cfg_wifi", "Configure WiFi & Web"); postFormAction(request, "cfg_ip", "Configure IP"); postFormAction(request, "cfg_mqtt", "Configure MQTT"); +#if ENABLE_HTTP_NAMES postFormAction(request, "cfg_name", "Configure Names"); +#endif #if ENABLE_HTTP_MAC postFormAction(request, "cfg_mac", "Change MAC"); #endif +#if ENABLE_HTTP_PING postFormAction(request, "cfg_ping", "Ping Watchdog (network lost restarter)"); +#endif +#if ENABLE_HTTP_WEBAPP postFormAction(request, "cfg_webapp", "Configure WebApp"); +#endif postFormAction(request, "ha_cfg", "Home Assistant Configuration"); postFormAction(request, "ota", "OTA (update software by WiFi)"); postFormAction(request, "cmd_tool", "Execute Custom Command"); diff --git a/src/httpserver/new_http.c b/src/httpserver/new_http.c index af5a085a6..e162e4124 100644 --- a/src/httpserver/new_http.c +++ b/src/httpserver/new_http.c @@ -769,11 +769,15 @@ int HTTP_ProcessPacket(http_request_t* request) { if (http_checkUrlBase(urlStr, "cfg_ip")) return http_fn_cfg_ip(request); if (http_checkUrlBase(urlStr, "cfg_mqtt_set")) return http_fn_cfg_mqtt_set(request); +#if ENABLE_HTTP_WEBAPP if (http_checkUrlBase(urlStr, "cfg_webapp")) return http_fn_cfg_webapp(request); if (http_checkUrlBase(urlStr, "cfg_webapp_set")) return http_fn_cfg_webapp_set(request); +#endif if (http_checkUrlBase(urlStr, "cfg_wifi")) return http_fn_cfg_wifi(request); +#if ENABLE_HTTP_NAMES if (http_checkUrlBase(urlStr, "cfg_name")) return http_fn_cfg_name(request); +#endif if (http_checkUrlBase(urlStr, "cfg_wifi_set")) return http_fn_cfg_wifi_set(request); if (http_checkUrlBase(urlStr, "cfg_loglevel_set")) return http_fn_cfg_loglevel_set(request); @@ -799,7 +803,10 @@ int HTTP_ProcessPacket(http_request_t* request) { if (http_checkUrlBase(urlStr, "cfg")) return http_fn_cfg(request); if (http_checkUrlBase(urlStr, "cfg_pins")) return http_fn_cfg_pins(request); +#if ENABLE_HTTP_PING if (http_checkUrlBase(urlStr, "cfg_ping")) return http_fn_cfg_ping(request); +#endif + if (http_checkUrlBase(urlStr, "ota")) return http_fn_ota(request); if (http_checkUrlBase(urlStr, "ota_exec")) return http_fn_ota_exec(request);