Skip to content

Commit

Permalink
Unify controller internal error code on ESP32-C2
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoweiliang2021 authored and ChrysalisChenJ committed Dec 9, 2022
1 parent 5c481c5 commit de7e62f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
18 changes: 10 additions & 8 deletions components/bt/controller/esp32c2/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,18 +597,20 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)

if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
return ESP_FAIL;
return ESP_ERR_INVALID_STATE;
}
if (cfg == NULL) {

if (!cfg) {
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "cfg is NULL");
return ESP_ERR_INVALID_ARG;
}

ble_rtc_clk_init();

if (esp_register_ext_funcs(&ext_funcs_ro) != 0) {
ret = esp_register_ext_funcs(&ext_funcs_ro);
if (ret != ESP_OK) {
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "register extend functions failed");
return ESP_ERR_INVALID_ARG;
return ret;
}

/* Initialize the function pointers for OS porting */
Expand All @@ -619,9 +621,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
return ESP_ERR_INVALID_ARG;
}

if (esp_register_npl_funcs(p_npl_funcs) != 0) {
ret = esp_register_npl_funcs(p_npl_funcs);
if (ret != ESP_OK) {
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "npl functions register failed");
ret = ESP_ERR_INVALID_ARG;
goto free_mem;
}

Expand All @@ -632,9 +634,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
}

/* Initialize the global memory pool */
if (os_msys_buf_alloc() != 0) {
ret = os_msys_buf_alloc();
if (ret != ESP_OK) {
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "os msys alloc failed");
ret = ESP_ERR_INVALID_ARG;
goto free_mem;
}

Expand Down
2 changes: 1 addition & 1 deletion components/bt/controller/lib_esp32c2/esp32c2-bt-lib
4 changes: 2 additions & 2 deletions components/bt/porting/nimble/src/os_msys_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ os_msys_buf_alloc(void)
#if OS_MSYS_1_BLOCK_COUNT > 0
os_msys_init_1_data = (os_membuf_t *)bt_osi_mem_calloc(1, (sizeof(os_membuf_t) * SYSINIT_MSYS_1_MEMPOOL_SIZE));
if (!os_msys_init_1_data) {
return ESP_FAIL;
return ESP_ERR_NO_MEM;
}
#endif

Expand All @@ -152,7 +152,7 @@ os_msys_buf_alloc(void)
bt_osi_mem_free(os_msys_init_1_data);
os_msys_init_1_data = NULL;
#endif
return ESP_FAIL;
return ESP_ERR_NO_MEM;
}
#endif

Expand Down

0 comments on commit de7e62f

Please sign in to comment.