added cumstom Panic Handler

master
Jan Umbach 2023-09-07 15:41:45 +02:00
parent 73f57b4d11
commit b5cd04fb86
2 changed files with 14 additions and 1 deletions

View File

@ -38,4 +38,6 @@ static EventGroupHandle_t s_wifi_event_group;
static const char *jannexTAG = "JANNEX";
void initJannex();
void updateJannex();
void updateJannex();
void setCustomPanicHandler(void (*func)());

View File

@ -216,12 +216,23 @@ void updateJannex()
// Declare the real panic handler function. We'll be able to call it after executing our custom code
void __real_esp_panic_handler(void *);
void (*customPanicHandler)() = NULL;
void setCustomPanicHandler(void (*func)())
{
customPanicHandler = func;
}
// This function will be considered the esp_panic_handler to call in case a panic occurs
void __wrap_esp_panic_handler(panic_info_t *info)
{
// Custom code, count the number of panics or simply print a message
panicRetryCounter++;
if (customPanicHandler != NULL)
{
customPanicHandler();
}
// Convert the integer to a string
// char retryCounterStr[10]; // Adjust the size as needed
// snprintf(retryCounterStr, sizeof(retryCounterStr), "%d", panicRetryCounter);