Merge branch 'bugfix/fix_blufi_init_crash_c3_v4.3' into 'release/v4.3'

Blufi [Nimble] Add fix to crash while running blufi on ESP32C3 (v4.3)

See merge request espressif/esp-idf!15219
This commit is contained in:
Jiang Jiang Jian 2021-09-23 07:44:12 +00:00
commit 1c1572ed51
3 changed files with 63 additions and 21 deletions

View File

@ -13,3 +13,4 @@ int blufi_security_init(void);
void blufi_security_deinit(void);
int esp_blufi_gap_register_callback(void);
esp_err_t esp_blufi_host_init(void);
esp_err_t esp_blufi_host_and_cb_init(esp_blufi_callbacks_t *callbacks);

View File

@ -385,23 +385,11 @@ void app_main(void)
return;
}
ret = esp_blufi_host_init();
ret = esp_blufi_host_and_cb_init(&example_callbacks);
if (ret) {
BLUFI_ERROR("%s initialise host failed: %s\n", __func__, esp_err_to_name(ret));
BLUFI_ERROR("%s initialise failed: %s\n", __func__, esp_err_to_name(ret));
return;
}
BLUFI_INFO("BLUFI VERSION %04x\n", esp_blufi_get_version());
ret = esp_blufi_register_callbacks(&example_callbacks);
if(ret){
BLUFI_ERROR("%s blufi register failed, error code = %x\n", __func__, ret);
return;
}
ret = esp_blufi_gap_register_callback();
if(ret){
BLUFI_ERROR("%s gap register failed, error code = %x\n", __func__, ret);
return;
}
}

View File

@ -3,10 +3,10 @@
#include "esp_blufi_api.h"
#include "esp_log.h"
#include "esp_blufi.h"
#include "blufi_example.h"
#ifdef CONFIG_BT_BLUEDROID_ENABLED
#include "esp_bt.h"
#include "esp_bt_main.h"
#include "blufi_example.h"
#include "esp_bt_device.h"
#endif
@ -42,15 +42,40 @@ esp_err_t esp_blufi_host_init(void)
}
int esp_blufi_gap_register_callback(void)
esp_err_t esp_blufi_gap_register_callback(void)
{
int rc;
rc = esp_ble_gap_register_callback(esp_blufi_gap_event_handler);
if(rc){
return rc;
}
esp_blufi_profile_init();
return 0;
return esp_blufi_profile_init();
}
esp_err_t esp_blufi_host_and_cb_init(esp_blufi_callbacks_t *example_callbacks)
{
esp_err_t ret = ESP_OK;
ret = esp_blufi_host_init();
if (ret) {
BLUFI_ERROR("%s initialise host failed: %s\n", __func__, esp_err_to_name(ret));
return ret;
}
ret = esp_blufi_register_callbacks(example_callbacks);
if(ret){
BLUFI_ERROR("%s blufi register failed, error code = %x\n", __func__, ret);
return ret;
}
ret = esp_blufi_gap_register_callback();
if(ret){
BLUFI_ERROR("%s gap register failed, error code = %x\n", __func__, ret);
return ret;
}
return ESP_OK;
}
#endif /* CONFIG_BT_BLUEDROID_ENABLED */
@ -115,14 +140,42 @@ esp_err_t esp_blufi_host_init(void)
/* XXX Need to have template for store */
ble_store_config_init();
nimble_port_freertos_init(bleprph_host_task);
esp_blufi_btc_init();
nimble_port_freertos_init(bleprph_host_task);
return ESP_OK;
}
int esp_blufi_gap_register_callback(void)
esp_err_t esp_blufi_gap_register_callback(void)
{
return 0;
return ESP_OK;
}
esp_err_t esp_blufi_host_and_cb_init(esp_blufi_callbacks_t *example_callbacks)
{
esp_err_t ret = ESP_OK;
ret = esp_blufi_register_callbacks(example_callbacks);
if(ret){
BLUFI_ERROR("%s blufi register failed, error code = %x\n", __func__, ret);
return ret;
}
ret = esp_blufi_gap_register_callback();
if(ret){
BLUFI_ERROR("%s gap register failed, error code = %x\n", __func__, ret);
return ret;
}
ret = esp_blufi_host_init();
if (ret) {
BLUFI_ERROR("%s initialise host failed: %s\n", __func__, esp_err_to_name(ret));
return ret;
}
return ret;
}
#endif /* CONFIG_BT_NIMBLE_ENABLED */