src/ESPStepperMotorServer.cpp
void ESPStepperMotorServer::getServerStatusAsJsonString(String &statusString)
{
    StaticJsonDocument<200> doc;
    JsonObject root = doc.to<JsonObject>();
    root["version"] = this->version;

    JsonObject wifiStatus = root.createNestedObject("wifi");
    wifiStatus["mode"] = (this->serverConfiguration->wifiMode == ESPServerWifiModeAccessPoint) ? "ap" : "client";
    wifiStatus["ip"] = (this->serverConfiguration->wifiMode == ESPServerWifiModeAccessPoint) ? WiFi.dnsIP().toString() : WiFi.localIP().toString();

    JsonObject spiffsStatus = root.createNestedObject("spiffss");
    if (this->isSPIFFSMounted())
    {
        spiffsStatus["total_space"] = (int)SPIFFS.totalBytes();
        spiffsStatus["free_space"] = this->getSPIFFSFreeSpace();
    }
    else
    {
        spiffsStatus["not_mounted"] = true;
    }

    JsonObject activeModules = root.createNestedObject("activeModules");
    activeModules["serial_cli"] = (this->cliHandler != NULL);
    activeModules["rest_api"] = (this->isRestApiEnabled);
    activeModules["web_ui"] = (this->isWebserverEnabled);

    serializeJson(root, statusString);
}
/**
 * get some server status information as a JSON formatted string.
 * Returns: version, wifi mode, ip address, spiffs information, enabled server modules
 */
get some server status information as a JSON formatted string.
Returns: version, wifi mode, ip address, spiffs information, enabled server modules
get some server status information as a JSON formatted string . Returns : version wifi mode ip address spiffs information enabled server modules
void ESPStepperMotorServer::getServerStatusAsJsonString(String &statusString)
{
    StaticJsonDocument<200> doc;
    JsonObject root = doc.to<JsonObject>();
    root["version"] = this->version;
    JsonObject wifiStatus = root.createNestedObject("wifi");
    wifiStatus["mode"] = (this->serverConfiguration->wifiMode == ESPServerWifiModeAccessPoint) ? "ap" : "client";
    wifiStatus["ip"] = (this->serverConfiguration->wifiMode == ESPServerWifiModeAccessPoint) ? WiFi.dnsIP().toString() : WiFi.localIP().toString();
    JsonObject spiffsStatus = root.createNestedObject("spiffss");
    if (this->isSPIFFSMounted())
    {
        spiffsStatus["total_space"] = (int)SPIFFS.totalBytes();
        spiffsStatus["free_space"] = this->getSPIFFSFreeSpace();
    }
    else
    {
        spiffsStatus["not_mounted"] = true;
    }
    JsonObject activeModules = root.createNestedObject("activeModules");
    activeModules["serial_cli"] = (this->cliHandler != NULL);
    activeModules["rest_api"] = (this->isRestApiEnabled);
    activeModules["web_ui"] = (this->isWebserverEnabled);
    serializeJson(root, statusString);
}
void ESPStepperMotorServer :: getServerStatusAsJsonString ( String & statusString ) { StaticJsonDocument < 200 > doc ; JsonObject root = doc . to < JsonObject > ( ) ; root [ " " ] = this -> version ; JsonObject wifiStatus = root . createNestedObject ( " " ) ; wifiStatus [ " " ] = ( this -> serverConfiguration -> wifiMode == ESPServerWifiModeAccessPoint ) ? " " : " " ; wifiStatus [ " " ] = ( this -> serverConfiguration -> wifiMode == ESPServerWifiModeAccessPoint ) ? WiFi . dnsIP ( ) . toString ( ) : WiFi . localIP ( ) . toString ( ) ; JsonObject spiffsStatus = root . createNestedObject ( " " ) ; if ( this -> isSPIFFSMounted ( ) ) { spiffsStatus [ " " ] = ( int ) SPIFFS . totalBytes ( ) ; spiffsStatus [ " " ] = this -> getSPIFFSFreeSpace ( ) ; } else { spiffsStatus [ " " ] = true ; } JsonObject activeModules = root . createNestedObject ( " " ) ; activeModules [ " " ] = ( this -> cliHandler != NULL ) ; activeModules [ " " ] = ( this -> isRestApiEnabled ) ; activeModules [ " " ] = ( this -> isWebserverEnabled ) ; serializeJson ( root , statusString ) ; }
get some server status information as a JSON formatted string.
get some server status information as a JSON formatted string .