When can I power OFF WIFI after TCP transaction ?!
Posted: Sat Jun 17, 2017 2:39 pm
Hi world,
I have an ESP-12 that stay awake to do some background jobs, but I turn WIFI OFF when not needed.
Periodically I turn WIFI ON, connect to WIFI AP, open TCP socket and send/receive some data from a server, and when this is done, I turn WIFI OFF.
My problem is : how do I know that all data I've sent have been received by the server ?
For exemple, if I turn WIFI OFF just after the data sending, the server don't receive last bytes, looks like I've switch OFF WIFI before the TCP job is done.
So I've add a "delay(5000)" and all is fine, but this is not a great solution :
> 5000ms is probably far too long 95% of time
> 5000ms will be too short a day with bad WIFI or busy server or ... ?!
So : how can I check that TCP socket have finish to send data ?
Thanks.
I have an ESP-12 that stay awake to do some background jobs, but I turn WIFI OFF when not needed.
Periodically I turn WIFI ON, connect to WIFI AP, open TCP socket and send/receive some data from a server, and when this is done, I turn WIFI OFF.
My problem is : how do I know that all data I've sent have been received by the server ?
For exemple, if I turn WIFI OFF just after the data sending, the server don't receive last bytes, looks like I've switch OFF WIFI before the TCP job is done.
So I've add a "delay(5000)" and all is fine, but this is not a great solution :
> 5000ms is probably far too long 95% of time
> 5000ms will be too short a day with bad WIFI or busy server or ... ?!
So : how can I check that TCP socket have finish to send data ?
Thanks.