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