Skip to content

Commit fccb3b6

Browse files
author
Scott Powell
committed
* companion: added CMD_FACTORY_RESET (51)
1 parent 7947e8a commit fccb3b6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

examples/companion_radio/MyMesh.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#define CMD_GET_TUNING_PARAMS 43
4949
// NOTE: CMD range 44..49 parked, potentially for WiFi operations
5050
#define CMD_SEND_BINARY_REQ 50
51+
#define CMD_FACTORY_RESET 51
5152

5253
#define RESP_CODE_OK 0
5354
#define RESP_CODE_ERR 1
@@ -1361,6 +1362,15 @@ void MyMesh::handleCmdFrame(size_t len) {
13611362
} else {
13621363
writeErrFrame(ERR_CODE_NOT_FOUND);
13631364
}
1365+
} else if (cmd_frame[0] == CMD_FACTORY_RESET && memcmp(&cmd_frame[1], "reset", 5) == 0) {
1366+
bool success = _store->formatFileSystem();
1367+
if (success) {
1368+
writeOKFrame();
1369+
delay(1000);
1370+
board.reboot(); // doesn't return
1371+
} else {
1372+
writeErrFrame(ERR_CODE_FILE_IO_ERROR);
1373+
}
13641374
} else {
13651375
writeErrFrame(ERR_CODE_UNSUPPORTED_CMD);
13661376
MESH_DEBUG_PRINTLN("ERROR: unknown command: %02X", cmd_frame[0]);

0 commit comments

Comments
 (0)