Files
2026-08-04 11:55:02 -07:00

46 lines
1.6 KiB
C

/*
* Host stand-in for ESP-IDF's esp_err.h.
*
* The simulator compiles the real firmware UI sources unmodified. Those
* sources include ESP-IDF headers, so the simulator supplies its own versions
* on the include path rather than sprinkling #ifdefs through main/. Only the
* surface the shared sources actually use is defined here -- if a new firmware
* source is added to the simulator build and fails to compile, extend this
* file, do not fork the firmware source.
*/
#ifndef ESP_ERR_H
#define ESP_ERR_H
#include <stdbool.h>
#include <stdint.h>
typedef int esp_err_t;
#define ESP_OK 0
#define ESP_FAIL -1
#define ESP_ERR_NO_MEM 0x101
#define ESP_ERR_INVALID_ARG 0x102
#define ESP_ERR_INVALID_STATE 0x103
#define ESP_ERR_INVALID_SIZE 0x104
#define ESP_ERR_NOT_FOUND 0x105
#define ESP_ERR_NOT_SUPPORTED 0x106
#define ESP_ERR_TIMEOUT 0x107
#define ESP_ERR_INVALID_RESPONSE 0x108
const char *esp_err_to_name(esp_err_t code);
/* Aborts on the host too -- a failed ESP_ERROR_CHECK is a bug worth crashing
* on in the simulator exactly as it is on the device. */
void esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *expr);
#define ESP_ERROR_CHECK(x) \
do { \
const esp_err_t err_rc_ = (x); \
if (err_rc_ != ESP_OK) { \
esp_error_check_failed(err_rc_, __FILE__, __LINE__, #x); \
} \
} while (0)
#endif