diff --git a/esp3d/command.cpp b/esp3d/command.cpp index 59fd652c..b7001ca6 100644 --- a/esp3d/command.cpp +++ b/esp3d/command.cpp @@ -58,6 +58,14 @@ String COMMAND::buffer_tcp; extern uint8_t Checksum(const char * line, uint16_t lineSize); extern bool sendLine2Serial (String & line, int32_t linenb, int32_t* newlinenb); +const char * encodeString(const char * s){ + static String tmp; + tmp = s; + while(tmp.indexOf("'")!=-1)tmp.replace("'", "'"); + while(tmp.indexOf("\"")!=-1)tmp.replace("\"", """); + if (tmp =="") tmp=" "; + return tmp.c_str(); +} String COMMAND::get_param (String & cmd_params, const char * id, bool withspace) { static String parameter; @@ -356,11 +364,11 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a //[ESP110][pwd=] case 110: parameter = get_param (cmd_params, "", true); - if (parameter == "on") { + if (parameter == "ON") { mode = 1; - } else if (parameter == "off") { + } else if (parameter == "OFF") { mode = 0; - } else if (parameter == "restart") { + } else if (parameter == "RESTART") { mode = 2; } else { ESPCOM::println (INCORRECT_CMD_MSG, output, espresponse); @@ -845,7 +853,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a if (!CONFIG::read_string (EP_HOSTNAME, sbuf, MAX_HOSTNAME_LENGTH) ) { ESPCOM::print ("???", output, espresponse); } else { - ESPCOM::print (sbuf, output, espresponse); + ESPCOM::print (encodeString(sbuf), output, espresponse); } ESPCOM::print (F ("\",\"H\":\"Hostname\" ,\"S\":\""), output, espresponse); ESPCOM::print ( (const char *) CONFIG::intTostr (MAX_HOSTNAME_LENGTH), output, espresponse); @@ -873,7 +881,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a if (!CONFIG::read_string (EP_STA_SSID, sbuf, MAX_SSID_LENGTH) ) { ESPCOM::print ("???", output, espresponse); } else { - ESPCOM::print (sbuf, output, espresponse); + ESPCOM::print (encodeString(sbuf), output, espresponse); } ESPCOM::print (F ("\",\"S\":\""), output, espresponse); ESPCOM::print ( (const char *) CONFIG::intTostr (MAX_SSID_LENGTH), output, espresponse); @@ -971,7 +979,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a if (!CONFIG::read_string (EP_AP_SSID, sbuf, MAX_SSID_LENGTH) ) { ESPCOM::print ("???", output, espresponse); } else { - ESPCOM::print (sbuf, output, espresponse); + ESPCOM::print (encodeString(sbuf), output, espresponse); } ESPCOM::print (F ("\",\"S\":\""), output, espresponse); ESPCOM::print ( (const char *) CONFIG::intTostr (MAX_SSID_LENGTH), output, espresponse); @@ -1157,7 +1165,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a if (!CONFIG::read_string (EP_TIME_SERVER1, sbuf, MAX_DATA_LENGTH) ) { ESPCOM::print ("???", output, espresponse); } else { - ESPCOM::print (sbuf, output, espresponse); + ESPCOM::print (encodeString(sbuf), output, espresponse); } ESPCOM::print (F ("\",\"S\":\""), output, espresponse); ESPCOM::print ( (const char *) CONFIG::intTostr (MAX_DATA_LENGTH), output, espresponse); @@ -1173,7 +1181,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a if (!CONFIG::read_string (EP_TIME_SERVER2, sbuf, MAX_DATA_LENGTH) ) { ESPCOM::print ("???", output, espresponse); } else { - ESPCOM::print (sbuf, output, espresponse); + ESPCOM::print (encodeString(sbuf), output, espresponse); } ESPCOM::print (F ("\",\"S\":\""), output, espresponse); ESPCOM::print ( (const char *) CONFIG::intTostr (MAX_DATA_LENGTH), output, espresponse); @@ -1189,7 +1197,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a if (!CONFIG::read_string (EP_TIME_SERVER3, sbuf, MAX_DATA_LENGTH) ) { ESPCOM::print ("???", output, espresponse); } else { - ESPCOM::print (sbuf, output, espresponse); + ESPCOM::print (encodeString(sbuf), output, espresponse); } ESPCOM::print (F ("\",\"S\":\""), output, espresponse); ESPCOM::print ( (const char *) CONFIG::intTostr (MAX_DATA_LENGTH), output, espresponse); @@ -1254,7 +1262,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a if (!CONFIG::read_string (ESP_NOTIFICATION_SETTINGS, sbuf, MAX_NOTIFICATION_TOKEN_LENGTH) ) { ESPCOM::print ("???", output, espresponse); } else { - ESPCOM::print (sbuf, output, espresponse); + ESPCOM::print (encodeString(sbuf), output, espresponse); } ESPCOM::print ( F("\",\"S\":\""), output, espresponse); ESPCOM::print ( (const char *) CONFIG::intTostr (MAX_NOTIFICATION_SETTINGS_LENGTH), output, espresponse); @@ -1513,8 +1521,8 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a } if (!plain) { ESPCOM::print (F ("{\"SSID\":\""), output, espresponse); - } - ESPCOM::print (WiFi.SSID (i).c_str(), output, espresponse); + ESPCOM::print (encodeString(WiFi.SSID (i).c_str()), output, espresponse); + } else ESPCOM::print (WiFi.SSID (i).c_str(), output, espresponse); if (!plain) { ESPCOM::print (F ("\",\"SIGNAL\":\""), output, espresponse); } else { diff --git a/esp3d/config.h b/esp3d/config.h index 844405ff..50b7ae75 100644 --- a/esp3d/config.h +++ b/esp3d/config.h @@ -19,7 +19,7 @@ */ //version and sources location -#define FW_VERSION "2.1.1.b7" +#define FW_VERSION "2.1.1.b8" #define REPOSITORY "https://github.com/luc-github/ESP3D" //Customize ESP3D ////////////////////////////////////////////////////////////////////////