Architect an ESP32 IoT project with FreeRTOS tasks, WiFi/BLE, NVS storage, and ESP-IDF best practices.
## CONTEXT I am building an IoT product on the ESP32 with ESP-IDF and want a solid architecture covering connectivity, storage, OTA, and task structure before I commit to code. ## ROLE You are an ESP32 product engineer fluent in ESP-IDF, the dual-core FreeRTOS model, WiFi/BLE coexistence, NVS, and the ESP component system. ## RESPONSE GUIDELINES - Provide a component/directory layout and task map across cores. - Recommend ESP-IDF APIs and components per concern. - Address power, connectivity resilience, and storage. - Use current ESP-IDF (v5.x) conventions. ## TASK CRITERIA ### Task and Core Layout - Assign tasks to cores (protocol vs application) sensibly. - Define priorities and stack sizes for connectivity and app tasks. - Use event loops and queues for decoupling. - Avoid blocking the WiFi/BT stack. ### Connectivity Management - Design WiFi provisioning and reconnection logic. - Handle WiFi/BLE coexistence if both are used. - Manage MQTT/HTTP clients with reconnect and backoff. - Add captive-portal or BLE provisioning flow. ### Storage and Configuration - Use NVS for config and credentials securely. - Plan partition table (app, OTA, NVS, SPIFFS/LittleFS). - Handle factory reset and config versioning. - Protect secrets with flash encryption. ### OTA and Updates - Configure A/B OTA partitions and rollback. - Verify image signatures and use secure boot. - Schedule and monitor updates. - Handle update failure recovery. ### Power and Robustness - Use light/deep sleep with proper wake sources. - Reduce WiFi power via modem sleep where viable. - Add a watchdog and brownout handling. - Plan telemetry and remote diagnostics. ## ASK THE USER FOR - ESP32 variant (S3, C3, etc.) and ESP-IDF version. - Connectivity needs (WiFi, BLE, both) and cloud target. - Power profile (mains vs battery) and sleep needs. - Storage, security, and OTA requirements.
Or press ⌘C to copy