@@ -58,6 +58,14 @@ String COMMAND::buffer_tcp;
58
58
extern uint8_t Checksum (const char * line, uint16_t lineSize);
59
59
extern bool sendLine2Serial (String & line, int32_t linenb, int32_t * newlinenb);
60
60
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
+ }
61
69
String COMMAND::get_param (String & cmd_params, const char * id, bool withspace)
62
70
{
63
71
static String parameter;
@@ -356,11 +364,11 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
356
364
// [ESP110]<state>[pwd=<admin password>]
357
365
case 110 :
358
366
parameter = get_param (cmd_params, " " , true );
359
- if (parameter == " on " ) {
367
+ if (parameter == " ON " ) {
360
368
mode = 1 ;
361
- } else if (parameter == " off " ) {
369
+ } else if (parameter == " OFF " ) {
362
370
mode = 0 ;
363
- } else if (parameter == " restart " ) {
371
+ } else if (parameter == " RESTART " ) {
364
372
mode = 2 ;
365
373
} else {
366
374
ESPCOM::println (INCORRECT_CMD_MSG, output, espresponse);
@@ -845,7 +853,7 @@ bool COMMAND::execute_command (int cmd, String cmd_params, tpipe output, level_a
845
853
if (!CONFIG::read_string (EP_HOSTNAME, sbuf, MAX_HOSTNAME_LENGTH) ) {
846
854
ESPCOM::print (" ???" , output, espresponse);
847
855
} else {
848
- ESPCOM::print (sbuf, output, espresponse);
856
+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
849
857
}
850
858
ESPCOM::print (F (" \" ,\" H\" :\" Hostname\" ,\" S\" :\" " ), output, espresponse);
851
859
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
873
881
if (!CONFIG::read_string (EP_STA_SSID, sbuf, MAX_SSID_LENGTH) ) {
874
882
ESPCOM::print (" ???" , output, espresponse);
875
883
} else {
876
- ESPCOM::print (sbuf, output, espresponse);
884
+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
877
885
}
878
886
ESPCOM::print (F (" \" ,\" S\" :\" " ), output, espresponse);
879
887
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
971
979
if (!CONFIG::read_string (EP_AP_SSID, sbuf, MAX_SSID_LENGTH) ) {
972
980
ESPCOM::print (" ???" , output, espresponse);
973
981
} else {
974
- ESPCOM::print (sbuf, output, espresponse);
982
+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
975
983
}
976
984
ESPCOM::print (F (" \" ,\" S\" :\" " ), output, espresponse);
977
985
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
1157
1165
if (!CONFIG::read_string (EP_TIME_SERVER1, sbuf, MAX_DATA_LENGTH) ) {
1158
1166
ESPCOM::print (" ???" , output, espresponse);
1159
1167
} else {
1160
- ESPCOM::print (sbuf, output, espresponse);
1168
+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
1161
1169
}
1162
1170
ESPCOM::print (F (" \" ,\" S\" :\" " ), output, espresponse);
1163
1171
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
1173
1181
if (!CONFIG::read_string (EP_TIME_SERVER2, sbuf, MAX_DATA_LENGTH) ) {
1174
1182
ESPCOM::print (" ???" , output, espresponse);
1175
1183
} else {
1176
- ESPCOM::print (sbuf, output, espresponse);
1184
+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
1177
1185
}
1178
1186
ESPCOM::print (F (" \" ,\" S\" :\" " ), output, espresponse);
1179
1187
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
1189
1197
if (!CONFIG::read_string (EP_TIME_SERVER3, sbuf, MAX_DATA_LENGTH) ) {
1190
1198
ESPCOM::print (" ???" , output, espresponse);
1191
1199
} else {
1192
- ESPCOM::print (sbuf, output, espresponse);
1200
+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
1193
1201
}
1194
1202
ESPCOM::print (F (" \" ,\" S\" :\" " ), output, espresponse);
1195
1203
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
1254
1262
if (!CONFIG::read_string (ESP_NOTIFICATION_SETTINGS, sbuf, MAX_NOTIFICATION_TOKEN_LENGTH) ) {
1255
1263
ESPCOM::print (" ???" , output, espresponse);
1256
1264
} else {
1257
- ESPCOM::print (sbuf, output, espresponse);
1265
+ ESPCOM::print (encodeString ( sbuf) , output, espresponse);
1258
1266
}
1259
1267
ESPCOM::print ( F (" \" ,\" S\" :\" " ), output, espresponse);
1260
1268
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
1513
1521
}
1514
1522
if (!plain) {
1515
1523
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);
1518
1526
if (!plain) {
1519
1527
ESPCOM::print (F (" \" ,\" SIGNAL\" :\" " ), output, espresponse);
1520
1528
} else {
0 commit comments