diff --git a/include/YaSolR.h b/include/YaSolR.h index 21c1e38..a5975b4 100644 --- a/include/YaSolR.h +++ b/include/YaSolR.h @@ -66,40 +66,51 @@ extern Mycila::Task dashboardUpdateTask; // Config extern Mycila::Config config; +extern void yasolr_init_config(); // Network extern Mycila::ESPConnect espConnect; extern Mycila::Task networkStartTask; +extern void yasolr_init_network(); // grid electricity extern Mycila::Grid grid; +extern void yasolr_init_grid(); +extern float yasolr_frequency(); // logging extern Mycila::Logger logger; +extern void yasolr_init_logging(); +extern void yasolr_configure_logging(); // router extern Mycila::PID pidController; extern Mycila::Router router; -// Remote JSY -extern AsyncUDP* udp; -extern Mycila::CircularBuffer* udpMessageRateBuffer; - // JSY extern Mycila::JSY* jsy; extern Mycila::Task* jsyTask; extern Mycila::TaskManager* jsyTaskManager; +extern void yasolr_init_jsy(); + +// JSY Remote +extern AsyncUDP* udp; +extern Mycila::CircularBuffer* udpMessageRateBuffer; +extern Mycila::Task* jsyRemoteTask; +extern void yasolr_init_jsy_remote(); // DS18 extern Mycila::DS18* ds18O1; extern Mycila::DS18* ds18O2; extern Mycila::DS18* ds18Sys; extern Mycila::Task* ds18Task; +extern void yasolr_init_ds18(); // Display extern Mycila::EasyDisplay* display; extern Mycila::Task* displayCarouselTask; extern Mycila::Task* displayTask; +extern void yasolr_init_display(); // ZCD extern Mycila::PulseAnalyzer* pulseAnalyzer; @@ -111,6 +122,7 @@ extern Mycila::Task* mqttPublishConfigTask; extern Mycila::Task* mqttPublishStaticTask; extern Mycila::Task* mqttPublishTask; extern Mycila::Task* haDiscoveryTask; +extern void yasolr_init_mqtt(); // PZEM extern Mycila::PZEM* pzemO1; @@ -119,9 +131,11 @@ extern Mycila::Task* pzemO1PairingTask; extern Mycila::Task* pzemO2PairingTask; extern Mycila::Task* pzemTask; extern Mycila::TaskManager* pzemTaskManager; +extern void yasolr_init_pzem(); // Lights extern Mycila::TrafficLight lights; +extern void yasolr_init_lights(); // System extern Mycila::Task resetTask; @@ -129,6 +143,19 @@ extern Mycila::Task restartTask; extern Mycila::Task safeBootTask; extern Mycila::TaskManager coreTaskManager; extern Mycila::TaskManager unsafeTaskManager; +extern void yasolr_boot(); +extern void yasolr_init_system(); + +// Trial +extern void yasolr_init_trial(); + +// init +extern void yasolr_init_web_server(); +extern void yasolr_init_zcd(); + +// TODO +extern void yasolr_divert(); +extern void yasolr_configure(); extern Mycila::Dimmer dimmerO1; extern Mycila::Dimmer dimmerO2; @@ -144,27 +171,3 @@ extern Mycila::RouterRelay routerRelay2; extern Mycila::Task calibrationTask; extern Mycila::Task relayTask; extern Mycila::Task routerTask; - -// fn -extern float yasolr_frequency(); -extern void yasolr_boot(); -extern void yasolr_configure(); -extern void yasolr_divert(); - -extern void yasolr_init_config(); -extern void yasolr_init_display(); -extern void yasolr_init_ds18(); -extern void yasolr_init_grid(); -extern void yasolr_init_jsy_remote_listener(); -extern void yasolr_init_jsy(); -extern void yasolr_init_lights(); -extern void yasolr_init_logging(); -extern void yasolr_init_mqtt(); -extern void yasolr_init_network(); -extern void yasolr_init_pzem(); -extern void yasolr_init_system(); -extern void yasolr_init_trial(); -extern void yasolr_init_web_server(); -extern void yasolr_init_zcd(); - -extern void yasolr_configure_logging(); diff --git a/src/Website.cpp b/src/Website.cpp index 855f9fc..74d301a 100644 --- a/src/Website.cpp +++ b/src/Website.cpp @@ -302,7 +302,7 @@ dash::LineChart _pidDTermHistory(dashboard, YASOLR_LBL_176); #endif void YaSolR::Website::begin() { - logger.debug(TAG, "Initializing layout"); + logger.info(TAG, "Initialize dashboard layout..."); for (int i = 0; i < YASOLR_GRAPH_POINTS; i++) _historyX[i] = i - YASOLR_GRAPH_POINTS; @@ -829,7 +829,7 @@ void YaSolR::Website::begin() { } void YaSolR::Website::initCards() { - logger.debug(TAG, "Initializing cards"); + logger.debug(TAG, "Initialize dashboard cards..."); // Statistics diff --git a/src/main.cpp b/src/main.cpp index c809eee..f062003 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,29 +18,36 @@ Mycila::RouterOutput output1("output1", dimmerO1, bypassRelayO1); Mycila::RouterOutput output2("output2", dimmerO2, bypassRelayO2); void setup() { + // boot yasolr_boot(); + // config yasolr_init_config(); - - yasolr_configure(); - + // logging + yasolr_init_logging(); + // system + yasolr_init_system(); + // hardware yasolr_init_display(); yasolr_init_ds18(); yasolr_init_grid(); yasolr_init_jsy(); + yasolr_init_jsy_remote(); yasolr_init_lights(); - yasolr_init_logging(); yasolr_init_mqtt(); yasolr_init_network(); yasolr_init_pzem(); - yasolr_init_system(); yasolr_init_trial(); yasolr_init_web_server(); yasolr_init_zcd(); - + // logging configuration yasolr_configure_logging(); + yasolr_configure(); // TODO + + // core task manager assert(coreTaskManager.asyncStart(512 * 8, 1, 1, 100, true)); + // task manager for long running tasks like mqtt / pzem if (unsafeTaskManager.getSize()) assert(unsafeTaskManager.asyncStart(512 * 8, 1, 1, 100, false)); diff --git a/src/tasks/calibrationTask.cpp b/src/tasks/calibrationTask.cpp deleted file mode 100644 index 88cb859..0000000 --- a/src/tasks/calibrationTask.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -/* - * Copyright (C) 2023-2024 Mathieu Carbou - */ -#include - -Mycila::Task calibrationTask("Calibration", [](void* params) { router.calibrate(); }); diff --git a/src/tasks/relayTask.cpp b/src/tasks/relayTask.cpp deleted file mode 100644 index 1dacead..0000000 --- a/src/tasks/relayTask.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -/* - * Copyright (C) 2023-2024 Mathieu Carbou - */ -#include - -Mycila::Task relayTask("Relay", [](void* params) { - if (grid.getPower().isAbsent()) - return; - - Mycila::Router::Metrics routerMetrics; - router.getRouterMeasurements(routerMetrics); - - float virtualGridPower = grid.getPower().get() - routerMetrics.power; - - if (routerRelay1.tryRelayStateAuto(true, virtualGridPower)) - return; - if (routerRelay2.tryRelayStateAuto(true, virtualGridPower)) - return; - if (routerRelay2.tryRelayStateAuto(false, virtualGridPower)) - return; - if (routerRelay1.tryRelayStateAuto(false, virtualGridPower)) - return; -}); diff --git a/src/tasks/routerTask.cpp b/src/tasks/routerTask.cpp deleted file mode 100644 index 36f68c1..0000000 --- a/src/tasks/routerTask.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -/* - * Copyright (C) 2023-2024 Mathieu Carbou - */ -#include - -Mycila::Task routerTask("Router", [](void* params) { - std::optional voltage = grid.getVoltage(); - - if (!voltage.has_value() || grid.getPower().isAbsent()) - router.noDivert(); - - output1.applyTemperatureLimit(); - output2.applyTemperatureLimit(); - - output1.applyAutoBypass(); - output2.applyAutoBypass(); -}); diff --git a/src/yasolr_configure.cpp b/src/todo/yasolr_configure.cpp similarity index 85% rename from src/yasolr_configure.cpp rename to src/todo/yasolr_configure.cpp index ff3b0ca..e2e968a 100644 --- a/src/yasolr_configure.cpp +++ b/src/todo/yasolr_configure.cpp @@ -7,6 +7,40 @@ #include +Mycila::Task calibrationTask("Calibration", [](void* params) { router.calibrate(); }); + +Mycila::Task relayTask("Relay", [](void* params) { + if (grid.getPower().isAbsent()) + return; + + Mycila::Router::Metrics routerMetrics; + router.getRouterMeasurements(routerMetrics); + + float virtualGridPower = grid.getPower().get() - routerMetrics.power; + + if (routerRelay1.tryRelayStateAuto(true, virtualGridPower)) + return; + if (routerRelay2.tryRelayStateAuto(true, virtualGridPower)) + return; + if (routerRelay2.tryRelayStateAuto(false, virtualGridPower)) + return; + if (routerRelay1.tryRelayStateAuto(false, virtualGridPower)) + return; +}); + +Mycila::Task routerTask("Router", [](void* params) { + std::optional voltage = grid.getVoltage(); + + if (!voltage.has_value() || grid.getPower().isAbsent()) + router.noDivert(); + + output1.applyTemperatureLimit(); + output2.applyTemperatureLimit(); + + output1.applyAutoBypass(); + output2.applyAutoBypass(); +}); + void yasolr_divert() { if (router.isCalibrationRunning()) return; diff --git a/src/yasolr_boot.cpp b/src/yasolr_boot.cpp index a0f5842..3daa16b 100644 --- a/src/yasolr_boot.cpp +++ b/src/yasolr_boot.cpp @@ -16,7 +16,7 @@ void yasolr_boot() { // early logging logger.forwardTo(&Serial); - logger.info(TAG, "Booting %s", Mycila::AppInfo.nameModelVersion.c_str()); + logger.info(TAG, "Booting %s...", Mycila::AppInfo.nameModelVersion.c_str()); // system Mycila::System::init(true, "fs"); diff --git a/src/yasolr_config.cpp b/src/yasolr_config.cpp index 0a49334..9b1129a 100644 --- a/src/yasolr_config.cpp +++ b/src/yasolr_config.cpp @@ -9,6 +9,8 @@ Mycila::Config config; void yasolr_init_config() { + logger.info(TAG, "Configuring %s...", Mycila::AppInfo.nameModelVersion.c_str()); + // setup config system config.begin("YASOLR"); config.configure(KEY_ADMIN_PASSWORD); @@ -239,8 +241,4 @@ void yasolr_init_config() { if (mqttPublishTask) mqttPublishTask->requestEarlyRun(); }); - - // pre-init logging - logger.setLevel(config.getBool(KEY_ENABLE_DEBUG) ? ARDUHAL_LOG_LEVEL_DEBUG : ARDUHAL_LOG_LEVEL_INFO); - esp_log_level_set("*", static_cast(logger.getLevel())); } diff --git a/src/yasolr_display.cpp b/src/yasolr_display.cpp index ad29a6e..ef5115f 100644 --- a/src/yasolr_display.cpp +++ b/src/yasolr_display.cpp @@ -24,6 +24,8 @@ void yasolr_init_display() { assert(!displayCarouselTask); assert(!displayTask); + logger.info(TAG, "Initialize display..."); + display = new Mycila::EasyDisplay(YASOLR_DISPLAY_LINES, YASOLR_DISPLAY_LINE_SIZE, 4, u8g2_font_6x12_tf); const std::string& displayType = config.getString(KEY_DISPLAY_TYPE); @@ -34,8 +36,10 @@ void yasolr_init_display() { else if (displayType == "SH1106") display->begin(Mycila::EasyDisplayType::SH1106, config.getLong(KEY_PIN_DISPLAY_SCL), config.getLong(KEY_PIN_DISPLAY_SDA), config.getLong(KEY_DISPLAY_ROTATION)); - if (!display->isEnabled()) + if (!display->isEnabled()) { + logger.error(TAG, "Display failed to initialize!"); return; + } display->clearDisplay(); display->setActive(true); diff --git a/src/yasolr_ds18.cpp b/src/yasolr_ds18.cpp index 5aaaba8..0d41da8 100644 --- a/src/yasolr_ds18.cpp +++ b/src/yasolr_ds18.cpp @@ -10,6 +10,7 @@ Mycila::DS18* ds18Sys; Mycila::Task* ds18Task; void yasolr_init_ds18() { + logger.info(TAG, "Initialize DS18 probes..."); uint8_t count = 0; if (config.getBool(KEY_ENABLE_DS18_SYSTEM)) { @@ -27,6 +28,8 @@ void yasolr_init_ds18() { mqttPublishTask->requestEarlyRun(); } }); + } else { + logger.error(TAG, "DS18 system probe failed to initialize!"); } } @@ -46,6 +49,8 @@ void yasolr_init_ds18() { mqttPublishTask->requestEarlyRun(); } }); + } else { + logger.error(TAG, "DS18 output 1 probe failed to initialize!"); } } @@ -66,6 +71,8 @@ void yasolr_init_ds18() { } }); ds18O2 = new Mycila::DS18(); + } else { + logger.error(TAG, "DS18 output 2 probe failed to initialize!"); } } diff --git a/src/yasolr_grid.cpp b/src/yasolr_grid.cpp index 4c623b8..c53fc36 100644 --- a/src/yasolr_grid.cpp +++ b/src/yasolr_grid.cpp @@ -37,6 +37,8 @@ float yasolr_frequency() { } void yasolr_init_grid() { + logger.info(TAG, "Initialize grid electricity..."); + grid.localMetrics().setExpiration(10000); // local is fast grid.remoteMetrics().setExpiration(10000); // remote JSY is fast grid.pzemMetrics().setExpiration(10000); // local is fast diff --git a/src/yasolr_jsy.cpp b/src/yasolr_jsy.cpp index 0ffceb6..7d3a80c 100644 --- a/src/yasolr_jsy.cpp +++ b/src/yasolr_jsy.cpp @@ -14,11 +14,15 @@ void yasolr_init_jsy() { assert(!jsyTask); assert(!jsyTaskManager); + logger.info(TAG, "Initialize JSY..."); + jsy = new Mycila::JSY(); jsy->begin(YASOLR_JSY_SERIAL, config.getLong(KEY_PIN_JSY_RX), config.getLong(KEY_PIN_JSY_TX)); - if (!jsy->isEnabled()) + if (!jsy->isEnabled()) { + logger.error(TAG, "JSY failed to initialize!"); return; + } if (jsy->getBaudRate() != jsy->getMaxAvailableBaudRate()) jsy->setBaudRate(jsy->getMaxAvailableBaudRate()); diff --git a/src/yasolr_jsy_remote_listener.cpp b/src/yasolr_jsy_remote.cpp similarity index 82% rename from src/yasolr_jsy_remote_listener.cpp rename to src/yasolr_jsy_remote.cpp index a6fca73..1f7e99f 100644 --- a/src/yasolr_jsy_remote_listener.cpp +++ b/src/yasolr_jsy_remote.cpp @@ -6,6 +6,7 @@ AsyncUDP* udp; Mycila::CircularBuffer* udpMessageRateBuffer; +Mycila::Task* jsyRemoteTask; void onData(AsyncUDPPacket packet) { // buffer[0] == MYCILA_UDP_MSG_TYPE_JSY_DATA (1) @@ -105,21 +106,26 @@ void onData(AsyncUDPPacket packet) { } } -void yasolr_init_jsy_remote_listener() { +void yasolr_init_jsy_remote() { if (config.getBool(KEY_ENABLE_JSY_REMOTE)) { - logger.info(TAG, "Enable JSY Remote Listener"); + assert(!udp); + assert(!udpMessageRateBuffer); + assert(!jsyRemoteTask); - if (!udp) { - udp = new AsyncUDP(); - udpMessageRateBuffer = new Mycila::CircularBuffer(); + logger.info(TAG, "Initialize JSY Remote..."); - Mycila::TaskMonitor.addTask("async_udp"); // AsyncUDP (stack size cannot be set) + udp = new AsyncUDP(); + udp->onPacket(onData); - udp->onPacket(onData); - } + udpMessageRateBuffer = new Mycila::CircularBuffer(); + + Mycila::TaskMonitor.addTask("async_udp"); // AsyncUDP (stack size cannot be set) - const uint16_t udpPort = config.getLong(KEY_UDP_PORT); - logger.info(TAG, "Enable UDP Server on port %" PRIu16, udpPort); - udp->listen(udpPort); + jsyRemoteTask = new Mycila::Task("JSY Remote", Mycila::TaskType::ONCE, [](void* params) { + const uint16_t udpPort = config.getLong(KEY_UDP_PORT); + logger.info(TAG, "Enable JSY Remote Listener on port %..." PRIu16, udpPort); + udp->listen(udpPort); + }); + jsyRemoteTask->setManager(coreTaskManager); } } diff --git a/src/yasolr_lights.cpp b/src/yasolr_lights.cpp index 271ba3e..5ba523d 100644 --- a/src/yasolr_lights.cpp +++ b/src/yasolr_lights.cpp @@ -43,6 +43,8 @@ Mycila::Task lightsTask("Lights", [](void* params) { }); void yasolr_init_lights() { + logger.info(TAG, "Initialize system lights..."); + if (config.getBool(KEY_ENABLE_LIGHTS)) lights.begin(config.getLong(KEY_PIN_LIGHTS_GREEN), config.getLong(KEY_PIN_LIGHTS_YELLOW), config.getLong(KEY_PIN_LIGHTS_RED)); diff --git a/src/yasolr_logging.cpp b/src/yasolr_logging.cpp index f8617cf..3f28450 100644 --- a/src/yasolr_logging.cpp +++ b/src/yasolr_logging.cpp @@ -22,6 +22,11 @@ Mycila::Task loggingTask("Debug", [](void* params) { }); void yasolr_init_logging() { + logger.info(TAG, "Initialize logging..."); + + logger.setLevel(config.getBool(KEY_ENABLE_DEBUG) ? ARDUHAL_LOG_LEVEL_DEBUG : ARDUHAL_LOG_LEVEL_INFO); + esp_log_level_set("*", static_cast(logger.getLevel())); + #ifdef APP_MODEL_PRO WebSerial.setID(Mycila::AppInfo.firmware.c_str()); WebSerial.setTitle((Mycila::AppInfo.name + " Web Console").c_str()); diff --git a/src/yasolr_mqtt.cpp b/src/yasolr_mqtt.cpp index a06fea7..689ac30 100644 --- a/src/yasolr_mqtt.cpp +++ b/src/yasolr_mqtt.cpp @@ -54,7 +54,7 @@ void connect() { } void subscribe() { - logger.info(TAG, "Initializing MQTT Subscribers"); + logger.info(TAG, "Subscribing to MQTT topics..."); const std::string& baseTopic = config.getString(KEY_MQTT_TOPIC); @@ -176,7 +176,7 @@ void subscribe() { } void publishConfig() { - logger.debug(TAG, "Publishing config to MQTT"); + logger.info(TAG, "Publishing config to MQTT..."); const std::string& baseTopic = config.getString(KEY_MQTT_TOPIC); for (auto& key : config.keys()) { @@ -188,7 +188,7 @@ void publishConfig() { } void publishStaticData() { - logger.debug(TAG, "Publishing static data to MQTT"); + logger.info(TAG, "Publishing static data to MQTT..."); const std::string& baseTopic = config.getString(KEY_MQTT_TOPIC); mqtt->publish(baseTopic + "/system/app/manufacturer", Mycila::AppInfo.manufacturer, true); @@ -397,7 +397,7 @@ void yasolr_init_mqtt() { assert(!mqttPublishStaticTask); assert(!mqttPublishTask); - logger.info(TAG, "Enable MQTT"); + logger.info(TAG, "Initialize MQTT..."); mqtt = new Mycila::MQTT(); mqttConnectTask = new Mycila::Task("MQTT Connect", Mycila::TaskType::ONCE, [](void* params) { connect(); }); diff --git a/src/yasolr_network.cpp b/src/yasolr_network.cpp index 2d4d025..28caf41 100644 --- a/src/yasolr_network.cpp +++ b/src/yasolr_network.cpp @@ -7,10 +7,10 @@ Mycila::Task networkManagerTask("ESPConnect", [](void* params) { espConnect.loop(); }); Mycila::Task networkStartTask("Network Start", Mycila::TaskType::ONCE, [](void* params) { - logger.info(TAG, "Enable Network Services"); + logger.info(TAG, "Enable Network Services..."); // Web server - logger.info(TAG, "Enable Web Server"); + logger.info(TAG, "Enable Web Server..."); webServer.begin(); webServer.onNotFound([](AsyncWebServerRequest* request) { request->send(404); @@ -18,14 +18,15 @@ Mycila::Task networkStartTask("Network Start", Mycila::TaskType::ONCE, [](void* if (!config.getBool(KEY_ENABLE_AP_MODE)) { // NTP - logger.info(TAG, "Enable NTP"); + logger.info(TAG, "Enable NTP..."); Mycila::NTP.sync(config.get(KEY_NTP_SERVER)); // mDNS - logger.info(TAG, "Enable mDNS"); + logger.info(TAG, "Enable mDNS..."); MDNS.addService("http", "tcp", 80); - yasolr_init_jsy_remote_listener(); + if (jsyRemoteTask) + jsyRemoteTask->resume(); if (mqttConnectTask) mqttConnectTask->resume(); @@ -33,6 +34,8 @@ Mycila::Task networkStartTask("Network Start", Mycila::TaskType::ONCE, [](void* }); void yasolr_init_network() { + logger.info(TAG, "Initialize networking..."); + // NTP Mycila::NTP.setTimeZone(config.get(KEY_NTP_TIMEZONE)); @@ -54,7 +57,7 @@ void yasolr_init_network() { logger.warn(TAG, "Disabled Network!"); break; case Mycila::ESPConnect::State::AP_STARTING: - logger.info(TAG, "Starting Access Point %s", espConnect.getAccessPointSSID().c_str()); + logger.info(TAG, "Starting Access Point %s...", espConnect.getAccessPointSSID().c_str()); break; case Mycila::ESPConnect::State::AP_STARTED: logger.info(TAG, "Access Point %s started with IP address %s", espConnect.getWiFiSSID().c_str(), espConnect.getIPAddress().toString().c_str()); @@ -74,10 +77,10 @@ void yasolr_init_network() { logger.warn(TAG, "Disconnected!"); break; case Mycila::ESPConnect::State::NETWORK_RECONNECTING: - logger.info(TAG, "Trying to reconnect"); + logger.info(TAG, "Trying to reconnect..."); break; case Mycila::ESPConnect::State::PORTAL_STARTING: - logger.info(TAG, "Starting Captive Portal %s for %" PRIu32 " seconds", espConnect.getAccessPointSSID().c_str(), espConnect.getCaptivePortalTimeout()); + logger.info(TAG, "Starting Captive Portal %s for %" PRIu32 " seconds...", espConnect.getAccessPointSSID().c_str(), espConnect.getCaptivePortalTimeout()); break; case Mycila::ESPConnect::State::PORTAL_STARTED: logger.info(TAG, "Captive Portal started at %s with IP address %s", espConnect.getWiFiSSID().c_str(), espConnect.getIPAddress().toString().c_str()); diff --git a/src/yasolr_pzem.cpp b/src/yasolr_pzem.cpp index 911b00b..8e1ddc3 100644 --- a/src/yasolr_pzem.cpp +++ b/src/yasolr_pzem.cpp @@ -12,6 +12,7 @@ Mycila::Task* pzemTask; Mycila::TaskManager* pzemTaskManager; void yasolr_init_pzem() { + logger.info(TAG, "Initialize PZEM..."); uint8_t count = 0; if (config.getBool(KEY_ENABLE_OUTPUT1_PZEM)) { @@ -79,6 +80,9 @@ void yasolr_init_pzem() { } }); pzemO1PairingTask->setManager(unsafeTaskManager); + + } else { + logger.error(TAG, "Failed to initialize PZEM for Output 1!"); } } @@ -147,6 +151,9 @@ void yasolr_init_pzem() { } }); pzemO2PairingTask->setManager(unsafeTaskManager); + + } else { + logger.error(TAG, "Failed to initialize PZEM for Output 2!"); } } diff --git a/src/yasolr_system.cpp b/src/yasolr_system.cpp index bdf5aae..1acfdc6 100644 --- a/src/yasolr_system.cpp +++ b/src/yasolr_system.cpp @@ -24,6 +24,8 @@ Mycila::Task safeBootTask("SafeBoot", Mycila::TaskType::ONCE, [](void* params) { }); void yasolr_init_system() { + logger.info(TAG, "Initialize system..."); + resetTask.setManager(coreTaskManager); restartTask.setManager(coreTaskManager); safeBootTask.setManager(coreTaskManager); diff --git a/src/yasolr_trial.cpp b/src/yasolr_trial.cpp index 7193d31..065eebc 100644 --- a/src/yasolr_trial.cpp +++ b/src/yasolr_trial.cpp @@ -10,6 +10,8 @@ Mycila::Task* trialTask; void yasolr_init_trial() { #ifdef APP_MODEL_TRIAL + logger.info(TAG, "Initialize trial..."); + Mycila::Trial.begin(); Mycila::Trial.validate(); diff --git a/src/yasolr_website.cpp b/src/yasolr_web_server.cpp similarity index 98% rename from src/yasolr_website.cpp rename to src/yasolr_web_server.cpp index 9480cd1..ab0aa31 100644 --- a/src/yasolr_website.cpp +++ b/src/yasolr_web_server.cpp @@ -25,13 +25,13 @@ Mycila::ESPConnect espConnect(webServer); YaSolR::Website website; -Mycila::Task dashboardInitTask("Dashboard Init", Mycila::TaskType::ONCE, [](void* params) { +Mycila::Task dashboardInitTask("Init Dashboard", Mycila::TaskType::ONCE, [](void* params) { website.initCards(); website.updateCards(); dashboard.sendUpdates(); }); -Mycila::Task dashboardUpdateTask("Dashboard Update", [](void* params) { +Mycila::Task dashboardUpdateTask("Dashboard", [](void* params) { if (website.pidCharts()) website.updatePID(); website.updateCards(); @@ -82,7 +82,7 @@ void routes() { } void rest_api() { - logger.info(TAG, "Initializing REST API"); + logger.info(TAG, "Initialize REST API..."); // debug @@ -496,7 +496,7 @@ void rest_api() { } void yasolr_init_web_server() { - logger.info(TAG, "Initializing Web Server"); + logger.info(TAG, "Initialize web server..."); // Middleware @@ -522,7 +522,7 @@ void yasolr_init_web_server() { #endif dashboard.onBeforeUpdate([](bool changes_only) { if (!changes_only) { - logger.info(TAG, "Dashboard refresh requested"); + logger.info(TAG, "Dashboard refresh requested!"); website.initCards(); } }); diff --git a/src/yasolr_zcd.cpp b/src/yasolr_zcd.cpp index 2282fd3..31ae406 100644 --- a/src/yasolr_zcd.cpp +++ b/src/yasolr_zcd.cpp @@ -14,6 +14,8 @@ void yasolr_init_zcd() { assert(!pulseAnalyzer); assert(!zcdTask); + logger.info(TAG, "Initialize ZCD pulse analyzer..."); + pulseAnalyzer = new Mycila::PulseAnalyzer(); pulseAnalyzer->onZeroCross(Mycila::Dimmer::onZeroCross); pulseAnalyzer->begin(config.getLong(KEY_PIN_ZCD));