-
-
Save anonymous/2d02337fa06985f5bc3e90b00369fe2c to your computer and use it in GitHub Desktop.
wifi init
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void WIFI_Init(void) | |
{ | |
ESP_ERROR_CHECK( nvs_flash_init() ); | |
tcpip_adapter_init(); | |
wifi_event_group = xEventGroupCreate(); | |
ESP_ERROR_CHECK( esp_event_loop_init(wifi_eventHandler, NULL) ); | |
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); | |
ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); | |
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_FLASH) ); | |
wifi_config_t wifi_config = { | |
.sta = { | |
.ssid = DEFAULT_SSID, | |
.password = DEFAULT_PWD, | |
}, | |
}; | |
ESP_LOGI("wifi", "Setting WiFi configuration SSID %s...", wifi_config.sta.ssid); | |
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); | |
ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); | |
ESP_ERROR_CHECK( esp_wifi_start() ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment