app_main.c 929 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. //take_photo();
  25. ESP_LOGI(TAG, "测试");
  26. while (true)
  27. {
  28. /* code */
  29. // 执行HTTP GET请求
  30. http_get_request();
  31. vTaskDelay(4*1000 / portTICK_PERIOD_MS);
  32. }
  33. }