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 confidential property of Nordic Semiconductor. The use,
yihui 1:a607cd9655d7 4 * copying, transfer or disclosure of such information is prohibited except by express written
yihui 1:a607cd9655d7 5 * agreement with Nordic Semiconductor.
yihui 1:a607cd9655d7 6 *
yihui 1:a607cd9655d7 7 */
yihui 1:a607cd9655d7 8 /**
yihui 1:a607cd9655d7 9 @addtogroup BLE_GATT Generic Attribute Profile (GATT) Common
yihui 1:a607cd9655d7 10 @{
yihui 1:a607cd9655d7 11 @brief Common definitions and prototypes for the GATT interfaces.
yihui 1:a607cd9655d7 12 */
yihui 1:a607cd9655d7 13
yihui 1:a607cd9655d7 14 #ifndef BLE_GATT_H__
yihui 1:a607cd9655d7 15 #define BLE_GATT_H__
yihui 1:a607cd9655d7 16
yihui 1:a607cd9655d7 17 #include "ble_types.h"
yihui 1:a607cd9655d7 18 #include "ble_ranges.h"
yihui 1:a607cd9655d7 19
yihui 1:a607cd9655d7 20
yihui 1:a607cd9655d7 21 /** @addtogroup BLE_GATT_DEFINES Defines
yihui 1:a607cd9655d7 22 * @{ */
yihui 1:a607cd9655d7 23
yihui 1:a607cd9655d7 24 /** @brief Default MTU size. */
yihui 1:a607cd9655d7 25 #define GATT_MTU_SIZE_DEFAULT 23
yihui 1:a607cd9655d7 26
yihui 1:a607cd9655d7 27 /** @brief Only the default MTU size of 23 is currently supported. */
yihui 1:a607cd9655d7 28 #define GATT_RX_MTU 23
yihui 1:a607cd9655d7 29
yihui 1:a607cd9655d7 30
yihui 1:a607cd9655d7 31 /**@brief Invalid Attribute Handle. */
yihui 1:a607cd9655d7 32 #define BLE_GATT_HANDLE_INVALID 0x0000
yihui 1:a607cd9655d7 33
yihui 1:a607cd9655d7 34 /** @defgroup BLE_GATT_TIMEOUT_SOURCES GATT Timeout sources
yihui 1:a607cd9655d7 35 * @{ */
yihui 1:a607cd9655d7 36 #define BLE_GATT_TIMEOUT_SRC_PROTOCOL 0x00 /**< ATT Protocol timeout. */
yihui 1:a607cd9655d7 37 /** @} */
yihui 1:a607cd9655d7 38
yihui 1:a607cd9655d7 39 /** @defgroup BLE_GATT_WRITE_OPS GATT Write operations
yihui 1:a607cd9655d7 40 * @{ */
yihui 1:a607cd9655d7 41 #define BLE_GATT_OP_INVALID 0x00 /**< Invalid Operation. */
yihui 1:a607cd9655d7 42 #define BLE_GATT_OP_WRITE_REQ 0x01 /**< Write Request. */
yihui 1:a607cd9655d7 43 #define BLE_GATT_OP_WRITE_CMD 0x02 /**< Write Command. */
yihui 1:a607cd9655d7 44 #define BLE_GATT_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */
yihui 1:a607cd9655d7 45 #define BLE_GATT_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */
yihui 1:a607cd9655d7 46 #define BLE_GATT_OP_EXEC_WRITE_REQ 0x05 /**< Execute Write Request. */
yihui 1:a607cd9655d7 47 /** @} */
yihui 1:a607cd9655d7 48
yihui 1:a607cd9655d7 49 /** @defgroup BLE_GATT_EXEC_WRITE_FLAGS GATT Execute Write flags
yihui 1:a607cd9655d7 50 * @{ */
yihui 1:a607cd9655d7 51 #define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL 0x00
yihui 1:a607cd9655d7 52 #define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE 0x01
yihui 1:a607cd9655d7 53 /** @} */
yihui 1:a607cd9655d7 54
yihui 1:a607cd9655d7 55 /** @defgroup BLE_GATT_HVX_TYPES GATT Handle Value operations
yihui 1:a607cd9655d7 56 * @{ */
yihui 1:a607cd9655d7 57 #define BLE_GATT_HVX_INVALID 0x00 /**< Invalid Operation. */
yihui 1:a607cd9655d7 58 #define BLE_GATT_HVX_NOTIFICATION 0x01 /**< Handle Value Notification. */
yihui 1:a607cd9655d7 59 #define BLE_GATT_HVX_INDICATION 0x02 /**< Handle Value Indication. */
yihui 1:a607cd9655d7 60 /** @} */
yihui 1:a607cd9655d7 61
yihui 1:a607cd9655d7 62 /** @defgroup BLE_GATT_STATUS_CODES GATT Status Codes
yihui 1:a607cd9655d7 63 * @{ */
yihui 1:a607cd9655d7 64 #define BLE_GATT_STATUS_SUCCESS 0x0000 /**< Success. */
yihui 1:a607cd9655d7 65 #define BLE_GATT_STATUS_UNKNOWN 0x0001 /**< Unknown or not applicable status. */
yihui 1:a607cd9655d7 66 #define BLE_GATT_STATUS_ATTERR_INVALID 0x0100 /**< ATT Error: Invalid Error Code. */
yihui 1:a607cd9655d7 67 #define BLE_GATT_STATUS_ATTERR_INVALID_HANDLE 0x0101 /**< ATT Error: Invalid Attribute Handle. */
yihui 1:a607cd9655d7 68 #define BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED 0x0102 /**< ATT Error: Read not permitted. */
yihui 1:a607cd9655d7 69 #define BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED 0x0103 /**< ATT Error: Write not permitted. */
yihui 1:a607cd9655d7 70 #define BLE_GATT_STATUS_ATTERR_INVALID_PDU 0x0104 /**< ATT Error: Used in ATT as Invalid PDU. */
yihui 1:a607cd9655d7 71 #define BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION 0x0105 /**< ATT Error: Authenticated link required. */
yihui 1:a607cd9655d7 72 #define BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED 0x0106 /**< ATT Error: Used in ATT as Request Not Supported. */
yihui 1:a607cd9655d7 73 #define BLE_GATT_STATUS_ATTERR_INVALID_OFFSET 0x0107 /**< ATT Error: Offset specified was past the end of the attribute. */
yihui 1:a607cd9655d7 74 #define BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION 0x0108 /**< ATT Error: Used in ATT as Insufficient Authorisation. */
yihui 1:a607cd9655d7 75 #define BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL 0x0109 /**< ATT Error: Used in ATT as Prepare Queue Full. */
yihui 1:a607cd9655d7 76 #define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND 0x010A /**< ATT Error: Used in ATT as Attribute not found. */
yihui 1:a607cd9655d7 77 #define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_LONG 0x010B /**< ATT Error: Attribute cannot be read or written using read/write blob requests. */
yihui 1:a607cd9655d7 78 #define BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE 0x010C /**< ATT Error: Encryption key size used is insufficient. */
yihui 1:a607cd9655d7 79 #define BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH 0x010D /**< ATT Error: Invalid value size. */
yihui 1:a607cd9655d7 80 #define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E /**< ATT Error: Very unlikely error. */
yihui 1:a607cd9655d7 81 #define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F /**< ATT Error: Encrypted link required. */
yihui 1:a607cd9655d7 82 #define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110 /**< ATT Error: Attribute type is not a supported grouping attribute. */
yihui 1:a607cd9655d7 83 #define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Encrypted link required. */
yihui 1:a607cd9655d7 84 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112 /**< ATT Error: Reserved for Future Use range #1 begin. */
yihui 1:a607cd9655d7 85 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F /**< ATT Error: Reserved for Future Use range #1 end. */
yihui 1:a607cd9655d7 86 #define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180 /**< ATT Error: Application range begin. */
yihui 1:a607cd9655d7 87 #define BLE_GATT_STATUS_ATTERR_APP_END 0x019F /**< ATT Error: Application range end. */
yihui 1:a607cd9655d7 88 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_BEGIN 0x01A0 /**< ATT Error: Reserved for Future Use range #2 begin. */
yihui 1:a607cd9655d7 89 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END 0x01DF /**< ATT Error: Reserved for Future Use range #2 end. */
yihui 1:a607cd9655d7 90 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN 0x01E0 /**< ATT Error: Reserved for Future Use range #3 begin. */
yihui 1:a607cd9655d7 91 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END 0x01FC /**< ATT Error: Reserved for Future Use range #3 end. */
yihui 1:a607cd9655d7 92 #define BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR 0x01FD /**< ATT Common Profile and Service Error: Client Characteristic Configuration Descriptor improperly configured. */
yihui 1:a607cd9655d7 93 #define BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG 0x01FE /**< ATT Common Profile and Service Error: Procedure Already in Progress. */
yihui 1:a607cd9655d7 94 #define BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE 0x01FF /**< ATT Common Profile and Service Error: Out Of Range. */
yihui 1:a607cd9655d7 95 /** @} */
yihui 1:a607cd9655d7 96
yihui 1:a607cd9655d7 97
yihui 1:a607cd9655d7 98 /** @defgroup BLE_GATT_CPF_FORMATS Characteristic Presentation Formats
yihui 1:a607cd9655d7 99 * @note Found at http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
yihui 1:a607cd9655d7 100 * @{ */
yihui 1:a607cd9655d7 101 #define BLE_GATT_CPF_FORMAT_RFU 0x00 /**< Reserved For Future Use. */
yihui 1:a607cd9655d7 102 #define BLE_GATT_CPF_FORMAT_BOOLEAN 0x01 /**< Boolean. */
yihui 1:a607cd9655d7 103 #define BLE_GATT_CPF_FORMAT_2BIT 0x02 /**< Unsigned 2-bit integer. */
yihui 1:a607cd9655d7 104 #define BLE_GATT_CPF_FORMAT_NIBBLE 0x03 /**< Unsigned 4-bit integer. */
yihui 1:a607cd9655d7 105 #define BLE_GATT_CPF_FORMAT_UINT8 0x04 /**< Unsigned 8-bit integer. */
yihui 1:a607cd9655d7 106 #define BLE_GATT_CPF_FORMAT_UINT12 0x05 /**< Unsigned 12-bit integer. */
yihui 1:a607cd9655d7 107 #define BLE_GATT_CPF_FORMAT_UINT16 0x06 /**< Unsigned 16-bit integer. */
yihui 1:a607cd9655d7 108 #define BLE_GATT_CPF_FORMAT_UINT24 0x07 /**< Unsigned 24-bit integer. */
yihui 1:a607cd9655d7 109 #define BLE_GATT_CPF_FORMAT_UINT32 0x08 /**< Unsigned 32-bit integer. */
yihui 1:a607cd9655d7 110 #define BLE_GATT_CPF_FORMAT_UINT48 0x09 /**< Unsigned 48-bit integer. */
yihui 1:a607cd9655d7 111 #define BLE_GATT_CPF_FORMAT_UINT64 0x0A /**< Unsigned 64-bit integer. */
yihui 1:a607cd9655d7 112 #define BLE_GATT_CPF_FORMAT_UINT128 0x0B /**< Unsigned 128-bit integer. */
yihui 1:a607cd9655d7 113 #define BLE_GATT_CPF_FORMAT_SINT8 0x0C /**< Signed 2-bit integer. */
yihui 1:a607cd9655d7 114 #define BLE_GATT_CPF_FORMAT_SINT12 0x0D /**< Signed 12-bit integer. */
yihui 1:a607cd9655d7 115 #define BLE_GATT_CPF_FORMAT_SINT16 0x0E /**< Signed 16-bit integer. */
yihui 1:a607cd9655d7 116 #define BLE_GATT_CPF_FORMAT_SINT24 0x0F /**< Signed 24-bit integer. */
yihui 1:a607cd9655d7 117 #define BLE_GATT_CPF_FORMAT_SINT32 0x10 /**< Signed 32-bit integer. */
yihui 1:a607cd9655d7 118 #define BLE_GATT_CPF_FORMAT_SINT48 0x11 /**< Signed 48-bit integer. */
yihui 1:a607cd9655d7 119 #define BLE_GATT_CPF_FORMAT_SINT64 0x12 /**< Signed 64-bit integer. */
yihui 1:a607cd9655d7 120 #define BLE_GATT_CPF_FORMAT_SINT128 0x13 /**< Signed 128-bit integer. */
yihui 1:a607cd9655d7 121 #define BLE_GATT_CPF_FORMAT_FLOAT32 0x14 /**< IEEE-754 32-bit floating point. */
yihui 1:a607cd9655d7 122 #define BLE_GATT_CPF_FORMAT_FLOAT64 0x15 /**< IEEE-754 64-bit floating point. */
yihui 1:a607cd9655d7 123 #define BLE_GATT_CPF_FORMAT_SFLOAT 0x16 /**< IEEE-11073 16-bit SFLOAT. */
yihui 1:a607cd9655d7 124 #define BLE_GATT_CPF_FORMAT_FLOAT 0x17 /**< IEEE-11073 32-bit FLOAT. */
yihui 1:a607cd9655d7 125 #define BLE_GATT_CPF_FORMAT_DUINT16 0x18 /**< IEEE-20601 format. */
yihui 1:a607cd9655d7 126 #define BLE_GATT_CPF_FORMAT_UTF8S 0x19 /**< UTF-8 string. */
yihui 1:a607cd9655d7 127 #define BLE_GATT_CPF_FORMAT_UTF16S 0x1A /**< UTF-16 string. */
yihui 1:a607cd9655d7 128 #define BLE_GATT_CPF_FORMAT_STRUCT 0x1B /**< Opaque Structure. */
yihui 1:a607cd9655d7 129 /** @} */
yihui 1:a607cd9655d7 130
yihui 1:a607cd9655d7 131 /** @defgroup BLE_GATT_CPF_NAMESPACES GATT Bluetooth Namespaces
yihui 1:a607cd9655d7 132 * @{
yihui 1:a607cd9655d7 133 */
yihui 1:a607cd9655d7 134 #define BLE_GATT_CPF_NAMESPACE_BTSIG 0x01
yihui 1:a607cd9655d7 135 #define BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN 0x0000
yihui 1:a607cd9655d7 136 /** @} */
yihui 1:a607cd9655d7 137
yihui 1:a607cd9655d7 138 /** @} */
yihui 1:a607cd9655d7 139
yihui 1:a607cd9655d7 140 /** @addtogroup BLE_GATT_STRUCTURES Structures
yihui 1:a607cd9655d7 141 * @{ */
yihui 1:a607cd9655d7 142
yihui 1:a607cd9655d7 143 /**@brief GATT Characteristic Properties. */
yihui 1:a607cd9655d7 144 typedef struct
yihui 1:a607cd9655d7 145 {
yihui 1:a607cd9655d7 146 /* Standard properties */
yihui 1:a607cd9655d7 147 uint8_t broadcast :1; /**< Broadcasting of value permitted. */
yihui 1:a607cd9655d7 148 uint8_t read :1; /**< Reading value permitted. */
yihui 1:a607cd9655d7 149 uint8_t write_wo_resp :1; /**< Writing value with Write Command permitted. */
yihui 1:a607cd9655d7 150 uint8_t write :1; /**< Writing value with Write Request permitted. */
yihui 1:a607cd9655d7 151 uint8_t notify :1; /**< Notications of value permitted. */
yihui 1:a607cd9655d7 152 uint8_t indicate :1; /**< Indications of value permitted. */
yihui 1:a607cd9655d7 153 uint8_t auth_signed_wr :1; /**< Writing value with Signed Write Command permitted. */
yihui 1:a607cd9655d7 154 } ble_gatt_char_props_t;
yihui 1:a607cd9655d7 155
yihui 1:a607cd9655d7 156 /**@brief GATT Characteristic Extended Properties. */
yihui 1:a607cd9655d7 157 typedef struct
yihui 1:a607cd9655d7 158 {
yihui 1:a607cd9655d7 159 /* Extended properties */
yihui 1:a607cd9655d7 160 uint8_t reliable_wr :1; /**< Writing value with Queued Write Request permitted. */
yihui 1:a607cd9655d7 161 uint8_t wr_aux :1; /**< Writing the Characteristic User Description permitted. */
yihui 1:a607cd9655d7 162 } ble_gatt_char_ext_props_t;
yihui 1:a607cd9655d7 163
yihui 1:a607cd9655d7 164 #endif // BLE_GATT_H__
yihui 1:a607cd9655d7 165
yihui 1:a607cd9655d7 166 /** @} */
yihui 1:a607cd9655d7 167
yihui 1:a607cd9655d7 168 /**
yihui 1:a607cd9655d7 169 @}
yihui 1:a607cd9655d7 170 @}
yihui 1:a607cd9655d7 171 */