mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
components/bt: Shutdown Bluetooth before esp_restart.
This commit is contained in:
parent
41efdb0b34
commit
862f335f05
@ -1387,6 +1387,23 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void bt_shutdown(void)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ESP_LOGD(BTDM_LOG_TAG, "stop/deinit bt");
|
||||
|
||||
ret = esp_bt_controller_disable();
|
||||
if (ESP_OK != ret) {
|
||||
ESP_LOGW(BTDM_LOG_TAG, "controller disable ret=%d", ret);
|
||||
}
|
||||
ret = esp_bt_controller_deinit();
|
||||
if (ESP_OK != ret) {
|
||||
ESP_LOGW(BTDM_LOG_TAG, "controller deinit ret=%d", ret);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
{
|
||||
int ret;
|
||||
@ -1450,6 +1467,10 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
}
|
||||
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED;
|
||||
ret = esp_register_shutdown_handler(bt_shutdown);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(BTDM_LOG_TAG, "Register shutdown handler failed, ret = 0x%x", ret);
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@ -1480,6 +1501,7 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
}
|
||||
esp_phy_rf_deinit(PHY_BT_MODULE);
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
esp_unregister_shutdown_handler(bt_shutdown);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
|
@ -44,7 +44,7 @@ static const char* TAG = "system_api";
|
||||
|
||||
static uint8_t base_mac_addr[6] = { 0 };
|
||||
|
||||
#define SHUTDOWN_HANDLERS_NO 2
|
||||
#define SHUTDOWN_HANDLERS_NO 3
|
||||
static shutdown_handler_t shutdown_handlers[SHUTDOWN_HANDLERS_NO];
|
||||
|
||||
esp_err_t esp_base_mac_addr_set(uint8_t *mac)
|
||||
|
Loading…
Reference in New Issue
Block a user