Skip to content

Commit

Permalink
global.h: add debug_webui and modify webui debug output
Browse files Browse the repository at this point in the history
add a variable debug_webui and modify existing debug code to make it
configurable
  • Loading branch information
madmartin committed Jun 24, 2018
1 parent 58f8a4a commit 3a73772
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Jarolift_MQTT.ino
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ String getContentType(String filename) {
// send the right file to the client (if it exists)
//####################################################################
bool handleFileRead(String path) {
Serial.println("handleFileRead: " + path);
if (debug_webui) Serial.println("handleFileRead: " + path);
if (path.endsWith("/")) path += "index.html"; // If a folder is requested, send the index file
String contentType = getContentType(path); // Get the MIME type
if (SPIFFS.exists(path)) { // If the file exists
Expand All @@ -291,7 +291,7 @@ bool handleFileRead(String path) {
file.close(); // Then close the file again
return true;
}
Serial.println("\tFile Not Found");
if (debug_webui) Serial.println("\tFile Not Found");
return false; // If the file doesn't exist, return false
} // bool handleFileRead

Expand Down
1 change: 1 addition & 0 deletions global.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ String web_log_message[NUM_WEB_LOG_MESSAGES];
int web_log_message_count = 0;

boolean debug_mqtt = true;
boolean debug_webui = false;

struct strConfig {
uint16_t cfgVersion;
Expand Down
10 changes: 6 additions & 4 deletions html_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
// API call to get data or execute commands via WebIf
//####################################################################
void html_api(){
Serial.printf("html_api server.args()=%d \n",server.args());
if (debug_webui) Serial.printf("html_api server.args()=%d \n",server.args());
if (server.args() > 0 )
{
// get server args from HTML POST
String cmd = "";
int channel;
String channel_name = "";
for ( uint8_t i = 0; i < server.args(); i++ ) {
Serial.printf("server.argName(%d) == %s\n",i,server.argName(i).c_str());
Serial.printf(" urldecode: %s\n",urldecode(server.arg(i)).c_str());
if (debug_webui) {
for ( uint8_t i = 0; i < server.args(); i++ ) {
Serial.printf("server.argName(%d) == %s\n",i,server.argName(i).c_str());
Serial.printf(" urldecode: %s\n",urldecode(server.arg(i)).c_str());
}
}
for ( uint8_t i = 0; i < server.args(); i++ ) {
if (server.argName(i) == "cmd") cmd = urldecode(server.arg(i));
Expand Down

0 comments on commit 3a73772

Please sign in to comment.