42 lines
834 B
C
42 lines
834 B
C
#include "esp_log.h"
|
|
#include <esp_system.h>
|
|
#include "nvs_flash.h"
|
|
|
|
#include "safety.h"
|
|
#include "metrics.h"
|
|
#include "outputs.h"
|
|
#include "inputs.h"
|
|
#include "control.h"
|
|
#include "wifi.h"
|
|
#include "sntp.h"
|
|
|
|
static const char *TAG = "smart-oil-heater-control-system";
|
|
|
|
void app_main(void)
|
|
{
|
|
ESP_LOGI(TAG, "starting ...");
|
|
|
|
// Initialize NVS
|
|
esp_err_t ret = nvs_flash_init();
|
|
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
|
|
{
|
|
ESP_ERROR_CHECK(nvs_flash_erase());
|
|
ret = nvs_flash_init();
|
|
}
|
|
ESP_ERROR_CHECK(ret);
|
|
|
|
// TODO: Error handling!
|
|
initOutputs();
|
|
initInputs();
|
|
initSafety();
|
|
initWifi();
|
|
initSntp();
|
|
initControl();
|
|
initMetrics();
|
|
|
|
while (1)
|
|
{
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
// Do nothing ;-)
|
|
}
|
|
} |