Skip to content

Commit

Permalink
Add factory reset btn
Browse files Browse the repository at this point in the history
  • Loading branch information
cziter15 committed Jun 13, 2024
1 parent 1797bbe commit 252679d
Show file tree
Hide file tree
Showing 3 changed files with 4,612 additions and 4,599 deletions.
16 changes: 13 additions & 3 deletions src/ksf/comp/ksDevicePortal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ namespace ksf::comps
ESP.restart();
}

void ksDevicePortal::triggerFactoryReset()
{
WiFi.mode(WIFI_OFF);
eraseConfigData();
rebootDevice();
}

std::string ksDevicePortal::handle_executeCommand(const std::string_view& body)
{
if (body.empty())
Expand All @@ -151,9 +158,7 @@ namespace ksf::comps
}
else if (body == PSTR("erase-config"))
{
WiFi.mode(WIFI_OFF);
eraseConfigData();
rebootDevice();
triggerFactoryReset();
}
else if (body == PSTR("erase-all-data"))
{
Expand Down Expand Up @@ -247,6 +252,11 @@ namespace ksf::comps
requestAppBreak();
return;
}
else if (command == PSTR("factoryReset"))
{
triggerFactoryReset();
return;
}
else if (command == PSTR("saveConfig"))
{
/* Grab all config components. */
Expand Down
5 changes: 5 additions & 0 deletions src/ksf/comp/ksDevicePortal.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ namespace ksf::comps
*/
void requestAppBreak() { breakApp = true; }

/*!
@brief Triggers factory reset (erase config and reboot).
*/
void triggerFactoryReset();

/*!
@brief Starts device portal HTTP server.
*/
Expand Down
Loading

0 comments on commit 252679d

Please sign in to comment.