Skip to content

Commit

Permalink
Replace all ESP.restart() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
hhvrc committed Feb 4, 2025
1 parent 8651074 commit 69bd74e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/serial/command_handlers/domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "http/HTTPRequestManager.h"
#include "serialization/JsonAPI.h"

#include <esp_system.h>

#include <string>

const char* const TAG = "Serial::CommandHandlers::Domain";
Expand Down Expand Up @@ -57,7 +59,7 @@ void _handleDomainCommand(std::string_view arg, bool isAutomated) {
SERPR_SUCCESS("Saved config, restarting...");

// Restart to use the new domain
ESP.restart();
esp_restart();
}

OpenShock::Serial::CommandGroup OpenShock::Serial::CommandHandlers::DomainHandler() {
Expand Down
4 changes: 3 additions & 1 deletion src/serial/command_handlers/factoryreset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

#include "config/Config.h"

#include <esp_system.h>

void _handleFactoryResetCommand(std::string_view arg, bool isAutomated)
{
(void)arg;

::Serial.println("Resetting to factory defaults...");
OpenShock::Config::FactoryReset();
::Serial.println("Restarting...");
ESP.restart();
esp_restart();
}

OpenShock::Serial::CommandGroup OpenShock::Serial::CommandHandlers::FactoryResetHandler()
Expand Down
4 changes: 3 additions & 1 deletion src/serial/command_handlers/hostname.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "config/Config.h"

#include <esp_system.h>

#include <string>

const char* const TAG = "Serial::CommandHandlers::Domain";
Expand All @@ -21,7 +23,7 @@ void _handleHostnameCommand(std::string_view arg, bool isAutomated) {
bool result = OpenShock::Config::SetWiFiHostname(arg);
if (result) {
SERPR_SUCCESS("Saved config, restarting...");
ESP.restart();
esp_restart();
} else {
SERPR_ERROR("Failed to save config");
}
Expand Down
4 changes: 3 additions & 1 deletion src/serial/command_handlers/jsonconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "config/Config.h"

#include <esp_system.h>

void _handleJsonConfigCommand(std::string_view arg, bool isAutomated) {
if (arg.empty()) {
// Get raw config
Expand All @@ -18,7 +20,7 @@ void _handleJsonConfigCommand(std::string_view arg, bool isAutomated) {

SERPR_SUCCESS("Saved config, restarting...");

ESP.restart();
esp_restart();
}

OpenShock::Serial::CommandGroup OpenShock::Serial::CommandHandlers::JsonConfigHandler() {
Expand Down
4 changes: 3 additions & 1 deletion src/serial/command_handlers/rawconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "config/Config.h"
#include "util/Base64Utils.h"

#include <esp_system.h>

#include <vector>

void _handleRawConfigCommand(std::string_view arg, bool isAutomated) {
Expand Down Expand Up @@ -38,7 +40,7 @@ void _handleRawConfigCommand(std::string_view arg, bool isAutomated) {

SERPR_SUCCESS("Saved config, restarting...");

ESP.restart();
esp_restart();
}

OpenShock::Serial::CommandGroup OpenShock::Serial::CommandHandlers::RawConfigHandler() {
Expand Down
4 changes: 2 additions & 2 deletions src/serial/command_handlers/restart.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "serial/command_handlers/common.h"

#include <Arduino.h>
#include <esp_system.h>

void _handleRestartCommand(std::string_view arg, bool isAutomated) {
(void)arg;

::Serial.println("Restarting ESP...");
ESP.restart();
esp_restart();
}

OpenShock::Serial::CommandGroup OpenShock::Serial::CommandHandlers::RestartHandler() {
Expand Down

1 comment on commit 69bd74e

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-format (v18.1.3) reports: 4 file(s) not formatted
  • src/serial/command_handlers/domain.cpp
  • src/serial/command_handlers/jsonconfig.cpp
  • src/serial/command_handlers/rawconfig.cpp
  • src/serial/command_handlers/restart.cpp

Have any feedback or feature suggestions? Share it here.

Please sign in to comment.