[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79EX1AX62G5HTBS80BX6GJR":3,"skill-same:01M79EX1AX62G5HTBS80BX6GJR":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M79EX1AX62G5HTBS80BX6GJR","esp32-arduino-embedded-c",null,"Guidance for production-grade ESP32 Arduino and Embedded C\u002FC++ development. Use when building firmware for ESP32, ESP32-S3, or ESP32-C3 microcontrollers, optimizing FreeRTOS tasks, managing SRAM\u002FPSRAM, writing ISR-safe code, or handling dual-core concurrency and hardware peripherals.","hamzabellouch\u002Fagent-skills","hamzabellouch","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F237856042?v=4","01M79BRYW7XAMK3YDWQEMTWGWS","Hamza Bellouch","01M79BRYWXQV3JK2TGVTX8GN2A",8,"MIT","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FProgramming\u002FSystems_and_Hardware\u002FEmbedded_and_IoT\u002Fesp32-arduino-embedded-c\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: esp32-arduino-embedded-c\ndescription: Guidance for production-grade ESP32 Arduino and Embedded C\u002FC++ development. Use when building firmware for ESP32, ESP32-S3, or ESP32-C3 microcontrollers, optimizing FreeRTOS tasks, managing SRAM\u002FPSRAM, writing ISR-safe code, or handling dual-core concurrency and hardware peripherals.\n---\n\n# ESP32 Arduino & Embedded C\u002FC++ Production Guidelines\n\nThis skill provides architecture patterns, memory management guidelines, hardware interrupt safety rules, and production code patterns for high-reliability ESP32 embedded applications using Arduino \u002F ESP-IDF C++.\n\n---\n\n## 1. Core Architecture & Multi-Core Strategy\n\n### 1.1 Dual-Core Pinning & Priority Allocation\nESP32 (dual-core Xtensa LX6\u002FLX7) splits responsibilities across **Core 0 (PRO_CPU)** and **Core 1 (APP_CPU)**:\n- **Core 0**: Reserved primarily for Wi-Fi, Bluetooth, TCP\u002FIP stack, and system tasks managed by ESP-IDF.\n- **Core 1**: Dedicated to application logic, sensor polling, motor control, display UI, and real-time DSP.\n\n```\n  Core 0 (PRO_CPU)                     Core 1 (APP_CPU)\n+-----------------------+            +-----------------------+\n| WiFi \u002F Bluetooth Task |            | App Logic \u002F Sensor    |\n| TCP\u002FIP Stack          |            | Data Processing Task  |\n| System Watchdog WDT   |            | Real-time Control Task|\n+-----------------------+            +-----------------------+\n            ^                                    ^\n            |       FreeRTOS Queue \u002F EventGroup  |\n            +------------------------------------+\n```\n\n- **Task Priorities**: FreeRTOS priorities range from `0` (lowest, idle) to `configMAX_PRIORITIES - 1` (highest, typically 24).\n  - Real-time hard timing tasks: Priority 18 - 22\n  - I\u002FO & Sensor Polling: Priority 10 - 15\n  - Network & Telemetry tasks: Priority 5 - 8\n  - Background\u002FIdle tasks: Priority 1 - 3\n\n### 1.2 Task Stack & Watchdog Timers (WDT)\n- **Task Watchdog Timer (TWDT)**: Monitors tasks for starvation or deadlocks. Any task pinned to a core executing a loop must either block (`vTaskDelay()`, `xQueueReceive()`) or trigger `esp_task_wdt_reset()`.\n- Never use blocking `delay()` from Arduino in FreeRTOS tasks — use `vTaskDelay(pdMS_TO_TICKS(ms))` or `vTaskDelayUntil()`.\n\n---\n\n## 2. Real-Time Memory Management\n\n### 2.1 Dynamic Allocation Hazards\nIn embedded real-time systems, heap allocation (`malloc`, `new`, `std::string`, `std::vector`, `Arduino String`) causes:\n1. **Heap Fragmentation**: Repeated allocations of varying sizes leave non-contiguous small gaps, leading to runtime `Out of Memory (OOM)` crashes after days\u002Fweeks of continuous operation.\n2. **Nondeterministic Execution**: Heap allocation time depends on current heap topology, violating hard real-time guarantees.\n\n### 2.2 Memory Allocation Best Practices\n- **Static Task Creation**: Use `xTaskCreateStatic()` instead of `xTaskCreate()` to allocate TCB (Task Control Block) and stack at compile time.\n- **Static Queues & Semaphores**: Use `xQueueCreateStatic()` and `xSemaphoreCreateBinaryStatic()`.\n- **Pre-allocated Buffers**: Allocate fixed-size array buffers in BSS\u002FData section or during initialization.\n- **PSRAM Allocation (ESP32-WROVER \u002F S3)**: For large buffers (e.g., audio samples, camera frames, network ring buffers), explicitly allocate from External SPI RAM:\n  ```cpp\n  uint8_t *frame_buffer = (uint8_t *)heap_caps_malloc(BUFFER_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);\n  ```\n\n### 2.3 Stack Monitoring & High Water Mark\nContinuously monitor task stack consumption during testing:\n```cpp\nUBaseType_t highWaterMark = uxTaskGetStackHighWaterMark(NULL);\nESP_LOGI(\"STACK\", \"Task remaining stack: %u bytes\", highWaterMark * sizeof(StackType_t));\n```\n\n---\n\n## 3. Hardware Interrupt Safety (ISR)\n\n### 3.1 IRAM Placement\nInterrupt Service Routines (ISRs) and functions invoked inside ISRs **must** reside in Internal RAM (IRAM) to prevent crash\u002Fexception if flash cache is disabled during flash write\u002Fread operations.\n- Annotate ISR functions with `IRAM_ATTR`.\n\n### 3.2 ISR Guardrails\n- **Keep ISRs Ultra-Short**: Only clear interrupt flags, sample raw hardware counter\u002Fregisters, and post notification to a FreeRTOS task.\n- **No Blocking Calls**: Never call `delay()`, `vTaskDelay()`, `printf()`, `ESP_LOGI()`, or `xQueueSend()` from inside an ISR.\n- **FromISR API**: Use only FreeRTOS functions suffixing with `FromISR` (e.g., `xQueueSendFromISR()`, `vTaskNotifyGiveFromISR()`).\n- **HigherPriorityTaskWoken**: Always pass `BaseType_t xHigherPriorityTaskWoken` and yield with `portYIELD_FROM_ISR(xHigherPriorityTaskWoken)`.\n\n### 3.3 Spinlocks & Critical Sections\nFor dual-core shared variables modified inside ISR:\n```cpp\nportMUX_TYPE mySpinlock = portMUX_INITIALIZER_UNLOCKED;\n\nvoid IRAM_ATTR gpio_isr_handler(void* arg) {\n    portENTER_CRITICAL_ISR(&mySpinlock);\n    \u002F\u002F Read\u002Fwrite shared hardware registers or variables safely\n    portEXIT_CRITICAL_ISR(&mySpinlock);\n}\n```\n\n---\n\n## 4. Anti-Patterns & Critical Pitfalls\n\n| Anti-Pattern | Severity | Consequence | Correct Pattern |\n|---|---|---|---|\n| Using `String` concats in loops | Critical | Heap fragmentation, silent OOM crashes | Use `char` arrays, `snprintf()`, or static buffers |\n| Long execution inside ISR | Critical | WDT trigger, interrupt starvation, system crash | Offload processing to high-priority FreeRTOS task via Task Notification |\n| Shared variable modification without lock | High | Data corruption, subtle race conditions across dual cores | Use `std::atomic`, `portMUX_TYPE`, or FreeRTOS Mutex |\n| `delay(100)` inside FreeRTOS tasks | Medium | Core starvation, WDT triggering, unhandled yields | Use `vTaskDelay(pdMS_TO_TICKS(100))` |\n| Unchecked pointer return from `malloc`\u002F`heap_caps_malloc` | High | Null pointer dereference panic | Always check `NULL` return before access |\n\n---\n\n## 5. Production Code Example\n\nBelow is a complete, production-grade ESP32 FreeRTOS C++ firmware template featuring static queues, ISR-to-Task notifications, hardware watchdog protection, and safe spinlock memory synchronization.\n\n```cpp\n#include \u003CArduino.h>\n#include \"freertos\u002FFreeRTOS.h\"\n#include \"freertos\u002Ftask.h\"\n#include \"freertos\u002Fqueue.h\"\n#include \"esp_task_wdt.h\"\n#include \"esp_log.h\"\n#include \u003Catomic>\n\nstatic const char *TAG = \"MAIN_APP\";\n\n\u002F\u002F Pin Definitions\nconstexpr gpio_num_t SENSOR_PIN = GPIO_NUM_4;\n\n\u002F\u002F Queue Configuration\nconstexpr size_t QUEUE_LENGTH = 16;\nconstexpr size_t ITEM_SIZE = sizeof(uint32_t);\n\n\u002F\u002F Static Queue Storage\nstatic QueueHandle_t xSensorQueue = nullptr;\nstatic StaticQueue_t xStaticQueueStruct;\nstatic uint8_t ucQueueStorageArea[QUEUE_LENGTH * ITEM_SIZE];\n\n\u002F\u002F Static Task Storage for Processing Task\nconstexpr configSTACK_DEPTH_TYPE PROCESS_STACK_SIZE = 4096;\nstatic TaskHandle_t xProcessingTaskHandle = nullptr;\nstatic StaticTask_t xProcessTaskBuffer;\nstatic StackType_t xProcessStack[PROCESS_STACK_SIZE];\n\n\u002F\u002F Spinlock for ISR Shared State\nstatic portMUX_TYPE g_spinlock = portMUX_INITIALIZER_UNLOCKED;\nstatic volatile uint32_t g_isr_event_count = 0;\n\n\u002F\u002F Thread-safe atomic counter for telemetry\nstatic std::atomic\u003Cuint32_t> g_processed_events(0);\n\n\u002F\u002F --- ISR Handler ---\nvoid IRAM_ATTR sensor_gpio_isr_handler(void *arg) {\n    BaseType_t xHigherPriorityTaskWoken = pdFALSE;\n    uint32_t timestamp = xTaskGetTickCountFromISR();\n\n    portENTER_CRITICAL_ISR(&g_spinlock);\n    g_isr_event_count++;\n    portEXIT_CRITICAL_ISR(&g_spinlock);\n\n    \u002F\u002F Send timestamp to static queue without blocking\n    xQueueSendFromISR(xSensorQueue, &timestamp, &xHigherPriorityTaskWoken);\n\n    \u002F\u002F Context switch if higher priority task was woken\n    portYIELD_FROM_ISR(xHigherPriorityTaskWoken);\n}\n\n\u002F\u002F --- Data Processing Task (Core 1) ---\nvoid ProcessingTask(void *pvParameters) {\n    uint32_t received_timestamp = 0;\n    ESP_LOGI(TAG, \"Processing Task started on Core %d\", xPortGetCoreID());\n\n    for (;;) {\n        \u002F\u002F Wait indefinitely for queue items\n        if (xQueueReceive(xSensorQueue, &received_timestamp, portMAX_DELAY) == pdTRUE) {\n            \u002F\u002F Business logic processing\n            g_processed_events.fetch_add(1, std::memory_order_relaxed);\n            \n            ESP_LOGD(TAG, \"Processed event registered at tick: %u\", received_timestamp);\n        }\n\n        \u002F\u002F Periodically log memory health\n        if (g_processed_events.load() % 100 == 0) {\n            UBaseType_t hwm = uxTaskGetStackHighWaterMark(NULL);\n            ESP_LOGI(TAG, \"Processed: %u | Task High Water Mark: %u bytes\", \n                     g_processed_events.load(), hwm * sizeof(StackType_t));\n        }\n    }\n}\n\nvoid setup() {\n    Serial.begin(115200);\n    while (!Serial && millis() \u003C 2000) {}\n\n    ESP_LOGI(TAG, \"Initializing Production ESP32 Firmware...\");\n\n    \u002F\u002F 1. Initialize Static Queue\n    xSensorQueue = xQueueCreateStatic(QUEUE_LENGTH, ITEM_SIZE, ucQueueStorageArea, &xStaticQueueStruct);\n    configASSERT(xSensorQueue != nullptr);\n\n    \u002F\u002F 2. Configure GPIO Pin & ISR Interrupt\n    gpio_config_t io_conf = {};\n    io_conf.intr_type = GPIO_INTR_NEGEDGE;\n    io_conf.mode = GPIO_MODE_INPUT;\n    io_conf.pin_bit_mask = (1ULL \u003C\u003C SENSOR_PIN);\n    io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;\n    io_conf.pull_up_en = GPIO_PULLUP_ENABLE;\n    gpio_config(&io_conf);\n\n    \u002F\u002F Install GPIO ISR Service and Attach Handler\n    gpio_install_isr_service(ESP_INTR_FLAG_IRAM);\n    gpio_isr_handler_add(SENSOR_PIN, sensor_gpio_isr_handler, nullptr);\n\n    \u002F\u002F 3. Create Static Worker Task pinned to Core 1\n    xProcessingTaskHandle = xTaskCreateStaticPinnedToCore(\n        ProcessingTask,\n        \"DataProcessor\",\n        PROCESS_STACK_SIZE,\n        nullptr,\n        12, \u002F\u002F Priority\n        xProcessStack,\n        &xProcessTaskBuffer,\n        1   \u002F\u002F Core 1 (APP_CPU)\n    );\n    configASSERT(xProcessingTaskHandle != nullptr);\n\n    ESP_LOGI(TAG, \"System initialization complete.\");\n}\n\nvoid loop() {\n    \u002F\u002F Main loop runs on Core 1 (Arduino default task priority 1)\n    \u002F\u002F Yield execution to allow lower-priority background routines\n    vTaskDelay(pdMS_TO_TICKS(1000));\n}\n```\n","# ESP32 Arduino & Embedded C\u002FC++ Production Guidelines\n\nThis skill provides architecture patterns, memory management guidelines, hardware interrupt safety rules, and production code patterns for high-reliability ESP32 embedded applications using Arduino \u002F ESP-IDF C++.\n\n---\n\n## 1. Core Architecture & Multi-Core Strategy\n\n### 1.1 Dual-Core Pinning & Priority Allocation\nESP32 (dual-core Xtensa LX6\u002FLX7) splits responsibilities across **Core 0 (PRO_CPU)** and **Core 1 (APP_CPU)**:\n- **Core 0**: Reserved primarily for Wi-Fi, Bluetooth, TCP\u002FIP stack, and system tasks managed by ESP-IDF.\n- **Core 1**: Dedicated to application logic, sensor polling, motor control, display UI, and real-time DSP.\n\n```\n  Core 0 (PRO_CPU)                     Core 1 (APP_CPU)\n+-----------------------+            +-----------------------+\n| WiFi \u002F Bluetooth Task |            | App Logic \u002F Sensor    |\n| TCP\u002FIP Stack          |            | Data Processing Task  |\n| System Watchdog WDT   |            | Real-time Control Task|\n+-----------------------+            +-----------------------+\n            ^                                    ^\n            |       FreeRTOS Queue \u002F EventGroup  |\n            +------------------------------------+\n```\n\n- **Task Priorities**: FreeRTOS priorities range from `0` (lowest, idle) to `configMAX_PRIORITIES - 1` (highest, typically 24).\n  - Real-time hard timing tasks: Priority 18 - 22\n  - I\u002FO & Sensor Polling: Priority 10 - 15\n  - Network & Telemetry tasks: Priority 5 - 8\n  - Background\u002FIdle tasks: Priority 1 - 3\n\n### 1.2 Task Stack & Watchdog Timers (WDT)\n- **Task Watchdog Timer (TWDT)**: Monitors tasks for starvation or deadlocks. Any task pinned to a core executing a loop must either block (`vTaskDelay()`, `xQueueReceive()`) or trigger `esp_task_wdt_reset()`.\n- Never use blocking `delay()` from Arduino in FreeRTOS tasks — use `vTaskDelay(pdMS_TO_TICKS(ms))` or `vTaskDelayUntil()`.\n\n---\n\n## 2. Real-Time Memory Management\n\n### 2.1 Dynamic Allocation Hazards\nIn embedded real-time systems, heap allocation (`malloc`, `new`, `std::string`, `std::vector`, `Arduino String`) causes:\n1. **Heap Fragmentation**: Repeated allocations of varying sizes leave non-contiguous small gaps, leading to runtime `Out of Memory (OOM)` crashes after days\u002Fweeks of continuous operation.\n2. **Nondeterministic Execution**: Heap allocation time depends on current heap topology, violating hard real-time guarantees.\n\n### 2.2 Memory Allocation Best Practices\n- **Static Task Creation**: Use `xTaskCreateStatic()` instead of `xTaskCreate()` to allocate TCB (Task Control Block) and stack at compile time.\n- **Static Queues & Semaphores**: Use `xQueueCreateStatic()` and `xSemaphoreCreateBinaryStatic()`.\n- **Pre-allocated Buffers**: Allocate fixed-size array buffers in BSS\u002FData section or during initialization.\n- **PSRAM Allocation (ESP32-WROVER \u002F S3)**: For large buffers (e.g., audio samples, camera frames, network ring buffers), explicitly allocate from External SPI RAM:\n  ```cpp\n  uint8_t *frame_buffer = (uint8_t *)heap_caps_malloc(BUFFER_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);\n  ```\n\n### 2.3 Stack Monitoring & High Water Mark\nContinuously monitor task stack consumption during testing:\n```cpp\nUBaseType_t highWaterMark = uxTaskGetStackHighWaterMark(NULL);\nESP_LOGI(\"STACK\", \"Task remaining stack: %u bytes\", highWaterMark * sizeof(StackType_t));\n```\n\n---\n\n## 3. Hardware Interrupt Safety (ISR)\n\n### 3.1 IRAM Placement\nInterrupt Service Routines (ISRs) and functions invoked inside ISRs **must** reside in Internal RAM (IRAM) to prevent crash\u002Fexception if flash cache is disabled during flash write\u002Fread operations.\n- Annotate ISR functions with `IRAM_ATTR`.\n\n### 3.2 ISR Guardrails\n- **Keep ISRs Ultra-Short**: Only clear interrupt flags, sample raw hardware counter\u002Fregisters, and post notification to a FreeRTOS task.\n- **No Blocking Calls**: Never call `delay()`, `vTaskDelay()`, `printf()`, `ESP_LOGI()`, or `xQueueSend()` from inside an ISR.\n- **FromISR API**: Use only FreeRTOS functions suffixing with `FromISR` (e.g., `xQueueSendFromISR()`, `vTaskNotifyGiveFromISR()`).\n- **HigherPriorityTaskWoken**: Always pass `BaseType_t xHigherPriorityTaskWoken` and yield with `portYIELD_FROM_ISR(xHigherPriorityTaskWoken)`.\n\n### 3.3 Spinlocks & Critical Sections\nFor dual-core shared variables modified inside ISR:\n```cpp\nportMUX_TYPE mySpinlock = portMUX_INITIALIZER_UNLOCKED;\n\nvoid IRAM_ATTR gpio_isr_handler(void* arg) {\n    portENTER_CRITICAL_ISR(&mySpinlock);\n    \u002F\u002F Read\u002Fwrite shared hardware registers or variables safely\n    portEXIT_CRITICAL_ISR(&mySpinlock);\n}\n```\n\n---\n\n## 4. Anti-Patterns & Critical Pitfalls\n\n| Anti-Pattern | Severity | Consequence | Correct Pattern |\n|---|---|---|---|\n| Using `String` concats in loops | Critical | Heap fragmentation, silent OOM crashes | Use `char` arrays, `snprintf()`, or static buffers |\n| Long execution inside ISR | Critical | WDT trigger, interrupt starvation, system crash | Offload processing to high-priority FreeRTOS task via Task Notification |\n| Shared variable modification without lock | High | Data corruption, subtle race conditions across dual cores | Use `std::atomic`, `portMUX_TYPE`, or FreeRTOS Mutex |\n| `delay(100)` inside FreeRTOS tasks | Medium | Core starvation, WDT triggering, unhandled yields | Use `vTaskDelay(pdMS_TO_TICKS(100))` |\n| Unchecked pointer return from `malloc`\u002F`heap_caps_malloc` | High | Null pointer dereference panic | Always check `NULL` return before access |\n\n---\n\n## 5. Production Code Example\n\nBelow is a complete, production-grade ESP32 FreeRTOS C++ firmware template featuring static queues, ISR-to-Task notifications, hardware watchdog protection, and safe spinlock memory synchronization.\n\n```cpp\n#include \u003CArduino.h>\n#include \"freertos\u002FFreeRTOS.h\"\n#include \"freertos\u002Ftask.h\"\n#include \"freertos\u002Fqueue.h\"\n#include \"esp_task_wdt.h\"\n#include \"esp_log.h\"\n#include \u003Catomic>\n\nstatic const char *TAG = \"MAIN_APP\";\n\n\u002F\u002F Pin Definitions\nconstexpr gpio_num_t SENSOR_PIN = GPIO_NUM_4;\n\n\u002F\u002F Queue Configuration\nconstexpr size_t QUEUE_LENGTH = 16;\nconstexpr size_t ITEM_SIZE = sizeof(uint32_t);\n\n\u002F\u002F Static Queue Storage\nstatic QueueHandle_t xSensorQueue = nullptr;\nstatic StaticQueue_t xStaticQueueStruct;\nstatic uint8_t ucQueueStorageArea[QUEUE_LENGTH * ITEM_SIZE];\n\n\u002F\u002F Static Task Storage for Processing Task\nconstexpr configSTACK_DEPTH_TYPE PROCESS_STACK_SIZE = 4096;\nstatic TaskHandle_t xProcessingTaskHandle = nullptr;\nstatic StaticTask_t xProcessTaskBuffer;\nstatic StackType_t xProcessStack[PROCESS_STACK_SIZE];\n\n\u002F\u002F Spinlock for ISR Shared State\nstatic portMUX_TYPE g_spinlock = portMUX_INITIALIZER_UNLOCKED;\nstatic volatile uint32_t g_isr_event_count = 0;\n\n\u002F\u002F Thread-safe atomic counter for telemetry\nstatic std::atomic\u003Cuint32_t> g_processed_events(0);\n\n\u002F\u002F --- ISR Handler ---\nvoid IRAM_ATTR sensor_gpio_isr_handler(void *arg) {\n    BaseType_t xHigherPriorityTaskWoken = pdFALSE;\n    uint32_t timestamp = xTaskGetTickCountFromISR();\n\n    portENTER_CRITICAL_ISR(&g_spinlock);\n    g_isr_event_count++;\n    portEXIT_CRITICAL_ISR(&g_spinlock);\n\n    \u002F\u002F Send timestamp to static queue without blocking\n    xQueueSendFromISR(xSensorQueue, &timestamp, &xHigherPriorityTaskWoken);\n\n    \u002F\u002F Context switch if higher priority task was woken\n    portYIELD_FROM_ISR(xHigherPriorityTaskWoken);\n}\n\n\u002F\u002F --- Data Processing Task (Core 1) ---\nvoid ProcessingTask(void *pvParameters) {\n    uint32_t received_timestamp = 0;\n    ESP_LOGI(TAG, \"Processing Task started on Core %d\", xPortGetCoreID());\n\n    for (;;) {\n        \u002F\u002F Wait indefinitely for queue items\n        if (xQueueReceive(xSensorQueue, &received_timestamp, portMAX_DELAY) == pdTRUE) {\n            \u002F\u002F Business logic processing\n            g_processed_events.fetch_add(1, std::memory_order_relaxed);\n            \n            ESP_LOGD(TAG, \"Processed event registered at tick: %u\", received_timestamp);\n        }\n\n        \u002F\u002F Periodically log memory health\n        if (g_processed_events.load() % 100 == 0) {\n            UBaseType_t hwm = uxTaskGetStackHighWaterMark(NULL);\n            ESP_LOGI(TAG, \"Processed: %u | Task High Water Mark: %u bytes\", \n                     g_processed_events.load(), hwm * sizeof(StackType_t));\n        }\n    }\n}\n\nvoid setup() {\n    Serial.begin(115200);\n    while (!Serial && millis() \u003C 2000) {}\n\n    ESP_LOGI(TAG, \"Initializing Production ESP32 Firmware...\");\n\n    \u002F\u002F 1. Initialize Static Queue\n    xSensorQueue = xQueueCreateStatic(QUEUE_LENGTH, ITEM_SIZE, ucQueueStorageArea, &xStaticQueueStruct);\n    configASSERT(xSensorQueue != nullptr);\n\n    \u002F\u002F 2. Configure GPIO Pin & ISR Interrupt\n    gpio_config_t io_conf = {};\n    io_conf.intr_type = GPIO_INTR_NEGEDGE;\n    io_conf.mode = GPIO_MODE_INPUT;\n    io_conf.pin_bit_mask = (1ULL \u003C\u003C SENSOR_PIN);\n    io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;\n    io_conf.pull_up_en = GPIO_PULLUP_ENABLE;\n    gpio_config(&io_conf);\n\n    \u002F\u002F Install GPIO ISR Service and Attach Handler\n    gpio_install_isr_service(ESP_INTR_FLAG_IRAM);\n    gpio_isr_handler_add(SENSOR_PIN, sensor_gpio_isr_handler, nullptr);\n\n    \u002F\u002F 3. Create Static Worker Task pinned to Core 1\n    xProcessingTaskHandle = xTaskCreateStaticPinnedToCore(\n        ProcessingTask,\n        \"DataProcessor\",\n        PROCESS_STACK_SIZE,\n        nullptr,\n        12, \u002F\u002F Priority\n        xProcessStack,\n        &xProcessTaskBuffer,\n        1   \u002F\u002F Core 1 (APP_CPU)\n    );\n    configASSERT(xProcessingTaskHandle != nullptr);\n\n    ESP_LOGI(TAG, \"System initialization complete.\");\n}\n\nvoid loop() {\n    \u002F\u002F Main loop runs on Core 1 (Arduino default task priority 1)\n    \u002F\u002F Yield execution to allow lower-priority background routines\n    vTaskDelay(pdMS_TO_TICKS(1000));\n}\n```\n",{"name":5,"description":7},"main","e905af21e5f1e1c3ca605e9656c3a7930360a84e","Programming\u002FSystems_and_Hardware\u002FEmbedded_and_IoT\u002Fesp32-arduino-embedded-c",1,"https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills","https:\u002F\u002Fhamzabellouch.github.io\u002F","https:\u002F\u002Fgithub.com\u002Fhamzabellouch","hamzabellouch.github.io","CEO & Founder of @tknoglobal | Researcher in Technology & Applied Sciences.","2026-10-17 03:20:19",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add hamzabellouch\u002Fagent-skills --skill esp32-arduino-embedded-c",{"tool":40,"command":41},"bunx","bunx skills add hamzabellouch\u002Fagent-skills --skill esp32-arduino-embedded-c",{"tool":43,"command":44},"pnpm","pnpm dlx skills add hamzabellouch\u002Fagent-skills --skill esp32-arduino-embedded-c","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FProgramming\u002FSystems_and_Hardware\u002FEmbedded_and_IoT\u002Fesp32-arduino-embedded-c\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M79FHH2H815A9TAP6WNKH4Q8","security-audit","Comprehensive security guidance, source code audit, vulnerability assessment, and penetration test review for codebases, APIs, microservices, CLI tools, libraries, and LLM-backed applications. Triggers on requests to audit a codebase, conduct security reviews, find vulnerabilities or flaws, pen-test source code, or when the user asks in Arabic (فحص أمني، تدقيق الكود أمنياً، مراجعة الثغرات، فحص أمان المشروع). Supports Guidance mode (focused review) and Full Audit mode (deterministic 6-phase harness).","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FSecurity_Audit_and_Code_Review\u002Fsecurity-audit\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M79FHBGXVBY6VQ1X7ETAZMF1","malware-analysis-reversing","Production malware analysis workflows, reverse engineering methodologies, isolated sandbox triage, static\u002Fdynamic binary analysis, memory forensics, and YARA detection rule authoring.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FOffensive_Security_and_Pentesting\u002Fmalware-analysis-reversing\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M79FH6EACDR801TZCE4R8SAC","application-security-pentesting","Production Application Security (AppSec) standards, OWASP Top 10 vulnerability remediation, SAST\u002FDAST pipeline integration, secure code review, threat modeling, and defensive security posture.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FOffensive_Security_and_Pentesting\u002Fapplication-security-pentesting\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M79FH0VKVT44FK923K520ZQA","oauth2-oidc-security-flows","Implement enterprise OAuth 2.1 and OpenID Connect (OIDC) authorization code flow with Proof Key for Code Exchange (PKCE), state and nonce verification, refresh token rotation, token revocation, and centralized IdP federation (Keycloak, Auth0, Okta). Trigger when building secure authentication, single sign-on (SSO), or third-party delegated authorization.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Foauth2-oidc-security-flows\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M79FGVVB3R4T88XXD8FRSV5B","jwt-session-management-hardening","Harden JWT-based authentication and session lifecycles using asymmetric signing (RS256\u002FEdDSA), JWKS rotation, strict claims validation, Redis-backed sliding window sessions, revocation lists, and secure HttpOnly cookie storage. Trigger when implementing token validation, session revocation, or hardening API authentication.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Fjwt-session-management-hardening\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M79FGNCPZ85CVEY0B3NE4H3B","soc2-compliance-automation","Best practices for implementing SOC 2 Type II compliance controls, continuous evidence collection, infrastructure policy-as-code, and automated security monitoring. Use when automating Trust Services Criteria (Security, Availability, Confidentiality, Processing Integrity, Privacy), audit logging, IAM least privilege, or CI\u002FCD security gates.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FGovernance_Compliance_and_Legal_Tech\u002Fsoc2-compliance-automation\u002FSKILL.md",[],[]]