mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
remove emsesp namespace
This commit is contained in:
@@ -105,7 +105,7 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// capture current heap memory before allocating the large return buffer
|
// capture current heap memory before allocating the large return buffer
|
||||||
emsesp::EMSESP::system_.refreshHeapMem();
|
EMSESP::system_.refreshHeapMem();
|
||||||
|
|
||||||
// output json buffer
|
// output json buffer
|
||||||
auto response = new AsyncJsonResponse();
|
auto response = new AsyncJsonResponse();
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ void WebDataService::device_data(AsyncWebServerRequest * request) {
|
|||||||
for (const auto & emsdevice : EMSESP::emsdevices) {
|
for (const auto & emsdevice : EMSESP::emsdevices) {
|
||||||
if (emsdevice->unique_id() == id) {
|
if (emsdevice->unique_id() == id) {
|
||||||
// wait max 2.5 sec for updated data (post_send_delay is 2 sec)
|
// wait max 2.5 sec for updated data (post_send_delay is 2 sec)
|
||||||
for (uint16_t i = 0; i < (emsesp::TxService::POST_SEND_DELAY + 500) && EMSESP::wait_validate(); i++) {
|
for (uint16_t i = 0; i < (TxService::POST_SEND_DELAY + 500) && EMSESP::wait_validate(); i++) {
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
EMSESP::wait_validate(0); // reset in case of timeout
|
EMSESP::wait_validate(0); // reset in case of timeout
|
||||||
|
|||||||
@@ -371,13 +371,13 @@ bool WebSchedulerService::command(const char * name, const std::string & command
|
|||||||
if (httpResult != 200) {
|
if (httpResult != 200) {
|
||||||
char error[100];
|
char error[100];
|
||||||
snprintf(error, sizeof(error), "Schedule %s: URL command failed with http code %d", name, httpResult);
|
snprintf(error, sizeof(error), "Schedule %s: URL command failed with http code %d", name, httpResult);
|
||||||
emsesp::EMSESP::logger().warning(error);
|
EMSESP::logger().warning(error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
char msg[100];
|
char msg[100];
|
||||||
snprintf(msg, sizeof(msg), "Schedule %s: URL command successful with http code %d", name, httpResult);
|
snprintf(msg, sizeof(msg), "Schedule %s: URL command successful with http code %d", name, httpResult);
|
||||||
emsesp::EMSESP::logger().debug(msg);
|
EMSESP::logger().debug(msg);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -416,7 +416,7 @@ bool WebSchedulerService::command(const char * name, const std::string & command
|
|||||||
snprintf(error, sizeof(error), "Schedule %s: command %s failed with error %s", name, cmd.c_str(), Command::return_code_string(return_code));
|
snprintf(error, sizeof(error), "Schedule %s: command %s failed with error %s", name, cmd.c_str(), Command::return_code_string(return_code));
|
||||||
}
|
}
|
||||||
|
|
||||||
emsesp::EMSESP::logger().warning(error);
|
EMSESP::logger().warning(error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,14 +439,14 @@ void WebSchedulerService::condition() {
|
|||||||
if (scheduleItem.active && scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_CONDITION) {
|
if (scheduleItem.active && scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_CONDITION) {
|
||||||
auto match = compute(scheduleItem.time);
|
auto match = compute(scheduleItem.time);
|
||||||
#ifdef EMESESP_DEBUG
|
#ifdef EMESESP_DEBUG
|
||||||
// emsesp::EMSESP::logger().debug("condition match: %s", match.c_str());
|
// EMSESP::logger().debug("condition match: %s", match.c_str());
|
||||||
#endif
|
#endif
|
||||||
if (match.length() == 1 && match[0] == '1' && scheduleItem.retry_cnt == 0xFF) {
|
if (match.length() == 1 && match[0] == '1' && scheduleItem.retry_cnt == 0xFF) {
|
||||||
scheduleItem.retry_cnt = command(scheduleItem.name.c_str(), scheduleItem.cmd, compute(scheduleItem.value)) ? 1 : 0xFF;
|
scheduleItem.retry_cnt = command(scheduleItem.name.c_str(), scheduleItem.cmd, compute(scheduleItem.value)) ? 1 : 0xFF;
|
||||||
} else if (match.length() == 1 && match[0] == '0' && scheduleItem.retry_cnt == 1) {
|
} else if (match.length() == 1 && match[0] == '0' && scheduleItem.retry_cnt == 1) {
|
||||||
scheduleItem.retry_cnt = 0xFF;
|
scheduleItem.retry_cnt = 0xFF;
|
||||||
} else if (match.length() != 1) { // the match is not boolean
|
} else if (match.length() != 1) { // the match is not boolean
|
||||||
emsesp::EMSESP::logger().debug("condition result: %s", match.c_str());
|
EMSESP::logger().debug("condition result: %s", match.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) {
|
|||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
uint8_t ntp_status = 0; // 0=disabled, 1=enabled, 2=connected
|
uint8_t ntp_status = 0; // 0=disabled, 1=enabled, 2=connected
|
||||||
if (esp_sntp_enabled()) {
|
if (esp_sntp_enabled()) {
|
||||||
ntp_status = (emsesp::EMSESP::system_.ntp_connected()) ? 2 : 1;
|
ntp_status = (EMSESP::system_.ntp_connected()) ? 2 : 1;
|
||||||
}
|
}
|
||||||
root["ntp_status"] = ntp_status;
|
root["ntp_status"] = ntp_status;
|
||||||
if (ntp_status == 2) {
|
if (ntp_status == 2) {
|
||||||
@@ -83,7 +83,7 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) {
|
|||||||
|
|
||||||
root["ap_status"] = EMSESP::esp32React.apStatus();
|
root["ap_status"] = EMSESP::esp32React.apStatus();
|
||||||
|
|
||||||
if (emsesp::EMSESP::system_.ethernet_connected()) {
|
if (EMSESP::system_.ethernet_connected()) {
|
||||||
root["network_status"] = 10; // custom code #10 - ETHERNET_STATUS_CONNECTED
|
root["network_status"] = 10; // custom code #10 - ETHERNET_STATUS_CONNECTED
|
||||||
root["wifi_rssi"] = 0;
|
root["wifi_rssi"] = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -196,7 +196,7 @@ void WebStatusService::action(AsyncWebServerRequest * request, JsonVariant json)
|
|||||||
} else if (action == "systemStatus" && is_admin) {
|
} else if (action == "systemStatus" && is_admin) {
|
||||||
ok = setSystemStatus(param.c_str());
|
ok = setSystemStatus(param.c_str());
|
||||||
} else if (action == "resetMQTT" && is_admin) {
|
} else if (action == "resetMQTT" && is_admin) {
|
||||||
emsesp::EMSESP::mqtt_.reset_mqtt();
|
EMSESP::mqtt_.reset_mqtt();
|
||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ void WebStatusService::action(AsyncWebServerRequest * request, JsonVariant json)
|
|||||||
|
|
||||||
// check for error
|
// check for error
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
emsesp::EMSESP::logger().err("Action '%s' failed", action.c_str());
|
EMSESP::logger().err("Action '%s' failed", action.c_str());
|
||||||
request->send(400); // bad request
|
request->send(400); // bad request
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ bool WebStatusService::checkUpgrade(JsonObject root, std::string & versions) {
|
|||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
// look for dev in the name to determine if we're using a dev release
|
// look for dev in the name to determine if we're using a dev release
|
||||||
bool using_dev_version = !current_version.prerelease().find("dev");
|
bool using_dev_version = !current_version.prerelease().find("dev");
|
||||||
emsesp::EMSESP::logger()
|
EMSESP::logger()
|
||||||
.debug("Checking version upgrade. This version=%d.%d.%d-%s (%s),latest dev=%d.%d.%d-%s (%s upgradeable),latest stable=%d.%d.%d-%s (%s upgradeable)",
|
.debug("Checking version upgrade. This version=%d.%d.%d-%s (%s),latest dev=%d.%d.%d-%s (%s upgradeable),latest stable=%d.%d.%d-%s (%s upgradeable)",
|
||||||
current_version.major(),
|
current_version.major(),
|
||||||
current_version.minor(),
|
current_version.minor(),
|
||||||
@@ -334,7 +334,7 @@ bool WebStatusService::getCustomSupport(JsonObject root) {
|
|||||||
if (!file) {
|
if (!file) {
|
||||||
// there is no custom file, return empty object
|
// there is no custom file, return empty object
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
emsesp::EMSESP::logger().debug("No custom support file found");
|
EMSESP::logger().debug("No custom support file found");
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -342,7 +342,7 @@ bool WebStatusService::getCustomSupport(JsonObject root) {
|
|||||||
// read the contents of the file into a json doc. We can't do this direct to object since 7.2.1
|
// read the contents of the file into a json doc. We can't do this direct to object since 7.2.1
|
||||||
DeserializationError error = deserializeJson(doc, file);
|
DeserializationError error = deserializeJson(doc, file);
|
||||||
if (error) {
|
if (error) {
|
||||||
emsesp::EMSESP::logger().err("Failed to read custom support file");
|
EMSESP::logger().err("Failed to read custom support file");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ bool WebStatusService::getCustomSupport(JsonObject root) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
emsesp::EMSESP::logger().debug("Showing custom support page");
|
EMSESP::logger().debug("Showing custom support page");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
root.set(doc.as<JsonObject>()); // add to web response root object
|
root.set(doc.as<JsonObject>()); // add to web response root object
|
||||||
@@ -362,14 +362,14 @@ bool WebStatusService::getCustomSupport(JsonObject root) {
|
|||||||
// uploads a firmware file from a URL
|
// uploads a firmware file from a URL
|
||||||
bool WebStatusService::uploadURL(const char * url) {
|
bool WebStatusService::uploadURL(const char * url) {
|
||||||
// this will keep a copy of the URL, but won't initiate the download yet
|
// this will keep a copy of the URL, but won't initiate the download yet
|
||||||
emsesp::EMSESP::system_.uploadFirmwareURL(url);
|
EMSESP::system_.uploadFirmwareURL(url);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// action = systemStatus
|
// action = systemStatus
|
||||||
// sets the system status
|
// sets the system status
|
||||||
bool WebStatusService::setSystemStatus(const char * status) {
|
bool WebStatusService::setSystemStatus(const char * status) {
|
||||||
emsesp::EMSESP::system_.systemStatus(Helpers::atoint(status));
|
EMSESP::system_.systemStatus(Helpers::atoint(status));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ WebAPIService * webAPIService;
|
|||||||
EMSESP application;
|
EMSESP application;
|
||||||
FS dummyFS;
|
FS dummyFS;
|
||||||
|
|
||||||
std::shared_ptr<emsesp::EMSESPConsole> shell;
|
std::shared_ptr<EMSESPConsole> shell;
|
||||||
char output_buffer[4096];
|
char output_buffer[4096];
|
||||||
|
|
||||||
class TestStream : public Stream {
|
class TestStream : public Stream {
|
||||||
|
|||||||
Reference in New Issue
Block a user