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 /**************************************************************************/
yihui 1:a607cd9655d7 2 /*!
yihui 1:a607cd9655d7 3 @file ble_error.h
yihui 1:a607cd9655d7 4 @author hathach (tinyusb.org)
yihui 1:a607cd9655d7 5
yihui 1:a607cd9655d7 6 @section LICENSE
yihui 1:a607cd9655d7 7
yihui 1:a607cd9655d7 8 Software License Agreement (BSD License)
yihui 1:a607cd9655d7 9
yihui 1:a607cd9655d7 10 Copyright (c) 2013, K. Townsend (microBuilder.eu)
yihui 1:a607cd9655d7 11 All rights reserved.
yihui 1:a607cd9655d7 12
yihui 1:a607cd9655d7 13 Redistribution and use in source and binary forms, with or without
yihui 1:a607cd9655d7 14 modification, are permitted provided that the following conditions are met:
yihui 1:a607cd9655d7 15 1. Redistributions of source code must retain the above copyright
yihui 1:a607cd9655d7 16 notice, this list of conditions and the following disclaimer.
yihui 1:a607cd9655d7 17 2. Redistributions in binary form must reproduce the above copyright
yihui 1:a607cd9655d7 18 notice, this list of conditions and the following disclaimer in the
yihui 1:a607cd9655d7 19 documentation and/or other materials provided with the distribution.
yihui 1:a607cd9655d7 20 3. Neither the name of the copyright holders nor the
yihui 1:a607cd9655d7 21 names of its contributors may be used to endorse or promote products
yihui 1:a607cd9655d7 22 derived from this software without specific prior written permission.
yihui 1:a607cd9655d7 23
yihui 1:a607cd9655d7 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
yihui 1:a607cd9655d7 25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
yihui 1:a607cd9655d7 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
yihui 1:a607cd9655d7 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
yihui 1:a607cd9655d7 28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
yihui 1:a607cd9655d7 29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
yihui 1:a607cd9655d7 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
yihui 1:a607cd9655d7 31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
yihui 1:a607cd9655d7 32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
yihui 1:a607cd9655d7 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
yihui 1:a607cd9655d7 34 */
yihui 1:a607cd9655d7 35 /**************************************************************************/
yihui 1:a607cd9655d7 36
yihui 1:a607cd9655d7 37 /** \file
yihui 1:a607cd9655d7 38 * \brief Error Header
yihui 1:a607cd9655d7 39 *
yihui 1:a607cd9655d7 40 * \note TBD
yihui 1:a607cd9655d7 41 */
yihui 1:a607cd9655d7 42
yihui 1:a607cd9655d7 43 /** \ingroup Group_Common
yihui 1:a607cd9655d7 44 * \defgroup Group_Error Error Codes
yihui 1:a607cd9655d7 45 * @{
yihui 1:a607cd9655d7 46 */
yihui 1:a607cd9655d7 47
yihui 1:a607cd9655d7 48 #ifndef _BLE_ERROR_H_
yihui 1:a607cd9655d7 49 #define _BLE_ERROR_H_
yihui 1:a607cd9655d7 50
yihui 1:a607cd9655d7 51 #include "projectconfig.h"
yihui 1:a607cd9655d7 52
yihui 1:a607cd9655d7 53 #ifdef __cplusplus
yihui 1:a607cd9655d7 54 extern "C" {
yihui 1:a607cd9655d7 55 #endif
yihui 1:a607cd9655d7 56
yihui 1:a607cd9655d7 57 typedef enum
yihui 1:a607cd9655d7 58 {
yihui 1:a607cd9655d7 59 /*=======================================================================
yihui 1:a607cd9655d7 60 NORDIC GLOBAL ERRORS 0x0000 .. 0x00FF
yihui 1:a607cd9655d7 61 -----------------------------------------------------------------------
yihui 1:a607cd9655d7 62 Errors mapped from nrf_error.h
yihui 1:a607cd9655d7 63 -----------------------------------------------------------------------*/
yihui 1:a607cd9655d7 64 ERROR_NONE = 0x0000 , ///< Successful command
yihui 1:a607cd9655d7 65 ERROR_SVC_HANDLER_MISSING = 0x0001 , ///< SVC handler is missing
yihui 1:a607cd9655d7 66 ERROR_SOFTDEVICE_NOT_ENABLED = 0x0002 , ///< SoftDevice has not been enabled
yihui 1:a607cd9655d7 67 ERROR_INTERNAL = 0x0003 , ///< Internal Error
yihui 1:a607cd9655d7 68 ERROR_NO_MEM = 0x0004 , ///< No Memory for operation
yihui 1:a607cd9655d7 69 ERROR_NOT_FOUND = 0x0005 , ///< Not found
yihui 1:a607cd9655d7 70 ERROR_NOT_SUPPORTED = 0x0006 , ///< Not supported
yihui 1:a607cd9655d7 71 ERROR_INVALID_PARAM = 0x0007 , ///< Invalid Parameter
yihui 1:a607cd9655d7 72 ERROR_INVALID_STATE = 0x0008 , ///< Invalid state, operation disallowed in this state
yihui 1:a607cd9655d7 73 ERROR_INVALID_LENGTH = 0x0009 , ///< Invalid Length
yihui 1:a607cd9655d7 74 ERROR_INVALID_FLAGS = 0x000A , ///< Invalid Flags
yihui 1:a607cd9655d7 75 ERROR_INVALID_DATA = 0x000B , ///< Invalid Data
yihui 1:a607cd9655d7 76 ERROR_DATA_SIZE = 0x000C , ///< Data size exceeds limit
yihui 1:a607cd9655d7 77 ERROR_TIMEOUT = 0x000D , ///< Operation timed out
yihui 1:a607cd9655d7 78 ERROR_NULL = 0x000E , ///< Null Pointer
yihui 1:a607cd9655d7 79 ERROR_FORBIDDEN = 0x000F , ///< Forbidden Operation
yihui 1:a607cd9655d7 80 ERROR_INVALID_ADDR = 0x0010 , ///< Bad Memory Address
yihui 1:a607cd9655d7 81 ERROR_BUSY = 0x0011 , ///< Busy
yihui 1:a607cd9655d7 82 /*=======================================================================*/
yihui 1:a607cd9655d7 83
yihui 1:a607cd9655d7 84 ERROR_INVALIDPARAMETER = 0x0100 , /**< An invalid parameter value was provided */
yihui 1:a607cd9655d7 85 ERROR_I2C_XFER_FAILED = 0x0101 , /**< an failed attempt to make I2C transfer */
yihui 1:a607cd9655d7 86
yihui 1:a607cd9655d7 87 /*=======================================================================
yihui 1:a607cd9655d7 88 SIMPLE BINARY PROTOCOL ERRORS 0x0120 .. 0x013F
yihui 1:a607cd9655d7 89 -----------------------------------------------------------------------
yihui 1:a607cd9655d7 90 Errors relating to the simple binary protocol (/src//protocol)
yihui 1:a607cd9655d7 91 -----------------------------------------------------------------------*/
yihui 1:a607cd9655d7 92 ERROR_PROT_INVALIDMSGTYPE = 0x121, /**< Unexpected msg type encountered */
yihui 1:a607cd9655d7 93 ERROR_PROT_INVALIDCOMMANDID = 0x122, /**< Unknown or out of range command ID */
yihui 1:a607cd9655d7 94 ERROR_PROT_INVALIDPAYLOAD = 0x123, /**< Message payload has a problem (invalid len, etc.) */
yihui 1:a607cd9655d7 95 /*=======================================================================*/
yihui 1:a607cd9655d7 96
yihui 1:a607cd9655d7 97 //------------- based on Nordic SDM nrf_error_sdm.h -------------//
yihui 1:a607cd9655d7 98 ERROR_SDM_LFCLK_SOURCE_UNKNOWN = 0x1000 , ///< Unknown lfclk source
yihui 1:a607cd9655d7 99 ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION = 0x1001 , ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts)
yihui 1:a607cd9655d7 100 ERROR_SDM_INCORRECT_CLENR0 = 0x1002 , ///< Incorrect CLENR0 (can be caused by erronous SoftDevice flashing)
yihui 1:a607cd9655d7 101
yihui 1:a607cd9655d7 102 //------------- based on Nordic SOC nrf_error_soc.h -------------//
yihui 1:a607cd9655d7 103 /* Mutex Errors */
yihui 1:a607cd9655d7 104 ERROR_SOC_MUTEX_ALREADY_TAKEN = 0x2000 , ///< Mutex already taken
yihui 1:a607cd9655d7 105
yihui 1:a607cd9655d7 106 /* NVIC errors */
yihui 1:a607cd9655d7 107 ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE = 0x2001 , ///< NVIC interrupt not available
yihui 1:a607cd9655d7 108 ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED = 0x2002 , ///< NVIC interrupt priority not allowed
yihui 1:a607cd9655d7 109 ERROR_SOC_NVIC_SHOULD_NOT_RETURN = 0x2003 , ///< NVIC should not return
yihui 1:a607cd9655d7 110
yihui 1:a607cd9655d7 111 /* Power errors */
yihui 1:a607cd9655d7 112 ERROR_SOC_POWER_MODE_UNKNOWN = 0x2004 , ///< Power mode unknown
yihui 1:a607cd9655d7 113 ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN = 0x2005 , ///< Power POF threshold unknown
yihui 1:a607cd9655d7 114 ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN = 0x2006 , ///< Power off should not return
yihui 1:a607cd9655d7 115
yihui 1:a607cd9655d7 116 /* Rand errors */
yihui 1:a607cd9655d7 117 ERROR_SOC_RAND_NOT_ENOUGH_VALUES = 0x2007 , ///< RAND not enough values
yihui 1:a607cd9655d7 118
yihui 1:a607cd9655d7 119 /* PPI errors */
yihui 1:a607cd9655d7 120 ERROR_SOC_PPI_INVALID_CHANNEL = 0x2008 , ///< Invalid PPI Channel
yihui 1:a607cd9655d7 121 ERROR_SOC_PPI_INVALID_GROUP = 0x2009 , ///< Invalid PPI Group
yihui 1:a607cd9655d7 122
yihui 1:a607cd9655d7 123 //------------- based on Nordic STK (ble) ble_err.h -------------//
yihui 1:a607cd9655d7 124 ERROR_BLE_INVALID_CONN_HANDLE = 0x3001 , /**< Invalid connection handle. */
yihui 1:a607cd9655d7 125 ERROR_BLE_INVALID_ATTR_HANDLE = 0x3002 , /**< Invalid attribute handle. */
yihui 1:a607cd9655d7 126 ERROR_BLE_NO_TX_BUFFERS = 0x3003 , /**< Buffer capacity exceeded. */
yihui 1:a607cd9655d7 127
yihui 1:a607cd9655d7 128 // L2CAP
yihui 1:a607cd9655d7 129 ERROR_BLE_L2CAP_CID_IN_USE = 0x3100 , /**< CID already in use. */
yihui 1:a607cd9655d7 130
yihui 1:a607cd9655d7 131 // GAP
yihui 1:a607cd9655d7 132 ERROR_BLE_GAP_UUID_LIST_MISMATCH = 0x3200 , /**< UUID list does not contain an integral number of UUIDs. */
yihui 1:a607cd9655d7 133 ERROR_BLE_GAP_DISCOVERABLE_WITH_WHITELIST = 0x3201 , /**< Use of Whitelist not permitted with discoverable advertising. */
yihui 1:a607cd9655d7 134 ERROR_BLE_GAP_INVALID_BLE_ADDR = 0x3202 , /**< The upper two bits of the address do not correspond to the specified address type. */
yihui 1:a607cd9655d7 135
yihui 1:a607cd9655d7 136 // GATTC
yihui 1:a607cd9655d7 137 ERROR_BLE_GATTC_PROC_NOT_PERMITTED = 0x3300 ,
yihui 1:a607cd9655d7 138
yihui 1:a607cd9655d7 139 // GATTS
yihui 1:a607cd9655d7 140 ERROR_BLEGATTS_INVALID_ATTR_TYPE = 0x3400 , /**< Invalid attribute type. */
yihui 1:a607cd9655d7 141 ERROR_BLEGATTS_SYS_ATTR_MISSING = 0x3401 , /**< System Attributes missing. */
yihui 1:a607cd9655d7 142
yihui 1:a607cd9655d7 143 }error_t;
yihui 1:a607cd9655d7 144
yihui 1:a607cd9655d7 145 #ifdef __cplusplus
yihui 1:a607cd9655d7 146 }
yihui 1:a607cd9655d7 147 #endif
yihui 1:a607cd9655d7 148
yihui 1:a607cd9655d7 149 #endif /* _BLE_ERROR_H_ */
yihui 1:a607cd9655d7 150
yihui 1:a607cd9655d7 151 /** @} */