DHCP ip lease renewal

JBastos
Posts: 2
Joined: Thu Oct 31, 2024 6:18 pm

DHCP ip lease renewal

Postby JBastos » Thu Oct 31, 2024 6:29 pm

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.

aliarifat794
Posts: 198
Joined: Sun Jun 23, 2024 6:18 pm

Re: DHCP ip lease renewal

Postby aliarifat794 » Fri Nov 01, 2024 1:26 pm

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.

JBastos
Posts: 2
Joined: Thu Oct 31, 2024 6:18 pm

Re: DHCP ip lease renewal

Postby JBastos » Fri Nov 01, 2024 1:38 pm

Thank you,
that solved my 1) point.
Any idea on the 2)?

Who is online

Users browsing this forum: No registered users and 177 guests