NimBLE-Arduino 2.3.4
Loading...
Searching...
No Matches
nimconfig.h
1 #pragma once
2
3#ifdef ESP_PLATFORM
4#include "sdkconfig.h"
5#else
6#include "ext_nimble_config.h"
7/* Clear redefinition warnings */
8#undef CONFIG_BT_NIMBLE_ROLE_CENTRAL
9#undef CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
10#undef CONFIG_BT_NIMBLE_ROLE_BROADCASTER
11#undef CONFIG_BT_NIMBLE_ROLE_OBSERVER
12#undef CONFIG_BT_ENABLED
13#define CONFIG_BT_ENABLED 1
14#endif
15
16#include "nimconfig_rename.h"
17
18/***********************************************
19 * Arduino user-config options start here
20 **********************************************/
21
23// #define CONFIG_BT_NIMBLE_MAX_CONNECTIONS 3
24
31// #define CONFIG_NIMBLE_CPP_ATT_VALUE_TIMESTAMP_ENABLED 0
32
39// #define CONFIG_NIMBLE_CPP_ATT_VALUE_INIT_LENGTH 20
40
41
42/****************************************************
43 * Extended advertising settings *
44 * NOT FOR USE WITH ORIGINAL ESP32 *
45 ***************************************************/
46
48// #define CONFIG_BT_NIMBLE_EXT_ADV 1
49
51// #define CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES 1
52
54// #define CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN 251
55
57// #define CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV 1
58
60// #define CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS 1
61
62/****************************************************
63 * END Extended advertising settings *
64 ***************************************************/
65
66
68// #define CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU 255
69
71// #define CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME "nimble"
72
77 // #define CONFIG_BT_NIMBLE_LOG_LEVEL 5
78
83 // #define CONFIG_NIMBLE_CPP_LOG_LEVEL 0
84
86// #define CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED 1
87
91// #define CONFIG_NIMBLE_CPP_ENABLE_RETURN_CODE_TEXT
92
96// #define CONFIG_NIMBLE_CPP_ENABLE_GAP_EVENT_CODE_TEXT
97
101// #define CONFIG_NIMBLE_CPP_ENABLE_ADVERTISEMENT_TYPE_TEXT
102
104// #define CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE 0x0
105
109// #define CONFIG_BT_NIMBLE_ROLE_CENTRAL 0
110
114// #define CONFIG_BT_NIMBLE_ROLE_OBSERVER 0
115
119// #define CONFIG_BT_NIMBLE_ROLE_PERIPHERAL 0
120
124// #define CONFIG_BT_NIMBLE_ROLE_BROADCASTER 0
125
127// #define CONFIG_BT_NIMBLE_MAX_BONDS 3
128
130// #define CONFIG_BT_NIMBLE_MAX_CCCDS 8
131
133// #define CONFIG_BT_NIMBLE_RPA_TIMEOUT 900
134
141// #define CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT 12
142
144// #define CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL 1
145
147// #define CONFIG_BT_NIMBLE_PINNED_TO_CORE 0
148
150// #define CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE 4096
151
157// #define CONFIG_NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT 31
158
162// #define CONFIG_NIMBLE_CPP_ADDR_FMT_EXCLUDE_DELIMITER 1
163
167// #define CONFIG_NIMBLE_CPP_ADDR_FMT_UPPERCASE 1
168
173// #define CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS 1
174
175/**********************************
176 End Arduino user-config
177**********************************/
178
179/* This section should not be altered */
180#ifndef CONFIG_BT_NIMBLE_ROLE_CENTRAL
181#ifndef CONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED
182#define CONFIG_BT_NIMBLE_ROLE_CENTRAL 1
183#else
184#define CONFIG_BT_NIMBLE_ROLE_CENTRAL 0
185#endif
186#endif
187
188#ifndef CONFIG_BT_NIMBLE_ROLE_OBSERVER
189#ifndef CONFIG_BT_NIMBLE_ROLE_OBSERVER_DISABLED
190#define CONFIG_BT_NIMBLE_ROLE_OBSERVER 1
191#else
192#define CONFIG_BT_NIMBLE_ROLE_OBSERVER 0
193#endif
194#endif
195
196#ifndef CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
197#ifndef CONFIG_BT_NIMBLE_ROLE_PERIPHERAL_DISABLED
198#define CONFIG_BT_NIMBLE_ROLE_PERIPHERAL 1
199#else
200#define CONFIG_BT_NIMBLE_ROLE_PERIPHERAL 0
201#endif
202#endif
203
204#ifndef CONFIG_BT_NIMBLE_ROLE_BROADCASTER
205#ifndef CONFIG_BT_NIMBLE_ROLE_BROADCASTER_DISABLED
206#define CONFIG_BT_NIMBLE_ROLE_BROADCASTER 1
207#else
208#define CONFIG_BT_NIMBLE_ROLE_BROADCASTER 0
209#endif
210#endif
211
212#ifndef CONFIG_BT_NIMBLE_PINNED_TO_CORE
213#define CONFIG_BT_NIMBLE_PINNED_TO_CORE 0
214#endif
215
216#ifndef CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE
217#define CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE 4096
218#endif
219
220#ifndef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL
221#define CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL 1
222#endif
223
224#ifndef CONFIG_BT_NIMBLE_MAX_CONNECTIONS
225#define CONFIG_BT_NIMBLE_MAX_CONNECTIONS 3
226#endif
227
228// bugfix: max connections macro renamed upstream
229#ifndef CONFIG_NIMBLE_MAX_CONNECTIONS
230#define CONFIG_NIMBLE_MAX_CONNECTIONS CONFIG_BT_NIMBLE_MAX_CONNECTIONS
231#endif
232
233#ifndef CONFIG_BT_NIMBLE_MAX_BONDS
234#define CONFIG_BT_NIMBLE_MAX_BONDS 3
235#endif
236
237#ifndef CONFIG_BT_NIMBLE_MAX_CCCDS
238#define CONFIG_BT_NIMBLE_MAX_CCCDS 8
239#endif
240
241#ifndef CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME
242#define CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME "nimble"
243#endif
244
245#ifndef CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU
246#define CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU 255
247#endif
248
249#ifndef CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE
250#define CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE 0x0
251#endif
252
253#ifdef CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT // backward compatibility
254#define MYNEWT_VAL_MSYS_1_BLOCK_COUNT CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT
255#else
256#define MYNEWT_VAL_MSYS_1_BLOCK_COUNT 12
257#endif
258
259#ifndef CONFIG_BT_NIMBLE_MSYS_1_BLOCK_SIZE
260#define CONFIG_BT_NIMBLE_MSYS_1_BLOCK_SIZE 256
261#endif
262
263#ifndef CONFIG_BT_NIMBLE_RPA_TIMEOUT
264#define CONFIG_BT_NIMBLE_RPA_TIMEOUT 900
265#endif
266
267#ifndef CONFIG_BT_NIMBLE_LOG_LEVEL
268#define CONFIG_BT_NIMBLE_LOG_LEVEL 5
269#endif
270
272#ifndef CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
273#define CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM 0
274#endif
275
277#define CONFIG_BT_NIMBLE_NVS_PERSIST 1
278
280#define CONFIG_BT_NIMBLE_SM_LEGACY 1
281
283#define CONFIG_BT_NIMBLE_SM_SC 1
284
286#define CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN 31
287
289#ifndef CONFIG_BT_NIMBLE_TRANSPORT_ACL_FROM_LL_COUNT
290#define CONFIG_BT_NIMBLE_TRANSPORT_ACL_FROM_LL_COUNT 12
291#endif
292
294#define CONFIG_BT_NIMBLE_TRANSPORT_ACL_SIZE 255
295
297#if CONFIG_BT_NIMBLE_EXT_ADV
298# define CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE 257
299#else
300# define CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE 70
301#endif
302
304#define CONFIG_BT_NIMBLE_TRANSPORT_EVT_COUNT 30
305
307#define CONFIG_BT_NIMBLE_TRANSPORT_EVT_DISCARD_COUNT 8
308
309#define CONFIG_BT_NIMBLE_L2CAP_COC_SDU_BUFF_COUNT 1
310#define CONFIG_BT_NIMBLE_EATT_CHAN_NUM 0
311#define CONFIG_BT_NIMBLE_SVC_GAP_CENT_ADDR_RESOLUTION -1
312#define CONFIG_BT_NIMBLE_GATT_MAX_PROCS 4
313#define CONFIG_BT_NIMBLE_HS_STOP_TIMEOUT_MS 2000
314
315#ifndef CONFIG_BT_ENABLED
316#define CONFIG_BT_ENABLED
317#endif
318
319#ifndef CONFIG_BT_NIMBLE_ENABLED
320#define CONFIG_BT_NIMBLE_ENABLED 1
321#endif
322
323#ifndef CONFIG_BT_CONTROLLER_ENABLED
324#define CONFIG_BT_CONTROLLER_ENABLED 1
325#endif
326
327#ifndef CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS
328#define CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS 0
329#endif
330
331#ifndef MYNEWT_VAL_BLE_CRYPTO_STACK_MBEDTLS
332#define MYNEWT_VAL_BLE_CRYPTO_STACK_MBEDTLS (CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS)
333#endif
334
335#ifdef ESP_PLATFORM
336#ifndef CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY
337#define CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY
338#endif
339
340#ifndef CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE
341#define CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE 0
342#endif
343
344#ifndef CONFIG_BTDM_SCAN_DUPL_TYPE_DATA
345#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA 1
346#endif
347
348#ifndef CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE
349#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE 2
350#endif
351
352#if !defined(CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE) && defined(CONFIG_IDF_TARGET_ESP32) || \
353defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
354#define CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE 1
355#endif
356
357#ifdef CONFIG_IDF_TARGET_ESP32
358#define CONFIG_BT_NIMBLE_HS_FLOW_CTRL 1
359#define CONFIG_BT_NIMBLE_HS_FLOW_CTRL_ITVL 1000
360#define CONFIG_BT_NIMBLE_HS_FLOW_CTRL_THRESH 2
361#define CONFIG_BT_NIMBLE_HS_FLOW_CTRL_TX_ON_DISCONNECT 1
362#endif
363
364#if !defined(CONFIG_BT_CONTROLLER_DISABLED)
365#define CONFIG_BT_CONTROLLER_DISABLED 0
366#endif
367
368#if CONFIG_BT_NIMBLE_EXT_ADV || CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV
369# if defined(CONFIG_IDF_TARGET_ESP32)
370# error Extended advertising is not supported on ESP32.
371# endif
372#endif
373
374#ifndef CONFIG_BT_NIMBLE_USE_ESP_TIMER
375#define CONFIG_BT_NIMBLE_USE_ESP_TIMER 1
376#endif
377
378#ifndef CONFIG_BT_NIMBLE_WHITELIST_SIZE
379#define CONFIG_BT_NIMBLE_WHITELIST_SIZE 12
380#endif
381
382#endif // ESP_PLATFORM
383
384#if CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV && !CONFIG_BT_NIMBLE_EXT_ADV
385# error Extended advertising must be enabled to use periodic advertising.
386#endif
387
388/* Must have max instances and data length set if extended advertising is enabled */
389#if CONFIG_BT_NIMBLE_EXT_ADV
390# if !defined(CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES)
391# define CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES 1
392# endif
393# if !defined(CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN)
394# define CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN 251
395# endif
396#endif
397
398/* Must set max number of syncs if periodic advertising is enabled */
399#if CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV && !defined(CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS)
400# define CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS 1
401#endif
402
403/* Enables the use of Arduino String class for attribute values */
404#if defined __has_include
405# if __has_include (<Arduino.h>)
406# define NIMBLE_CPP_ARDUINO_STRING_AVAILABLE
407# endif
408#endif
409
410#ifndef CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED
411#define CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED 0
412#endif
413
414#ifndef CONFIG_NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT
415#define CONFIG_NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT 31
416#endif
417
418#if CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED && !defined NDEBUG
419void nimble_cpp_assert(const char *file, unsigned line) __attribute((weak, noreturn));
420# define NIMBLE_ATT_VAL_FILE (__builtin_strrchr(__FILE__, '/') ? \
421 __builtin_strrchr (__FILE__, '/') + 1 : __FILE__)
422# define NIMBLE_CPP_DEBUG_ASSERT(cond) \
423 if (!(cond)) { \
424 nimble_cpp_assert(NIMBLE_ATT_VAL_FILE, __LINE__); \
425 }
426#else
427# define NIMBLE_CPP_DEBUG_ASSERT(cond) (void(0))
428#endif