Getting this error "E (762367) esp_netif_lwip: esp_netif_new: Failed to configure netif with config=0x3fce53b4 (config o

VintageSlots
Posts: 2
Joined: Thu Nov 17, 2022 4:36 am

Getting this error "E (762367) esp_netif_lwip: esp_netif_new: Failed to configure netif with config=0x3fce53b4 (config o

Postby VintageSlots » Thu Nov 17, 2022 5:08 am

I am relatively new to ESP32 and network programming.

I am running an ESP32S3 chip. I want to be able to scan all packets coming in and then connect to an access point to send a report to a url and then resume scanning.

It is pretty much working but I get this error when going to the access point.

E (762367) esp_netif_lwip: esp_netif_new: Failed to configure netif with config=0x3fce53b4 (config or if_key is NULL or duplicate key)

Below is the code in setup() to initialize the scan.
  1. nvs_flash_init();
  2.   tcpip_adapter_init();
  3.  
  4.   esp_event_loop_init(event_handler, NULL);
  5. wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  6.  
  7.   esp_wifi_init(&cfg);
  8.   esp_wifi_set_storage(WIFI_STORAGE_RAM);
  9.   esp_wifi_set_mode(WIFI_MODE_NULL);
  10.   esp_wifi_start();
  11.   esp_wifi_set_promiscuous(true);
  12.   esp_wifi_set_promiscuous_rx_cb(&callback);
  13.  
  14.   esp_wifi_set_channel(6, WIFI_SECOND_CHAN_NONE);
  15.  
Everything is working fine. No errors and I am getting the packets.

Now I want to connect to an access point and this is the code I run.
  1.  printf("Stopping Scanning \r\n");
  2.   esp_err_t errorNumber;
  3.   errorNumber = esp_wifi_stop();
  4.   printf("errorNumber: %x \r\n", (int) errorNumber);
  5.   errorNumber = esp_wifi_disconnect();
  6.   printf("errorNumber: %x \r\n", (int) errorNumber); // Getting error 0x3002
  7.   errorNumber = esp_wifi_deinit();
  8.   printf("errorNumber: %x \r\n", (int) errorNumber);
  9.   esp_netif_init();
  10.   esp_wifi_restore();
  11.   delay(5000);
I do get error 0x3002 when I call esp_wifi_disconnect(). ESP_ERR_WIFI_NOT_STARTED (0x3002): WiFi driver was not started by esp_wifi_start so maybe I need to call something else to stop the driver. Not sure what to call to do this.

I put the delay in just to give things time.

I now connect to the network with this code
  1. wifiMulti.addAP("NetworkIWantToConnectTo", "password");
  2. delay(5000);
  3. httpUrl = "www.whereIwantToGoTo.com";
So far so good.

Now in the loop() code I have
  1. if (strlen(httpUrl) > 0)
  2.   {
  3.     int rc = wifiMulti.run(); // This is the line where I am getting the error
  4.     if ((rc == WL_CONNECTED)) {
  5.       printf("wifiMulti is connected \r\n");
  6.  
  7.       HTTPClient http;
  8.       Serial.print("[HTTP] begin...\n");
  9.       // configure traged server and url
  10.      
  11.       printf("Going out to %s \r\n", httpUrl);
  12.       http.begin(httpUrl);
  13.       Serial.print("[HTTP] GET...\n");
  14.       // start connection and send HTTP header
  15.       int httpCode = http.GET();
  16.  
  17.       // httpCode will be negative on error
  18.  
  19.       if (httpCode > 0) {
  20.         // HTTP header has been send and Server response header has been handled
  21.         Serial.printf("[HTTP] GET... code: %d\n", httpCode);
  22.       } else {
  23.         Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
  24.       }
  25.       httpDataReceived = true;
  26.  
  27.       strcpy(httpUrl, "");
  28.  
  29.       http.end();
  30.       stopHttpNetwork();
  31.       //delay(5000);
  32.       initializeScanning();
  33.     }
The code does appear to work as I am going out to the Internet and getting the web page. However, the error is concerning and sometimes it appears the chip does get confused and I have to call stopHttpNetwork() several times as well as initializeScanning()
  1. void stopHttpNetwork()
  2. {
  3.   esp_wifi_disconnect();
  4.   delay(5000);
  5.   printf("Just disconnected from Internet\r\n");
  6.   return;
  7. }
  8. void initializeScanning()
  9. {
  10.   printf("Initializing Remote ID Scanning \r\n");
  11.   wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  12.  
  13.   esp_wifi_init(&cfg);
  14.   esp_wifi_set_storage(WIFI_STORAGE_RAM);
  15.   esp_wifi_set_mode(WIFI_MODE_NULL);
  16.   esp_wifi_start();
  17.   esp_wifi_set_promiscuous(true);
  18.   esp_wifi_set_promiscuous_rx_cb(&callback);
  19.  
  20.   esp_wifi_set_channel(6, WIFI_SECOND_CHAN_NONE);
  21.  
  22.   return;
  23. }
I assume I should be doing something else when I shut down the scanning to free up some memory or resources but I don't know what to call to do it.

Any help would be greatly appreciated.

Thanks

Who is online

Users browsing this forum: No registered users and 26 guests