Skip to content

Commit

Permalink
tre
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Jan 6, 2025
1 parent 43fc465 commit fa81a98
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 93 deletions.
106 changes: 13 additions & 93 deletions src/httpserver/http_fns.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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, "<br>");
//
// ///res = bekken_hal_flash_read (ofs, buffer,len);
// //sprintf(tmpA,"Result %i",res);
// // strcat(outbuf,tmpA);
// /// strcat(outbuf,"<br>");
//
// 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, "<br>");
// }
// poststr(request, "<form action=\"/flash_read_tool\">");
//
// poststr(request, "<input type=\"checkbox\" id=\"hex\" name=\"hex\" value=\"1\"");
// if (hex) {
// poststr(request, " checked");
// }
// poststr(request, "><label for=\"hex\">Show all hex?</label><br>");
//
// add_label_numeric_field(request, "Offset", "offset", ofs, "");
// add_label_numeric_field(request, "Length", "len", len, "<br>");
// 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";
Expand Down Expand Up @@ -2498,12 +2412,18 @@ int http_fn_cfg(http_request_t* request) {
postFormAction(request, "cfg_wifi", "Configure WiFi &amp; 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");
Expand Down
7 changes: 7 additions & 0 deletions src/httpserver/new_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit fa81a98

Please sign in to comment.