51 lines
1.1 KiB
C
51 lines
1.1 KiB
C
/*
|
|
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
|
|
*
|
|
* SPDX-License-Identifier: CC0-1.0
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
/* ESP drivers */
|
|
#include "esp_log.h"
|
|
|
|
/* FreeRTOS */
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
|
|
/* NVS */
|
|
#include "nvs_flash.h"
|
|
|
|
/* Config */
|
|
#include "app_wifi.h"
|
|
#include "sdkconfig.h"
|
|
|
|
#define APP_LOG_TAG "MAIN"
|
|
|
|
void app_main(void) {
|
|
printf("Hello world!\n");
|
|
|
|
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_LOGW(APP_LOG_TAG, "NVS content corrupted or outdated, cleared.");
|
|
}
|
|
|
|
ESP_ERROR_CHECK(ret);
|
|
|
|
ESP_ERROR_CHECK(app_wifi_init());
|
|
|
|
EventBits_t bits = xEventGroupWaitBits(g_app_wifi_event_group,
|
|
APP_WIFI_EVENT_GROUP_EVENT_CONNECTED | APP_WIFI_EVENT_GROUP_EVENT_FAILED,
|
|
pdFALSE, pdFALSE, portMAX_DELAY);
|
|
|
|
if (bits & APP_WIFI_EVENT_GROUP_EVENT_FAILED) {
|
|
/* ?? */
|
|
}
|
|
|
|
vTaskSuspend(NULL);
|
|
}
|