Two problems made the camera stay offline after a WiFi outage (router
reboot, WiFi briefly turned off) until it was power-cycled manually:
1. If the configured SSID was not visible at boot, Init() skipped
WiFi.begin() entirely. Both recovery paths (WiFiReconnect() and
WiFiWatchdog()) only run once FirstConnected is true, which is set on
the first GOT_IP event, so nothing ever retried and the camera stayed
disconnected forever.
-> Start the STA connection even when the SSID is not found at boot,
and let WiFiReconnect() call WiFiStaConnect() periodically while the
camera has never been connected since boot.
2. When the STA connection was lost, WiFiWatchdog() ran a full WiFi scan
(scanNetworks + JSON document + String formatting) from the
WiFiWatchdog task, which only has a 2200 B stack. This crashed the MCU
right after the disconnect (LoadProhibited in the task WDT list,
followed by a stack canary panic). The reboot then hit problem 1.
-> Remove the scan from the watchdog (it was only used for a log
message) and raise the task stack to 4096 B as a safety margin.
Tested on a Seeed XIAO ESP32-S3 Sense (OV3660 sensor), firmware 1.1.2:
WiFi turned off on the router for 3 minutes; the camera rebooted via the
WiFi watchdog, kept retrying, and reconnected on its own when the network
came back. No more Guru Meditation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HTTP does not allow Content-Length header to be set when Transfer-Encoding is present (https://greenbytes.de/tech/webdav/rfc2616.html#rfc.section.4.4)
When chunked, Transfer-Encoding is set. This causes issues, for example when adding the camera to HomeAssistant, since it causes an error in the http library.
This commit removes the Content-Length header in this case.