Skip to content

Commit

Permalink
not crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
h2zero committed Jun 12, 2024
1 parent 2aebb92 commit 88d8541
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 33 deletions.
4 changes: 3 additions & 1 deletion src/NimBLEDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,12 @@ void NimBLEDevice::init(const std::string &deviceName) {

esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT);

#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) || !defined(CONFIG_NIMBLE_CPP_IDF)
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
# if defined (CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
bt_cfg.bluetooth_mode = ESP_BT_MODE_BLE;
# elif defined (CONFIG_IDF_TARGET_ESP32C6)
bt_cfg.nimble_max_connections = CONFIG_BT_NIMBLE_MAX_CONNECTIONS;
# else
bt_cfg.mode = ESP_BT_MODE_BLE;
bt_cfg.ble_max_conn = CONFIG_BT_NIMBLE_MAX_CONNECTIONS;
Expand Down
7 changes: 4 additions & 3 deletions src/nimble/porting/nimble/src/nimble_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ esp_err_t esp_nimble_init(void)
/* Initialize the function pointers for OS porting */
npl_freertos_funcs_init();

npl_freertos_mempool_init();
npl_freertos_mempool_init_ovr();
#endif

#if false // Arduino disabled
Expand All @@ -118,7 +118,8 @@ esp_err_t esp_nimble_init(void)
os_msys_init();

#else
ble_npl_eventq_init(&g_eventq_dflt);
npl_freertos_mempool_init_ovr();
ble_npl_eventq_init(nimble_port_get_dflt_eventq());
#endif

/* Initialize the host */
Expand Down Expand Up @@ -201,7 +202,7 @@ nimble_port_init(void)
/* Initialize the function pointers for OS porting */
npl_freertos_funcs_init();

npl_freertos_mempool_init();
npl_freertos_mempool_init_ovr();
#endif
/* Initialize default event queue */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ UBaseType_t nimble_port_freertos_get_hs_hwm(void);
#if CONFIG_NIMBLE_STACK_USE_MEM_POOLS
void npl_freertos_funcs_init(void);
void npl_freertos_funcs_deinit(void);
int npl_freertos_mempool_init(void);
int npl_freertos_mempool_init_ovr(void);
struct npl_funcs_t * npl_freertos_funcs_get(void);
#endif

Expand Down
Loading

0 comments on commit 88d8541

Please sign in to comment.