mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
Arduino v7
This commit is contained in:
@@ -115,7 +115,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||
}
|
||||
|
||||
void WebStatusService::webStatusService(AsyncWebServerRequest * request) {
|
||||
auto * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_LARGE);
|
||||
auto * response = new AsyncJsonResponse(false);
|
||||
JsonObject root = response->getRoot();
|
||||
|
||||
root["status"] = EMSESP::bus_status(); // 0, 1 or 2
|
||||
@@ -125,29 +125,29 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) {
|
||||
root["num_sensors"] = EMSESP::temperaturesensor_.no_sensors();
|
||||
root["num_analogs"] = EMSESP::analogsensor_.no_sensors();
|
||||
|
||||
JsonArray statsJson = root.createNestedArray("stats");
|
||||
JsonArray statsJson = root["stats"].to<JsonArray>();
|
||||
JsonObject statJson;
|
||||
|
||||
statJson = statsJson.createNestedObject();
|
||||
statJson = statsJson.add<JsonObject>();
|
||||
statJson["id"] = 0;
|
||||
statJson["s"] = EMSESP::rxservice_.telegram_count();
|
||||
statJson["f"] = EMSESP::rxservice_.telegram_error_count();
|
||||
statJson["q"] = EMSESP::rxservice_.quality();
|
||||
|
||||
statJson = statsJson.createNestedObject();
|
||||
statJson = statsJson.add<JsonObject>();
|
||||
statJson["id"] = 1;
|
||||
statJson["s"] = EMSESP::txservice_.telegram_read_count();
|
||||
statJson["f"] = EMSESP::txservice_.telegram_read_fail_count();
|
||||
statJson["q"] = EMSESP::txservice_.read_quality();
|
||||
|
||||
statJson = statsJson.createNestedObject();
|
||||
statJson = statsJson.add<JsonObject>();
|
||||
statJson["id"] = 2;
|
||||
statJson["s"] = EMSESP::txservice_.telegram_write_count();
|
||||
statJson["f"] = EMSESP::txservice_.telegram_write_fail_count();
|
||||
statJson["q"] = EMSESP::txservice_.write_quality();
|
||||
|
||||
if (EMSESP::sensor_enabled()) {
|
||||
statJson = statsJson.createNestedObject();
|
||||
statJson = statsJson.add<JsonObject>();
|
||||
statJson["id"] = 3;
|
||||
statJson["s"] = EMSESP::temperaturesensor_.reads() - EMSESP::temperaturesensor_.fails();
|
||||
statJson["f"] = EMSESP::temperaturesensor_.fails();
|
||||
@@ -155,21 +155,21 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) {
|
||||
EMSESP::temperaturesensor_.reads() == 0 ? 100 : 100 - (uint8_t)((100 * EMSESP::temperaturesensor_.fails()) / EMSESP::temperaturesensor_.reads());
|
||||
}
|
||||
if (EMSESP::analog_enabled()) {
|
||||
statJson = statsJson.createNestedObject();
|
||||
statJson = statsJson.add<JsonObject>();
|
||||
statJson["id"] = 4;
|
||||
statJson["s"] = EMSESP::analogsensor_.reads() - EMSESP::analogsensor_.fails();
|
||||
statJson["f"] = EMSESP::analogsensor_.fails();
|
||||
statJson["q"] = EMSESP::analogsensor_.reads() == 0 ? 100 : 100 - (uint8_t)((100 * EMSESP::analogsensor_.fails()) / EMSESP::analogsensor_.reads());
|
||||
}
|
||||
if (Mqtt::enabled()) {
|
||||
statJson = statsJson.createNestedObject();
|
||||
statJson = statsJson.add<JsonObject>();
|
||||
statJson["id"] = 5;
|
||||
statJson["s"] = Mqtt::publish_count() - Mqtt::publish_fails();
|
||||
statJson["f"] = Mqtt::publish_fails();
|
||||
statJson["q"] = Mqtt::publish_count() == 0 ? 100 : 100 - (uint8_t)((100 * Mqtt::publish_fails()) / Mqtt::publish_count());
|
||||
}
|
||||
|
||||
statJson = statsJson.createNestedObject();
|
||||
statJson = statsJson.add<JsonObject>();
|
||||
statJson["id"] = 6;
|
||||
statJson["s"] = WebAPIService::api_count(); // + WebAPIService::api_fails();
|
||||
statJson["f"] = WebAPIService::api_fails();
|
||||
@@ -179,7 +179,7 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) {
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
if (EMSESP::system_.syslog_enabled()) {
|
||||
statJson = statsJson.createNestedObject();
|
||||
statJson = statsJson.add<JsonObject>();
|
||||
statJson["id"] = 7;
|
||||
statJson["s"] = EMSESP::system_.syslog_count();
|
||||
statJson["f"] = EMSESP::system_.syslog_fails();
|
||||
|
||||
Reference in New Issue
Block a user