added cumstom Panic Handler
parent
73f57b4d11
commit
b5cd04fb86
|
@ -39,3 +39,5 @@ static const char *jannexTAG = "JANNEX";
|
||||||
|
|
||||||
void initJannex();
|
void initJannex();
|
||||||
void updateJannex();
|
void updateJannex();
|
||||||
|
|
||||||
|
void setCustomPanicHandler(void (*func)());
|
11
src/jannex.c
11
src/jannex.c
|
@ -216,12 +216,23 @@ void updateJannex()
|
||||||
// Declare the real panic handler function. We'll be able to call it after executing our custom code
|
// 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 __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
|
// 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)
|
void __wrap_esp_panic_handler(panic_info_t *info)
|
||||||
{
|
{
|
||||||
// Custom code, count the number of panics or simply print a message
|
// Custom code, count the number of panics or simply print a message
|
||||||
panicRetryCounter++;
|
panicRetryCounter++;
|
||||||
|
|
||||||
|
if (customPanicHandler != NULL)
|
||||||
|
{
|
||||||
|
customPanicHandler();
|
||||||
|
}
|
||||||
|
|
||||||
// Convert the integer to a string
|
// Convert the integer to a string
|
||||||
// char retryCounterStr[10]; // Adjust the size as needed
|
// char retryCounterStr[10]; // Adjust the size as needed
|
||||||
// snprintf(retryCounterStr, sizeof(retryCounterStr), "%d", panicRetryCounter);
|
// snprintf(retryCounterStr, sizeof(retryCounterStr), "%d", panicRetryCounter);
|
||||||
|
|
Loading…
Reference in New Issue