pub unsafe extern "C" fn esp_bt_mem_release(mode: u32) -> i32Expand description
@brief Release the Controller memory, BSS and data section of the BLE Host stack as per the mode
@note
- This function is optional and should be called only if you want to free up memory for other components.
- This function should only be called when the Controller is in
ESP_BT_CONTROLLER_STATUS_IDLEstatus. - Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function.
- If your firmware will upgrade the Bluetooth Controller mode later (such as from disabled to enabled), then do not call this function.
This function first releases Controller memory by internally calling esp_bt_controller_mem_release(), then releases Host memory.
If you never intend to use Bluetooth in a current boot-up cycle, calling esp_bt_mem_release(ESP_BT_MODE_BLE) could release the BSS and data consumed by BLE stack to heap.
For example, if you only use Bluetooth for setting the Wi-Fi configuration, and do not use Bluetooth in the rest of the product operation, after receiving the Wi-Fi configuration, you can disable/de-init Bluetooth and release its memory. Below is the sequence of APIs to be called for such scenarios:
esp_bluedroid_disable();
esp_bluedroid_deinit();
esp_bt_controller_disable();
esp_bt_controller_deinit();
esp_bt_mem_release(ESP_BT_MODE_BLE);@param[in] mode The Bluetooth Controller mode
@return - ESP_OK: Success - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state - ESP_ERR_NOT_FOUND: Requested resource not found