When I turn on WiFi
- esp_err_t wifi_setup() {
- esp_err_t ret;
- WiFi.mode(WIFI_STA);
- WiFi.disconnect(true);
- WiFi.onEvent(WiFiEvent); //not depend
- delay(100);
- return ESP_OK;
- }
I also try init with low level:
- esp_err_t wifi_setup(void)
- {
- //s_wifi_event_group = xEventGroupCreate();
- esp_err_t ret;
- tcpip_adapter_init();
- ret = esp_event_loop_create_default();
- if (ret != ESP_OK) return ret;
- wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
- //cfg.event_handler = NULL;
- ret = esp_wifi_init(&cfg); //OK BUT SDIO HALTED AFTER
- if (wf_debug)
- {
- if (ret==ESP_OK) Serial.println("WiFi= Init OK ");
- else Serial.println("WiFi= Init ERR ");
- }
- if (ret != ESP_OK) return ret;
- ret = esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL);
- if (ret != ESP_OK) return ret;
- ret = esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL);
- // wifi_config = {
- // .sta = {
- // .ssid = DEFAULT_SSID,
- // .password = DEFAULT_PWD,
- //// scan_method : DEFAULT_SCAN_METHOD,
- //// sort_method : DEFAULT_SORT_METHOD,
- //// .threshold.rssi = DEFAULT_RSSI,
- //// .threshold.authmode = DEFAULT_AUTHMODE,
- // }
- //
- // };
- return ret;
- }
Please help, what happened?