47 lines
1.1 KiB
C
47 lines
1.1 KiB
C
#include <stdio.h>
|
|
|
|
#include "sdkconfig.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "freertos/event_groups.h"
|
|
#include "esp_system.h"
|
|
#include "esp_spi_flash.h"
|
|
#include "nvs_flash.h"
|
|
#include "esp_log.h"
|
|
|
|
static const char *TAG = "APP_MAIN";
|
|
|
|
extern EventGroupHandle_t g_wifi_event_group;
|
|
|
|
void app_wifi_init(void);
|
|
|
|
// Tasks
|
|
extern TaskHandle_t xTaskDiscoLEDHandle;
|
|
void vTaskDiscoLED(void *pvParameters);
|
|
|
|
void app_main(void) {
|
|
|
|
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);
|
|
|
|
printf("Playground started.\r\n");
|
|
|
|
app_wifi_init();
|
|
EventBits_t bits = xEventGroupWaitBits(g_wifi_event_group, 0x03, pdFALSE, pdFALSE, portMAX_DELAY);
|
|
if(bits & 0x01) {
|
|
ESP_LOGI(TAG, "WiFi connected.");
|
|
} else {
|
|
ESP_LOGE(TAG, "WiFi failed.");
|
|
}
|
|
|
|
xTaskCreate(vTaskDiscoLED, "vTaskDisco", 1024, NULL, 3, &xTaskDiscoLEDHandle);
|
|
|
|
for(;;) {
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
}
|
|
}
|