Skip to content

Commit

Permalink
New command - DELETE
Browse files Browse the repository at this point in the history
  • Loading branch information
daniszewski committed Mar 23, 2019
1 parent 3450fab commit c749e30
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions emulator/storage/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ <h2>Help</h2>
- WIFITEST {ssid} {password} - same a above but the setting will be restored after restart
- WIFIAP {1 or 0} - enable or disable the AccessPoint mode
- WIFIAPTEST {1 or 0} - same a above but the setting will be restored after restart
- DELETE {filename} - delete a file from internal storage
- RESTART - reset the module

# Remarks
Expand Down
1 change: 1 addition & 0 deletions help/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- WIFITEST {ssid} {password} - same a above but the setting will be restored after restart
- WIFIAP {1 or 0} - enable or disable the AccessPoint mode
- WIFIAPTEST {1 or 0} - same a above but the setting will be restored after restart
- DELETE {filename} - delete a file from internal storage
- RESTART - reset the module

# Remarks
Expand Down
1 change: 1 addition & 0 deletions src/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bool execute(String line) {
else if (adm && cmd == "WIFITEST") WiFiSTA(getWord(line, 1), getWord(line, 2), false); // Syntax: WIFITEST <ssid> <password>
else if (adm && cmd == "WIFIAP") WiFiAP(getWord(line, 1)=="1", true); // Syntax: WIFIAP <0 or 1>
else if (adm && cmd == "WIFIAPTEST") WiFiAP(getWord(line, 1)=="1", false); // Syntax: WIFIAPTEST <0 or 1>
else if (adm && cmd == "DELETE") deleteFile(getWord(line, 1)); // Syntax: DELETE <full_filepath>
else if (adm && cmd == "RESTART") ESP.restart(); // Syntax: RESTART

else if (cmd == "LOGIN") login(getWord(line, 1)); // Syntax: LOGIN <password>
Expand Down
4 changes: 4 additions & 0 deletions src/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,7 @@ bool executeFile(String filename) {
ERR(filename+": file doesn't exist.");
return false;
}

void deleteFile(String filename) {
if (isAdmin()) SPIFFS.remove(filename);
}
1 change: 1 addition & 0 deletions src/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bool executeFile(String filename);
void bootStart();
void firstBoot();
void bootComplete();
void deleteFile(String filename);


#define ERR(...) { logToSerial("ERROR: "); logToSerial( __VA_ARGS__ ); logToSerial("\n"); setLastError(__VA_ARGS__); }
Expand Down
2 changes: 1 addition & 1 deletion src/_Config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Stream.h>

String version = "0.9.1";
String version = "0.9.1.1";

String AP_prefix = "LIGHTS_"; // max length 14 because the MAC address (17 chars) will be added later and max total SSID length is 31
String adminpwd = "esplight";
Expand Down

0 comments on commit c749e30

Please sign in to comment.