Removed a warning in the WEBServer.h file and added a new api endpoint to get the software version

This commit is contained in:
Th3maz1ng 2022-06-11 12:05:56 +02:00
parent 007dcbdaa4
commit 0687f05bc0
4 changed files with 17 additions and 1 deletions

View File

@ -374,7 +374,7 @@ class WEBServer : public TCPServer<T>, public HttpConstants
//Parsing done!
#if 1//def DEBUG_WEBS
Serial.println("Post params :");
for(int i = 0; i < client->_httpRequestData.postParams.count(); i++)
for(unsigned int i = 0; i < client->_httpRequestData.postParams.count(); i++)
{
Serial.print(client->_httpRequestData.postParams.getParameter(i));Serial.print(" : ");Serial.println(client->_httpRequestData.postParams.getAt(i)->getString());
}

View File

@ -94,6 +94,7 @@ void setup()
sab.getWebServer().addApiRoutine("/sab/io/set/level", &(ioSetLevelApi), &sab, WEBServer<WEBClient>::GET);
sab.getWebServer().addApiRoutine("/sab/io/get/mode", &(ioGetModeApi), &sab, WEBServer<WEBClient>::GET);
sab.getWebServer().addApiRoutine("/sab/io/set/mode", &(ioSetModeApi), &sab, WEBServer<WEBClient>::GET);
sab.getWebServer().addApiRoutine("/sab/firmwareinfo", &(fwInfoApi), &sab, WEBServer<WEBClient>::GET);
sab.getWebServer().addApiRoutine("/sab/ota/update", &(otaUpdateApi), NULL, WEBServer<WEBClient>::POST);
sab.getIoManager().setISROnIOChange(&(ioISR), GPIO_3_RX);

View File

@ -560,6 +560,20 @@ boolean ioSetModeApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc,
return true;
}
boolean fwInfoApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData)
{
(void)HRD;
(void)pData;
char buffer[100] = "";
sprintf(buffer ,"{\"status\":\"ok\",\"version\":\"%s\"}", SOFT_VERSION);
WEBServer<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer));
wc->print(buffer);
return true;
}
boolean otaUpdateApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData)
{
(void)HRD;

View File

@ -30,6 +30,7 @@ boolean ioGetLevelApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*
boolean ioSetLevelApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean ioGetModeApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean ioSetModeApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean fwInfoApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean otaUpdateApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
#endif