Skip to content

Commit d58372f

Browse files
committed
working error handler
1 parent 0aca10e commit d58372f

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

libs/bluetooth/jswrap_bluetooth.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ bool nfcEnabled = false;
9696
#endif
9797
#define BLE_HANDLE_MAX 0xFFFF /**< Max handle value in BLE. */
9898

99-
#define DEAD_BEEF 0xDEADBEEF /**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */
100-
10199
static ble_nus_t m_nus; /**< Structure to identify the Nordic UART Service. */
102100
static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; /**< Handle of the current connection. */
103101
#if CENTRAL_LINK_COUNT>0
@@ -215,9 +213,19 @@ Called when an NFC field is no longer detected
215213
* @details
216214
*/
217215
void ble_app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name) {
218-
jsiConsolePrintf("NRF ERROR 0x%x at %s:%d\n", error_code, p_file_name, line_num);
216+
#ifdef LED1_PININDEX
217+
jshPinOutput(LED1_PININDEX, LED1_ONSTATE);
218+
#endif
219+
#ifdef LED2_PININDEX
220+
jshPinOutput(LED2_PININDEX, LED2_ONSTATE);
221+
#endif
222+
#ifdef LED3_PININDEX
223+
jshPinOutput(LED3_PININDEX, LED3_ONSTATE);
224+
#endif
225+
jsiConsolePrintf("NRF ERROR 0x%x at %s:%d\n", error_code, p_file_name?p_file_name:"?", line_num);
219226
jsiConsolePrint("REBOOTING.\n");
220227
jshTransmitFlush();
228+
jshDelayMicroseconds(1000000);
221229
NVIC_SystemReset();
222230
}
223231

@@ -232,11 +240,15 @@ void ble_app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t
232240
* @param[in] line_num Line number of the failing ASSERT call.
233241
* @param[in] p_file_name File name of the failing ASSERT call.
234242
*/
235-
void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name)
236-
{
237-
ble_app_error_handler(DEAD_BEEF, line_num, p_file_name);
243+
void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name) {
244+
ble_app_error_handler(0xDEADBEEF, line_num, p_file_name);
245+
}
246+
247+
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) {
248+
ble_app_error_handler(id, pc, 0);
238249
}
239250

251+
240252
#ifdef USE_BOOTLOADER
241253
/**@brief Function for stopping advertising.
242254
*/

0 commit comments

Comments
 (0)