Wifi disconnect after a time
Posted: Fri Jan 26, 2018 1:31 pm
Hi All,
I use a WIFI connection, and after init (about 5 minutes) the wifi connection breaks.
Here is the log message:
I (822129) wifi: bcn_timout,ap_probe_send_start
I (824632) wifi: ap_probe_send over, resett wifi status to disassoc
I (824632) wifi: state: run -> init (1)
I (824633) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (824636) wifi: pm stop, total sleep time: 0/820681527
I use dhcp, and here is the wifi init code:
and I have an event handler:
but it cannot catch this problem.
How can I catch this, and how can I reconnect when it happens?
My hw is an ESP WROVER KIT V3, and ESP_IDF is a fresh master branch in git repository.
thx,
Zamek
I use a WIFI connection, and after init (about 5 minutes) the wifi connection breaks.
Here is the log message:
I (822129) wifi: bcn_timout,ap_probe_send_start
I (824632) wifi: ap_probe_send over, resett wifi status to disassoc
I (824632) wifi: state: run -> init (1)
I (824633) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (824636) wifi: pm stop, total sleep time: 0/820681527
I use dhcp, and here is the wifi init code:
Code: Select all
nvs_flash_init();
tcpip_adapter_init();
esp_log_level_set("*", ESP_LOG_DEBUG);
ESP_ERROR_CHECK( esp_event_loop_init(event_handler, 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_RAM) );
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
wifi_config_t sta_config = {
.sta = {
.ssid = CONFIG_WIFI_AP,
.password = CONFIG_WIFI_PW,
.bssid_set = false
}
};
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &sta_config) );
ESP_ERROR_CHECK( esp_wifi_start() );
Code: Select all
esp_err_t event_handler(void *ctx, system_event_t *event) {
switch(event->event_id) {
case SYSTEM_EVENT_STA_START:
ESP_LOGD(LOG_TAG, "SYSTEM_EVENT_STA_START");
esp_wifi_connect();
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
ESP_LOGD(LOG_TAG, "SYSTEM_EVENT_STA_DISCONNECTED");
esp_wifi_connect();
xEventGroupClearBits(wifi_event_group, EVT_WIFI_CONNECTED);
break;
case SYSTEM_EVENT_STA_LOST_IP :
wifi_reinit();
break;
case SYSTEM_EVENT_STA_GOT_IP:
ESP_LOGD(LOG_TAG, "SYSTEM_EVENT_STA_GOT_IP");
ESP_LOGI(LOG_TAG, "ip address:%s\n", inet_ntoa(event->event_info.got_ip.ip_info.ip.addr));
xEventGroupSetBits(wifi_event_group, EVT_WIFI_CONNECTED);
break;
default:
ESP_LOGD(LOG_TAG, "System event code:%d", event->event_id);
break;
}
return ESP_OK;
}
How can I catch this, and how can I reconnect when it happens?
My hw is an ESP WROVER KIT V3, and ESP_IDF is a fresh master branch in git repository.
thx,
Zamek