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.
- nvs_flash_init();
- tcpip_adapter_init();
- esp_event_loop_init(event_handler, NULL);
- wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
- esp_wifi_init(&cfg);
- esp_wifi_set_storage(WIFI_STORAGE_RAM);
- esp_wifi_set_mode(WIFI_MODE_NULL);
- esp_wifi_start();
- esp_wifi_set_promiscuous(true);
- esp_wifi_set_promiscuous_rx_cb(&callback);
- esp_wifi_set_channel(6, WIFI_SECOND_CHAN_NONE);
Now I want to connect to an access point and this is the code I run.
- printf("Stopping Scanning \r\n");
- esp_err_t errorNumber;
- errorNumber = esp_wifi_stop();
- printf("errorNumber: %x \r\n", (int) errorNumber);
- errorNumber = esp_wifi_disconnect();
- printf("errorNumber: %x \r\n", (int) errorNumber); // Getting error 0x3002
- errorNumber = esp_wifi_deinit();
- printf("errorNumber: %x \r\n", (int) errorNumber);
- esp_netif_init();
- esp_wifi_restore();
- delay(5000);
I put the delay in just to give things time.
I now connect to the network with this code
- wifiMulti.addAP("NetworkIWantToConnectTo", "password");
- delay(5000);
- httpUrl = "www.whereIwantToGoTo.com";
Now in the loop() code I have
- if (strlen(httpUrl) > 0)
- {
- int rc = wifiMulti.run(); // This is the line where I am getting the error
- if ((rc == WL_CONNECTED)) {
- printf("wifiMulti is connected \r\n");
- HTTPClient http;
- Serial.print("[HTTP] begin...\n");
- // configure traged server and url
- printf("Going out to %s \r\n", httpUrl);
- http.begin(httpUrl);
- Serial.print("[HTTP] GET...\n");
- // start connection and send HTTP header
- int httpCode = http.GET();
- // httpCode will be negative on error
- if (httpCode > 0) {
- // HTTP header has been send and Server response header has been handled
- Serial.printf("[HTTP] GET... code: %d\n", httpCode);
- } else {
- Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
- }
- httpDataReceived = true;
- strcpy(httpUrl, "");
- http.end();
- stopHttpNetwork();
- //delay(5000);
- initializeScanning();
- }
- void stopHttpNetwork()
- {
- esp_wifi_disconnect();
- delay(5000);
- printf("Just disconnected from Internet\r\n");
- return;
- }
- void initializeScanning()
- {
- printf("Initializing Remote ID Scanning \r\n");
- wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
- esp_wifi_init(&cfg);
- esp_wifi_set_storage(WIFI_STORAGE_RAM);
- esp_wifi_set_mode(WIFI_MODE_NULL);
- esp_wifi_start();
- esp_wifi_set_promiscuous(true);
- esp_wifi_set_promiscuous_rx_cb(&callback);
- esp_wifi_set_channel(6, WIFI_SECOND_CHAN_NONE);
- return;
- }
Any help would be greatly appreciated.
Thanks