Warning

This document is not updated for ESP32H4 yet, so some of the content may not be correct.

This warning was automatically inserted due to the source file being in the add_warnings_pages list.

# Bluetooth® Main API

## API Reference

### Header File

- components/bt/host/bluedroid/api/include/api/esp_bt_main.h

- This header file can be included with:

  >     #include "esp_bt_main.h"

- This header file is a part of the API provided by the `bt` component. To declare that your component depends on `bt`, add the following to your CMakeLists.txt:

  >     REQUIRES bt

  > or

  >     PRIV_REQUIRES bt

### Functions

esp_bluedroid_status_t esp_bluedroid_get_status(void)

  Get bluetooth stack status.

  Returns:

    Bluetooth stack status

esp_err_t esp_bluedroid_enable(void)

  Enable bluetooth, must after esp_bluedroid_init_with_cfg().

  Returns:

    - ESP_OK : Succeed

    - Other : Failed

esp_err_t esp_bluedroid_disable(void)

  Disable Bluetooth, must be called prior to esp_bluedroid_deinit().

  Note

  Before calling this API, ensure that all activities related to the application, such as connections, scans, etc., are properly closed.

  Returns:

    - ESP_OK : Succeed

    - Other : Failed

esp_err_t esp_bluedroid_init(void)

  Init and alloc the resource for bluetooth, must be prior to every bluetooth stuff.

  Returns:

    - ESP_OK : Succeed

    - Other : Failed

esp_err_t esp_bluedroid_init_with_cfg(esp_bluedroid_config_t *cfg)

  Init and alloc the resource for bluetooth, must be prior to every bluetooth stuff.

  Parameters:

    cfg -- Initial configuration of ESP Bluedroid stack.

  Returns:

    - ESP_OK : Succeed

    - Other : Failed

esp_err_t esp_bluedroid_deinit(void)

  Deinit and free the resource for bluetooth, must be after every bluetooth stuff.

  Returns:

    - ESP_OK : Succeed

    - Other : Failed

### Structures

struct esp_bluedroid_config_t

  Bluetooth stack configuration.

  Public Members

  bool ssp_en

    Whether SSP(secure simple pairing) or legacy pairing is used for Classic Bluetooth

  bool sc_en

    Whether secure connection host support is enabled or disabled for Classic Bluetooth

### Macros

BT_BLUEDROID_INIT_CONFIG_DEFAULT()

### Enumerations

enum esp_bluedroid_status_t

  Bluetooth stack status type, to indicate whether the bluetooth stack is ready.

  Values:

  enumerator ESP_BLUEDROID_STATUS_UNINITIALIZED

    Bluetooth stack is not initialized

  enumerator ESP_BLUEDROID_STATUS_INITIALIZED

    Bluetooth stack is initialized but not yet enabled

  enumerator ESP_BLUEDROID_STATUS_ENABLED

    Bluetooth stack is fully initialized and enabled

  enumerator ESP_BLUEDROID_STATUS_DISABLING

    Bluetooth stack is in the process of being disabled

Was this page helpful?

- Thank you! We received your feedback.
- If you have any comments, fill in Espressif Documentation Feedback Form.

- We value your feedback.
- Let us know how we can improve this page by filling in Espressif Documentation Feedback Form.