331 ESP_LOGI(TAG, "NTP server %s", sntp_getservername(0)); |
331 ESP_LOGI(TAG, "NTP server %s", sntp_getservername(0)); |
332 ESP_LOGI(TAG, "NTP server %s", sntp_getservername(1)); |
332 ESP_LOGI(TAG, "NTP server %s", sntp_getservername(1)); |
333 #endif |
333 #endif |
334 break; |
334 break; |
335 |
335 |
336 case SYSTEM_EVENT_STA_LOST_IP: |
336 case IP_EVENT_STA_LOST_IP: |
337 ESP_LOGW(TAG, "Lost IP address"); |
337 ESP_LOGW(TAG, "Lost IP address"); |
338 xEventGroupClearBits(xEventGroupWifi, TASK_WIFI_HAS_IP); |
338 xEventGroupClearBits(xEventGroupWifi, TASK_WIFI_HAS_IP); |
339 if (xSemaphoreTake(xSemaphoreWiFi, 25) == pdTRUE) { |
339 if (xSemaphoreTake(xSemaphoreWiFi, 25) == pdTRUE) { |
340 wifi_state->STA_ip[0] = '\0'; |
340 wifi_state->STA_ip[0] = '\0'; |
341 wifi_state->STA_nm[0] = '\0'; |
341 wifi_state->STA_nm[0] = '\0'; |
438 */ |
442 */ |
439 wifi_init_config_t wifi_init_config = WIFI_INIT_CONFIG_DEFAULT(); |
443 wifi_init_config_t wifi_init_config = WIFI_INIT_CONFIG_DEFAULT(); |
440 ESP_ERROR_CHECK(esp_wifi_init(&wifi_init_config)); |
444 ESP_ERROR_CHECK(esp_wifi_init(&wifi_init_config)); |
441 |
445 |
442 ESP_ERROR_CHECK( esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL) ); |
446 ESP_ERROR_CHECK( esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL) ); |
443 ESP_ERROR_CHECK( esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &got_ip_event_handler, NULL) ); |
447 ESP_ERROR_CHECK( esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID /*IP_EVENT_STA_GOT_IP*/, &got_ip_event_handler, NULL) ); |
444 |
448 |
445 ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); |
449 ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); |
446 ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA)); |
450 ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA)); |
447 ESP_ERROR_CHECK(esp_wifi_set_bandwidth(WIFI_IF_AP, config.ap_bandwidth)); |
451 ESP_ERROR_CHECK(esp_wifi_set_bandwidth(WIFI_IF_AP, config.ap_bandwidth)); |
448 |
452 |