/* Desktop port of the httpd thread wrappers (replaces ESP-IDF's src/port/esp32/osal.h) */ #pragma once #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_err.h" #define OS_SUCCESS ESP_OK #define OS_FAIL ESP_FAIL typedef TaskHandle_t othread_t; static inline int httpd_os_thread_create(othread_t *thread, const char *name, uint16_t stacksize, int prio, void (*thread_routine)(void *arg), void *arg, BaseType_t core_id, uint32_t caps) { (void)core_id; (void)caps; return xTaskCreate(thread_routine, name, stacksize, arg, (UBaseType_t)prio, thread) == pdPASS ? OS_SUCCESS : OS_FAIL; } // Only the calling task can delete itself static inline void httpd_os_thread_delete(void) { vTaskDelete(NULL); } static inline void httpd_os_thread_sleep(int msecs) { vTaskDelay(msecs / portTICK_PERIOD_MS); } static inline othread_t httpd_os_thread_handle(void) { return xTaskGetCurrentTaskHandle(); }