From 06d4cda9d815e15d9e010f6907519b8af7fcd44f Mon Sep 17 00:00:00 2001 From: Francesco Zardi Date: Mon, 25 Feb 2019 09:35:21 +0100 Subject: [PATCH] Loop infinitely if the custom failure handler returns --- src/hal/hal.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/hal/hal.cpp b/src/hal/hal.cpp index 82167ad4..4cbdd278 100644 --- a/src/hal/hal.cpp +++ b/src/hal/hal.cpp @@ -25,6 +25,7 @@ static const Arduino_LMIC::HalPinmap_t *plmic_pins; static Arduino_LMIC::HalConfiguration_t *pHalConfig; static Arduino_LMIC::HalConfiguration_t nullHalConig; +static hal_failure_handler_t* custom_hal_failure_handler = NULL; static void hal_interrupt_init(); // Fwd declaration @@ -385,21 +386,24 @@ bool hal_init_with_pinmap(const HalPinmap_t *pPinmap) }; // namespace Arduino_LMIC -static hal_failure_handler_t* custom_hal_failure_handler = NULL; - void hal_failed (const char *file, u2_t line) { if (custom_hal_failure_handler != NULL) { (*custom_hal_failure_handler)(file, line); - } else { + } + #if defined(LMIC_FAILURE_TO) - LMIC_FAILURE_TO.println("FAILURE "); - LMIC_FAILURE_TO.print(file); - LMIC_FAILURE_TO.print(':'); - LMIC_FAILURE_TO.println(line); - LMIC_FAILURE_TO.flush(); + LMIC_FAILURE_TO.println("FAILURE "); + LMIC_FAILURE_TO.print(file); + LMIC_FAILURE_TO.print(':'); + LMIC_FAILURE_TO.println(line); + LMIC_FAILURE_TO.flush(); #endif - hal_disableIRQs(); - while(1); + + hal_disableIRQs(); + + // Infinite loop + while (1) { + ; } }