Merge branch 'core3' into core3

This commit is contained in:
Proddy
2026-05-12 19:47:59 +02:00
committed by GitHub
14 changed files with 362 additions and 292 deletions

View File

@@ -1711,6 +1711,11 @@ void EMSESP::start() {
bool factory_settings = false;
#endif
#if defined(EMSESP_DEBUG)
// LOG_DEBUG("Listing root directory before:");
// system_.listDir("/", 3); // show the contents of the root directory
#endif
// start NVS storage
if (!nvs_.begin("ems-esp", false, "nvs1")) { // try bigger nvs partition on 16M flash first
nvs_.begin("ems-esp", false, "nvs"); // fallback to small nvs
@@ -1725,6 +1730,11 @@ void EMSESP::start() {
// loads core system services settings (mqtt, ap, ntp etc)
esp32React.begin();
#if defined(EMSESP_DEBUG)
// LOG_DEBUG("Listing root directory after:");
// system_.listDir("/", 3); // show the contents of the root directory
#endif
#ifndef EMSESP_STANDALONE
if (factory_settings) {
LOG_WARNING("No settings found on filesystem. Using factory settings.");

View File

@@ -412,7 +412,7 @@ void Network::startmDNS() const {
MDNS.addService("telnet", "tcp", 23); // add our telnet console
MDNS.addServiceTxt("http", "tcp", "address", address_s.c_str());
emsesp::EMSESP::logger().info("Starting mDNS Responder service");
emsesp::EMSESP::logger().info("Starting mDNS Responder service for %s", address_s.c_str());
#endif
}

View File

@@ -740,18 +740,16 @@ void System::start() {
last_system_check_ = 0; // force the LED to go from fast flash to pulse
uart_init(); // start UART
syslog_init(); // start syslog
modbus_init(); // start modbus
modbus_init(); // start modbus
}
// button single click
void System::button_OnClick(PButton & b) {
LOG_NOTICE("Button pressed - single click");
#if defined(EMSESP_TEST)
#ifndef EMSESP_STANDALONE
// show filesystem
Test::listDir(LittleFS, "/", 3);
#endif
listDir("/", 3);
#endif
}
@@ -3486,4 +3484,39 @@ void System::restore_snapshot_gpios(std::vector<int8_t> & u_gpios, std::vector<i
}
}
// show the contents of a directory in the LittleFS filesystem
void System::listDir(const char * dirname, uint8_t levels) {
#if defined(EMSESP_DEBUG)
#ifndef EMSESP_STANDALONE
File root = LittleFS.open(dirname);
if (!root) {
LOG_DEBUG("Failed to open directory %s", dirname);
return;
}
if (!root.isDirectory()) {
LOG_DEBUG("%s is not a directory", dirname);
return;
}
LOG_DEBUG("(directory) %s", dirname);
File file = root.openNextFile();
while (file) {
if (file.isDirectory()) {
std::string line = std::string(file.name()) + "/";
if (levels) {
// prefix a / to the name to make it a full path
listDir(("/" + String(file.name())).c_str(), levels - 1);
}
} else {
std::string line = " (file) " + std::string(file.name()) + " (" + std::to_string(file.size()) + " bytes)";
LOG_DEBUG("%s", line.c_str());
}
file = root.openNextFile();
}
#endif
#endif
}
} // namespace emsesp

View File

@@ -103,6 +103,8 @@ class System {
static void get_value_json(JsonObject output, const std::string & circuit, const std::string & name, JsonVariant val);
static std::string get_metrics_prometheus();
static void listDir(const char * dirname, uint8_t levels);
#if defined(EMSESP_TEST)
static bool command_test(const char * value, const int8_t id);
#endif