1 /** @file
2  *  @brief Bluetooth Generic Access Profile defines and Assigned Numbers.
3  */
4 
5 /*
6  * Copyright (c) 2019 Nordic Semiconductor ASA
7  *
8  * SPDX-License-Identifier: Apache-2.0
9  */
10 
11 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_GAP_H_
12 #define ZEPHYR_INCLUDE_BLUETOOTH_GAP_H_
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /**
19  * @brief Bluetooth Generic Access Profile defines and Assigned Numbers.
20  * @defgroup bt_gap_defines Defines and Assigned Numbers
21  * @ingroup bluetooth
22  * @{
23  */
24 
25 /** Company Identifiers (see Bluetooth Assigned Numbers) */
26 #define BT_COMP_ID_LF           0x05f1 /* The Linux Foundation */
27 
28 /** EIR/AD data type definitions */
29 #define BT_DATA_FLAGS                   0x01 /* AD flags */
30 #define BT_DATA_UUID16_SOME             0x02 /* 16-bit UUID, more available */
31 #define BT_DATA_UUID16_ALL              0x03 /* 16-bit UUID, all listed */
32 #define BT_DATA_UUID32_SOME             0x04 /* 32-bit UUID, more available */
33 #define BT_DATA_UUID32_ALL              0x05 /* 32-bit UUID, all listed */
34 #define BT_DATA_UUID128_SOME            0x06 /* 128-bit UUID, more available */
35 #define BT_DATA_UUID128_ALL             0x07 /* 128-bit UUID, all listed */
36 #define BT_DATA_NAME_SHORTENED          0x08 /* Shortened name */
37 #define BT_DATA_NAME_COMPLETE           0x09 /* Complete name */
38 #define BT_DATA_TX_POWER                0x0a /* Tx Power */
39 #define BT_DATA_SM_TK_VALUE             0x10 /* Security Manager TK Value */
40 #define BT_DATA_SM_OOB_FLAGS            0x11 /* Security Manager OOB Flags */
41 #define BT_DATA_SOLICIT16               0x14 /* Solicit UUIDs, 16-bit */
42 #define BT_DATA_SOLICIT128              0x15 /* Solicit UUIDs, 128-bit */
43 #define BT_DATA_SVC_DATA16              0x16 /* Service data, 16-bit UUID */
44 #define BT_DATA_GAP_APPEARANCE          0x19 /* GAP appearance */
45 #define BT_DATA_LE_BT_DEVICE_ADDRESS    0x1b /* LE Bluetooth Device Address */
46 #define BT_DATA_LE_ROLE                 0x1c /* LE Role */
47 #define BT_DATA_SOLICIT32               0x1f /* Solicit UUIDs, 32-bit */
48 #define BT_DATA_SVC_DATA32              0x20 /* Service data, 32-bit UUID */
49 #define BT_DATA_SVC_DATA128             0x21 /* Service data, 128-bit UUID */
50 #define BT_DATA_LE_SC_CONFIRM_VALUE     0x22 /* LE SC Confirmation Value */
51 #define BT_DATA_LE_SC_RANDOM_VALUE      0x23 /* LE SC Random Value */
52 #define BT_DATA_URI                     0x24 /* URI */
53 #define BT_DATA_MESH_PROV               0x29 /* Mesh Provisioning PDU */
54 #define BT_DATA_MESH_MESSAGE            0x2a /* Mesh Networking PDU */
55 #define BT_DATA_MESH_BEACON             0x2b /* Mesh Beacon */
56 
57 #define BT_DATA_MANUFACTURER_DATA       0xff /* Manufacturer Specific Data */
58 
59 #define BT_LE_AD_LIMITED                0x01 /* Limited Discoverable */
60 #define BT_LE_AD_GENERAL                0x02 /* General Discoverable */
61 #define BT_LE_AD_NO_BREDR               0x04 /* BR/EDR not supported */
62 
63 /* Defined GAP timers */
64 #define BT_GAP_SCAN_FAST_INTERVAL               0x0060  /* 60 ms    */
65 #define BT_GAP_SCAN_FAST_WINDOW                 0x0030  /* 30 ms    */
66 #define BT_GAP_SCAN_SLOW_INTERVAL_1             0x0800  /* 1.28 s   */
67 #define BT_GAP_SCAN_SLOW_WINDOW_1               0x0012  /* 11.25 ms */
68 #define BT_GAP_SCAN_SLOW_INTERVAL_2             0x1000  /* 2.56 s   */
69 #define BT_GAP_SCAN_SLOW_WINDOW_2               0x0012  /* 11.25 ms */
70 #define BT_GAP_ADV_FAST_INT_MIN_1               0x0030  /* 30 ms    */
71 #define BT_GAP_ADV_FAST_INT_MAX_1               0x0060  /* 60 ms    */
72 #define BT_GAP_ADV_FAST_INT_MIN_2               0x00a0  /* 100 ms   */
73 #define BT_GAP_ADV_FAST_INT_MAX_2               0x00f0  /* 150 ms   */
74 #define BT_GAP_ADV_SLOW_INT_MIN                 0x0640  /* 1 s      */
75 #define BT_GAP_ADV_SLOW_INT_MAX                 0x0780  /* 1.2 s    */
76 #define BT_GAP_INIT_CONN_INT_MIN                0x0018  /* 30 ms    */
77 #define BT_GAP_INIT_CONN_INT_MAX                0x0028  /* 50 ms    */
78 
79 /** LE PHY types */
80 enum {
81 	/** LE 1M PHY */
82 	BT_GAP_LE_PHY_1M                      = BIT(0),
83 	 /** LE 2M PHY */
84 	BT_GAP_LE_PHY_2M                      = BIT(1),
85 	/** LE Coded PHY */
86 	BT_GAP_LE_PHY_CODED                   = BIT(2),
87 };
88 
89 /** Advertising PDU types */
90 enum {
91 	/** Scannable and connectable advertising. */
92 	BT_GAP_ADV_TYPE_ADV_IND               = 0x00,
93 	/** Directed connectable advertising. */
94 	BT_GAP_ADV_TYPE_ADV_DIRECT_IND        = 0x01,
95 	/** Non-connectable and scannable advertising. */
96 	BT_GAP_ADV_TYPE_ADV_SCAN_IND          = 0x02,
97 	/** Non-connectable and non-scannable advertising. */
98 	BT_GAP_ADV_TYPE_ADV_NONCONN_IND       = 0x03,
99 	/** Additional advertising data requested by an active scanner. */
100 	BT_GAP_ADV_TYPE_SCAN_RSP              = 0x04,
101 	/** Extended advertising, see advertising properties. */
102 	BT_GAP_ADV_TYPE_EXT_ADV               = 0x05,
103 };
104 
105 /** Advertising PDU properties */
106 enum {
107 	/** Connectable advertising. */
108 	BT_GAP_ADV_PROP_CONNECTABLE           = BIT(0),
109 	/** Scannable advertising. */
110 	BT_GAP_ADV_PROP_SCANNABLE             = BIT(1),
111 	/** Directed advertising. */
112 	BT_GAP_ADV_PROP_DIRECTED              = BIT(2),
113 	/** Additional advertising data requested by an active scanner. */
114 	BT_GAP_ADV_PROP_SCAN_RESPONSE         = BIT(3),
115 	/** Extended advertising. */
116 	BT_GAP_ADV_PROP_EXT_ADV               = BIT(4),
117 };
118 
119 /** Maximum advertising data length. */
120 #define BT_GAP_ADV_MAX_ADV_DATA_LEN             31
121 /** Maximum extended advertising data length.
122  *
123  *  @note The maximum advertising data length that can be sent by an extended
124  *        advertiser is defined by the controller.
125  */
126 #define BT_GAP_ADV_MAX_EXT_ADV_DATA_LEN         1650
127 
128 #define BT_GAP_TX_POWER_INVALID                 0x7f
129 #define BT_GAP_RSSI_INVALID                     0x7f
130 #define BT_GAP_SID_INVALID                      0xff
131 #define BT_GAP_NO_TIMEOUT                       0x0000
132 
133 /* The maximum allowed high duty cycle directed advertising timeout, 1.28
134  * seconds in 10 ms unit.
135  */
136 #define BT_GAP_ADV_HIGH_DUTY_CYCLE_MAX_TIMEOUT  128
137 
138 #define BT_GAP_DATA_LEN_DEFAULT                 0x001b /* 27 bytes */
139 #define BT_GAP_DATA_LEN_MAX                     0x00fb /* 251 bytes */
140 
141 #define BT_GAP_DATA_TIME_DEFAULT                0x0148 /* 328 us */
142 #define BT_GAP_DATA_TIME_MAX                    0x4290 /* 17040 us */
143 
144 /**
145  * @}
146  */
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_GAP_H_ */
153