esp8266 Access point lease time

Hi Guys

I am working on a project where I want a esp8266 controller to connect to another esp8266 microcontroller that is working as an access point.

When it conects to the access point controller the AP should then turn on a relay, that's working very well, but when the module is out of wifi reach of the AP, then the AP should turn of the relay again, but there is a large lease time, so it takes about 5min before the AP leases the other module and then turn of the relay.

I have been looking in C:\Program Files (x86)\Arduino\libraries\WiFi but I can't really figure out how I can change the lease time.

I'm using the

if ((WiFi.softAPgetStationNum()) > 0) {
digitalWrite(0,LOW);

I hope someone in here know how to change that lease time or maybe have another solution.

Thanks...

Kind regards
Term

When it conects to the access point controller the AP should then turn on a relay, that's working very well, but when the module is out of wifi reach of the AP, then the AP should turn of the relay again, but there is a large lease time, so it takes about 5min before the AP leases the other module and then turn of the relay.

My approach to that would be to send keep alive packets between the two ESP8266s. Send a packet from 1 to the other, send an acknowledgement back. Do this every few seconds, every second even, whatever you need. When the replies stop coming turn off the relay.