static boolean setconfig_handler(TinyWebServer& web_server) { const char* length_str = web_server.get_header_value("Content-Length"); int length = atoi(length_str); uint32_t start_time = millis(); StringParse buf; Client& client = web_server.get_client(); if (length <= 0) return true; while (buf.length() < length && client.connected() && (millis() - start_time < 30000)) { if (!client.available()) continue; buf += client.readString(); } IP_Config.ParseConfig(buf); IP_Config.SaveConfig(); return true; }
static boolean config_handler(TinyWebServer& web_server) { web_server.send_error_code(200); web_server.end_headers(); const char* length_str = web_server.get_header_value("Content-Length"); int length = atoi(length_str); uint32_t start_time = millis(); StringParse buf; EthernetClient client = web_server.get_client(); while (buf.length() < length && client.connected() && (millis() - start_time < 30000)) { if (!client.available()) continue; buf += client.readString(); } ParseConfig(buf); IP_Config.SaveConfig(); main_page(client, F("<font color='green'>IP Config saved</font>")); return true; }