Skip to content

Commit

Permalink
Loop infinitely if the custom failure handler returns
Browse files Browse the repository at this point in the history
  • Loading branch information
frazar committed Feb 25, 2019
1 parent a334e3b commit 06d4cda
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/hal/hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) {
;
}
}

Expand Down

0 comments on commit 06d4cda

Please sign in to comment.