One detail: I deviously wrote "last sending ATTEMPT". If your WiFi becomes unreachable for a few hours, you do not want the power consumption to go up during that time.
Depending on RAM availability, a few hours of WiFi breakdown need not lead to loss of a single measurement.
Code becomes more complicated. Simply restarting the whole thing would lead to stored measurement amnesia, so do that only as last resort.