ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x400d8148
Posted: Tue May 09, 2023 3:50 am
Hello there,
in my example i am doing wifi scan. after i get the result. i want to start wifi enterprise or bluetooth but during deinit the above error is coming.Codebox=text file=Untitled.txt]void task(void *pvParameter) {
while(1){
vTaskDelay(4000/portTICK_PERIOD_MS);
ESP_ERROR_CHECK(esp_wifi_disconnect() );
vTaskDelay(1000/portTICK_PERIOD_MS);
ESP_LOGI(TAG, "wifi_init_sta stop sta");
ESP_ERROR_CHECK(esp_wifi_stop() );
vTaskDelay(1000/portTICK_PERIOD_MS);
ESP_LOGI(TAG, "wifi_init_sta deinit sta");
ESP_ERROR_CHECK(esp_wifi_deinit() );
vTaskDelay(1000/portTICK_PERIOD_MS);
if(k==0){
app();k=1;}
ble_init();
}
vTaskDelay(pdMS_TO_TICKS(1000));
}[/Codebox]
in my example i am doing wifi scan. after i get the result. i want to start wifi enterprise or bluetooth but during deinit the above error is coming.Codebox=text file=Untitled.txt]void task(void *pvParameter) {
while(1){
vTaskDelay(4000/portTICK_PERIOD_MS);
ESP_ERROR_CHECK(esp_wifi_disconnect() );
vTaskDelay(1000/portTICK_PERIOD_MS);
ESP_LOGI(TAG, "wifi_init_sta stop sta");
ESP_ERROR_CHECK(esp_wifi_stop() );
vTaskDelay(1000/portTICK_PERIOD_MS);
ESP_LOGI(TAG, "wifi_init_sta deinit sta");
ESP_ERROR_CHECK(esp_wifi_deinit() );
vTaskDelay(1000/portTICK_PERIOD_MS);
if(k==0){
app();k=1;}
ble_init();
}
vTaskDelay(pdMS_TO_TICKS(1000));
}[/Codebox]
- static void wifi_scan(void)
- {
- int j =0;
- ESP_ERROR_CHECK(esp_netif_init());
- ESP_ERROR_CHECK(esp_event_loop_create_default());
- esp_netif_t *sta_netif = esp_netif_create_default_wifi_sta();
- assert(sta_netif);
- wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
- ESP_ERROR_CHECK(esp_wifi_init(&cfg));
- uint16_t number = DEFAULT_SCAN_LIST_SIZE;
- wifi_ap_record_t ap_info[DEFAULT_SCAN_LIST_SIZE];
- uint16_t ap_count = 0;
- memset(ap_info, 0, sizeof(ap_info));
- ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
- ESP_ERROR_CHECK(esp_wifi_start());
- esp_wifi_scan_start(NULL, true);
- ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&number, ap_info));
- ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count));
- ESP_LOGI(TAG, "Total APs scanned = %u", ap_count);
- j=0;
- for (int i = 0; (i < DEFAULT_SCAN_LIST_SIZE) && (i < ap_count); i++) {
- send_dat[0]='S';
- send_data1[j]='^';
- j++;
- ESP_LOGI(TAG, "SSID \t\t%s", ap_info[i].ssid);
- for (int k=0;k<33;k++){
- send_data1[j] =ap_info[i].ssid[k];
- printf("%c",send_data1[k]);
- j++;
- }
- ESP_LOGI(TAG, "RSSI \t\t%d", ap_info[i].rssi);
- print_auth_mode(ap_info[i].authmode);
- if (ap_info[i].authmode != WIFI_AUTH_WEP) {
- print_cipher_type(ap_info[i].pairwise_cipher, ap_info[i].group_cipher);
- }
- ESP_LOGI(TAG, "Channel \t\t%d\n", ap_info[i].primary);
- }
- }