Updated some API endpoints due to the renaming of the injectApiHeader method

This commit is contained in:
anschrammh 2022-04-05 21:05:24 +02:00
parent 651d0ee060
commit 5fb02304be

View File

@ -6,9 +6,9 @@ boolean apiTesterApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient* wc,
{
(void)HRD;
(void)pData;
char buffer[200];
char buffer[] = "{\"status\":\"ok\",\"API\":\"available\"}";
WEBServer<WEBClient>::injectApiHeader(buffer, "application/json", "{\"status\":\"ok\",\"API\":\"available\"}");
WEBServer<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer));
wc->print(buffer);
return true;
}
@ -75,7 +75,7 @@ boolean rtcGetTimeApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc
DateTime d = p->getRtcManager().getDateTime();
sprintf(buffer, "{\"status\":\"ok\",\"date\":\"%d/%d/%d\",\"time\":\"%d:%d:%d\"}", d.day(), d.month(), d.year(), d.hour(), d.minute(), d.second());
WEBServer<WEBClient>::injectApiHeader(buffer, "application/json", buffer);
WEBServer<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer));
wc->print(buffer);
return true;
@ -172,7 +172,8 @@ boolean sdCardActionApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *
}
}
WEBServer<WEBClient>::injectApiHeader(buffer, "application/json", buffer);
WEBServer<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer));
wc->print(buffer);
return true;
}
@ -221,7 +222,7 @@ boolean staWifiInfoApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *w
IPAddress IP = p->getConnectivityManager().localIP();
sprintf(buffer,"{\"status\":\"ok\",\"RSSI\":%d,\"RSSI2\":%d,\"local IP\":\"%u.%u.%u.%u\",\"mac\":\"%s\"}", p->getConnectivityManager().RSSI(), p->getConnectivityManager().RSSIPercent(), IP[0], IP[1], IP[2], IP[3], p->getConnectivityManager().macAddress().c_str());
WEBServer<WEBClient>::injectApiHeader(buffer, "application/json", buffer);
WEBServer<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer));
wc->print(buffer);
return true;
@ -235,7 +236,7 @@ boolean staWifiInfoApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *w
p->getSdCardManager().getCFGFile(AP_CFG_FILE);
sprintf(buffer, "");
WEBServer<WEBClient>::injectApiHeader(buffer, "application/json", buffer);
WEBServer<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer));
wc->print(buffer);
return true;
@ -269,7 +270,7 @@ boolean systemInfoApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc
TimeSpan ts(p->getUpTime());
sprintf(buffer, "{\"status\":\"ok\",\"CPU freq\":%u,\"free RAM\":%u,\"heap frag\":%u,\"max block\":%u,\"nb views\":%u,\"up time\":{\"days\":%d,\"hours\":%d,\"minutes\":%d,\"seconds\":%d},\"temperature\":{\"level\":%.2f, \"unit\":\"°C\"}}", ESP.getCpuFreqMHz(), freeMem, frag, biggestContigMemBlock, p->getScreenManager().getViewCount(), ts.days(), ts.hours(), ts.minutes(), ts.seconds(), p->getRtcManager().getTemperature());
WEBServer<WEBClient>::injectApiHeader(buffer, "application/json", buffer);
WEBServer<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer));
wc->print(buffer);
return true;
@ -315,7 +316,7 @@ boolean powerSettingsApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient
strcpy(buffer, "{\"status\":\"error\",\"message\":\"Parameter FREQ expected\"}");
}
WEBServer<WEBClient>::injectApiHeader(buffer, "application/json", buffer);
WEBServer<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer));
wc->print(buffer);
return true;