BLE FOTA APP

Dependencies:   BLE_API mbed

It doesn't work with the default FOTA bootloader. It use NVIC_SystemReset() to enter a bootloader.

Committer:
yihui
Date:
Fri Oct 10 03:36:28 2014 +0000
Revision:
1:a607cd9655d7
use NVIC_SystemReset() to run bootloader

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 1:a607cd9655d7 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
yihui 1:a607cd9655d7 2 *
yihui 1:a607cd9655d7 3 * The information contained herein is property of Nordic Semiconductor ASA.
yihui 1:a607cd9655d7 4 * Terms and conditions of usage are described in detail in NORDIC
yihui 1:a607cd9655d7 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
yihui 1:a607cd9655d7 6 *
yihui 1:a607cd9655d7 7 * Licensees are granted free, non-transferable use of the information. NO
yihui 1:a607cd9655d7 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
yihui 1:a607cd9655d7 9 * the file.
yihui 1:a607cd9655d7 10 *
yihui 1:a607cd9655d7 11 */
yihui 1:a607cd9655d7 12
yihui 1:a607cd9655d7 13 /** @file
yihui 1:a607cd9655d7 14 *
yihui 1:a607cd9655d7 15 * @defgroup ble_error_log_module Error Log Module
yihui 1:a607cd9655d7 16 * @{
yihui 1:a607cd9655d7 17 * @ingroup ble_sdk_lib
yihui 1:a607cd9655d7 18 * @brief Module for writing error and stack to flash memory.
yihui 1:a607cd9655d7 19 *
yihui 1:a607cd9655d7 20 * @details It contains functions for writing an error code, line number, filename/message and
yihui 1:a607cd9655d7 21 * the stack to the flash during an error, e.g. in the assert handler.
yihui 1:a607cd9655d7 22 *
yihui 1:a607cd9655d7 23 */
yihui 1:a607cd9655d7 24 #ifndef BLE_ERROR_LOG_H__
yihui 1:a607cd9655d7 25 #define BLE_ERROR_LOG_H__
yihui 1:a607cd9655d7 26
yihui 1:a607cd9655d7 27 #include <stdint.h>
yihui 1:a607cd9655d7 28 #include <stdbool.h>
yihui 1:a607cd9655d7 29 #include "ble_flash.h"
yihui 1:a607cd9655d7 30
yihui 1:a607cd9655d7 31 #define ERROR_MESSAGE_LENGTH 128 /**< Length of error message to stored. */
yihui 1:a607cd9655d7 32 #define STACK_DUMP_LENGTH 256 /**< Length of stack to be stored at max: 64 entries of 4 bytes each. */
yihui 1:a607cd9655d7 33 #define FLASH_PAGE_ERROR_LOG (BLE_FLASH_PAGE_END - 2) /**< Address in flash where stack trace can be stored. */
yihui 1:a607cd9655d7 34
yihui 1:a607cd9655d7 35 /**@brief Error Log Data structure.
yihui 1:a607cd9655d7 36 *
yihui 1:a607cd9655d7 37 * @details The structure contains the error, message/filename, line number as well as the current
yihui 1:a607cd9655d7 38 * stack, at the time where an error occured.
yihui 1:a607cd9655d7 39 */
yihui 1:a607cd9655d7 40 typedef struct
yihui 1:a607cd9655d7 41 {
yihui 1:a607cd9655d7 42 uint16_t failure; /**< Indication that a major failure has occurred during last execution of the application. */
yihui 1:a607cd9655d7 43 uint16_t line_number; /**< Line number indicating at which line the failure occurred. */
yihui 1:a607cd9655d7 44 uint32_t err_code; /**< Error code when failure occurred. */
yihui 1:a607cd9655d7 45 uint8_t message[ERROR_MESSAGE_LENGTH]; /**< Will just use the first 128 bytes of filename to store for debugging purposes. */
yihui 1:a607cd9655d7 46 uint32_t stack_info[STACK_DUMP_LENGTH / 4]; /**< Will contain stack information, can be manually unwinded for debug purposes. */
yihui 1:a607cd9655d7 47 } ble_error_log_data_t;
yihui 1:a607cd9655d7 48
yihui 1:a607cd9655d7 49
yihui 1:a607cd9655d7 50 /**@brief Function for writing the file name/message, line number, and current program stack
yihui 1:a607cd9655d7 51 * to flash.
yihui 1:a607cd9655d7 52 *
yihui 1:a607cd9655d7 53 * @note This function will force the writing to flash, and disregard any radio communication.
yihui 1:a607cd9655d7 54 * USE THIS FUNCTION WITH CARE.
yihui 1:a607cd9655d7 55 *
yihui 1:a607cd9655d7 56 * @param[in] err_code Error code to be logged.
yihui 1:a607cd9655d7 57 * @param[in] p_message Message to be written to the flash together with stack dump, usually
yihui 1:a607cd9655d7 58 * the file name where the error occured.
yihui 1:a607cd9655d7 59 * @param[in] line_number Line number where the error occured.
yihui 1:a607cd9655d7 60 *
yihui 1:a607cd9655d7 61 * @return NRF_SUCCESS on successful writing of the error log.
yihui 1:a607cd9655d7 62 *
yihui 1:a607cd9655d7 63 */
yihui 1:a607cd9655d7 64 uint32_t ble_error_log_write(uint32_t err_code, const uint8_t * p_message, uint16_t line_number);
yihui 1:a607cd9655d7 65
yihui 1:a607cd9655d7 66
yihui 1:a607cd9655d7 67 #endif /* BLE_ERROR_LOG_H__ */
yihui 1:a607cd9655d7 68
yihui 1:a607cd9655d7 69 /** @} */