kopia lustrzana https://github.com/espressif/esp-idf
Blufi [Nimble] Add fix to crash while running blufi on ESP32C3
A race condition is occuring while creating task on ESP32C3. Task is getting created, but the function returns with a delay. Since task was created, events start getting posted, but existing application initializes certain threads / callbacks after stack initialization. The same application works in different ways for bluedroid and nimble. Hence modified the order during initialization accordingly.pull/7680/head
rodzic
bc3c9d27f6
commit
351653f6b3
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
Ładowanie…
Reference in New Issue