mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-11-30 18:23:03 +05:00
73 lines
1.5 KiB
C++
73 lines
1.5 KiB
C++
#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
|
|
|
|
#include <app.h>
|
|
#include <metrics.h>
|
|
#include <esp_system.h>
|
|
|
|
#include <cstdlib>
|
|
|
|
#if ARDUINO_USB_CDC_ON_BOOT && !ARDUINO_USB_MODE
|
|
#include <USB.h>
|
|
#endif
|
|
|
|
#ifndef ARDUINO_ARCH_ESP32
|
|
#error Only ESP32 boards are supported
|
|
#endif
|
|
|
|
#include <LittleFS.h>
|
|
|
|
// Vars
|
|
Sensors::Result sensorsResults[SENSORS_AMOUNT];
|
|
|
|
TaskManager appTaskManager("App");
|
|
|
|
|
|
extern "C" void app_main() {
|
|
// https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/main.cpp
|
|
#if defined(F_XTAL_MHZ) && !CONFIG_IDF_TARGET_ESP32S2
|
|
rtc_clk_xtal_freq_update((rtc_xtal_freq_t)F_XTAL_MHZ);
|
|
rtc_clk_cpu_freq_set_xtal();
|
|
#endif
|
|
|
|
#ifdef F_CPU
|
|
setCpuFrequencyMhz(F_CPU / 1000000);
|
|
#endif
|
|
|
|
#if ARDUINO_USB_DFU_ON_BOOT && !ARDUINO_USB_MODE
|
|
USB.enableDFU();
|
|
#endif
|
|
|
|
#if ARDUINO_USB_ON_BOOT && !ARDUINO_USB_MODE
|
|
USB.begin();
|
|
#endif
|
|
|
|
initArduino();
|
|
initCoreDumpMetrics();
|
|
Sensors::setMaxSensors(SENSORS_AMOUNT);
|
|
Sensors::settings = sensorsSettings;
|
|
Sensors::results = sensorsResults;
|
|
TaskManager::configureWDT(60, true);
|
|
LittleFS.begin();
|
|
|
|
if (!initLogging()) {
|
|
std::abort();
|
|
}
|
|
|
|
initConfig();
|
|
initNetwork();
|
|
initControl();
|
|
initRegulator();
|
|
initLeds();
|
|
initMqtt();
|
|
initPortal();
|
|
initOpenTherm();
|
|
initSystem();
|
|
initSensors();
|
|
|
|
// App runs control and MQTT tasks
|
|
if (!appTaskManager.asyncStart(4608, 4, tskNO_AFFINITY, 100, false)) {
|
|
esp_system_abort("Failed to start App task manager");
|
|
}
|
|
ESP_LOGI(L_MAIN, "Started %s task manager", appTaskManager.name());
|
|
}
|