main.cc 873 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <esp_log.h>
  2. #include <esp_err.h>
  3. #include <nvs.h>
  4. #include <nvs_flash.h>
  5. #include <driver/gpio.h>
  6. #include <esp_event.h>
  7. #include "application.h"
  8. #include "system_info.h"
  9. #define TAG "main"
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13. #include "freertos/FreeRTOS.h"
  14. #include "freertos/task.h"
  15. #include "freertos/queue.h"
  16. extern "C" void app_main(void)
  17. {
  18. // 初始化默认事件循环
  19. ESP_ERROR_CHECK(esp_event_loop_create_default());
  20. // 初始化NVS闪存
  21. esp_err_t ret = nvs_flash_init();
  22. if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
  23. ESP_LOGW(TAG, "Erasing NVS flash to fix corruption");
  24. ESP_ERROR_CHECK(nvs_flash_erase());
  25. ret = nvs_flash_init();
  26. }
  27. ESP_ERROR_CHECK(ret);
  28. // 启动应用程序(如果有)
  29. Application::GetInstance().Start();
  30. }