NimBLE-Arduino 2.3.2
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 CONFIG_BT_NIMBLE_MSYS_1_BLOCK_COUNT CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT
255#elif !defined(CONFIG_BT_NIMBLE_MSYS_1_BLOCK_COUNT)
256#define CONFIG_BT_NIMBLE_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#define CONFIG_BT_NIMBLE_TRANSPORT_ACL_FROM_LL_COUNT 12
290
292#define CONFIG_BT_NIMBLE_TRANSPORT_ACL_SIZE 255
293
295#if CONFIG_BT_NIMBLE_EXT_ADV
296# define CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE 257
297#else
298# define CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE 70
299#endif
300
302#define CONFIG_BT_NIMBLE_TRANSPORT_EVT_COUNT 30
303
305#define CONFIG_BT_NIMBLE_TRANSPORT_EVT_DISCARD_COUNT 8
306
307#define CONFIG_BT_NIMBLE_L2CAP_COC_SDU_BUFF_COUNT 1
308#define CONFIG_BT_NIMBLE_EATT_CHAN_NUM 0
309#define CONFIG_BT_NIMBLE_SVC_GAP_CENT_ADDR_RESOLUTION -1
310#define CONFIG_BT_NIMBLE_GATT_MAX_PROCS 4
311#define CONFIG_BT_NIMBLE_HS_STOP_TIMEOUT_MS 2000
312
313#ifndef CONFIG_BT_ENABLED
314#define CONFIG_BT_ENABLED
315#endif
316
317#ifndef CONFIG_BT_NIMBLE_ENABLED
318#define CONFIG_BT_NIMBLE_ENABLED 1
319#endif
320
321#ifndef CONFIG_BT_CONTROLLER_ENABLED
322#define CONFIG_BT_CONTROLLER_ENABLED 1
323#endif
324
325#ifndef CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS
326#define CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS 0
327#endif
328
329#ifndef MYNEWT_VAL_BLE_CRYPTO_STACK_MBEDTLS
330#define MYNEWT_VAL_BLE_CRYPTO_STACK_MBEDTLS (CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS)
331#endif
332
333#ifdef ESP_PLATFORM
334#ifndef CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY
335#define CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY
336#endif
337
338#ifndef CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE
339#define CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE 0
340#endif
341
342#ifndef CONFIG_BTDM_SCAN_DUPL_TYPE_DATA
343#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA 1
344#endif
345
346#ifndef CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE
347#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE 2
348#endif
349
350#if !defined(CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE) && defined(CONFIG_IDF_TARGET_ESP32) || \
351defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
352#define CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE 1
353#endif
354
355#ifdef CONFIG_IDF_TARGET_ESP32
356#define CONFIG_BT_NIMBLE_HS_FLOW_CTRL 1
357#define CONFIG_BT_NIMBLE_HS_FLOW_CTRL_ITVL 1000
358#define CONFIG_BT_NIMBLE_HS_FLOW_CTRL_THRESH 2
359#define CONFIG_BT_NIMBLE_HS_FLOW_CTRL_TX_ON_DISCONNECT 1
360#endif
361
362#if !defined(CONFIG_BT_CONTROLLER_DISABLED)
363#define CONFIG_BT_CONTROLLER_DISABLED 0
364#endif
365
366#if CONFIG_BT_NIMBLE_EXT_ADV || CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV
367# if defined(CONFIG_IDF_TARGET_ESP32)
368# error Extended advertising is not supported on ESP32.
369# endif
370#endif
371
372#ifndef CONFIG_BT_NIMBLE_USE_ESP_TIMER
373#define CONFIG_BT_NIMBLE_USE_ESP_TIMER 1
374#endif
375
376#ifndef CONFIG_BT_NIMBLE_WHITELIST_SIZE
377#define CONFIG_BT_NIMBLE_WHITELIST_SIZE 12
378#endif
379
380#endif // ESP_PLATFORM
381
382#if CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV && !CONFIG_BT_NIMBLE_EXT_ADV
383# error Extended advertising must be enabled to use periodic advertising.
384#endif
385
386/* Must have max instances and data length set if extended advertising is enabled */
387#if CONFIG_BT_NIMBLE_EXT_ADV
388# if !defined(CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES)
389# define CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES 1
390# endif
391# if !defined(CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN)
392# define CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN 251
393# endif
394#endif
395
396/* Must set max number of syncs if periodic advertising is enabled */
397#if CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV && !defined(CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS)
398# define CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS 1
399#endif
400
401/* Enables the use of Arduino String class for attribute values */
402#if defined __has_include
403# if __has_include (<Arduino.h>)
404# define NIMBLE_CPP_ARDUINO_STRING_AVAILABLE
405# endif
406#endif
407
408#ifndef CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED
409#define CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED 0
410#endif
411
412#ifndef CONFIG_NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT
413#define CONFIG_NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT 31
414#endif
415
416#if CONFIG_NIMBLE_CPP_DEBUG_ASSERT_ENABLED && !defined NDEBUG
417void nimble_cpp_assert(const char *file, unsigned line) __attribute((weak, noreturn));
418# define NIMBLE_ATT_VAL_FILE (__builtin_strrchr(__FILE__, '/') ? \
419 __builtin_strrchr (__FILE__, '/') + 1 : __FILE__)
420# define NIMBLE_CPP_DEBUG_ASSERT(cond) \
421 if (!(cond)) { \
422 nimble_cpp_assert(NIMBLE_ATT_VAL_FILE, __LINE__); \
423 }
424#else
425# define NIMBLE_CPP_DEBUG_ASSERT(cond) (void(0))
426#endif