蓝牙初始化时esp_bt_controller_mem_release()函数的理解
Posted: Mon Jan 30, 2023 4:18 am
根据Blufi例程里的代码,esp_bt_controller_mem_release release the controller memory as per the mode。如果选用BLE模式就要在初始化之前先释放CLASSIC模式的内存,这个方式逻辑上有点不好理解。都还未被初始化,何须来释放?如果是用BLE模式,来初始化BLE内存是否更合理?
Code: Select all
void app_main(void)
{
esp_err_t ret;
// Initialize NVS
ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK( ret );
initialise_wifi();
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
ret = esp_bt_controller_init(&bt_cfg);
if (ret) {
BLUFI_ERROR("%s initialize bt controller failed: %s\n", __func__, esp_err_to_name(ret));
}
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
if (ret) {
BLUFI_ERROR("%s enable bt controller failed: %s\n", __func__, esp_err_to_name(ret));
return;
}
ret = esp_blufi_host_and_cb_init(&example_callbacks);
if (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());
}