recuperator fan control with esp32
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
esp-recuperator/main/shutdown_handlers.c

32 lines
846 B

#include "esp_log.h"
#include "shutdown_handlers.h"
static const char *TAG = "shutdown_hdl";
#define MAX_SHUTDOWN_HANDLERS 10
static int shutdown_handlers_next = 0;
static shutdown_handler_t shutdown_handlers[MAX_SHUTDOWN_HANDLERS];
// ---------------------------
esp_err_t cspemu_add_shutdown_handler(shutdown_handler_t handler)
{
ESP_LOGI(TAG, "+ new shutdown handler %p", handler);
if (shutdown_handlers_next < MAX_SHUTDOWN_HANDLERS) {
shutdown_handlers[shutdown_handlers_next++] = handler;
return ESP_OK;
} else {
return ESP_FAIL;
}
}
void cspemu_run_shutdown_handlers(void)
{
ESP_LOGI(TAG, "Running shutdown handlers");
for (int i = 0; i < shutdown_handlers_next; i++) {
shutdown_handlers[i]();
}
// prevent them being run multiple times
shutdown_handlers_next = 0;
}