Jonathan Austin / nRF51822

Dependents:   microbit_rubber_ducky microbit_mouse_BLE microbit_mouse_BLE_daybreak_version microbit_presenter

Fork of nRF51822 by Nordic Semiconductor

Committer:
vcoubard
Date:
Mon Jan 11 10:29:13 2016 +0000
Revision:
607:e98331f1d6b5
Import nordic sdk from https://github.com/ARMmbed/nrf51-sdk.git#a0faa63aae1f6351ac36cd70f28ce037d6f4ae11

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 607:e98331f1d6b5 1 /*
vcoubard 607:e98331f1d6b5 2 * Copyright (c) Nordic Semiconductor ASA
vcoubard 607:e98331f1d6b5 3 * All rights reserved.
vcoubard 607:e98331f1d6b5 4 *
vcoubard 607:e98331f1d6b5 5 * Redistribution and use in source and binary forms, with or without modification,
vcoubard 607:e98331f1d6b5 6 * are permitted provided that the following conditions are met:
vcoubard 607:e98331f1d6b5 7 *
vcoubard 607:e98331f1d6b5 8 * 1. Redistributions of source code must retain the above copyright notice, this
vcoubard 607:e98331f1d6b5 9 * list of conditions and the following disclaimer.
vcoubard 607:e98331f1d6b5 10 *
vcoubard 607:e98331f1d6b5 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this
vcoubard 607:e98331f1d6b5 12 * list of conditions and the following disclaimer in the documentation and/or
vcoubard 607:e98331f1d6b5 13 * other materials provided with the distribution.
vcoubard 607:e98331f1d6b5 14 *
vcoubard 607:e98331f1d6b5 15 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
vcoubard 607:e98331f1d6b5 16 * contributors to this software may be used to endorse or promote products
vcoubard 607:e98331f1d6b5 17 * derived from this software without specific prior written permission.
vcoubard 607:e98331f1d6b5 18 *
vcoubard 607:e98331f1d6b5 19 *
vcoubard 607:e98331f1d6b5 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
vcoubard 607:e98331f1d6b5 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
vcoubard 607:e98331f1d6b5 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
vcoubard 607:e98331f1d6b5 23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
vcoubard 607:e98331f1d6b5 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
vcoubard 607:e98331f1d6b5 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
vcoubard 607:e98331f1d6b5 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
vcoubard 607:e98331f1d6b5 27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
vcoubard 607:e98331f1d6b5 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
vcoubard 607:e98331f1d6b5 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
vcoubard 607:e98331f1d6b5 30 *
vcoubard 607:e98331f1d6b5 31 */
vcoubard 607:e98331f1d6b5 32
vcoubard 607:e98331f1d6b5 33 /**
vcoubard 607:e98331f1d6b5 34 @addtogroup BLE_GATT Generic Attribute Profile (GATT) Common
vcoubard 607:e98331f1d6b5 35 @{
vcoubard 607:e98331f1d6b5 36 @brief Common definitions and prototypes for the GATT interfaces.
vcoubard 607:e98331f1d6b5 37 */
vcoubard 607:e98331f1d6b5 38
vcoubard 607:e98331f1d6b5 39 #ifndef BLE_GATT_H__
vcoubard 607:e98331f1d6b5 40 #define BLE_GATT_H__
vcoubard 607:e98331f1d6b5 41
vcoubard 607:e98331f1d6b5 42 #include "ble_types.h"
vcoubard 607:e98331f1d6b5 43 #include "ble_ranges.h"
vcoubard 607:e98331f1d6b5 44
vcoubard 607:e98331f1d6b5 45
vcoubard 607:e98331f1d6b5 46 /** @addtogroup BLE_GATT_DEFINES Defines
vcoubard 607:e98331f1d6b5 47 * @{ */
vcoubard 607:e98331f1d6b5 48
vcoubard 607:e98331f1d6b5 49 /** @brief Default MTU size. */
vcoubard 607:e98331f1d6b5 50 #define GATT_MTU_SIZE_DEFAULT 23
vcoubard 607:e98331f1d6b5 51
vcoubard 607:e98331f1d6b5 52 /** @brief Only the default MTU size of 23 is currently supported. */
vcoubard 607:e98331f1d6b5 53 #define GATT_RX_MTU 23
vcoubard 607:e98331f1d6b5 54
vcoubard 607:e98331f1d6b5 55
vcoubard 607:e98331f1d6b5 56 /**@brief Invalid Attribute Handle. */
vcoubard 607:e98331f1d6b5 57 #define BLE_GATT_HANDLE_INVALID 0x0000
vcoubard 607:e98331f1d6b5 58
vcoubard 607:e98331f1d6b5 59 /** @defgroup BLE_GATT_TIMEOUT_SOURCES GATT Timeout sources
vcoubard 607:e98331f1d6b5 60 * @{ */
vcoubard 607:e98331f1d6b5 61 #define BLE_GATT_TIMEOUT_SRC_PROTOCOL 0x00 /**< ATT Protocol timeout. */
vcoubard 607:e98331f1d6b5 62 /** @} */
vcoubard 607:e98331f1d6b5 63
vcoubard 607:e98331f1d6b5 64 /** @defgroup BLE_GATT_WRITE_OPS GATT Write operations
vcoubard 607:e98331f1d6b5 65 * @{ */
vcoubard 607:e98331f1d6b5 66 #define BLE_GATT_OP_INVALID 0x00 /**< Invalid Operation. */
vcoubard 607:e98331f1d6b5 67 #define BLE_GATT_OP_WRITE_REQ 0x01 /**< Write Request. */
vcoubard 607:e98331f1d6b5 68 #define BLE_GATT_OP_WRITE_CMD 0x02 /**< Write Command. */
vcoubard 607:e98331f1d6b5 69 #define BLE_GATT_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */
vcoubard 607:e98331f1d6b5 70 #define BLE_GATT_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */
vcoubard 607:e98331f1d6b5 71 #define BLE_GATT_OP_EXEC_WRITE_REQ 0x05 /**< Execute Write Request. */
vcoubard 607:e98331f1d6b5 72 /** @} */
vcoubard 607:e98331f1d6b5 73
vcoubard 607:e98331f1d6b5 74 /** @defgroup BLE_GATT_EXEC_WRITE_FLAGS GATT Execute Write flags
vcoubard 607:e98331f1d6b5 75 * @{ */
vcoubard 607:e98331f1d6b5 76 #define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL 0x00
vcoubard 607:e98331f1d6b5 77 #define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE 0x01
vcoubard 607:e98331f1d6b5 78 /** @} */
vcoubard 607:e98331f1d6b5 79
vcoubard 607:e98331f1d6b5 80 /** @defgroup BLE_GATT_HVX_TYPES GATT Handle Value operations
vcoubard 607:e98331f1d6b5 81 * @{ */
vcoubard 607:e98331f1d6b5 82 #define BLE_GATT_HVX_INVALID 0x00 /**< Invalid Operation. */
vcoubard 607:e98331f1d6b5 83 #define BLE_GATT_HVX_NOTIFICATION 0x01 /**< Handle Value Notification. */
vcoubard 607:e98331f1d6b5 84 #define BLE_GATT_HVX_INDICATION 0x02 /**< Handle Value Indication. */
vcoubard 607:e98331f1d6b5 85 /** @} */
vcoubard 607:e98331f1d6b5 86
vcoubard 607:e98331f1d6b5 87 /** @defgroup BLE_GATT_STATUS_CODES GATT Status Codes
vcoubard 607:e98331f1d6b5 88 * @{ */
vcoubard 607:e98331f1d6b5 89 #define BLE_GATT_STATUS_SUCCESS 0x0000 /**< Success. */
vcoubard 607:e98331f1d6b5 90 #define BLE_GATT_STATUS_UNKNOWN 0x0001 /**< Unknown or not applicable status. */
vcoubard 607:e98331f1d6b5 91 #define BLE_GATT_STATUS_ATTERR_INVALID 0x0100 /**< ATT Error: Invalid Error Code. */
vcoubard 607:e98331f1d6b5 92 #define BLE_GATT_STATUS_ATTERR_INVALID_HANDLE 0x0101 /**< ATT Error: Invalid Attribute Handle. */
vcoubard 607:e98331f1d6b5 93 #define BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED 0x0102 /**< ATT Error: Read not permitted. */
vcoubard 607:e98331f1d6b5 94 #define BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED 0x0103 /**< ATT Error: Write not permitted. */
vcoubard 607:e98331f1d6b5 95 #define BLE_GATT_STATUS_ATTERR_INVALID_PDU 0x0104 /**< ATT Error: Used in ATT as Invalid PDU. */
vcoubard 607:e98331f1d6b5 96 #define BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION 0x0105 /**< ATT Error: Authenticated link required. */
vcoubard 607:e98331f1d6b5 97 #define BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED 0x0106 /**< ATT Error: Used in ATT as Request Not Supported. */
vcoubard 607:e98331f1d6b5 98 #define BLE_GATT_STATUS_ATTERR_INVALID_OFFSET 0x0107 /**< ATT Error: Offset specified was past the end of the attribute. */
vcoubard 607:e98331f1d6b5 99 #define BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION 0x0108 /**< ATT Error: Used in ATT as Insufficient Authorisation. */
vcoubard 607:e98331f1d6b5 100 #define BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL 0x0109 /**< ATT Error: Used in ATT as Prepare Queue Full. */
vcoubard 607:e98331f1d6b5 101 #define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND 0x010A /**< ATT Error: Used in ATT as Attribute not found. */
vcoubard 607:e98331f1d6b5 102 #define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_LONG 0x010B /**< ATT Error: Attribute cannot be read or written using read/write blob requests. */
vcoubard 607:e98331f1d6b5 103 #define BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE 0x010C /**< ATT Error: Encryption key size used is insufficient. */
vcoubard 607:e98331f1d6b5 104 #define BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH 0x010D /**< ATT Error: Invalid value size. */
vcoubard 607:e98331f1d6b5 105 #define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E /**< ATT Error: Very unlikely error. */
vcoubard 607:e98331f1d6b5 106 #define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F /**< ATT Error: Encrypted link required. */
vcoubard 607:e98331f1d6b5 107 #define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110 /**< ATT Error: Attribute type is not a supported grouping attribute. */
vcoubard 607:e98331f1d6b5 108 #define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Encrypted link required. */
vcoubard 607:e98331f1d6b5 109 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112 /**< ATT Error: Reserved for Future Use range #1 begin. */
vcoubard 607:e98331f1d6b5 110 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F /**< ATT Error: Reserved for Future Use range #1 end. */
vcoubard 607:e98331f1d6b5 111 #define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180 /**< ATT Error: Application range begin. */
vcoubard 607:e98331f1d6b5 112 #define BLE_GATT_STATUS_ATTERR_APP_END 0x019F /**< ATT Error: Application range end. */
vcoubard 607:e98331f1d6b5 113 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_BEGIN 0x01A0 /**< ATT Error: Reserved for Future Use range #2 begin. */
vcoubard 607:e98331f1d6b5 114 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END 0x01DF /**< ATT Error: Reserved for Future Use range #2 end. */
vcoubard 607:e98331f1d6b5 115 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN 0x01E0 /**< ATT Error: Reserved for Future Use range #3 begin. */
vcoubard 607:e98331f1d6b5 116 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END 0x01FC /**< ATT Error: Reserved for Future Use range #3 end. */
vcoubard 607:e98331f1d6b5 117 #define BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR 0x01FD /**< ATT Common Profile and Service Error: Client Characteristic Configuration Descriptor improperly configured. */
vcoubard 607:e98331f1d6b5 118 #define BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG 0x01FE /**< ATT Common Profile and Service Error: Procedure Already in Progress. */
vcoubard 607:e98331f1d6b5 119 #define BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE 0x01FF /**< ATT Common Profile and Service Error: Out Of Range. */
vcoubard 607:e98331f1d6b5 120 /** @} */
vcoubard 607:e98331f1d6b5 121
vcoubard 607:e98331f1d6b5 122
vcoubard 607:e98331f1d6b5 123 /** @defgroup BLE_GATT_CPF_FORMATS Characteristic Presentation Formats
vcoubard 607:e98331f1d6b5 124 * @note Found at http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
vcoubard 607:e98331f1d6b5 125 * @{ */
vcoubard 607:e98331f1d6b5 126 #define BLE_GATT_CPF_FORMAT_RFU 0x00 /**< Reserved For Future Use. */
vcoubard 607:e98331f1d6b5 127 #define BLE_GATT_CPF_FORMAT_BOOLEAN 0x01 /**< Boolean. */
vcoubard 607:e98331f1d6b5 128 #define BLE_GATT_CPF_FORMAT_2BIT 0x02 /**< Unsigned 2-bit integer. */
vcoubard 607:e98331f1d6b5 129 #define BLE_GATT_CPF_FORMAT_NIBBLE 0x03 /**< Unsigned 4-bit integer. */
vcoubard 607:e98331f1d6b5 130 #define BLE_GATT_CPF_FORMAT_UINT8 0x04 /**< Unsigned 8-bit integer. */
vcoubard 607:e98331f1d6b5 131 #define BLE_GATT_CPF_FORMAT_UINT12 0x05 /**< Unsigned 12-bit integer. */
vcoubard 607:e98331f1d6b5 132 #define BLE_GATT_CPF_FORMAT_UINT16 0x06 /**< Unsigned 16-bit integer. */
vcoubard 607:e98331f1d6b5 133 #define BLE_GATT_CPF_FORMAT_UINT24 0x07 /**< Unsigned 24-bit integer. */
vcoubard 607:e98331f1d6b5 134 #define BLE_GATT_CPF_FORMAT_UINT32 0x08 /**< Unsigned 32-bit integer. */
vcoubard 607:e98331f1d6b5 135 #define BLE_GATT_CPF_FORMAT_UINT48 0x09 /**< Unsigned 48-bit integer. */
vcoubard 607:e98331f1d6b5 136 #define BLE_GATT_CPF_FORMAT_UINT64 0x0A /**< Unsigned 64-bit integer. */
vcoubard 607:e98331f1d6b5 137 #define BLE_GATT_CPF_FORMAT_UINT128 0x0B /**< Unsigned 128-bit integer. */
vcoubard 607:e98331f1d6b5 138 #define BLE_GATT_CPF_FORMAT_SINT8 0x0C /**< Signed 2-bit integer. */
vcoubard 607:e98331f1d6b5 139 #define BLE_GATT_CPF_FORMAT_SINT12 0x0D /**< Signed 12-bit integer. */
vcoubard 607:e98331f1d6b5 140 #define BLE_GATT_CPF_FORMAT_SINT16 0x0E /**< Signed 16-bit integer. */
vcoubard 607:e98331f1d6b5 141 #define BLE_GATT_CPF_FORMAT_SINT24 0x0F /**< Signed 24-bit integer. */
vcoubard 607:e98331f1d6b5 142 #define BLE_GATT_CPF_FORMAT_SINT32 0x10 /**< Signed 32-bit integer. */
vcoubard 607:e98331f1d6b5 143 #define BLE_GATT_CPF_FORMAT_SINT48 0x11 /**< Signed 48-bit integer. */
vcoubard 607:e98331f1d6b5 144 #define BLE_GATT_CPF_FORMAT_SINT64 0x12 /**< Signed 64-bit integer. */
vcoubard 607:e98331f1d6b5 145 #define BLE_GATT_CPF_FORMAT_SINT128 0x13 /**< Signed 128-bit integer. */
vcoubard 607:e98331f1d6b5 146 #define BLE_GATT_CPF_FORMAT_FLOAT32 0x14 /**< IEEE-754 32-bit floating point. */
vcoubard 607:e98331f1d6b5 147 #define BLE_GATT_CPF_FORMAT_FLOAT64 0x15 /**< IEEE-754 64-bit floating point. */
vcoubard 607:e98331f1d6b5 148 #define BLE_GATT_CPF_FORMAT_SFLOAT 0x16 /**< IEEE-11073 16-bit SFLOAT. */
vcoubard 607:e98331f1d6b5 149 #define BLE_GATT_CPF_FORMAT_FLOAT 0x17 /**< IEEE-11073 32-bit FLOAT. */
vcoubard 607:e98331f1d6b5 150 #define BLE_GATT_CPF_FORMAT_DUINT16 0x18 /**< IEEE-20601 format. */
vcoubard 607:e98331f1d6b5 151 #define BLE_GATT_CPF_FORMAT_UTF8S 0x19 /**< UTF-8 string. */
vcoubard 607:e98331f1d6b5 152 #define BLE_GATT_CPF_FORMAT_UTF16S 0x1A /**< UTF-16 string. */
vcoubard 607:e98331f1d6b5 153 #define BLE_GATT_CPF_FORMAT_STRUCT 0x1B /**< Opaque Structure. */
vcoubard 607:e98331f1d6b5 154 /** @} */
vcoubard 607:e98331f1d6b5 155
vcoubard 607:e98331f1d6b5 156 /** @defgroup BLE_GATT_CPF_NAMESPACES GATT Bluetooth Namespaces
vcoubard 607:e98331f1d6b5 157 * @{
vcoubard 607:e98331f1d6b5 158 */
vcoubard 607:e98331f1d6b5 159 #define BLE_GATT_CPF_NAMESPACE_BTSIG 0x01 /**< Bluetooth SIG defined Namespace. */
vcoubard 607:e98331f1d6b5 160 #define BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN 0x0000 /**< Namespace Description Unknown. */
vcoubard 607:e98331f1d6b5 161 /** @} */
vcoubard 607:e98331f1d6b5 162
vcoubard 607:e98331f1d6b5 163 /** @} */
vcoubard 607:e98331f1d6b5 164
vcoubard 607:e98331f1d6b5 165 /** @addtogroup BLE_GATT_STRUCTURES Structures
vcoubard 607:e98331f1d6b5 166 * @{ */
vcoubard 607:e98331f1d6b5 167
vcoubard 607:e98331f1d6b5 168 /**@brief GATT Characteristic Properties. */
vcoubard 607:e98331f1d6b5 169 typedef struct
vcoubard 607:e98331f1d6b5 170 {
vcoubard 607:e98331f1d6b5 171 /* Standard properties */
vcoubard 607:e98331f1d6b5 172 uint8_t broadcast :1; /**< Broadcasting of the value permitted. */
vcoubard 607:e98331f1d6b5 173 uint8_t read :1; /**< Reading the value permitted. */
vcoubard 607:e98331f1d6b5 174 uint8_t write_wo_resp :1; /**< Writing the value with Write Command permitted. */
vcoubard 607:e98331f1d6b5 175 uint8_t write :1; /**< Writing the value with Write Request permitted. */
vcoubard 607:e98331f1d6b5 176 uint8_t notify :1; /**< Notications of the value permitted. */
vcoubard 607:e98331f1d6b5 177 uint8_t indicate :1; /**< Indications of the value permitted. */
vcoubard 607:e98331f1d6b5 178 uint8_t auth_signed_wr :1; /**< Writing the value with Signed Write Command permitted. */
vcoubard 607:e98331f1d6b5 179 } ble_gatt_char_props_t;
vcoubard 607:e98331f1d6b5 180
vcoubard 607:e98331f1d6b5 181 /**@brief GATT Characteristic Extended Properties. */
vcoubard 607:e98331f1d6b5 182 typedef struct
vcoubard 607:e98331f1d6b5 183 {
vcoubard 607:e98331f1d6b5 184 /* Extended properties */
vcoubard 607:e98331f1d6b5 185 uint8_t reliable_wr :1; /**< Writing the value with Queued Write operations permitted. */
vcoubard 607:e98331f1d6b5 186 uint8_t wr_aux :1; /**< Writing the Characteristic User Description descriptor permitted. */
vcoubard 607:e98331f1d6b5 187 } ble_gatt_char_ext_props_t;
vcoubard 607:e98331f1d6b5 188
vcoubard 607:e98331f1d6b5 189 #endif // BLE_GATT_H__
vcoubard 607:e98331f1d6b5 190
vcoubard 607:e98331f1d6b5 191 /** @} */
vcoubard 607:e98331f1d6b5 192
vcoubard 607:e98331f1d6b5 193 /**
vcoubard 607:e98331f1d6b5 194 @}
vcoubard 607:e98331f1d6b5 195 @}
vcoubard 607:e98331f1d6b5 196 */