20 lines
1.0 KiB
C
20 lines
1.0 KiB
C
#pragma once
|
|
|
|
#include "esp_log.h"
|
|
|
|
#define ESP_ERROR_RETRY(action, max_retries) \
|
|
{ \
|
|
uint8_t retry_count = 0; \
|
|
esp_err_t error; \
|
|
while (retry_count < max_retries) { \
|
|
error = action; \
|
|
if (error == ESP_OK) break; \
|
|
retry_count++; \
|
|
ESP_LOGI("RETRY", "Retrying... (%d/%d)\n", retry_count + 1, \
|
|
max_retries); \
|
|
} \
|
|
if (error != ESP_OK) { \
|
|
ESP_LOGE("RETRY", "retry failed. %d", error); \
|
|
ESP_ERROR_CHECK(error); \
|
|
} \
|
|
} |