|
|
|
@ -1305,6 +1305,54 @@ void MyMesh::checkCLIRescueCmd() { |
|
|
|
} else { |
|
|
|
Serial.println(" Error: erase failed"); |
|
|
|
} |
|
|
|
} else if (memcmp(cli_command, "ls", 2) == 0) { |
|
|
|
|
|
|
|
// get path from command e.g: "ls /adafruit"
|
|
|
|
const char *path = &cli_command[3]; |
|
|
|
|
|
|
|
// log each file and directory
|
|
|
|
File root = _store->openRead(path); |
|
|
|
File file = root.openNextFile(); |
|
|
|
while (file) { |
|
|
|
|
|
|
|
if (file.isDirectory()) { |
|
|
|
Serial.print("[dir] "); |
|
|
|
Serial.println(file.name()); |
|
|
|
} else { |
|
|
|
Serial.print("[file] "); |
|
|
|
Serial.print(file.name()); |
|
|
|
Serial.print(" ("); |
|
|
|
Serial.print(file.size()); |
|
|
|
Serial.println(" bytes)"); |
|
|
|
} |
|
|
|
|
|
|
|
// move to next file
|
|
|
|
file = root.openNextFile(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (memcmp(cli_command, "cat", 3) == 0) { |
|
|
|
|
|
|
|
// get path from command e.g: "cat /contacts3"
|
|
|
|
const char *path = &cli_command[4]; |
|
|
|
|
|
|
|
// log file content as hex
|
|
|
|
File file = _store->openRead(path); |
|
|
|
if(file){ |
|
|
|
|
|
|
|
// get file content
|
|
|
|
int file_size = file.available(); |
|
|
|
uint8_t buffer[file_size]; |
|
|
|
file.read(buffer, file_size); |
|
|
|
|
|
|
|
// print hex
|
|
|
|
mesh::Utils::printHex(Serial, buffer, file_size); |
|
|
|
Serial.print("\n"); |
|
|
|
|
|
|
|
file.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (strcmp(cli_command, "reboot") == 0) { |
|
|
|
board.reboot(); // doesn't return
|
|
|
|
} else { |
|
|
|
|