Beispiel #1
0
static boolean getconfig_handler(TinyWebServer& web_server)
{
	web_server.send_error_code(200);
	web_server.send_content_type("text/xml");
	web_server.end_headers();
	web_server << IP_Config.toXML();
	return true;
}
Beispiel #2
0
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;
}
Beispiel #3
0
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;
}