mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-07 14:15:53 +02:00
merged #736 remove obsolete JSON Endpoint
This commit is contained in:
parent
39c02f8668
commit
f5ef19ccab
3 changed files with 1 additions and 36 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
## 0.5.95
|
||||
* merged #742 MI Improvments
|
||||
* merged #736 remove obsolete JSON Endpoint
|
||||
|
||||
## 0.5.94
|
||||
* added ePaper (for ESP32 only!), thx @dAjaY85 #735
|
||||
|
|
|
@ -30,9 +30,6 @@
|
|||
#undef MIDNIGHTTICKER_OFFSET
|
||||
#define MIDNIGHTTICKER_OFFSET (mCalculatedTimezoneOffset + 1)
|
||||
|
||||
// To enable the json endpoint at /json
|
||||
// #define ENABLE_JSON_EP
|
||||
|
||||
// To enable the endpoint for prometheus to scrape data from at /metrics
|
||||
// #define ENABLE_PROMETHEUS_EP
|
||||
|
||||
|
|
|
@ -72,9 +72,6 @@ class Web {
|
|||
mWeb.on("/live", HTTP_ANY, std::bind(&Web::onLive, this, std::placeholders::_1));
|
||||
//mWeb.on("/api1", HTTP_POST, std::bind(&Web::showWebApi, this, std::placeholders::_1));
|
||||
|
||||
#ifdef ENABLE_JSON_EP
|
||||
mWeb.on("/json", HTTP_ANY, std::bind(&Web::showJson, this, std::placeholders::_1));
|
||||
#endif
|
||||
#ifdef ENABLE_PROMETHEUS_EP
|
||||
mWeb.on("/metrics", HTTP_ANY, std::bind(&Web::showMetrics, this, std::placeholders::_1));
|
||||
#endif
|
||||
|
@ -722,36 +719,6 @@ class Web {
|
|||
request->send(response);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_JSON_EP
|
||||
void showJson(AsyncWebServerRequest *request) {
|
||||
DPRINTLN(DBG_VERBOSE, F("web::showJson"));
|
||||
String modJson;
|
||||
Inverter<> *iv;
|
||||
record_t<> *rec;
|
||||
char topic[40], val[25];
|
||||
|
||||
modJson = F("{\n");
|
||||
for (uint8_t id = 0; id < mSys->getNumInverters(); id++) {
|
||||
iv = mSys->getInverterByPos(id);
|
||||
if (NULL == iv)
|
||||
continue;
|
||||
|
||||
rec = iv->getRecordStruct(RealTimeRunData_Debug);
|
||||
snprintf(topic, 30, "\"%s\": {\n", iv->config->name);
|
||||
modJson += String(topic);
|
||||
for (uint8_t i = 0; i < rec->length; i++) {
|
||||
snprintf(topic, 40, "\t\"ch%d/%s\"", rec->assign[i].ch, iv->getFieldName(i, rec));
|
||||
snprintf(val, 25, "[%.3f, \"%s\"]", iv->getValue(i, rec), iv->getUnit(i, rec));
|
||||
modJson += String(topic) + ": " + String(val) + F(",\n");
|
||||
}
|
||||
modJson += F("\t\"last_msg\": \"") + ah::getDateTimeStr(rec->ts) + F("\"\n\t},\n");
|
||||
}
|
||||
modJson += F("\"json_ts\": \"") + String(ah::getDateTimeStr(mApp->getTimestamp())) + F("\"\n}\n");
|
||||
|
||||
AsyncWebServerResponse *response = request->beginResponse(200, F("application/json"), modJson);
|
||||
request->send(response);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_PROMETHEUS_EP
|
||||
enum {
|
||||
|
|
Loading…
Add table
Reference in a new issue