feat: boot-phase OTA, RS485 variant, async melody download, HAL guards
- bootOtaCheck() runs at top of setup() before any task/timer; streams firmware to flash on update, reboots, otherwise returns immediately - New bespoke-rs485-v1 build env + Rs485OutputManager for Waveshare 16CH Modbus RTU relay; vesper.hpp renamed vesper-std.hpp, env renamed accordingly - Player: permanent melodyDownloadTaskFn task; fast path (built-in/SD) before async download; uid accepted as alias for pid - CommunicationRouter: HAS_UART guards throughout so UART transport compiles out when Serial2 is claimed by Modbus - OTAManager: stack 8KB→16KB, pinned to Core 1, HTTPClient recreated per retry, download timeout 30s→60s - FileManager: heap guard before SSL alloc; watchdog log cleanup - ConfigManager: OTA fallback URLs http (no TLS for firmware servers) - agnus.hpp: HAS_UART 1 added - provisioning/nvs_agnus_lab_device.csv added - Version bumped to v2.0.1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "FileManager.hpp"
|
||||
#include <esp_task_wdt.h>
|
||||
|
||||
#define TAG "FileManager"
|
||||
#include "../BuiltInMelodies/BuiltInMelodies.hpp"
|
||||
@@ -75,6 +76,12 @@ bool FileManager::downloadFile(const String& url, const String& directory, const
|
||||
|
||||
// Configure HTTP client based on protocol
|
||||
if (isHttps) {
|
||||
size_t largestBlock = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT);
|
||||
LOG_DEBUG(TAG, "Largest free heap block before SSL alloc: %u bytes", largestBlock);
|
||||
if (largestBlock < 40000) {
|
||||
LOG_ERROR(TAG, "Insufficient contiguous heap for SSL context (%u bytes free, need ~40KB)", largestBlock);
|
||||
return false;
|
||||
}
|
||||
secureClient = new WiFiClientSecure();
|
||||
secureClient->setInsecure(); // Skip certificate validation for Firebase
|
||||
secureClient->setTimeout(15); // 15 second timeout for TLS operations
|
||||
@@ -88,17 +95,12 @@ bool FileManager::downloadFile(const String& url, const String& directory, const
|
||||
http.setTimeout(30000); // 30 second timeout for large files
|
||||
http.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS); // Follow redirects automatically
|
||||
|
||||
// Disable task watchdog for current task during blocking HTTPS operation
|
||||
// The TLS handshake can take several seconds and would trigger watchdog
|
||||
LOG_DEBUG(TAG, "Disabling watchdog for download...");
|
||||
// Remove this task from the WDT while the TLS handshake blocks.
|
||||
// The handshake can take several seconds and would otherwise starve async_tcp.
|
||||
esp_task_wdt_delete(NULL);
|
||||
|
||||
LOG_DEBUG(TAG, "Sending HTTP GET request...");
|
||||
int httpCode = http.GET();
|
||||
|
||||
// Re-enable task watchdog after HTTP request completes
|
||||
esp_task_wdt_add(NULL);
|
||||
LOG_DEBUG(TAG, "Watchdog re-enabled after HTTP request");
|
||||
|
||||
if (httpCode != HTTP_CODE_OK && httpCode != HTTP_CODE_MOVED_PERMANENTLY && httpCode != HTTP_CODE_FOUND) {
|
||||
LOG_ERROR(TAG, "HTTP GET failed, code: %d, error: %s", httpCode, http.errorToString(httpCode).c_str());
|
||||
|
||||
Reference in New Issue
Block a user