|
| 1 | +/** @file |
| 2 | + * |
| 3 | + * IGNORE THIS FILE IF USING ESP-IDF, USE MENUCONFIG TO SET NIMBLE OPTIONS. |
| 4 | + * |
| 5 | + * The config options here are for Arduino use only. |
| 6 | + */ |
| 7 | + |
1 | 8 | #pragma once |
2 | 9 |
|
3 | 10 | #include "sdkconfig.h" |
4 | | -/** For ESP-IDF compatibility |
5 | | - * |
6 | | - * Some versions of ESP-IDF used the config name format "CONFIG_NIMBLE_". |
7 | | - * This converts them to "CONFIG_BT_NIMBLE_" format used in the latest IDF. |
| 11 | + |
| 12 | +/* |
| 13 | + * For ESP-IDF compatibility |
| 14 | + * Some versions of ESP-IDF used the config name format "CONFIG_NIMBLE_". |
| 15 | + * This converts them to "CONFIG_BT_NIMBLE_" format used in the latest IDF. |
8 | 16 | */ |
9 | | -/* Detect if using ESP-IDF or Arduino (Arduino won't have these defines in sdkconfig)*/ |
| 17 | + |
| 18 | +/* Detect if using ESP-IDF or Arduino (Arduino won't have these defines in sdkconfig) */ |
10 | 19 | #if defined(CONFIG_BT_NIMBLE_TASK_STACK_SIZE) || defined(CONFIG_NIMBLE_TASK_STACK_SIZE) |
11 | 20 |
|
12 | 21 | #if defined(CONFIG_NIMBLE_ENABLED) && !defined(CONFIG_BT_NIMBLE_ENABLED) |
|
36 | 45 | #else // Using Arduino |
37 | 46 |
|
38 | 47 | /*********************************************** |
39 | | - * Arduino config options |
| 48 | + * Arduino config options start here |
40 | 49 | **********************************************/ |
41 | 50 |
|
42 | | -/** Comment out if not using NimBLE Client functions |
| 51 | +/** @brief Comment out if not using NimBLE Client functions \n |
43 | 52 | * Reduces flash size by approx. 7kB. |
44 | 53 | */ |
45 | 54 | #define CONFIG_BT_NIMBLE_ROLE_CENTRAL |
46 | 55 |
|
47 | | -/** Comment out if not using NimBLE Scan functions |
| 56 | +/** @brief Comment out if not using NimBLE Scan functions \n |
48 | 57 | * Reduces flash size by approx. 26kB. |
49 | 58 | */ |
50 | 59 | #define CONFIG_BT_NIMBLE_ROLE_OBSERVER |
51 | 60 |
|
52 | | -/** Comment out if not using NimBLE Server functions |
| 61 | +/** @brief Comment out if not using NimBLE Server functions \n |
53 | 62 | * Reduces flash size by approx. 16kB. |
54 | 63 | */ |
55 | 64 | #define CONFIG_BT_NIMBLE_ROLE_PERIPHERAL |
56 | 65 |
|
57 | | -/** Comment out if not using NimBLE Advertising functions |
| 66 | +/** @brief Comment out if not using NimBLE Advertising functions \n |
58 | 67 | * Reduces flash size by approx. 5kB. |
59 | 68 | */ |
60 | 69 | #define CONFIG_BT_NIMBLE_ROLE_BROADCASTER |
61 | 70 |
|
62 | | -/** Uncomment to see debug log messages from the NimBLE host |
| 71 | +/* Uncomment to see debug log messages from the NimBLE host |
63 | 72 | * Uses approx. 32kB of flash memory. |
64 | 73 | */ |
65 | 74 | // #define CONFIG_BT_NIMBLE_DEBUG |
66 | 75 |
|
67 | | -/** Uncomment to see NimBLE host return codes as text debug log messages. |
| 76 | +/* Uncomment to see NimBLE host return codes as text debug log messages. |
68 | 77 | * Uses approx. 7kB of flash memory. |
69 | 78 | */ |
70 | 79 | // #define CONFIG_NIMBLE_CPP_ENABLE_RETURN_CODE_TEXT |
71 | 80 |
|
72 | | -/** Uncomment to see GAP event codes as text in debug log messages. |
| 81 | +/* Uncomment to see GAP event codes as text in debug log messages. |
73 | 82 | * Uses approx. 1kB of flash memory. |
74 | 83 | */ |
75 | 84 | // #define CONFIG_NIMBLE_CPP_ENABLE_GAP_EVENT_CODE_TEXT |
76 | 85 |
|
77 | | -/** Uncomment to see advertisment types as text while scanning in debug log messages. |
| 86 | +/* Uncomment to see advertisment types as text while scanning in debug log messages. |
78 | 87 | * Uses approx. 250 bytes of flash memory. |
79 | 88 | */ |
80 | 89 | // #define CONFIG_NIMBLE_CPP_ENABLE_ADVERTISMENT_TYPE_TEXT |
81 | 90 |
|
82 | | -/** Sets the core NimBLE host runs on */ |
| 91 | +/** @brief Sets the core NimBLE host runs on */ |
83 | 92 | #define CONFIG_BT_NIMBLE_PINNED_TO_CORE 0 |
84 | 93 |
|
85 | | -/** Sets the stack size for the NimBLE host task */ |
| 94 | +/** @brief Sets the stack size for the NimBLE host task */ |
86 | 95 | #define CONFIG_BT_NIMBLE_TASK_STACK_SIZE 4096 |
87 | 96 |
|
88 | | -/** Sets the number of simultaneous connections (esp controller max is 9) */ |
| 97 | +/** |
| 98 | + * @brief Sets the memory pool where NimBLE will be loaded |
| 99 | + * @details By default NimBLE is loaded in internal ram.\n |
| 100 | + * To use external PSRAM you must change this to `#define CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL 1` |
| 101 | + */ |
| 102 | +#define CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL 1 |
| 103 | + |
| 104 | +/** |
| 105 | + * @brief Sets the number of simultaneous connections (esp controller max is 9) |
| 106 | + * @details To increase max connections in Arduino it is also required to change the |
| 107 | + * controller max connections defined in sdkconfig.h.\n |
| 108 | + * |
| 109 | + * This is located in your Arduino/hardware/espressif/esp32/tools/sdk/include/config folder.\n\n |
| 110 | + * |
| 111 | + * The values in sdkconfig.h you will need to change are:\n\n |
| 112 | + * `CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN 3`\n |
| 113 | + * `CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF 3` |
| 114 | + */ |
89 | 115 | #define CONFIG_BT_NIMBLE_MAX_CONNECTIONS 3 |
90 | 116 |
|
91 | | -/** Sets the number of devices allowed to store/bond with */ |
| 117 | +/** @brief Sets the number of devices allowed to store/bond with */ |
92 | 118 | #define CONFIG_BT_NIMBLE_MAX_BONDS 3 |
93 | 119 |
|
94 | | -/** Sets the number of CCCD's to store per bonded device */ |
| 120 | +/** @brief Sets the maximum number of CCCD subscriptions to store */ |
95 | 121 | #define CONFIG_BT_NIMBLE_MAX_CCCDS 8 |
96 | 122 |
|
| 123 | +/** @brief Set if CCCD's and bond data should be stored in NVS */ |
97 | 124 | #define CONFIG_BT_NIMBLE_NVS_PERSIST 1 |
| 125 | + |
| 126 | +/** @brief Allow legacy paring */ |
98 | 127 | #define CONFIG_BT_NIMBLE_SM_LEGACY 1 |
| 128 | + |
| 129 | +/** @brief Allow BLE secure connections */ |
99 | 130 | #define CONFIG_BT_NIMBLE_SM_SC 1 |
| 131 | + |
| 132 | +/** @brief Default device name */ |
100 | 133 | #define CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME "nimble" |
| 134 | + |
| 135 | +/** @brief Max device name length (bytes) */ |
101 | 136 | #define CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN 31 |
| 137 | + |
| 138 | +/** @brief Default MTU size */ |
102 | 139 | #define CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU 256 |
| 140 | + |
| 141 | +/** @brief Default GAP appearance */ |
103 | 142 | #define CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE 0x0 |
| 143 | + |
| 144 | +/** @brief ACL Buffer count */ |
104 | 145 | #define CONFIG_BT_NIMBLE_ACL_BUF_COUNT 12 |
| 146 | + |
| 147 | +/** @brief ACL Buffer size */ |
105 | 148 | #define CONFIG_BT_NIMBLE_ACL_BUF_SIZE 255 |
| 149 | + |
| 150 | +/** @brief HCI Event Buffer size */ |
106 | 151 | #define CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE 70 |
| 152 | + |
| 153 | +/** @brief Number of high priority HCI event buffers */ |
107 | 154 | #define CONFIG_BT_NIMBLE_HCI_EVT_HI_BUF_COUNT 30 |
| 155 | + |
| 156 | +/** @brief Number of low priority HCI event buffers */ |
108 | 157 | #define CONFIG_BT_NIMBLE_HCI_EVT_LO_BUF_COUNT 8 |
| 158 | + |
| 159 | +/** |
| 160 | + * @brief Sets the number of MSYS buffers available. |
| 161 | + * @details MSYS is a system level mbuf registry. For prepare write & prepare \n |
| 162 | + * responses MBUFs are allocated out of msys_1 pool. This may need to be increased if\n |
| 163 | + * you are sending large blocks of data with a low MTU. E.g: 512 bytes with 23 MTU will fail. |
| 164 | + */ |
109 | 165 | #define CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT 12 |
| 166 | + |
| 167 | + |
| 168 | +/** @brief Random address refresh time in seconds */ |
| 169 | +#define CONFIG_BT_NIMBLE_RPA_TIMEOUT 900 |
| 170 | + |
| 171 | +/** @brief Maximum number of connection oriented channels */ |
| 172 | +#define CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM 0 |
| 173 | + |
| 174 | +/* These should not be altered */ |
110 | 175 | #define CONFIG_BT_NIMBLE_HS_FLOW_CTRL 1 |
111 | 176 | #define CONFIG_BT_NIMBLE_HS_FLOW_CTRL_ITVL 1000 |
112 | 177 | #define CONFIG_BT_NIMBLE_HS_FLOW_CTRL_THRESH 2 |
113 | 178 | #define CONFIG_BT_NIMBLE_HS_FLOW_CTRL_TX_ON_DISCONNECT 1 |
114 | | -#define CONFIG_BT_NIMBLE_RPA_TIMEOUT 900 |
115 | | -#define CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM 0 |
116 | 179 |
|
117 | | -/** Do not comment out */ |
118 | 180 | #ifndef CONFIG_BT_ENABLED |
119 | 181 | #define CONFIG_BT_ENABLED |
120 | 182 | #endif |
| 183 | + |
121 | 184 | #define CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY |
122 | | -#define CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL |
123 | 185 |
|
124 | 186 | #endif // #if defined(CONFIG_BT_NIMBLE_TASK_STACK_SIZE) || defined(CONFIG_NIMBLE_TASK_STACK_SIZE) |
125 | 187 |
|
126 | | -/** Cannot use client without scan */ |
| 188 | +/********************************** |
| 189 | + End Arduino config |
| 190 | +**********************************/ |
| 191 | + |
| 192 | + |
| 193 | +/* Cannot use client without scan */ |
127 | 194 | #if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL) && !defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER) |
128 | 195 | #define CONFIG_BT_NIMBLE_ROLE_OBSERVER |
129 | 196 | #endif |
130 | 197 |
|
131 | | -/** Cannot use server without advertise */ |
| 198 | +/* Cannot use server without advertise */ |
132 | 199 | #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL) && !defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER) |
133 | 200 | #define CONFIG_BT_NIMBLE_ROLE_BROADCASTER |
134 | 201 | #endif |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | +#ifdef _DOXYGEN_ |
| 206 | +/** @brief Uncomment to see debug log messages from the NimBLE host \n |
| 207 | + * Uses approx. 32kB of flash memory. |
| 208 | + */ |
| 209 | +#define CONFIG_BT_NIMBLE_DEBUG |
| 210 | + |
| 211 | +/** @brief Uncomment to see NimBLE host return codes as text debug log messages. \n |
| 212 | + * Uses approx. 7kB of flash memory. |
| 213 | + */ |
| 214 | +#define CONFIG_NIMBLE_CPP_ENABLE_RETURN_CODE_TEXT |
| 215 | + |
| 216 | +/** @brief Uncomment to see GAP event codes as text in debug log messages. \n |
| 217 | + * Uses approx. 1kB of flash memory. |
| 218 | + */ |
| 219 | +#define CONFIG_NIMBLE_CPP_ENABLE_GAP_EVENT_CODE_TEXT |
| 220 | + |
| 221 | +/** @brief Uncomment to see advertisment types as text while scanning in debug log messages. \n |
| 222 | + * Uses approx. 250 bytes of flash memory. |
| 223 | + */ |
| 224 | +#define CONFIG_NIMBLE_CPP_ENABLE_ADVERTISMENT_TYPE_TEXT |
| 225 | +#endif // _DOXYGEN_ |
0 commit comments