@@ -58,6 +58,14 @@ String COMMAND::buffer_tcp;
5858extern uint8_t Checksum (const char * line, uint16_t lineSize);
5959extern bool sendLine2Serial (String & line, int32_t linenb, int32_t * newlinenb);
6060
61+ const char * encodeString (const char * s){
62+ static String tmp;
63+ tmp = s;
64+ while (tmp.indexOf (" '" )!=-1 )tmp.replace (" '" , " '" );
65+ while (tmp.indexOf (" \" " )!=-1 )tmp.replace (" \" " , " "" );
66+ if (tmp ==" " ) tmp=" " ;
67+ return tmp.c_str ();
68+ }
6169String COMMAND::get_param (String & cmd_params, const char * id, bool withspace)
6270{
6371 static String parameter;
@@ -356,11 +364,11 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
356364 // [ESP110]<state>[pwd=<admin password>]
357365 case 110 :
358366 parameter = get_param (cmd_params, " " , true );
359- if (parameter == " on " ) {
367+ if (parameter == " ON " ) {
360368 mode = 1 ;
361- } else if (parameter == " off " ) {
369+ } else if (parameter == " OFF " ) {
362370 mode = 0 ;
363- } else if (parameter == " restart " ) {
371+ } else if (parameter == " RESTART " ) {
364372 mode = 2 ;
365373 } else {
366374 ESPCOM::println (INCORRECT_CMD_MSG, output, espresponse);
@@ -845,7 +853,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
845853 if (!CONFIG::read_string (EP_HOSTNAME, sbuf, MAX_HOSTNAME_LENGTH) ) {
846854 ESPCOM::print (" ???" , output, espresponse);
847855 } else {
848- ESPCOM::print (sbuf, output, espresponse);
856+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
849857 }
850858 ESPCOM::print (F (" \" ,\" H\" :\" Hostname\" ,\" S\" :\" " ), output, espresponse);
851859 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
873881 if (!CONFIG::read_string (EP_STA_SSID, sbuf, MAX_SSID_LENGTH) ) {
874882 ESPCOM::print (" ???" , output, espresponse);
875883 } else {
876- ESPCOM::print (sbuf, output, espresponse);
884+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
877885 }
878886 ESPCOM::print (F (" \" ,\" S\" :\" " ), output, espresponse);
879887 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
971979 if (!CONFIG::read_string (EP_AP_SSID, sbuf, MAX_SSID_LENGTH) ) {
972980 ESPCOM::print (" ???" , output, espresponse);
973981 } else {
974- ESPCOM::print (sbuf, output, espresponse);
982+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
975983 }
976984 ESPCOM::print (F (" \" ,\" S\" :\" " ), output, espresponse);
977985 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
11571165 if (!CONFIG::read_string (EP_TIME_SERVER1, sbuf, MAX_DATA_LENGTH) ) {
11581166 ESPCOM::print (" ???" , output, espresponse);
11591167 } else {
1160- ESPCOM::print (sbuf, output, espresponse);
1168+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
11611169 }
11621170 ESPCOM::print (F (" \" ,\" S\" :\" " ), output, espresponse);
11631171 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
11731181 if (!CONFIG::read_string (EP_TIME_SERVER2, sbuf, MAX_DATA_LENGTH) ) {
11741182 ESPCOM::print (" ???" , output, espresponse);
11751183 } else {
1176- ESPCOM::print (sbuf, output, espresponse);
1184+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
11771185 }
11781186 ESPCOM::print (F (" \" ,\" S\" :\" " ), output, espresponse);
11791187 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
11891197 if (!CONFIG::read_string (EP_TIME_SERVER3, sbuf, MAX_DATA_LENGTH) ) {
11901198 ESPCOM::print (" ???" , output, espresponse);
11911199 } else {
1192- ESPCOM::print (sbuf, output, espresponse);
1200+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
11931201 }
11941202 ESPCOM::print (F (" \" ,\" S\" :\" " ), output, espresponse);
11951203 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
12541262 if (!CONFIG::read_string (ESP_NOTIFICATION_SETTINGS, sbuf, MAX_NOTIFICATION_TOKEN_LENGTH) ) {
12551263 ESPCOM::print (" ???" , output, espresponse);
12561264 } else {
1257- ESPCOM::print (sbuf, output, espresponse);
1265+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
12581266 }
12591267 ESPCOM::print ( F (" \" ,\" S\" :\" " ), output, espresponse);
12601268 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
15131521 }
15141522 if (!plain) {
15151523 ESPCOM::print (F (" {\" SSID\" :\" " ), output, espresponse);
1516- }
1517- ESPCOM::print (WiFi.SSID (i).c_str (), output, espresponse);
1524+ ESPCOM::print ( encodeString (WiFi. SSID (i). c_str ()), output, espresponse);
1525+ } else ESPCOM::print (WiFi.SSID (i).c_str (), output, espresponse);
15181526 if (!plain) {
15191527 ESPCOM::print (F (" \" ,\" SIGNAL\" :\" " ), output, espresponse);
15201528 } else {
0 commit comments