dragoon  4383
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ble_gatt.h
1 /*
2  * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form, except as embedded into a Nordic
12  * Semiconductor ASA integrated circuit in a product or a software update for
13  * such product, must reproduce the above copyright notice, this list of
14  * conditions and the following disclaimer in the documentation and/or other
15  * materials provided with the distribution.
16  *
17  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * 4. This software, with or without modification, must only be used with a
22  * Nordic Semiconductor ASA integrated circuit.
23  *
24  * 5. Any software provided in binary form under this license must not be reverse
25  * engineered, decompiled, modified and/or disassembled.
26  *
27  * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
28  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29  * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
30  * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
33  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
36  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38 
45 #ifndef BLE_GATT_H__
46 #define BLE_GATT_H__
47 
48 #include "ble_types.h"
49 #include "ble_ranges.h"
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
59 #define BLE_GATT_ATT_MTU_DEFAULT 23
60 
62 #define BLE_GATT_HANDLE_INVALID 0x0000
63 
65 #define BLE_GATT_HANDLE_START 0x0001
66 
68 #define BLE_GATT_HANDLE_END 0xFFFF
69 
72 #define BLE_GATT_TIMEOUT_SRC_PROTOCOL 0x00
77 #define BLE_GATT_OP_INVALID 0x00
78 #define BLE_GATT_OP_WRITE_REQ 0x01
79 #define BLE_GATT_OP_WRITE_CMD 0x02
80 #define BLE_GATT_OP_SIGN_WRITE_CMD 0x03
81 #define BLE_GATT_OP_PREP_WRITE_REQ 0x04
82 #define BLE_GATT_OP_EXEC_WRITE_REQ 0x05
87 #define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL 0x00
88 #define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE 0x01
93 #define BLE_GATT_HVX_INVALID 0x00
94 #define BLE_GATT_HVX_NOTIFICATION 0x01
95 #define BLE_GATT_HVX_INDICATION 0x02
100 #define BLE_GATT_STATUS_SUCCESS 0x0000
101 #define BLE_GATT_STATUS_UNKNOWN 0x0001
102 #define BLE_GATT_STATUS_ATTERR_INVALID 0x0100
103 #define BLE_GATT_STATUS_ATTERR_INVALID_HANDLE 0x0101
104 #define BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED 0x0102
105 #define BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED 0x0103
106 #define BLE_GATT_STATUS_ATTERR_INVALID_PDU 0x0104
107 #define BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION 0x0105
108 #define BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED 0x0106
109 #define BLE_GATT_STATUS_ATTERR_INVALID_OFFSET 0x0107
110 #define BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION 0x0108
111 #define BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL 0x0109
112 #define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND 0x010A
113 #define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_LONG 0x010B
114 #define BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE 0x010C
115 #define BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH 0x010D
116 #define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E
117 #define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F
118 #define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110
119 #define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111
120 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112
121 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F
122 #define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180
123 #define BLE_GATT_STATUS_ATTERR_APP_END 0x019F
124 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_BEGIN 0x01A0
125 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END 0x01DF
126 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN 0x01E0
127 #define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END 0x01FC
128 #define BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR 0x01FD
129 #define BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG 0x01FE
130 #define BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE 0x01FF
137 #define BLE_GATT_CPF_FORMAT_RFU 0x00
138 #define BLE_GATT_CPF_FORMAT_BOOLEAN 0x01
139 #define BLE_GATT_CPF_FORMAT_2BIT 0x02
140 #define BLE_GATT_CPF_FORMAT_NIBBLE 0x03
141 #define BLE_GATT_CPF_FORMAT_UINT8 0x04
142 #define BLE_GATT_CPF_FORMAT_UINT12 0x05
143 #define BLE_GATT_CPF_FORMAT_UINT16 0x06
144 #define BLE_GATT_CPF_FORMAT_UINT24 0x07
145 #define BLE_GATT_CPF_FORMAT_UINT32 0x08
146 #define BLE_GATT_CPF_FORMAT_UINT48 0x09
147 #define BLE_GATT_CPF_FORMAT_UINT64 0x0A
148 #define BLE_GATT_CPF_FORMAT_UINT128 0x0B
149 #define BLE_GATT_CPF_FORMAT_SINT8 0x0C
150 #define BLE_GATT_CPF_FORMAT_SINT12 0x0D
151 #define BLE_GATT_CPF_FORMAT_SINT16 0x0E
152 #define BLE_GATT_CPF_FORMAT_SINT24 0x0F
153 #define BLE_GATT_CPF_FORMAT_SINT32 0x10
154 #define BLE_GATT_CPF_FORMAT_SINT48 0x11
155 #define BLE_GATT_CPF_FORMAT_SINT64 0x12
156 #define BLE_GATT_CPF_FORMAT_SINT128 0x13
157 #define BLE_GATT_CPF_FORMAT_FLOAT32 0x14
158 #define BLE_GATT_CPF_FORMAT_FLOAT64 0x15
159 #define BLE_GATT_CPF_FORMAT_SFLOAT 0x16
160 #define BLE_GATT_CPF_FORMAT_FLOAT 0x17
161 #define BLE_GATT_CPF_FORMAT_DUINT16 0x18
162 #define BLE_GATT_CPF_FORMAT_UTF8S 0x19
163 #define BLE_GATT_CPF_FORMAT_UTF16S 0x1A
164 #define BLE_GATT_CPF_FORMAT_STRUCT 0x1B
170 #define BLE_GATT_CPF_NAMESPACE_BTSIG 0x01
171 #define BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN 0x0000
184 typedef struct
185 {
186  uint16_t att_mtu;
194 
196 typedef struct
197 {
198  /* Standard properties */
199  uint8_t broadcast :1;
200  uint8_t read :1;
201  uint8_t write_wo_resp :1;
202  uint8_t write :1;
203  uint8_t notify :1;
204  uint8_t indicate :1;
205  uint8_t auth_signed_wr :1;
207 
209 typedef struct
210 {
211  /* Extended properties */
212  uint8_t reliable_wr :1;
213  uint8_t wr_aux :1;
215 
218 #ifdef __cplusplus
219 }
220 #endif
221 #endif // BLE_GATT_H__
222