diff --git a/esp8266_deauther/Names.cpp b/esp8266_deauther/Names.cpp index fa9dfd1..f85e4f7 100644 --- a/esp8266_deauther/Names.cpp +++ b/esp8266_deauther/Names.cpp @@ -38,7 +38,7 @@ void Names::save(bool force) { String buf = String(OPEN_BRACKET); // [ if (!writeFile(FILE_PATH, buf)) { - prnt(N_ERROR_SAVING); + prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; } @@ -61,7 +61,7 @@ void Names::save(bool force) { if(buf.length() >= 1024){ if (!appendFile(FILE_PATH, buf)) { - prnt(N_ERROR_SAVING); + prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; } @@ -73,7 +73,7 @@ void Names::save(bool force) { buf += String(CLOSE_BRACKET); // ] if (!appendFile(FILE_PATH, buf)) { - prnt(N_ERROR_SAVING); + prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; } diff --git a/esp8266_deauther/SSIDs.cpp b/esp8266_deauther/SSIDs.cpp index 49d7d64..eb9ce40 100644 --- a/esp8266_deauther/SSIDs.cpp +++ b/esp8266_deauther/SSIDs.cpp @@ -42,7 +42,7 @@ void SSIDs::save(bool force) { buf += String(DOUBLEQUOTES) + str(SS_JSON_SSIDS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + String(OPEN_BRACKET); // "ssids":[ if (!writeFile(FILE_PATH, buf)) { - prnt(SS_ERROR_SAVING); + prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; } @@ -61,7 +61,7 @@ void SSIDs::save(bool force) { if(buf.length() >= 1024){ if (!appendFile(FILE_PATH, buf)) { - prnt(SS_ERROR_SAVING); + prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; } @@ -73,7 +73,7 @@ void SSIDs::save(bool force) { buf += String(CLOSE_BRACKET) + String(CLOSE_CURLY_BRACKET); // ]} if (!appendFile(FILE_PATH, buf)) { - prnt(SS_ERROR_SAVING); + prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; } diff --git a/esp8266_deauther/Scan.cpp b/esp8266_deauther/Scan.cpp index bc4b08d..86d8208 100644 --- a/esp8266_deauther/Scan.cpp +++ b/esp8266_deauther/Scan.cpp @@ -253,7 +253,7 @@ void Scan::save(bool force) { String buf = String(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SC_JSON_APS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + String(OPEN_BRACKET); // {"aps":[ if(!writeFile(FILE_PATH, buf)) { // overwrite old file - prnt(SC_ERROR_SAVING); + prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; } @@ -274,7 +274,7 @@ void Scan::save(bool force) { if(buf.length() >= 1024){ if(!appendFile(FILE_PATH, buf)) { - prnt(SC_ERROR_SAVING); + prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; } @@ -300,7 +300,7 @@ void Scan::save(bool force) { if(buf.length() >= 1024){ if(!appendFile(FILE_PATH, buf)) { - prnt(SC_ERROR_SAVING); + prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; } @@ -312,7 +312,7 @@ void Scan::save(bool force) { buf += String(CLOSE_BRACKET) + String(CLOSE_CURLY_BRACKET); // ]} if(!appendFile(FILE_PATH, buf)) { - prnt(SC_ERROR_SAVING); + prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; } diff --git a/esp8266_deauther/SerialInterface.cpp b/esp8266_deauther/SerialInterface.cpp index 37170e9..f690c36 100644 --- a/esp8266_deauther/SerialInterface.cpp +++ b/esp8266_deauther/SerialInterface.cpp @@ -789,17 +789,22 @@ void SerialInterface::runCommand(String input) { // ===== WRITE ==== // // write else if (list->size() >= 3 && eqlsCMD(0, CLI_WRITE)) { - String tmp = String(); - for (int i = 2; i < list->size(); i++) { - tmp += list->get(i); - if (i < list->size() - 1) tmp += SPACE; + String path = list->get(1); + String buf = String(); + + int listSize = list->size(); + for (int i = 2; i < listSize; i++) { + buf += list->get(i); + if (i < listSize - 1) buf += SPACE; } + prnt(CLI_WRITTEN); - prnt(tmp); + prnt(buf); prnt(CLI_TO); prntln(list->get(1)); - tmp += NEWLINE; - appendFile(list->get(1), tmp); + + buf += NEWLINE; + appendFile(path, buf); } // ===== REPLACE ==== // diff --git a/esp8266_deauther/language.h b/esp8266_deauther/language.h index e2c9de8..ccc6a73 100644 --- a/esp8266_deauther/language.h +++ b/esp8266_deauther/language.h @@ -473,7 +473,6 @@ static const char S_DISPLAY_TIMEOUT[] PROGMEM = "displayTimeout"; static const char S_SETTINGS_LOADED[] PROGMEM = "Settings loaded from "; static const char S_SETTINGS_RESETED[] PROGMEM = "Settings reseted"; static const char S_SETTINGS_SAVED[] PROGMEM = "Settings saved in "; -static const char S_ERROR_SAVING[] PROGMEM = "ERROR: saving "; static const char S_SETTINGS_HEADER[] PROGMEM = "[========== Settings ==========]"; static const char S_ERROR_VERSION[] PROGMEM = "Sorry, you can't change the version number"; static const char S_ERROR_NOT_FOUND[] PROGMEM = "ERROR: No setting found for "; @@ -521,7 +520,6 @@ static const char L_OUTPUT_B[] PROGMEM = "(%u,%u,%u)\r\n"; // ===== NAMES ===== // static const char N_SAVED[] PROGMEM = "Device names saved in "; static const char N_LOADED[] PROGMEM = "Device names loaded from "; -static const char N_ERROR_SAVING[] PROGMEM = "ERROR: saving "; static const char N_REMOVED_ALL[] PROGMEM = "Removed all saved device names"; static const char N_HEADER[] PROGMEM = "[===== Saved Devices =====]"; static const char N_TABLE_HEADER[] PROGMEM = "ID MAC Vendor Name AP-BSSID Ch Selected"; @@ -547,7 +545,6 @@ static const char SS_LOADED[] PROGMEM = "SSIDs loaded from "; static const char SS_CLEARED[] PROGMEM = "Cleared SSID list"; static const char SS_SAVED[] PROGMEM = "SSIDs saved"; static const char SS_SAVED_IN[] PROGMEM = "SSIDs saved in "; -static const char SS_ERROR_SAVING[] PROGMEM = "ERROR: saving "; static const char SS_REMOVED[] PROGMEM = "Removed SSID "; static const char SS_ERROR_FULL[] PROGMEM = "ERROR: SSID list is full! Remove some SSIDs first or run command with -f (force) parameter."; static const char SS_ADDED[] PROGMEM = "Added SSID "; @@ -583,7 +580,6 @@ static const char SC_JSON_STATIONS[] PROGMEM = "stations"; static const char SC_JSON_NAMES[] PROGMEM = "names"; static const char SC_SAVED[] PROGMEM = "Saved scan results"; static const char SC_SAVED_IN[] PROGMEM = "Scan results saved in "; -static const char SC_ERROR_SAVING[] PROGMEM = "ERROR: Saving scan results in "; // ===== FUNCTIONS ===== // static const char F_ERROR_MAC[] PROGMEM = "ERROR: MAC address invalid"; @@ -596,6 +592,7 @@ static const char F_ERROR_PARSING_JSON[] PROGMEM = "ERROR parsing JSON "; static const char F_ERROR_TO_BIG[] PROGMEM = "ERROR file too big "; static const char F_TMP[] PROGMEM = "/tmp"; static const char F_COPY[] PROGMEM = "_copy"; +static const char F_ERROR_SAVING[] PROGMEM = "ERROR: saving file. Try 'format' and restart - "; // ===== WIFI ===== // static const char W_STOPPED_AP[] PROGMEM = "Stopped Access Point";