Productize / nRF51822

Dependencies:   nrf51-sdk

Fork of nRF51822 by Nordic Semiconductor

Committer:
vcoubard
Date:
Mon Jan 11 10:19:02 2016 +0000
Revision:
541:884f95bf5351
Synchronized with git rev 60a7c0c0
Author: Rohit Grover
bring in the latest changes for BLE::init() where we allow <object, member> tuples for init callback.

Who changed what in which revision?

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