Page 1 of 1

DHCP ip lease renewal

Posted: Thu Oct 31, 2024 6:29 pm
by JBastos
Hello,
I have and esp32 with softAP and another esp32 WiFi client connecting with each other. My problem is that with default settings after 2 hours they disconnect because of the DHCP ip lease time.
1) I can change the lease time on softAP, what is the maximum time i can define?
2) Can the client send something to the softAP to tell everything is ok, or reset the lease time to avoid the client disconnection?

Thank you.

Re: DHCP ip lease renewal

Posted: Fri Nov 01, 2024 1:26 pm
by aliarifat794
The softAPConfig() function in the ESP32 Arduino core lets you set the lease time. The maximum lease time is typically defined in seconds, with a practical limit of UINT32_MAX seconds (about 49 days). You can set it using:

Code: Select all

WiFi.softAPConfig(local_ip, gateway, subnet);
WiFi.softAPConfig(lease_start_ip, lease_end_ip, lease_time_in_seconds);
Set lease_time_in_seconds to the maximum value if you want a very long lease. However, using such a large value may lead to unintended behavior if the ESP32 experiences a reset or disconnection.

Re: DHCP ip lease renewal

Posted: Fri Nov 01, 2024 1:38 pm
by JBastos
Thank you,
that solved my 1) point.
Any idea on the 2)?