app_main.c 782 B

123456789101112131415161718192021222324252627282930
  1. // app_main.c
  2. #include "freertos/FreeRTOS.h"
  3. #include "freertos/task.h"
  4. #include "esp_log.h"
  5. #include "nvs_flash.h"
  6. #include "wifi_http.h" // 引入wifi_http.c中的头文件
  7. #include "http_request.h" // 引入http_request.c中的头文件
  8. #include "camera.h"
  9. static const char *TAG = "app_main";
  10. // 主函数
  11. void app_main(void)
  12. {
  13. // 初始化NVS
  14. esp_err_t ret = nvs_flash_init();
  15. if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
  16. ESP_ERROR_CHECK(nvs_flash_erase());
  17. ret = nvs_flash_init();
  18. }
  19. ESP_ERROR_CHECK(ret);
  20. // 初始化Wi-Fi并连接
  21. wifi_init_sta();
  22. // 等待Wi-Fi连接
  23. vTaskDelay(10000 / portTICK_PERIOD_MS);
  24. xTaskCreate(take_photo, "take_photo", 1024 * 50, NULL, 20, NULL);
  25. }