-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Static DHCP Lease not working #6031
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
Comments
Ref:#5594 |
Where was a change in WiFi.softAP(ssid, password); |
Debug from APConfig is false, it says 192.168.0.100 but in reality, first IP address has not been updated to this value.
This is new and was not the case in the past because the first @ was 100 as described in softAPConfig When WiFi.softAP(ssid, password); is called, there is a call to wifi_softap_set_config_current() and this function remove the nodes from the list with calls to node_remove_from_list() I do not have access to the code of wifi_softap_set_config_current() so there is no way to remove it and understand why they've done it. Your code is now :
Could you confirm that it's working and now, your first unknown device is always 192.168.0.4 ? |
@SmartBlug , I did your suggestion and moved wifi_softap_add_dhcps_lease() after WiFi.softAP and its working. my first unknown device ip is 192.168.0.4. thanks My new question is why config debug tells the start ip is 192.168.0.100 but the real start ip is 192.168.0.2 and how can i change the start and end ip? |
This is because the code from softAPConfig() and from wifi_softap_init_dhcps_lease() are not compatible. |
@SmartBlug No matter who wrote that part of the code, you can create pull request and make the changes you want. |
Yes and no, there is probably a reason why they changed and do not respect +100 as in the past... |
where is the function "wifi_softap_init_dhcps_lease()"? i cant find it in library's file. |
/tools/sdk/lwip2/builder/glue-lwip/esp-dhcpserver.c |
Yes but that file need to build and someone must do that. |
The lwip glue is used to build the lwip libs, and the lwip libs are used to build our core. If you change those source files, you must first rebuild lwip from sources, then rebuild the core. |
You can use the blame button / git blame command to see the commit comments around these lines |
The code in softAP and softAPConfig is ours, so changes there can be discussed here. struct dhcps_lease dhcp_lease;
IPAddress ip = local_ip;
ip[3] += 99;
dhcp_lease.start_ip.addr = ip.v4();
DEBUG_WIFI("[APConfig] DHCP IP start: %s\n", ip.toString().c_str());
ip[3] += 100;
dhcp_lease.end_ip.addr = ip.v4();
DEBUG_WIFI("[APConfig] DHCP IP end: %s\n", ip.toString().c_str());
if(!wifi_softap_set_dhcps_lease(&dhcp_lease)) {
DEBUG_WIFI("[APConfig] wifi_set_ip_info failed!\n");
ret = false;
} Edit: NVM, I was confusing init_lease() with set_lease() |
@devyte , do you know where is wifi_softap_set_config_current() that seems to decide to remove the nodes from the list ? |
The code in /tools/sdk/lwip2/builder/glue-lwip/esp-dhcpserver.c is also owned by us and could therefore be changed as well, if it makes sense to do so. However, care must be taken with the function signatures. |
I think the set_config_current() calls aren't ours, they're in the sdk. |
|
any news on this bug (and the duplicates) ? if you pass a netmask smaller than a /24 (eg a /29), then the softAP hands out invalid DHCP leases. for example, for a also, this 'local_ip+99' calculation is clearly wrong if local_ip is near the end of the network, even for /24 networks. it's perfectly valid for local_ip to be here's something that i came up with that gives reasonable defaults for smaller networks: auto network_start = lwip_ntohl(info.gw.addr & info.netmask.addr);
auto network_size = ~lwip_ntohl(info.netmask.addr);
auto network_end = network_start + network_size;
DEBUG_WIFI("[APConfig] DHCP Network Start: %s\n", IPAddress(lwip_htonl(network_start)).toString().c_str());
DEBUG_WIFI("[APConfig] DHCP Network End: %s\n", IPAddress(lwip_htonl(network_end)).toString().c_str());
DEBUG_WIFI("[APConfig] DHCP Network Size: 0x%x\n", network_size);
struct dhcps_lease dhcp_lease;
dhcp_lease.start_ip.addr = lwip_htonl(network_start + network_size * 99 / 255 + 1);
DEBUG_WIFI("[APConfig] DHCP IP start: %s\n", IPAddress(dhcp_lease.start_ip.addr).toString().c_str());
dhcp_lease.end_ip.addr = lwip_htonl(network_start + network_size * 200 / 255);
DEBUG_WIFI("[APConfig] DHCP IP end: %s\n", IPAddress(dhcp_lease.end_ip.addr).toString().c_str()); this produces the following DHCP pools for these different
|
DHCP server is going to be brought into this core when #6680 is merged, after 2.7.0 is released. |
Basic Infos
Platform
Settings in IDE
Problem Description
unknown device must get ip 192.168.0.102 but never get that ip Sometimes get IP 192.168.0.100 and sometimes 192.168.0.2
MCVE Sketch
Debug Messages
The text was updated successfully, but these errors were encountered: