The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
emilmont
Date:
Fri Feb 21 12:21:39 2014 +0000
Revision:
80:8e73be2a2ac1
First alpha release for the NRF51822 target (to be tested in the online IDE)

Who changed what in which revision?

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