From ddad0dec9888620a0300dced14a5d742d0ff4e63 Mon Sep 17 00:00:00 2001 From: mvdbro Date: Wed, 9 Aug 2017 08:05:42 +0200 Subject: [PATCH] Resync --- ArduinoEasy.ino | 3 +++ WebServer.ino | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/ArduinoEasy.ino b/ArduinoEasy.ino index 83881f6..40cd6e9 100644 --- a/ArduinoEasy.ino +++ b/ArduinoEasy.ino @@ -36,6 +36,9 @@ // User specific configuration // ******************************************************************************** + +//#define DEBUG_WEB + // Set default configuration settings if you want (not mandatory) // You can always change these during runtime and save to eeprom // After loading firmware, issue a 'reset' command to load the defaults. diff --git a/WebServer.ino b/WebServer.ino index c953ff8..9f1ca44 100644 --- a/WebServer.ino +++ b/WebServer.ino @@ -17,7 +17,11 @@ void WebServerHandleClient() { char c = client.read(); if (getrequest) request += c; - //Serial.write(c); + + #ifdef DEBUG_WEB + Serial.write(c); + #endif + // if you've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so you can send a reply @@ -29,6 +33,16 @@ void WebServerHandleClient() { webdata += c; } + if (webdata.length() !=0) + webdata = "&" + webdata; + + #ifdef DEBUG_WEB + Serial.print("webdata0:"); + Serial.println(webdata); + Serial.print("len:"); + Serial.println(webdata.length()); + #endif + int pos = request.indexOf("/"); if (pos > 0) request = request.substring(pos + 1); @@ -44,6 +58,12 @@ void WebServerHandleClient() { } webdata = URLDecode(webdata.c_str()); + + #ifdef DEBUG_WEB + Serial.print("webdata1:"); + Serial.println(webdata); + #endif + if (request.startsWith(F(" HTTP")) or request.length() == 0) // root page { addHeader(true, client); @@ -127,7 +147,18 @@ void WebServerHandleClient() { String WebServerarg(String arg) { + #ifdef DEBUG_WEB2 + Serial.print("webdata3:"); + Serial.println(webdata); + #endif + arg = "&" + arg; + + #ifdef DEBUG_WEB2 + Serial.print("arg:"); + Serial.println(arg); + #endif + String returnarg = ""; int pos = webdata.indexOf(arg); if (pos >= 0) @@ -489,8 +520,19 @@ void update_config() { char tmpString[64]; + #ifdef DEBUG_WEB + Serial.print("webdata2:"); + Serial.println(webdata); + #endif + String arg = ""; arg = WebServerarg(F("name")); + + #ifdef DEBUG_WEB + Serial.print("name:"); + Serial.println(arg); + #endif + if (arg[0] != 0) { strncpy(Settings.Name, arg.c_str(), sizeof(Settings.Name)); @@ -1405,7 +1447,7 @@ void addTaskValueSelect(String& str, String name, int choice, byte TaskIndex) void handle_rules(EthernetClient client, String &post) { //if (!isLoggedIn()) return; - String rules = post.substring(6); + String rules = post.substring(7); webdata = ""; if (rules.length() > 0)