From 46e9ac08301d11a9136d993b6fa8d207247c3b3d Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Mon, 30 Nov 2015 16:49:39 +0000 Subject: [PATCH] use espruino-specific error handler --- Makefile | 1 - libs/bluetooth/jswrap_bluetooth.c | 26 ++++++++++++-------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index f4c4789e9..8567d996d 100755 --- a/Makefile +++ b/Makefile @@ -1311,7 +1311,6 @@ ifdef NRF5X SOURCES += \ $(NRF5X_SDK_PATH)/components/libraries/button/app_button.c \ - $(NRF5X_SDK_PATH)/components/libraries/util/app_error.c \ $(NRF5X_SDK_PATH)/components/libraries/fifo/app_fifo.c \ $(NRF5X_SDK_PATH)/components/libraries/timer/app_timer.c \ $(NRF5X_SDK_PATH)/components/libraries/trace/app_trace.c \ diff --git a/libs/bluetooth/jswrap_bluetooth.c b/libs/bluetooth/jswrap_bluetooth.c index b8595cc26..60f9051d9 100644 --- a/libs/bluetooth/jswrap_bluetooth.c +++ b/libs/bluetooth/jswrap_bluetooth.c @@ -74,22 +74,20 @@ static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; static ble_uuid_t m_adv_uuids[] = {{BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE}}; /**< Universally unique service identifier. */ -/**@brief Function for assert macro callback. - * - * @details This function will be called in case of an assert in the SoftDevice. - * - * @warning This handler is an example only and does not fit a final product. You need to analyse - * how your product is supposed to react in case of Assert. - * @warning On assert from the SoftDevice, the system can only recover on reset. - * - * @param[in] line_num Line number of the failing ASSERT call. - * @param[in] p_file_name File name of the failing ASSERT call. - */ -void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name) -{ - app_error_handler(DEAD_BEEF, line_num, p_file_name); +// --------------------------------------------------------------------------- +// Error handlers... +void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name) { + jsiConsolePrintf("NRF ERROR 0x%x at %s:%d\n", error_code, p_file_name, line_num); + jsiConsolePrint("REBOOTING.\n"); + jshTransmitFlush(); + NVIC_SystemReset(); } +void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name) { + app_error_handler(0xDEADBEEF, line_num, p_file_name); +} +// --------------------------------------------------------------------------- + /**@brief Function for the GAP initialization. *