1 /**
2   ******************************************************************************
3   * @file    ble_const.h
4   * @author  GPM WBL Application Team
5   * @brief   Header file that includes Bluetooth LE stack defines for APIs
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2024 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 #ifndef __BLE_CONST_H__
20 #define __BLE_CONST_H__
21 
22 #include "ble_gatt.h"
23 #include "uuid.h"
24 #include "compiler.h"
25 /**
26  *@addtogroup HCI HCI
27  *@{
28  */
29 
30 /**
31  * @defgroup Link_Layer Link Layer constants and types
32  * @brief Constants and types related to Link Layer functions
33  * @{
34  */
35 
36 /* Macros for Enable parameters in HCI commands. */
37 #define HCI_DISABLE                                    0x00
38 #define HCI_ENABLE                                     0x01
39 
40 #define BD_ADDR_SIZE                                   0x06U
41 
42 /* Address types */
43 #define HCI_ADDR_PUBLIC                                0x00U
44 #define HCI_ADDR_RANDOM_ADDR                           0x01U
45 #define HCI_ADDR_STATIC_RANDOM_ADDR                    0x01U
46 #define HCI_ADDR_RESOLVABLE_PRIVATE_ADDR               0x02U
47 #define HCI_ADDR_NON_RESOLVABLE_PRIVATE_ADDR           0x03U
48 
49 /* HCI_LE_Set_Advertising_Parameters: Advertising_Type */
50 #define HCI_ADV_TYPE_ADV_IND                           0x00U
51 #define HCI_ADV_TYPE_ADV_DIRECT_IND_HDC                0x01U
52 #define HCI_ADV_TYPE_ADV_SCAN_IND                      0x02U
53 #define HCI_ADV_TYPE_ADV_NONCONN_IND                   0x03U
54 #define HCI_ADV_TYPE_ADV_DIRECT_IND_LDC                0x04U
55 
56 /* HCI_LE_Set_Advertising_Parameters: Advertising_Filter_Policy */
57 #define HCI_ADV_FILTER_NONE                            0x00U
58 #define HCI_ADV_FILTER_ACCEPT_LIST_SCAN                0x01U
59 #define HCI_ADV_FILTER_ACCEPT_LIST_CONNECT             0x02U
60 #define HCI_ADV_FILTER_ACCEPT_LIST_SCAN_CONNECT        0x03U
61 
62 #define HCI_ADV_CH_37                                  0x01U
63 #define HCI_ADV_CH_38                                  0x02U
64 #define HCI_ADV_CH_39                                  0x04U
65 #define HCI_ADV_CH_ALL                                 0x07U
66 
67 /* HCI_LE_Set_[Advertising/Scan]_Parameters: Own_Address_Type */
68 #define HCI_OWN_ADDR_TYPE_PUBLIC                       0x00U
69 #define HCI_OWN_ADDR_TYPE_RANDOM                       0x01U
70 #define HCI_OWN_ADDR_TYPE_RP_OR_PUBLIC                 0x02U
71 #define HCI_OWN_ADDR_TYPE_RP_OR_RANDOM                 0x03U
72 
73 /* HCI_LE_Set_Scan_Parameters: LE_Scan_Type */
74 #define HCI_SCAN_TYPE_PASSIVE                          0x00U
75 #define HCI_SCAN_TYPE_ACTIVE                           0x01U
76 
77 /* HCI_LE_Set_Scan_Parameters: Scanning_Filter_Policy */
78 #define HCI_SCAN_FILTER_BASIC_UNFILTERED               0x00U
79 #define HCI_SCAN_FILTER_BASIC_FILTERED                 0x01U
80 #define HCI_SCAN_FILTER_EXTENDED_UNFILTERED            0x02U
81 #define HCI_SCAN_FILTER_EXTENDED_FILTERED              0x03U
82 
83 /* HCI_LE_Create_Connection: Initiator_Filter_Policy */
84 #define HCI_INIT_FILTER_ACCEPT_LIST_NONE               0x00U
85 #define HCI_INIT_FILTER_ACCEPT_LIST                    0x01U
86 
87 /* HCI_LE_Read_PHY: TX_PHY */
88 #define HCI_TX_PHY_LE_1M                               0x01U
89 #define HCI_TX_PHY_LE_2M                               0x02U
90 #define HCI_TX_PHY_LE_CODED                            0x03U
91 
92 /* HCI_LE_Read_PHY: RX_PHY */
93 #define HCI_RX_PHY_LE_1M                               0x01U
94 #define HCI_RX_PHY_LE_2M                               0x02U
95 #define HCI_RX_PHY_LE_CODED                            0x03U
96 
97 /* HCI_LE_Set_PHY: ALL_PHYS */
98 #define HCI_ALL_PHYS_TX_NO_PREF                        0x01U
99 #define HCI_ALL_PHYS_RX_NO_PREF                        0x02U
100 
101 /* HCI_LE_Set_PHY: TX_PHYS */
102 #define HCI_TX_PHYS_LE_1M_PREF                         0x01U
103 #define HCI_TX_PHYS_LE_2M_PREF                         0x02U
104 #define HCI_TX_PHYS_LE_CODED_PREF                      0x04U
105 
106 /* HCI_LE_Set_PHY: RX_PHYS */
107 #define HCI_RX_PHYS_LE_1M_PREF                         0x01U
108 #define HCI_RX_PHYS_LE_2M_PREF                         0x02U
109 #define HCI_RX_PHYS_LE_CODED_PREF                      0x04U
110 
111 /* HCI_LE_Set_Extended_Advertising_Parameters: Advertising_Event_Properties */
112 #define HCI_ADV_EVENT_PROP_NONE                        0x0000U
113 #define HCI_ADV_EVENT_PROP_CONNECTABLE                 0x0001U
114 #define HCI_ADV_EVENT_PROP_SCANNABLE                   0x0002U
115 #define HCI_ADV_EVENT_PROP_DIRECTED                    0x0004U
116 #define HCI_ADV_EVENT_PROP_HDC_DIRECTED                0x0008U
117 #define HCI_ADV_EVENT_PROP_LEGACY                      0x0010U
118 #define HCI_ADV_EVENT_PROP_ANONYMOUS                   0x0020U
119 #define HCI_ADV_EVENT_PROP_TXPOWER_INC                 0x0040U
120 
121 /* HCI_LE_Set_Extended_Advertising_Parameters: Primary_Advertising_PHY and Secondary_Advertising_PHY */
122 #define HCI_ADV_PHY_LE_1M                      0x01U
123 #define HCI_ADV_PHY_LE_2M                      0x02U
124 #define HCI_ADV_PHY_LE_CODED                   0x03U
125 
126 /* HCI_LE_Set_Extended_Advertising_Data: Operation */
127 #define HCI_SET_ADV_DATA_OPERATION_INTERMEDIATE        0x00U
128 #define HCI_SET_ADV_DATA_OPERATION_FIRST               0x01U
129 #define HCI_SET_ADV_DATA_OPERATION_LAST                0x02U
130 #define HCI_SET_ADV_DATA_OPERATION_COMPLETE            0x03U
131 #define HCI_SET_ADV_DATA_OPERATION_UNCHANGED           0x04U
132 
133 /* HCI_LE_Advertising_Report: Event_Type */
134 #define HCI_ADV_EVT_TYPE_ADV_IND                       0x00U
135 #define HCI_ADV_EVT_TYPE_ADV_DIRECT_IND                0x01U
136 #define HCI_ADV_EVT_TYPE_ADV_SCAN_IND                  0x02U
137 #define HCI_ADV_EVT_TYPE_ADV_NONCONN_IND               0x03U
138 #define HCI_ADV_EVT_TYPE_SCAN_RSP                      0x04U
139 
140 /* HCI_LE_Extended_Advertising_Report: Event_Type */
141 #define HCI_EXT_ADV_EVT_TYPE_CONNECTABLE               0x0001U
142 #define HCI_EXT_ADV_EVT_TYPE_SCANNABLE                 0x0002U
143 #define HCI_EXT_ADV_EVT_TYPE_DIRECTED                  0x0004U
144 #define HCI_EXT_ADV_EVT_TYPE_SCAN_RESP                 0x0008U
145 #define HCI_EXT_ADV_EVT_TYPE_LEGACY                    0x0010U
146 #define HCI_EXT_ADV_EVT_TYPE_DATA_STATUS_MASK          0x0060U
147 #define HCI_EXT_ADV_EVT_TYPE_DATA_STATUS_COMPLETE      0x0000U
148 #define HCI_EXT_ADV_EVT_TYPE_DATA_STATUS_MORE_DATA     0x0020U
149 #define HCI_EXT_ADV_EVT_TYPE_DATA_STATUS_TRUNCATED     0x0040U
150 
151 /* HCI_LE_Set_Extended_Scan_Parameters: Scanning_PHYs */
152 #define HCI_SCANNING_PHYS_LE_1M                        0x01U
153 #define HCI_SCANNING_PHYS_LE_CODED                     0x04U
154 
155 /* HCI_LE_Extended_Create_Connection: Initiating_PHYs */
156 #define HCI_INIT_PHYS_SCAN_CONN_LE_1M                  0x01U
157 #define HCI_INIT_PHYS_CONN_LE_2M                       0x02U
158 #define HCI_INIT_PHYS_SCAN_CONN_LE_CODED               0x04U
159 
160 /* HCI_LE_Receiver_Test/HCI_LE_Transmitter_Test [v2]: PHY */
161 #define HCI_TEST_PHY_LE_1M                             0x01U
162 #define HCI_TEST_PHY_LE_2M                             0x02U
163 
164 /* HCI_LE_Connection_Complete/HCI_LE_Enhanced_Connection_Complete: Role */
165 #define HCI_ROLE_CENTRAL                               0x00U
166 #define HCI_ROLE_PERIPHERAL                            0x01U
167 
168 /* HCI_LE_Set_Privacy_Mode: Privacy_Mode */
169 #define HCI_PRIV_MODE_NETWORK                          0x00U
170 #define HCI_PRIV_MODE_DEVICE                           0x01U
171 
172 /* HCI_LE_Periodic_Advertising_Report: Data_Status */
173 #define HCI_PADV_DATA_STATUS_COMPLETE                  0x00U
174 #define HCI_PADV_DATA_STATUS_MORE_DATA                 0x01U
175 #define HCI_PADV_DATA_STATUS_TRUNCATED                 0x02U
176 #define HCI_PADV_DATA_STATUS_FAILED                    0xFFU
177 
178 
179 /**
180  * @name Duplicate filtering
181  * @{
182  */
183 #define DUPLICATE_FILTER_DISABLED                   0
184 #define DUPLICATE_FILTER_ENABLED                    1
185 #define DUPLICATE_FILTER_ENABLED_FOR_SCAN_PERIOD    2
186 /**
187  * @}
188  */
189 
190 /**
191  * @name Bitmasks for Link Layer PHYs
192  * @{
193  */
194 #define LE_1M_PHY_BIT       0x01
195 #define LE_2M_PHY_BIT       0x02
196 #define LE_CODED_PHY_BIT    0x04
197 
198 /**
199  * @}
200  */
201 
202 /**
203  * @name Values for Link Layer PHYs
204  * @{
205  */
206 #define HCI_PHY_LE_1M                   0x01
207 #define HCI_PHY_LE_2M                   0x02
208 #define HCI_PHY_LE_CODED                0x03
209 #define HCI_PHY_LE_CODED_S8             0x03
210 #define HCI_PHY_LE_CODED_S2             0x04
211 
212 /**
213  * @}
214  */
215 
216 /**
217  * @name Link Layer State
218  * @{
219  */
220 #define LL_IDLE         0x00
221 #define LL_ADV          0x01
222 #define LL_CONN_SLAVE   0x02
223 #define LL_SCAN         0x03
224 #define LL_CONN_REQ     0x04
225 #define LL_CONN_MASTER  0x05
226 #define LL_TX_TEST      0x06
227 #define LL_RX_TEST      0x07
228 /**
229  * @}
230  */
231 
232 /**
233  * @name CTE Type
234  * @{
235  */
236 #define CTE_AOA         0x00
237 #define CTE_AOD_1us     0x01
238 #define CTE_AOD_2us     0x02
239 /**
240  * @}
241  */
242 
243 /**
244  * @name CTE Type bitmask
245  * @{
246  */
247 #define CTE_AOA_BIT         0x01
248 #define CTE_AOD_1us_BIT     0x02
249 #define CTE_AOD_2us_BIT     0x04
250 /**
251  * @}
252  */
253 
254 /**
255  * @name CTE Slot Duration
256  * @{
257  */
258 #define CTE_SLOT_1us        0x01
259 #define CTE_SLOT_2us        0x02
260 /**
261  * @}
262  */
263 
264 /**
265  * @name Reason for hci_le_transmit_power_reporting_event()
266  * @{
267  */
268 #define LOCAL_TX_POWER_CHANGE               0x00
269 #define REMOTE_TX_POWER_CHANGE              0x01
270 #define READ_REMOTE_TX_POWER_COMPLETE       0x02
271 /**
272  * @}
273  */
274 
275 /**
276  * @name Transmit_Power_Level value
277  * @{
278  */
279 #define POWER_NOT_MANAGED                   0x7E
280 #define POWER_NA                            0x7F
281 /**
282  * @}
283  */
284 
285 /**
286  * @name Transmit_Power_Level_Flag values
287  * @{
288  */
289 #define MIN_TX_POWER_BIT                    0x01
290 #define MAX_TX_POWER_BIT                    0x02
291 /**
292  * @}
293  */
294 
295 /**
296  * @name LE Event Mask
297  * @see hci_le_set_event_mask()
298  * @{
299  */
300 #define HCI_LE_EVT_MASK_BYTE0_CONNECTION_COMPLETE                                         (0x01U)
301 #define HCI_LE_EVT_MASK_BYTE0_ADVERTISING_REPORT                                          (0x02U)
302 #define HCI_LE_EVT_MASK_BYTE0_CONNECTION_UPDATE_COMPLETE                                  (0x04U)
303 #define HCI_LE_EVT_MASK_BYTE0_READ_REMOTE_FEATURES_COMPLETE                               (0x08U)
304 #define HCI_LE_EVT_MASK_BYTE0_LTK_REQUEST                                                 (0x10U)
305 #define HCI_LE_EVT_MASK_BYTE0_REMOTE_CONNECTION_PARAMETER_REQUEST                         (0x20U)
306 #define HCI_LE_EVT_MASK_BYTE0_DATA_LEN_CHANGE                                             (0x40U)
307 #define HCI_LE_EVT_MASK_BYTE0_READ_LOCAL_P256_COMPLETE                                    (0x80U)
308 #define HCI_LE_EVT_MASK_BYTE1_GENERATE_DHKEY_COMPLETE                                     (0x01U)
309 #define HCI_LE_EVT_MASK_BYTE1_ENHANCED_CONNECTION_COMPLETE                                (0x02U)
310 #define HCI_LE_EVT_MASK_BYTE1_DIRECTED_ADVERTISING_REPORT                                 (0x04U)
311 #define HCI_LE_EVT_MASK_BYTE1_PHY_UPDATE_COMPLETE                                         (0x08U)
312 #define HCI_LE_EVT_MASK_BYTE1_EXTENDED_ADVERTISING_REPORT                                 (0x10U)
313 #define HCI_LE_EVT_MASK_BYTE1_PERIODIC_ADVERTISING_SYNC_ESTABLISHED                       (0x20U)
314 #define HCI_LE_EVT_MASK_BYTE1_PERIODIC_ADVERTISING_REPORT                                 (0x40U)
315 #define HCI_LE_EVT_MASK_BYTE1_PERIODIC_ADVERTISING_SYNC_LOST                              (0x80U)
316 #define HCI_LE_EVT_MASK_BYTE2_SCAN_TIMEOUT                                                (0x01U)
317 #define HCI_LE_EVT_MASK_BYTE2_ADVERTISING_SET_TERMINATED                                  (0x02U)
318 #define HCI_LE_EVT_MASK_BYTE2_SCAN_REQUEST_RECEIVED                                       (0x04U)
319 #define HCI_LE_EVT_MASK_BYTE2_CHANNEL_SELECTION_ALGORITHM                                 (0x08U)
320 #define HCI_LE_EVT_MASK_BYTE2_CONNECTIONLESS_IQ_REPORT                                    (0x10U)
321 #define HCI_LE_EVT_MASK_BYTE2_CONNECTION_IQ_REPORT                                        (0x20U)
322 #define HCI_LE_EVT_MASK_BYTE2_CTE_REQUEST_FAILED                                          (0x40U)
323 #define HCI_LE_EVT_MASK_BYTE2_PERIODIC_ADVERTISING_SYNC_TRANSFER                          (0x80U)
324 #define HCI_LE_EVT_MASK_BYTE3_CIS_ESTABLISHED                                             (0x01U)
325 #define HCI_LE_EVT_MASK_BYTE3_CIS_REQUEST                                                 (0x02U)
326 #define HCI_LE_EVT_MASK_BYTE3_CREATE_BIG_COMPLETE                                         (0x04U)
327 #define HCI_LE_EVT_MASK_BYTE3_TERMINATE_BIG_COMPLETE                                      (0x08U)
328 #define HCI_LE_EVT_MASK_BYTE3_BIG_SYNC_ESTABLISHED                                        (0x10U)
329 #define HCI_LE_EVT_MASK_BYTE3_BIG_SYNC_LOST                                               (0x20U)
330 #define HCI_LE_EVT_MASK_BYTE3_REQUEST_PEER_SCA_COMPLETE                                   (0x40U)
331 #define HCI_LE_EVT_MASK_BYTE3_PATH_LOSS_THRESHOLD                                         (0x80U)
332 #define HCI_LE_EVT_MASK_BYTE4_TRANSMIT_POWER_REPORTING                                    (0x01U)
333 #define HCI_LE_EVT_MASK_BYTE4_BIG_INFO_ADVERTISING_REPORT                                 (0x02U)
334 #define HCI_LE_EVT_MASK_BYTE4_SUBRATE_CHANGE                                              (0x04U)
335 #define HCI_LE_EVT_MASK_BYTE4_PERIODIC_ADVERTISING_SYNC_ESTABLISHED_V2                    (0x08U)
336 #define HCI_LE_EVT_MASK_BYTE4_PERIODIC_ADVERTISING_REPORT_V2                              (0x10U)
337 #define HCI_LE_EVT_MASK_BYTE4_PERIODIC_ADVERTISING_SYNC_TRANSFER_V2                       (0x20U)
338 #define HCI_LE_EVT_MASK_BYTE4_PERIODIC_ADVERTISING_SUBEVENT_DATA_REQ                      (0x40U)
339 #define HCI_LE_EVT_MASK_BYTE4_PERIODIC_ADVERTISING_RESPONSE_REPORT                        (0x80U)
340 #define HCI_LE_EVT_MASK_BYTE5_ENHANCED_CONNECTION_COMPLETE_V2                             (0x01U)
341 
342 /**
343  * @}
344  */
345 
346 /**
347  * @}
348  */
349 
350 /**
351  * @}
352  */
353 
354 /**
355  *@addtogroup HAL_LL HAL/LL
356  *@{
357  */
358 /**
359  *@addtogroup HAL_constants HAL/LL Constants
360  *@brief Constants for Hardware abstraction Layer and Link Layer.
361  *@{
362  */
363 
364 /**
365  * @name Configuration values.
366  * See @ref aci_hal_write_config_data() and @ref aci_hal_read_config_data().
367  * @{
368  */
369 #define CONFIG_DATA_PUBADDR_OFFSET                  (0x00) /**< Bluetooth public address */
370 #define CONFIG_DATA_ER_OFFSET                       (0x08) /**< Encryption root key used to derive LTK and CSRK */
371 #define CONFIG_DATA_IR_OFFSET                       (0x18) /**< Identity root key used to derive LTK and CSRK */
372 #define CONFIG_DATA_LL_WITHOUT_HOST                 (0x2C) /**< Switch on/off Link Layer only mode. Set to 1 to disable Host.
373                            It can be written only if aci_hal_write_config_data() is the first command
374                            after reset. */
375 #define CONFIG_DATA_STATIC_RANDOM_ADDRESS           (0x2E) /**< To set the static random address used by the stack, instead of the one stored in NVM. */
376 #define CONFIG_DATA_SCAN_CH_MAP                     (0x2F) /**< To set the channel map for scanning. */
377 #define CONFIG_DATA_STORED_STATIC_RANDOM_ADDRESS    (0x80) /**< The static random address stored in NVM. */
378 #define CONFIG_DATA_DEBUG_KEY                       (0xD0) /**< Use debug key for secure connections. */
379 #define CONFIG_DATA_DLE                             (0xD1) /**< To set the maximum allowed parameter values for Data Length Extension */
380 /**
381  * @}
382  */
383 
384 /**
385  * @name Length for configuration values.
386  * See @ref aci_hal_write_config_data() and @ref aci_hal_read_config_data().
387  * @{
388  */
389 #define CONFIG_DATA_PUBADDR_LEN                 (6)
390 #define CONFIG_DATA_ER_LEN                      (16)
391 #define CONFIG_DATA_IR_LEN                      (16)
392 #define CONFIG_DATA_LL_WITHOUT_HOST_LEN         (1)
393 #define CONFIG_DATA_STATIC_RANDOM_ADDRESS_LEN   (6)
394 #define CONFIG_DATA_SCAN_CH_MAP_LEN             (1)
395 #define CONFIG_DATA_DEBUG_KEY_LEN               (1)
396 #define CONFIG_DATA_DLE_LEN                     (1)
397 /**
398  * @}
399  */
400 
401 
402 /**
403  * @name Types for fw error event
404  * @brief See aci_hal_fw_error_event().
405  * @{
406  */
407 
408 #define HAL_FW_L2CAP_RECOMBINATION_ERROR            0x01 /**< L2CAP layer failed recombining a PDU */
409 #define HAL_FW_GATT_UNEXPECTED_RESPONSE_ERROR       0x02 /**< GATT layer received an unexpteced response. Peer probably violated the ATT protocol. */
410 #define HAL_FW_GATT_SEQUENTIAL_PROTOCOL_ERROR       0x03 /**< GATT layer received an unexpteced request. Peer probably violated the sequentiality of ATT protocol. */
411 #define HAL_FW_BONDING_DB_FULL_GATTSERVICE_ERROR    0x04 /**< No space to store info GATT database info in NVM. Database needs to be cleaned up (remove invalidated records) or some bonding entries need to be removed. */
412 #define HAL_FW_BONDING_DB_FULL_PAIRING_ERROR        0x05 /**< No space to store bonding info in NVM. Database needs to be cleaned up (remove invalidated records) or some bonding entries need to be removed. */
413 #define HAL_FW_SCHEDULER_OVERRUN_ERROR              0x06 /**< Link Layer scheduler failed to reschedule slots for too many times. This may indicate an unrecoverable situation. A system reset is recommended. */
414 #define HAL_FW_MEMBUF_NOT_AVAILABLE                 0x07 /**< Out of memory resources for isochronous channels. */
415 #define HAL_FW_CTE_TIMER_PROGRAM_ERROR              0x08 /**< Error in programming timer for CTE reception functionality. */
416 #define HAL_FW_MBM_RESOURCE_MISS                    0x09 /**< Requested resources are not available. */
417 
418 /**
419  * @}
420  */
421 
422  /**
423  * @name Types for aci_hal_pawr_data_free_event()
424  * @brief See aci_hal_pawr_data_free_event().
425  * @{
426  */
427 
428 #define HAL_PAWR_DATA_TYPE_SUBEVENT                 0x00 /**< PAwR subevevent data */
429 #define HAL_PAWR_DATA_TYPE_RESPONSE                 0x01 /**< PAwR response data */
430 
431 /**
432  * @}
433  */
434 
435 /**
436  * @}
437  */
438 /**
439  * @}
440  */
441 
442 
443 /**
444  *@addtogroup GAP GAP
445  *@brief Generic Access Profile
446  *@{
447  */
448 
449 /**
450  *@addtogroup GAP_constants GAP Constants
451  *@brief Constants for GAP layer
452  *@{
453  */
454 
455 /**
456  * @name Characteristic value lengths
457  * @{
458  */
459 #define APPEARANCE_CHAR_LEN                     (2)
460 #define PERIPHERAL_PREFERRED_CONN_PARAMS_CHAR_LEN (8)
461 #define CENTRAL_ADDRESS_RESOLUTION_CHAR_LEN         (1)
462 /**
463  * @}
464  */
465 
466 /**
467  * @name AD Types
468  * @brief AD types for adv data and scan response data
469  * @{
470  */
471 
472 #define AD_TYPE_FLAGS                   (0x01)
473 
474 #define AD_TYPE_16_BIT_SERV_UUID          (0x02)
475 #define AD_TYPE_16_BIT_SERV_UUID_CMPLT_LIST     (0x03)
476 #define AD_TYPE_32_BIT_SERV_UUID                (0x04)
477 #define AD_TYPE_32_BIT_SERV_UUID_CMPLT_LIST     (0x05)
478 #define AD_TYPE_128_BIT_SERV_UUID               (0x06)
479 #define AD_TYPE_128_BIT_SERV_UUID_CMPLT_LIST    (0x07)
480 
481 #define AD_TYPE_SHORTENED_LOCAL_NAME            (0x08)
482 #define AD_TYPE_COMPLETE_LOCAL_NAME             (0x09)
483 
484 /** TX power level AD type*/
485 #define AD_TYPE_TX_POWER_LEVEL                  (0x0A)
486 
487 /** Class of device */
488 #define AD_TYPE_CLASS_OF_DEVICE                 (0x0D)
489 
490 /** Security manager TK value AD type */
491 #define AD_TYPE_SEC_MGR_TK_VALUE                (0x10)
492 
493 /** Security manager OOB flags */
494 #define AD_TYPE_SEC_MGR_OOB_FLAGS               (0x11)
495 
496 /** Slave connection interval AD type */
497 #define AD_TYPE_SLAVE_CONN_INTERVAL             (0x12)
498 
499 #define AD_TYPE_SERV_SOLICIT_16_BIT_UUID_LIST   (0x14)
500 #define AD_TYPE_SERV_SOLICIT_32_BIT_UUID_LIST   (0x1F)
501 #define AD_TYPE_SERV_SOLICIT_128_BIT_UUID_LIST  (0x15)
502 
503 #define AD_TYPE_16_BIT_UUID_SERVICE_DATA        (0x16)
504 #define AD_TYPE_32_BIT_UUID_SERVICE_DATA        (0x20)
505 #define AD_TYPE_128_BIT_UUID_SERVICE_DATA       (0x21)
506 
507 /** Manufaturer specific data AD type */
508 #define AD_TYPE_MANUFACTURER_SPECIFIC_DATA      (0xFF)
509 
510 /**
511  * @}
512  */
513 
514 /**
515  * @name Flags AD Type bits
516  * @brief Bits for Flags AD Type
517  * @{
518  */
519 #define FLAG_BIT_LE_LIMITED_DISCOVERABLE_MODE   (0x01)
520 #define FLAG_BIT_LE_GENERAL_DISCOVERABLE_MODE   (0x02)
521 #define FLAG_BIT_BR_EDR_NOT_SUPPORTED           (0x04)
522 #define FLAG_BIT_LE_BR_EDR_CONTROLLER           (0x08)
523 #define FLAG_BIT_LE_BR_EDR_HOST                 (0x10)
524 /**
525  * @}
526  */
527 
528 
529 /**
530  * @name GAP modes
531  * @{
532  */
533 #define GAP_MODE_NON_DISCOVERABLE             0
534 #define GAP_MODE_LIMITED_DISCOVERABLE         1
535 #define GAP_MODE_GENERAL_DISCOVERABLE         2
536 #define GAP_MODE_BROADCAST                    3
537 /**
538  * @}
539  */
540 
541 /**
542  * @name Privacy type
543  * @{
544  */
545 #define PRIVACY_DISABLED                        (0x00)
546 #define PRIVACY_HOST_ENABLED                    (0x01)
547 #define PRIVACY_CONTROLLER_ENABLED              (0x02)
548 /**
549  * @}
550  */
551 
552 /**
553  * @name Operation
554  * Values for Operation parameter (see aci_gap_set_advertising_data()).
555  * @{
556  */
557 #define ADV_COMPLETE_DATA           (0x03)
558 #define ADV_UNCHANGED_DATA            (0x04)
559 /**
560  * @}
561  */
562 
563 /**
564  * @name Recommended advertising intervals
565  * Intervals in terms of 625 micro seconds
566  * @{
567  */
568 #define GAP_ADV_INT_MIN_USER_INITIATED_CONN          (48)   /* 30 ms  */
569 #define GAP_ADV_INT_MAX_USER_INITIATED_CONN          (96)   /* 60 ms  */
570 #define GAP_ADV_INT_MIN_USER_INITIATED_NONCONN       (160)  /* 100 ms */
571 #define GAP_ADV_INT_MAX_USER_INITIATED_NONCONN       (240)  /* 150 ms */
572 #define GAP_ADV_INT_MIN_BACKGROUND                   (1600) /* 1 s    */
573 #define GAP_ADV_INT_MAX_BACKGROUND                   (1920) /* 1.2 s  */
574 /**
575  * @}
576  */
577 
578 /**
579  * @anchor gap_roles
580  * @name GAP Roles
581  * @{
582 */
583 #define GAP_PERIPHERAL_ROLE                     (0x01)
584 #define GAP_BROADCASTER_ROLE                    (0x02)
585 #define GAP_CENTRAL_ROLE                        (0x04)
586 #define GAP_OBSERVER_ROLE                       (0x08)
587 /**
588  * @}
589  */
590 
591 /**
592  * @anchor gap_procedure_codes
593  * @name GAP procedure codes
594  * Procedure codes for aci_gap_start_procedure()
595  * and aci_gap_terminate_proc() commands.
596  * @{
597  */
598 #define GAP_LIMITED_DISCOVERY_PROC                  (0x00)
599 #define GAP_GENERAL_DISCOVERY_PROC                  (0x01)
600 #define GAP_AUTO_CONNECTION_ESTABLISHMENT_PROC      (0x02)
601 #define GAP_GENERAL_CONNECTION_ESTABLISHMENT_PROC   (0x03)
602 #define GAP_SELECTIVE_CONNECTION_ESTABLISHMENT_PROC (0x04)
603 #define GAP_OBSERVATION_PROC                        (0x05)
604 #define GAP_DIRECT_CONNECTION_ESTABLISHMENT_PROC    (0x06)
605 #define GAP_NAME_DISCOVERY_PROC                     (0x07)
606 
607 /**
608  * @}
609  */
610 
611 /**
612  * @anchor gap_appearance_values
613  * @name GAP Appearance values
614  * Values for GAP Appearance characteristic.
615  * @{
616  */
617 #define GAP_APPEARANCE_UNKNOWN                                 0x0000
618 #define GAP_APPEARANCE_GENERIC_PHONE                           0x0040
619 #define GAP_APPEARANCE_GENERIC_COMPUTER                        0x0080
620 #define GAP_APPEARANCE_GENERIC_WATCH                           0x00C0
621 #define GAP_APPEARANCE_WATCH_SPORT_WATCH                       0x00C1
622 #define GAP_APPEARANCE_GENERIC_CLOCK                           0x0100
623 #define GAP_APPEARANCE_GENERIC_DISPLAY                         0x0140
624 #define GAP_APPEARANCE_GENERIC_REMOTE_CONTROL                  0x0180
625 #define GAP_APPEARANCE_GENERIC_EYE_GLASSES                     0x01C0
626 #define GAP_APPEARANCE_GENERIC_TAG                             0x0200
627 #define GAP_APPEARANCE_GENERIC_KEYRING                         0x0240
628 #define GAP_APPEARANCE_GENERIC_MEDIA_PLAYER                    0x0280
629 #define GAP_APPEARANCE_GENERIC_BARCODE_SCANNER                 0x02C0
630 #define GAP_APPEARANCE_GENERIC_THERMOMETER                     0x0300
631 #define GAP_APPEARANCE_THERMOMETER_EAR                         0x0301
632 #define GAP_APPEARANCE_GENERIC_HEART_RATE_SENSOR               0x0340
633 #define GAP_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT       0x0341
634 #define GAP_APPEARANCE_GENERIC_BLOOD_PRESSURE                  0x0380
635 #define GAP_APPEARANCE_BLOOD_PRESSURE_ARM                      0x0381
636 #define GAP_APPEARANCE_BLOOD_PRESSURE_WRIST                    0x0382
637 #define GAP_APPEARANCE_HUMAN_INTERFACE_DEVICE                  0x03C0
638 #define GAP_APPEARANCE_KEYBOARD                                0x03C1
639 #define GAP_APPEARANCE_MOUSE                                   0x03C2
640 #define GAP_APPEARANCE_JOYSTICK                                0x03C3
641 #define GAP_APPEARANCE_GAMEPAD                                 0x03C4
642 #define GAP_APPEARANCE_DIGITIZER_TABLET                        0x03C5
643 #define GAP_APPEARANCE_CARD_READER                             0x03C6
644 #define GAP_APPEARANCE_DIGITAL_PEN                             0x03C7
645 #define GAP_APPEARANCE_BARCODE_SCANNER                         0x03C8
646 #define GAP_APPEARANCE_GENERIC_GLUCOSE_METER                   0x0400
647 #define GAP_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR          0x0440
648 #define GAP_APPEARANCE_RUNNING_WALKING_IN_SHOE                 0x0441
649 #define GAP_APPEARANCE_RUNNING_WALKING_ON_SHOE                 0x0442
650 #define GAP_APPEARANCE_RUNNING_WALKING_ON_HIP                  0x0443
651 #define GAP_APPEARANCE_GENERIC_CYCLING                         0x0480
652 #define GAP_APPEARANCE_CYCLING_CYCLING_COMPUTER                0x0481
653 #define GAP_APPEARANCE_CYCLING_SPEED_SENSOR                    0x0482
654 #define GAP_APPEARANCE_CYCLING_CADENCE_SENSOR                  0x0483
655 #define GAP_APPEARANCE_CYCLING_POWER_SENSOR                    0x0484
656 #define GAP_APPEARANCE_CYCLING_SPEED_AND_CADENCE_SENSOR        0x0485
657 #define GAP_APPEARANCE_GENERIC_PULSE_OXYMETER                  0x0C40
658 #define GAP_APPEARANCE_FINGERTIP                               0x0C41
659 #define GAP_APPEARANCE_WRIST_WORN                              0x0C42
660 #define GAP_APPEARANCE_GENERIC_WEIGHT_SCALE                    0x0C80
661 #define GAP_APPEARANCE_GENERIC_OUTDOOR_SPORT_ACTIVITY          0x1440
662 #define GAP_APPEARANCE_LOCATION_DISPLAY_DEVICE                 0x1441
663 #define GAP_APPEARANCE_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE  0x1442
664 #define GAP_APPEARANCE_LOCATION_POD                            0x1443
665 #define GAP_APPEARANCE_LOCATION_AND_NAVIGATION_POD             0x1444
666 #define GAP_APPEARANCE_GENERIC_ENVIRONMENTAL_SENSOR            0x1640
667 
668 /**
669  * @}
670  */
671 
672 /**
673  * @anchor IO_capabilities
674  * @name IO capabilities
675  * @{
676  */
677 #define GAP_IO_CAP_DISPLAY_ONLY                                 0x00
678 #define GAP_IO_CAP_DISPLAY_YES_NO                               0x01
679 #define GAP_IO_CAP_KEYBOARD_ONLY                                0x02
680 #define GAP_IO_CAP_NO_INPUT_NO_OUTPUT                           0x03
681 #define GAP_IO_CAP_KEYBOARD_DISPLAY                             0x04
682 /**
683  * @}
684  */
685 
686 /**
687  * @anchor Auth_req
688  * @name Authentication requirements
689  * @{
690  */
691 #define BONDING                (0x01)
692 #define NO_BONDING         (0x00)
693 /**
694  * @}
695  */
696 
697 /**
698  * @anchor MITM_req
699  * @name MITM protection requirements
700  * @{
701  */
702 #define GAP_MITM_PROTECTION_NOT_REQUIRED                        0x00
703 #define GAP_MITM_PROTECTION_REQUIRED                            0x01
704 /**
705  * @}
706  */
707 
708 /**
709  * @anchor OOB_Data
710  * @name Out-Of-Band data
711  * @{
712  */
713 #define OOB_AUTH_DATA_ABSENT     (0x00)
714 #define OOB_AUTH_DATA_PRESENT        (0x01)
715 /**
716  * @}
717  */
718 
719 /**
720  * @anchor Author_req
721  * @name Authorization requirements
722  * @{
723  */
724 #define AUTHORIZATION_NOT_REQUIRED    (0x00)
725 #define AUTHORIZATION_REQUIRED      (0x01)
726 /**
727  * @}
728  */
729 
730 /**
731  * @anchor Conn_authorization
732  * @name Connection authorization
733  * @{
734  */
735 #define CONNECTION_AUTHORIZED     (0x01)
736 #define CONNECTION_REJECTED     (0x02)
737 /**
738  * @}
739  */
740 
741 /**
742  * @anchor link_security_status
743  * @name Link security status
744  * @{
745  */
746 #define SM_LINK_AUTHENTICATED               (0x01)
747 #define SM_LINK_AUTHORIZED                  (0x02)
748 #define SM_LINK_ENCRYPTED                   (0x04)
749 /**
750  * @}
751  */
752 
753 /**
754  * @anchor SMP_pairing_failed_codes
755  * @name SMP pairing failed reason codes
756  * @{
757  */
758 #define PASSKEY_ENTRY_FAILED      (0x01)
759 #define OOB_NOT_AVAILABLE     (0x02)
760 #define AUTH_REQ_CANNOT_BE_MET      (0x03)
761 #define CONFIRM_VALUE_FAILED      (0x04)
762 #define PAIRING_NOT_SUPPORTED     (0x05)
763 #define INSUFF_ENCRYPTION_KEY_SIZE    (0x06)
764 #define CMD_NOT_SUPPORTED     (0x07)
765 #define UNSPECIFIED_REASON      (0x08)
766 #define VERY_EARLY_NEXT_ATTEMPT     (0x09)
767 #define SM_INVALID_PARAMS     (0x0A)
768 /**
769  * @}
770  */
771 
772 /**
773  * @anchor pairing_failed_codes
774  * @name Pairing failed error codes
775  * Error codes in @ref aci_gap_pairing_complete_event event
776  * @{
777  */
778 #define SM_PAIRING_SUCCESS              (0x00)
779 #define SM_PAIRING_TIMEOUT              (0x01)
780 #define SM_PAIRING_FAILED               (0x02)
781 /**
782  * @}
783  */
784 
785 /**
786  * @anchor secure_connections_support
787  * @name Secure connection support option code
788  * Error codes in @ref aci_gap_set_authentication_requirement API
789  * @{
790  */
791 #define GAP_SC_NOT_SUPPORTED (0x00) /* Not supported */
792 #define GAP_SC_OPTIONAL      (0x01) /* Supported but optional (i.e. a Legacy Pairing may be accepted) */
793 #define GAP_SC_MANDATORY     (0x02) /* Supported but mandatory (i.e. do not accept Legacy Pairing but only Secure Connections v.4.2 Pairing) */
794 
795 /**
796  * @}
797  */
798 
799 /**
800  * @anchor keypress_support
801  * @name Secure connection key press notification option code
802  * Error codes in @ref aci_gap_set_authentication_requirement API
803  * @{
804  */
805 #define GAP_KEYPRESS_NOT_SUPPORTED (0x00)
806 #define GAP_KEYPRESS_SUPPORTED     (0x01)
807 
808 /**
809  * @}
810  */
811 
812 /**
813  * @anchor gap_pairing_resp
814  * @name Values for Pairing_Response parameter of aci_gap_set_security_requirements
815  * @{
816  */
817 #define GAP_PAIRING_RESP_NONE                   (0x00)
818 #define GAP_PAIRING_RESP_FOR_BONDED_DEVICES     (0x01)
819 #define GAP_PAIRING_RESP_FOR_ALL                (0x02)
820 
821 
822 /**
823  * @}
824  */
825 
826  /**
827  * @anchor gap_security_level
828  * @name Values for Security_Level parameter of aci_gap_set_security
829  * @{
830  */
831 #define GAP_SECURITY_LEVEL_1                   	(0x01)
832 #define GAP_SECURITY_LEVEL_2                  	(0x02)
833 #define GAP_SECURITY_LEVEL_3                   	(0x03)
834 #define GAP_SECURITY_LEVEL_4                   	(0x04)
835 
836 
837 /**
838  * @}
839  */
840 
841 
842 /**
843  * @}
844  */
845 
846 /**
847  * @}
848  */
849 
850 /**
851  *@addtogroup GATT GATT
852  *@{
853  */
854 /**
855  *@defgroup GATT_constants GATT Constants
856  *@{
857  */
858 
859 /**
860  * @anchor Access_permissions
861  * @name Access permissions
862  * Access permissions for an attribute
863  * @{
864  */
865 #define ATTR_NO_ACCESS                             (0x00)
866 #define ATTR_ACCESS_READ_ONLY                      (0x01)
867 #define ATTR_ACCESS_WRITE_REQ_ONLY                 (0x02)
868 #define ATTR_ACCESS_READ_WRITE                     (0x03)
869 #define ATTR_ACCESS_WRITE_WITHOUT_RESPONSE         (0x04)
870 #define ATTR_ACCESS_SIGNED_WRITE_ALLOWED           (0x08)
871 /**
872  * Allows all write procedures
873  */
874 #define ATTR_ACCESS_WRITE_ANY                      (0x0E)
875 /**
876  * @}
877  */
878 
879 /**
880  * @anchor Char_properties
881  * @name Characteristic properties.
882  * @{
883  */
884 #define CHAR_PROP_BROADCAST               (0x01)
885 #define CHAR_PROP_READ          (0x02)
886 #define CHAR_PROP_WRITE_WITHOUT_RESP      (0x04)
887 #define CHAR_PROP_WRITE                     (0x08)
888 #define CHAR_PROP_NOTIFY              (0x10)
889 #define CHAR_PROP_INDICATE              (0x20)
890 #define CHAR_PROP_SIGNED_WRITE                          (0x40)
891 #define CHAR_PROP_EXT                             (0x80)
892 /**
893  * @}
894  */
895 
896 
897 /**
898  * @anchor Security_permissions
899  * @name Security permissions for an attribute.
900  * @{
901  */
902 #define ATTR_PERMISSION_NONE                       (0x00) /**< No security. */
903 #define ATTR_PERMISSION_AUTHEN_READ                (0x01) /**< Need authentication to read */
904 #define ATTR_PERMISSION_AUTHOR_READ                (0x02) /**< Need authorization to read */
905 #define ATTR_PERMISSION_ENCRY_READ                 (0x04) /**< Link must be encrypted to read */
906 #define ATTR_PERMISSION_AUTHEN_WRITE               (0x08) /**< Need authentication to write */
907 #define ATTR_PERMISSION_AUTHOR_WRITE               (0x10) /**< Need authorization to write */
908 #define ATTR_PERMISSION_ENCRY_WRITE                (0x20) /**< Link must be encrypted for write */
909 /**
910  * @}
911  */
912 
913 /**
914  * @anchor UUID_Types
915  * @name Type of UUID (16 bit or 128 bit).
916  * @{
917  */
918 #define UUID_TYPE_16                               (0x01)
919 #define UUID_TYPE_128                              (0x02)
920 /**
921  * @}
922  */
923 
924 /**
925  * @anchor Service_type
926  * @name Type of service (primary or secondary)
927  * @{
928  */
929 #define PRIMARY_SERVICE                            (0x01)
930 #define SECONDARY_SERVICE                          (0x02)
931 /**
932  * @}
933  */
934 
935 /**
936  * @anchor Notification_type
937  * @name Type of notification
938  * @{
939  */
940 #define GATT_NOTIFICATION                          (0x00)
941 #define GATT_INDICATION                            (0x02)
942 /**
943  * @}
944  */
945 
946 /**
947  * @anchor Gatt_Event_Mask
948  * @name Gatt Event Mask
949  * Type of event generated by GATT server
950  * @{
951  */
952 #define GATT_DONT_NOTIFY_EVENTS                       (0x00) /**< Do not notify events. */
953 #define GATT_NOTIFY_ATTRIBUTE_WRITE                   (0x01) /**< The application will be notified when a client writes to this attribute.
954                                                                   An @ref aci_gatt_srv_attribute_modified_event will be issued. */
955 #define GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP  (0x02) /**< The application will be notified when a write request, a write cmd
956                                                                     or a signed write cmd are received by the server for this attribute.*/
957 #define GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP   (0x04) /**< The application will be notified when a read request of any type is
958                                                                   received for this attribute. */
959 /**
960  * @}
961  */
962 
963 /**
964  * @name Type of characteristic length
965  * See aci_gatt_add_char()
966  * @{
967  */
968 #define CHAR_VALUE_LEN_CONSTANT           (0x00)
969 #define CHAR_VALUE_LEN_VARIABLE           (0x01)
970 /**
971  * @}
972  */
973 
974 
975 /**
976  * @name Encryption key size
977  * @{
978  */
979 /**
980  * Minimum encryption key size
981  */
982 #define MIN_ENCRY_KEY_SIZE                (7)
983 
984 /**
985  * Maximum encryption key size
986  */
987 #define MAX_ENCRY_KEY_SIZE                (0x10)
988 /**
989  * @}
990  */
991 
992 /**
993  * @name Characteristic Presentation Format
994  * @{
995  */
996 typedef PACKED(struct) _charactFormat {
997     uint8_t format;
998     int8_t exp;
999     uint16_t unit;
1000     uint8_t name_space;
1001     uint16_t desc;
1002 } charactFormat;
1003 
1004 /**
1005  * @}
1006  */
1007 
1008 /**
1009  * @name Format
1010  * @{
1011  */
1012 #define FORMAT_UINT8         0x04
1013 #define FORMAT_UINT16        0x06
1014 #define FORMAT_SINT16        0x0E
1015 #define FORMAT_SINT24        0x0F
1016 /**
1017  * @}
1018  */
1019 
1020 /**
1021  * @name Unit
1022  * @{
1023  */
1024 #define UNIT_UNITLESS        0x2700
1025 #define UNIT_TEMP_CELSIUS    0x272F
1026 #define UNIT_PRESSURE_BAR    0x2780
1027 /**
1028  * @}
1029  */
1030 
1031 
1032 /**
1033  * @}
1034  */
1035 /**
1036  * @}
1037  */
1038 
1039 
1040 /**
1041  *@addtogroup L2CAP L2CAP
1042  *@{
1043  */
1044 /**
1045  *@addtogroup L2CAP_constants L2CAP Constants
1046  *@brief Constants for L2CAP layer.
1047  *@{
1048  */
1049 
1050 /**
1051  *@name L2CAP Connection Event Type
1052  *@see aci_l2cap_cfc_connection_event
1053  *@{
1054  */
1055 #define L2CAP_CONN_REQ                 0
1056 #define L2CAP_CONN_RESP                1
1057 /**
1058  *@}
1059  */
1060 
1061 #define L2CAP_CHANNEL_TYPE_LE_CFC 0x00
1062 #define L2CAP_CHANNEL_TYPE_ECFC   0x01
1063 
1064 #define L2CAP_CONN_SUCCESSFUL                           0x0000
1065 #define L2CAP_CONN_FAIL_SPSM_NOT_SUPPORTED              0x0002
1066 #define L2CAP_CONN_FAIL_INSUFFICIENT_RESOURCES          0x0004
1067 #define L2CAP_CONN_FAIL_INSUFFICIENT_AUTHENTICATION     0x0005
1068 #define L2CAP_CONN_FAIL_INSUFFICIENT_AUTHORIZATION      0x0006
1069 #define L2CAP_CONN_FAIL_KEY_SIZE_TOO_SHORT              0x0007
1070 #define L2CAP_CONN_FAIL_INSUFFICIENT_ENCRYPTION         0x0008
1071 #define L2CAP_CONN_FAIL_INVALID_SOURCE_CID              0x0009
1072 #define L2CAP_CONN_FAIL_SOURCE_CID_ALREADY_ALLOCATED    0x000A
1073 #define L2CAP_CONN_FAIL_UNACCEPTABLE_PARAMETERS         0x000B
1074 #define L2CAP_CONN_FAIL_INVALID_PARAMETERS              0x000C
1075 #define L2CAP_CONN_FAIL_NO_INFO                         0x000D
1076 #define L2CAP_CONN_FAIL_AUTHENTICATION_PENDING          0x000E
1077 #define L2CAP_CONN_FAIL_AUTHORIZATION_PENDING           0x000F
1078 
1079 #define L2CAP_CFC_MANUAL                                0x00
1080 #define L2CAP_CFC_AUTO                                  0x01
1081 
1082 /**
1083  *@}
1084  */
1085 /**
1086  *@}
1087  */
1088 
1089 
1090 #endif /* __BLE_CONST_H__ */
1091