Reworked the reset and restart api calls
This commit is contained in:
parent
9c030518c5
commit
6c06233dd6
@ -1,5 +1,6 @@
|
|||||||
#include "SAB.h"
|
#include "SAB.h"
|
||||||
#include "webApi.h"
|
#include "webApi.h"
|
||||||
|
#include "tasks.h"
|
||||||
|
|
||||||
boolean apiTesterApi(WEBServerManager::HttpRequestData &HRD, WiFiClient* wc, void* pData)
|
boolean apiTesterApi(WEBServerManager::HttpRequestData &HRD, WiFiClient* wc, void* pData)
|
||||||
{
|
{
|
||||||
@ -134,16 +135,28 @@ boolean sdCardMountApi(WEBServerManager::HttpRequestData &HRD, WiFiClient *wc, v
|
|||||||
|
|
||||||
boolean espRestartApi(WEBServerManager::HttpRequestData &HRD, WiFiClient *wc, void *pData)
|
boolean espRestartApi(WEBServerManager::HttpRequestData &HRD, WiFiClient *wc, void *pData)
|
||||||
{
|
{
|
||||||
ESP.restart();
|
SAB *sab = (SAB*)pData;
|
||||||
|
char buffer[200];
|
||||||
|
|
||||||
|
sprintf(buffer,"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"ok\", \"message\" : \"module restarting in 10 seconds\" }");
|
||||||
|
|
||||||
|
wc->print(buffer);
|
||||||
|
|
||||||
|
unsigned int id = sab->getTaskSchedulerManager().taskCount()+1;
|
||||||
|
|
||||||
|
sab->getTaskSchedulerManager().addTask(id, TaskSchedulerManagerHelper::Schedule::scheduleBuilder()
|
||||||
|
->setSeconds(10)
|
||||||
|
->setTriggerType(TaskSchedulerManagerHelper::Schedule::TRIGGER_ONCE_AND_DELETE)
|
||||||
|
->setTriggerRightAway(false), &(task_esp_reset_restart), NULL);
|
||||||
|
|
||||||
|
Serial.print(F("Task id : "));Serial.println(id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean espResetApi(WEBServerManager::HttpRequestData &HRD, WiFiClient *wc, void *pData)
|
boolean espResetApi(WEBServerManager::HttpRequestData &HRD, WiFiClient *wc, void *pData)
|
||||||
{
|
{
|
||||||
ESP.restart();
|
return espRestartApi(HRD, wc, pData);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean sdCardSizeApi(WEBServerManager::HttpRequestData &HRD, WiFiClient *wc, void *pData)
|
boolean sdCardSizeApi(WEBServerManager::HttpRequestData &HRD, WiFiClient *wc, void *pData)
|
||||||
|
Loading…
Reference in New Issue
Block a user