Added new api endpoint to reload and apply screen config from sd card

This commit is contained in:
anschrammh 2019-10-20 18:05:06 +02:00
parent 882e97dfcd
commit d06b1e49d9
2 changed files with 20 additions and 5 deletions

View File

@ -4,7 +4,7 @@
boolean apiTesterApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient* wc, void* pData)
{
wc->print(F("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"ok\", \"API\" : \"available\" }"));
wc->printf_P(PSTR("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"ok\", \"API\" : \"available\" }"));
return true;
}
@ -16,17 +16,17 @@ boolean viewByUIDApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc,
if(pSE == NULL)
{
sprintf(buffer,"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"failed\", \"message\" : \"expected UID parameter\" }");
sprintf_P(buffer,PSTR("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"failed\", \"message\" : \"expected UID parameter\" }"));
}
else if(strlen(pSE->getString()) > 0)
{
if(p->getScreenManager().displayView(atoi(pSE->getString())))
sprintf(buffer,"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"ok\", \"ViewUID\" : \"%d\" }", p->getScreenManager().getCurrentViewUID());
sprintf_P(buffer,PSTR("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"ok\", \"ViewUID\" : \"%d\" }"), p->getScreenManager().getCurrentViewUID());
else
sprintf(buffer,"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"failed\", \"message\" : \"%s\" }", p->getScreenManager().getErrorMessage());
sprintf_P(buffer,PSTR("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"failed\", \"message\" : \"%s\" }"), p->getScreenManager().getErrorMessage());
}
else
sprintf(buffer,"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"failed\", \"message\" : \"UID parameter empty\" }");
sprintf_P(buffer,PSTR("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"failed\", \"message\" : \"UID parameter empty\" }"));
wc->print(buffer);
return true;
}
@ -43,6 +43,20 @@ boolean nextViewApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc,
return true;
}
boolean reloadViewApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData)
{
SAB *p = (SAB *)pData;
char buffer[200];
if(p->getScreenManager().init())
strcpy_P(buffer,PSTR("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"ok\", \"message\" : \"config reloaded\" }"));
else
strcpy_P(buffer,PSTR("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"failed\", \"message\" : \"unable to reload config\" }"));
wc->print(buffer);
return true;
}
boolean rtcGetTimeApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData)
{
SAB *p = (SAB *)pData;

View File

@ -6,6 +6,7 @@
boolean apiTesterApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean nextViewApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean reloadViewApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean viewByUIDApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean rtcGetTimeApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean rtcSetTimeApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);