-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
softAPConfig fails with "DHCPS Set Netmask Failed! 0x5001" #9069
Comments
Provide code pls |
I got a very minimal piece of code here: #include <Arduino.h>
#include <IPAddress.h>
#include <WiFiGeneric.h>
#include <WiFi.h>
void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
IPAddress apIP(192,168,4,1);
IPAddress gwIP(192,168,4,1);
IPAddress subnet(255,255,255,0);
WiFi.softAPConfig(apIP, gwIP, subnet);
}
void loop() {
delay(1000);
} With output:
Including a complete PlatformIO build env: |
OK, added PIO envs for C2/C3/C6/S2/S3 to the MCVE repo. |
@TD-er - What happens when the AP IP address is different from the GW IP address, but still both are in the same subnetwork? IPAddress gwIP(192,168,4,1);
IPAddress apIP(192,168,4,2); // DHCP range will be 192.168.4.3 to 192.168.4.12
IPAddress subnet(255,255,255,0); |
I've just run the example code with the C3. It works fine:
|
I change it to use Arduino Core 3.0.0-Alpha3 with the Arduino IDE. No errors, using the same AP_IP and GW_IP (192.168.4.1)
|
@TD-er - I can't reproduce the error. Could you please also try it using the Arduino IDE? Thanks. |
I will and I will also contact @Jason2866 about this. |
@TD-er Using https://github.com/espressif/esp-lwip/tree/542ba2997f6cc14fe9c3d781bf9b0d890cd70bb1 which is same in espressif branch IDF 5.1 |
Using PlatformIO, I'm not (yet) able to use the latest Arduino code and it seems to be using 2.0.14
Any idea how I can use the arduino 3.0.0 code without using the packages Jason made, so we can be sure about where the issue may come from? |
@TD-er Which core you are talking? 2.0.14 or alpha 3.0.0 or latest master? |
I see this issue with platform packages 1877 you made. Edit:
|
It seems like the Arduino repo is slightly behind with the ESP-IDF code compared to what @Jason2866 uses for his platform builds. As far as I can see, the Arduino repo is using 5.1.2 of ESP-IDF: And the change was made 1 day before the release of 5.1.2 so probably not included: Purely based on the comment here in the LWIP code: arduino-esp32/libraries/WiFi/src/WiFiGeneric.cpp Lines 194 to 203 in b2e7338
And now I can get an IP from the softAP where it failed before. Also the mentioned Maybe this code can be wrapped in some I can't find the exact reported issue, but when searching through the issues on esp-idf, it seems like there have been multiple issues with DHCPs for quite some time. |
I also tested with 2.0.14 by removing the linked lines in WiFiGeneric.cpp and it still works fine to setup DHCP on the softAP. |
This is something to check in the next release, for sure. Thanks @TD-er! |
Yep, only the lines I mentioned. |
yes. the lines in question set the DHCP Server option, not the netmask of the interface. Through those options we set what is advertised to the clients (what is the gateway address, DNS, if we have NTP server, etc.) |
Just to be sure we're talking about the same line (we probably are) I was talking about this line where the netmask is being set:
|
N.B. as you can see in the GitHub view, there is some indentation mess, so it looks like there has been some moving around of blocks in the past in that function? |
it's about to be rewritten altogether, so all lines will be checked :) |
This will be backported to 2.X branch too, fixes in 3.0.0 version will be covered by networking refactoring. |
Board
ESP32-S2
Device Description
Hardware Configuration
Version
latest master (checkout manually)
IDE Name
PlatformIO
Operating System
Windows 11
Flash frequency
40MHz
PSRAM enabled
yes
Upload speed
115200
Description
I call
WiFi.softAPConfig
with192.168.4.1
for both IP and gateway and255.255.255.0
as subnet mask.This is during the setup process, so there is no STA interface active, only the AP interface.
The error is
ESP_ERR_ESP_NETIF_INVALID_PARAMS
As far as I can see it is generated here (???)
https://github.com/espressif/esp-idf/blob/5524b692ee5d04d7a1000eb0c41640746fc67f3c/components/esp_netif/lwip/esp_netif_lwip.c#L2260-L2279
The comment suggests you need to set the IP of the interface first, but it is set in the same function. (
set_esp_interface_ip
)I found this PR which might be related?
https://github.com/espressif/arduino-esp32/pull/6731/files
Apparently this has been an issue which went unnoticed for quite a while but a user reported it was not working anymore when I switched to
ESP32 SDK 4.4.4.20230310
Using
ESP32 SDK 4.4.4.20230208
was apparently still working.Might be broken in this commit in esp-idf???
espressif/esp-idf@a71fa82
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: