Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

add reboot cmd to sys shell

Geo501c2244e2b0
diff --git a/src/Data/UniversalRemoteCommands.h b/src/Data/UniversalRemoteCommands.h
index a25b3912..faf131fb 100644
--- a/src/Data/UniversalRemoteCommands.h
+++ b/src/Data/UniversalRemoteCommands.h
@@ -9,10 +9,9 @@ struct InfraredCommandStruct{
int subdevice;
int function;
- // ctor utilisable en expression constante
+ // constexpr for compile time initialization
constexpr InfraredCommandStruct(InfraredProtocolEnum p, int d, int s, int f)
: proto(p), device(d), subdevice(s), function(f) {}
- // si tu fais des calculs (encode NEC, etc.), assure-toi qu’ils sont aussi constexpr
};
inline constexpr InfraredCommandStruct universalOnOff[] = {
diff --git a/src/Services/SystemService.cpp b/src/Services/SystemService.cpp
index 705635fb..a4bdcd3b 100644
--- a/src/Services/SystemService.cpp
+++ b/src/Services/SystemService.cpp
@@ -361,3 +361,11 @@ std::string SystemService::getNvsEntries() const {
return out;
}
+
+void SystemService::reboot(bool hard) const {
+ if (hard) {
+ ESP.restart(); // Arduino-style reset
+ } else {
+ esp_restart(); // IDF reset
+ }
+}
\ No newline at end of file
diff --git a/src/Services/SystemService.h b/src/Services/SystemService.h
index 757ae19b..9c143ecc 100644
--- a/src/Services/SystemService.h
+++ b/src/Services/SystemService.h
@@ -40,18 +40,17 @@ public:
// Network
std::string getBaseMac() const;
- // Filesystems LittleFS & SPIFFS
+ // Filesystems
bool littlefsBegin(bool autoFormat) const;
void littlefsEnd() const;
size_t littlefsTotalBytes() const;
size_t littlefsUsedBytes() const;
- bool spiffsBegin(bool autoFormat) const;
- void spiffsEnd() const;
- size_t spiffsTotalBytes() const;
- size_t spiffsUsedBytes() const;
// Formatted output
std::string getPartitions() const;
std::string getNvsStats() const;
std::string getNvsEntries() const;
+
+ // Boot
+ void reboot(bool hard = false) const;
};
diff --git a/src/Shells/SysInfoShell.cpp b/src/Shells/SysInfoShell.cpp
index 08a7f2f4..5839c261 100644
--- a/src/Shells/SysInfoShell.cpp
+++ b/src/Shells/SysInfoShell.cpp
@@ -31,7 +31,8 @@ void SysInfoShell::run() {
case 5: cmdNVS(false); break;
case 6: cmdNVS(true); break;
case 7: cmdNet(); break;
- case 8: // Exit
+ case 8: cmdReboot(); break;
+ case 9: // Exit
default:
loop = false;
break;
@@ -181,3 +182,11 @@ void SysInfoShell::cmdNet() {
terminalView.println("Status : " + std::string(wlStatusToStr(status)));
terminalView.println("Prov enabled : " + std::string(wifiService.isProvisioningEnabled() ? "Yes" : "No"));
}
+
+void SysInfoShell::cmdReboot(bool hard) {
+ auto confirmation = userInputManager.readYesNo("Reboot the device? (y/n)", false);
+ if (confirmation) {
+ terminalView.println("\nRebooting, your session will be lost...");
+ systemService.reboot(hard);
+ }
+}
\ No newline at end of file
diff --git a/src/Shells/SysInfoShell.h b/src/Shells/SysInfoShell.h
index 941eff90..51803932 100644
--- a/src/Shells/SysInfoShell.h
+++ b/src/Shells/SysInfoShell.h
@@ -31,7 +31,8 @@ private:
" 🧰 NVS stats",
" πŸ“’ NVS entries",
" 🌐 Network",
- " πŸšͺ Exit"
+ " πŸ”„ Reboot",
+ "πŸšͺ Exit"
};
const char* resetReasonToStr(int r) {
@@ -99,6 +100,7 @@ private:
void cmdFS();
void cmdNVS(bool listEntries);
void cmdNet();
+ void cmdReboot(bool hard = false);
ITerminalView& terminalView;
IInput& terminalInput;