mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
fix display partition name, remove double quotes in shuntingyard
This commit is contained in:
@@ -108,8 +108,8 @@ build_type = release
|
||||
board_build.filesystem = littlefs
|
||||
lib_deps =
|
||||
bblanchon/ArduinoJson @ 7.4.2
|
||||
ESP32Async/AsyncTCP @ 3.4.7
|
||||
ESP32Async/ESPAsyncWebServer @ 3.8.0
|
||||
ESP32Async/AsyncTCP @ 3.4.8
|
||||
ESP32Async/ESPAsyncWebServer @ 3.8.1
|
||||
https://github.com/emsesp/EMS-ESP-Modules.git @ 1.0.8
|
||||
|
||||
;
|
||||
|
||||
@@ -67,7 +67,12 @@ std::deque<Token> exprToTokens(const std::string & expr) {
|
||||
if (*p) {
|
||||
++p;
|
||||
}
|
||||
const auto s = std::string(b, p);
|
||||
auto s = std::string(b, p);
|
||||
auto n = s.find("\"\"");
|
||||
while (n != std::string::npos) {
|
||||
s.erase(n, 2);
|
||||
n = s.find("\"\"");
|
||||
}
|
||||
tokens.emplace_back(Token::Type::String, s, -3);
|
||||
if (*p == '\0') {
|
||||
--p;
|
||||
@@ -360,8 +365,8 @@ bool isnum(const std::string & s) {
|
||||
std::string commands(std::string & expr, bool quotes = true) {
|
||||
auto expr_new = emsesp::Helpers::toLower(expr);
|
||||
for (uint8_t device = 0; device < emsesp::EMSdevice::DeviceType::UNKNOWN; device++) {
|
||||
const char * d = emsesp::EMSdevice::device_type_2_device_name(device);
|
||||
auto f = expr_new.find(d);
|
||||
std::string d = (std::string)emsesp::EMSdevice::device_type_2_device_name(device) + "/";
|
||||
auto f = expr_new.find(d);
|
||||
while (f != std::string::npos) {
|
||||
// entity names are alphanumeric or _
|
||||
auto e = expr_new.find_first_not_of("/._abcdefghijklmnopqrstuvwxyz0123456789", f);
|
||||
@@ -401,6 +406,14 @@ std::string commands(std::string & expr, bool quotes = true) {
|
||||
f = expr_new.find(d, e);
|
||||
}
|
||||
}
|
||||
if (quotes) {
|
||||
// remove double quotes
|
||||
auto f = expr.find("\"\"");
|
||||
while (f != std::string::npos) {
|
||||
expr.erase(f, 2);
|
||||
f = expr.find("\"\"");
|
||||
}
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
|
||||
@@ -442,7 +455,7 @@ std::string to_hex(uint32_t i) {
|
||||
// RPN calculator
|
||||
std::string calculate(const std::string & expr) {
|
||||
std::string expr_new = expr;
|
||||
commands(expr_new);
|
||||
// commands(expr_new);
|
||||
|
||||
const auto tokens = exprToTokens(expr_new);
|
||||
if (tokens.empty()) {
|
||||
@@ -679,6 +692,7 @@ std::string calculate(const std::string & expr) {
|
||||
// check for multiple instances of <cond> ? <expr1> : <expr2>
|
||||
std::string compute(const std::string & expr) {
|
||||
std::string expr_new = expr;
|
||||
commands(expr_new); // replace ems-esp commands with values
|
||||
|
||||
// search json with url:
|
||||
auto f = expr_new.find_first_of('{');
|
||||
|
||||
@@ -1572,7 +1572,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
|
||||
node["freeCaps"] = heap_caps_get_free_size(MALLOC_CAP_8BIT) / 1024; // includes heap and psram
|
||||
node["usedApp"] = EMSESP::system_.appUsed(); // kilobytes
|
||||
node["freeApp"] = EMSESP::system_.appFree(); // kilobytes
|
||||
node["partition"] = esp_ota_get_running_partition()->label; // active partition
|
||||
node["partition"] = (const char *)esp_ota_get_running_partition()->label; // active partition
|
||||
node["flash_chip_size"] = ESP.getFlashChipSize() / 1024; // kilobytes
|
||||
#endif
|
||||
node["resetReason"] = EMSESP::system_.reset_reason(0) + " / " + EMSESP::system_.reset_reason(1);
|
||||
|
||||
@@ -351,7 +351,7 @@ bool WebSchedulerService::command(const char * name, const std::string & command
|
||||
}
|
||||
std::string value = doc["value"] | data.c_str(); // extract value if its in the command, or take the data
|
||||
std::string method = doc["method"] | "GET"; // default GET
|
||||
|
||||
commands(value, false);
|
||||
// if there is data, force a POST
|
||||
int httpResult = 0;
|
||||
if (value.length() || method == "post") { // we have all lowercase
|
||||
|
||||
@@ -115,7 +115,7 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) {
|
||||
root["max_alloc_heap"] = EMSESP::system_.getMaxAllocMem();
|
||||
root["arduino_version"] = ARDUINO_VERSION;
|
||||
root["sdk_version"] = ESP.getSdkVersion();
|
||||
root["partition"] = esp_ota_get_running_partition()->label; // active partition
|
||||
root["partition"] = (const char *)esp_ota_get_running_partition()->label; // active partition
|
||||
root["flash_chip_size"] = ESP.getFlashChipSize() / 1024;
|
||||
root["flash_chip_speed"] = ESP.getFlashChipSpeed();
|
||||
root["app_used"] = EMSESP::system_.appUsed();
|
||||
|
||||
Reference in New Issue
Block a user