Merge branch 'feature/add_new_bluedroid_init' into 'master'

Feat(bt/bluedroid): Add new ESP Bluedroid stack init API

Closes BTQABR2023-32

See merge request espressif/esp-idf!25248
This commit is contained in:
Wang Meng Yang 2023-09-04 11:24:44 +08:00
commit 78af508654
93 changed files with 820 additions and 520 deletions

View File

@ -108,7 +108,8 @@ if(CONFIG_BT_ENABLED)
host/bluedroid/stack/a2dp/include
host/bluedroid/stack/rfcomm/include
host/bluedroid/stack/include
host/bluedroid/common/include)
host/bluedroid/common/include
host/bluedroid/config/include)
list(APPEND include_dirs host/bluedroid/api/include/api)
@ -364,7 +365,8 @@ if(CONFIG_BT_ENABLED)
"host/bluedroid/stack/smp/smp_keys.c"
"host/bluedroid/stack/smp/smp_l2c.c"
"host/bluedroid/stack/smp/smp_main.c"
"host/bluedroid/stack/smp/smp_utils.c")
"host/bluedroid/stack/smp/smp_utils.c"
"host/bluedroid/config/stack_config.c")
list(APPEND srcs "common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c")

View File

@ -135,14 +135,6 @@ choice BT_HID_ROLE
This enables the BT HID Device
endchoice
config BT_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
config BT_BLE_ENABLED
bool "Bluetooth Low Energy"
depends on BT_BLUEDROID_ENABLED

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -11,6 +11,7 @@
#include "esp_bt.h"
#include "osi/future.h"
#include "osi/allocator.h"
#include "config/stack_config.h"
static bool bd_already_enable = false;
static bool bd_already_init = false;
@ -106,11 +107,22 @@ esp_err_t esp_bluedroid_disable(void)
}
esp_err_t esp_bluedroid_init(void)
{
esp_bluedroid_config_t cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
return esp_bluedroid_init_with_cfg(&cfg);
}
esp_err_t esp_bluedroid_init_with_cfg(esp_bluedroid_config_t *cfg)
{
btc_msg_t msg;
future_t **future_p;
bt_status_t ret;
if (!cfg) {
LOG_ERROR("%s cfg is NULL", __func__);
return ESP_ERR_INVALID_ARG;
}
if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_ENABLED) {
LOG_ERROR("Controller not initialised\n");
return ESP_ERR_INVALID_STATE;
@ -125,9 +137,15 @@ esp_err_t esp_bluedroid_init(void)
osi_mem_dbg_init();
#endif
ret = bluedriod_config_init(cfg);
if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("Bluedroid stack initialize fail, ret:%d", ret);
return ESP_FAIL;
}
/*
* BTC Init
*/
* BTC Init
*/
ret = btc_init();
if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("Bluedroid Initialize Fail");
@ -199,6 +217,8 @@ esp_err_t esp_bluedroid_deinit(void)
btc_deinit();
bluedriod_config_deinit();
bd_already_init = false;
return ESP_OK;

View File

@ -8,14 +8,18 @@
#include <string.h>
#include "esp_bt_main.h"
#include "esp_gap_bt_api.h"
#include "esp_log.h"
#include "common/bt_trace.h"
#include "bta/bta_api.h"
#include "btc/btc_manage.h"
#include "btc_gap_bt.h"
#include "btc/btc_storage.h"
#include "config/stack_config.h"
#if (BTC_GAP_BT_INCLUDED == TRUE)
#define TAG "BT_GAP"
esp_err_t esp_bt_gap_register_callback(esp_bt_gap_cb_t callback)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
@ -307,7 +311,6 @@ esp_err_t esp_bt_gap_pin_reply(esp_bd_addr_t bd_addr, bool accept, uint8_t pin_c
btc_gap_bt_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if (BT_SSP_INCLUDED == TRUE)
esp_err_t esp_bt_gap_set_security_param(esp_bt_sp_param_t param_type,
void *value, uint8_t len)
{
@ -318,6 +321,11 @@ esp_err_t esp_bt_gap_set_security_param(esp_bt_sp_param_t param_type,
return ESP_ERR_INVALID_STATE;
}
if (!(bluedriod_config_get()->get_ssp_enabled())) {
ESP_LOGE(TAG, "%s is not supported when `ssp_en` in `esp_bluedroid_config_t` is disabled!", __func__);
return ESP_ERR_NOT_SUPPORTED;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_ACT_SET_SECURITY_PARAM;
@ -338,6 +346,11 @@ esp_err_t esp_bt_gap_ssp_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint3
return ESP_ERR_INVALID_STATE;
}
if (!(bluedriod_config_get()->get_ssp_enabled())) {
ESP_LOGE(TAG, "%s is not supported when `ssp_en` in `esp_bluedroid_config_t` is disabled!", __func__);
return ESP_ERR_NOT_SUPPORTED;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_ACT_PASSKEY_REPLY;
@ -357,6 +370,11 @@ esp_err_t esp_bt_gap_ssp_confirm_reply(esp_bd_addr_t bd_addr, bool accept)
return ESP_ERR_INVALID_STATE;
}
if (!(bluedriod_config_get()->get_ssp_enabled())) {
ESP_LOGE(TAG, "%s is not supported when `ssp_en` in `esp_bluedroid_config_t` is disabled!", __func__);
return ESP_ERR_NOT_SUPPORTED;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_ACT_CONFIRM_REPLY;
@ -366,8 +384,6 @@ esp_err_t esp_bt_gap_ssp_confirm_reply(esp_bd_addr_t bd_addr, bool accept)
btc_gap_bt_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /*(BT_SSP_INCLUDED == TRUE)*/
esp_err_t esp_bt_gap_set_afh_channels(esp_bt_gap_afh_channels channels)
{
btc_msg_t msg;

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -7,6 +7,9 @@
#ifndef __ESP_BT_MAIN_H__
#define __ESP_BT_MAIN_H__
#include <stdbool.h>
#include <stdint.h>
#include "esp_err.h"
#ifdef __cplusplus
@ -22,6 +25,18 @@ typedef enum {
ESP_BLUEDROID_STATUS_ENABLED /*!< Bluetooth initialized and enabled */
} esp_bluedroid_status_t;
/**
* @brief Bluetooth stack configuration
*/
typedef struct {
bool ssp_en; /*!< Whether SSP(secure simple pairing) or legacy pairing is used for Classic Bluetooth */
} esp_bluedroid_config_t;
#define BT_BLUEDROID_INIT_CONFIG_DEFAULT() \
{ \
.ssp_en = true, \
}
/**
* @brief Get bluetooth stack status
*
@ -31,7 +46,7 @@ typedef enum {
esp_bluedroid_status_t esp_bluedroid_get_status(void);
/**
* @brief Enable bluetooth, must after esp_bluedroid_init().
* @brief Enable bluetooth, must after esp_bluedroid_init()/esp_bluedroid_init_with_cfg().
*
* @return
* - ESP_OK : Succeed
@ -55,7 +70,18 @@ esp_err_t esp_bluedroid_disable(void);
* - ESP_OK : Succeed
* - Other : Failed
*/
esp_err_t esp_bluedroid_init(void);
esp_err_t esp_bluedroid_init(void) __attribute__((deprecated("Please use esp_bluedroid_init_with_cfg")));
/**
* @brief Init and alloc the resource for bluetooth, must be prior to every bluetooth stuff.
*
* @param cfg Initial configuration of ESP Bluedroid stack.
*
* @return
* - ESP_OK : Succeed
* - Other : Failed
*/
esp_err_t esp_bluedroid_init_with_cfg(esp_bluedroid_config_t *cfg);
/**
* @brief Deinit and free the resource for bluetooth, must be after every bluetooth stuff.

View File

@ -709,7 +709,6 @@ esp_err_t esp_bt_gap_set_pin(esp_bt_pin_type_t pin_type, uint8_t pin_code_len, e
*/
esp_err_t esp_bt_gap_pin_reply(esp_bd_addr_t bd_addr, bool accept, uint8_t pin_code_len, esp_bt_pin_code_t pin_code);
#if (BT_SSP_INCLUDED == TRUE)
/**
* @brief Set a GAP security parameter value. Overrides the default value.
*
@ -758,8 +757,6 @@ esp_err_t esp_bt_gap_ssp_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint3
*/
esp_err_t esp_bt_gap_ssp_confirm_reply(esp_bd_addr_t bd_addr, bool accept);
#endif /*(BT_SSP_INCLUDED == TRUE)*/
/**
* @brief Set the AFH channels
*

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*
@ -277,9 +277,10 @@ typedef void (*esp_hd_cb_t)(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *para
esp_err_t esp_bt_hid_device_register_callback(esp_hd_cb_t callback);
/**
* @brief Initializes HIDD interface. This function should be called after esp_bluedroid_init() and
* esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_register_callback.
* When the operation is complete, the callback function will be called with ESP_HIDD_INIT_EVT.
* @brief Initializes HIDD interface. This function should be called after
* esp_bluedroid_init()/esp_bluedroid_init_with_cfg() and esp_bluedroid_enable() success, and should be
* called after esp_bt_hid_device_register_callback. When the operation is complete, the callback
* function will be called with ESP_HIDD_INIT_EVT.
*
* @return
* - ESP_OK: success
@ -288,9 +289,10 @@ esp_err_t esp_bt_hid_device_register_callback(esp_hd_cb_t callback);
esp_err_t esp_bt_hid_device_init(void);
/**
* @brief De-initializes HIDD interface. This function should be called after esp_bluedroid_init() and
* esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init(). When the
* operation is complete, the callback function will be called with ESP_HIDD_DEINIT_EVT.
* @brief De-initializes HIDD interface. This function should be called after
* esp_bluedroid_init()/esp_bluedroid_init_with_cfg() and esp_bluedroid_enable() success, and should be
* called after esp_bt_hid_device_init(). When the operation is complete, the callback function will be
* called with ESP_HIDD_DEINIT_EVT.
*
* @return
* - ESP_OK: success
@ -300,9 +302,9 @@ esp_err_t esp_bt_hid_device_deinit(void);
/**
* @brief Registers HIDD parameters with SDP and sets l2cap Quality of Service. This function should be
* called after esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after
* esp_bt_hid_device_init(). When the operation is complete, the callback function will be called
* with ESP_HIDD_REGISTER_APP_EVT.
* called after esp_bluedroid_init()/esp_bluedroid_init_with_cfg() and esp_bluedroid_enable() success,
* and should be called after esp_bt_hid_device_init(). When the operation is complete, the callback
* function will be called with ESP_HIDD_REGISTER_APP_EVT.
*
* @param[in] app_param: HIDD parameters
* @param[in] in_qos: incoming QoS parameters
@ -317,9 +319,9 @@ esp_err_t esp_bt_hid_device_register_app(esp_hidd_app_param_t *app_param, esp_hi
/**
* @brief Removes HIDD parameters from SDP and resets l2cap Quality of Service. This function should be
* called after esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after
* esp_bt_hid_device_init(). When the operation is complete, the callback function will be called
* with ESP_HIDD_UNREGISTER_APP_EVT.
* called after esp_bluedroid_init()/esp_bluedroid_init_with_cfg() and esp_bluedroid_enable() success,
* and should be called after esp_bt_hid_device_init(). When the operation is complete, the callback
* function will be called with ESP_HIDD_UNREGISTER_APP_EVT.
*
* @return
* - ESP_OK: success
@ -329,8 +331,9 @@ esp_err_t esp_bt_hid_device_unregister_app(void);
/**
* @brief Connects to the peer HID Host with virtual cable. This function should be called after
* esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init().
* When the operation is complete, the callback function will be called with ESP_HIDD_OPEN_EVT.
* esp_bluedroid_init()/esp_bluedroid_init_with_cfg() and esp_bluedroid_enable() success, and should be
* called after esp_bt_hid_device_init(). When the operation is complete, the callback function will
* be called with ESP_HIDD_OPEN_EVT.
*
* @param[in] bd_addr: Remote host bluetooth device address.
*
@ -342,8 +345,9 @@ esp_err_t esp_bt_hid_device_connect(esp_bd_addr_t bd_addr);
/**
* @brief Disconnects from the currently connected HID Host. This function should be called after
* esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init().
* When the operation is complete, the callback function will be called with ESP_HIDD_CLOSE_EVT.
* esp_bluedroid_init()/esp_bluedroid_init_with_cfg() and esp_bluedroid_enable() success, and should be
* called after esp_bt_hid_device_init(). When the operation is complete, the callback function will
* be called with ESP_HIDD_CLOSE_EVT.
*
* @note The disconnect operation will not remove the virtually cabled device. If the connect request from the
* different HID Host, it will reject the request.
@ -356,8 +360,9 @@ esp_err_t esp_bt_hid_device_disconnect(void);
/**
* @brief Sends HID report to the currently connected HID Host. This function should be called after
* esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init().
* When the operation is complete, the callback function will be called with ESP_HIDD_SEND_REPORT_EVT.
* esp_bluedroid_init()/esp_bluedroid_init_with_cfg() and esp_bluedroid_enable() success, and should be
* called after esp_bt_hid_device_init(). When the operation is complete, the callback function will
* be called with ESP_HIDD_SEND_REPORT_EVT.
*
* @param[in] type: type of report
* @param[in] id: report id as defined by descriptor
@ -372,9 +377,9 @@ esp_err_t esp_bt_hid_device_send_report(esp_hidd_report_type_t type, uint8_t id,
/**
* @brief Sends HID Handshake with error info for invalid set_report to the currently connected HID Host.
* This function should be called after esp_bluedroid_init() and esp_bluedroid_enable() success, and
* should be called after esp_bt_hid_device_init(). When the operation is complete, the callback
* function will be called with ESP_HIDD_REPORT_ERR_EVT.
* This function should be called after esp_bluedroid_init()/esp_bluedroid_init_with_cfg() and
* esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init(). When the
* operation is complete, the callback function will be called with ESP_HIDD_REPORT_ERR_EVT.
*
* @param[in] error: type of error
*
@ -385,9 +390,10 @@ esp_err_t esp_bt_hid_device_send_report(esp_hidd_report_type_t type, uint8_t id,
esp_err_t esp_bt_hid_device_report_error(esp_hidd_handshake_error_t error);
/**
* @brief Remove the virtually cabled device. This function should be called after esp_bluedroid_init()
* and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init(). When the
* operation is complete, the callback function will be called with ESP_HIDD_VC_UNPLUG_EVT.
* @brief Remove the virtually cabled device. This function should be called after
* esp_bluedroid_init()/esp_bluedroid_init_with_cfg() and esp_bluedroid_enable() success, and should be
* called after esp_bt_hid_device_init(). When the operation is complete, the callback function will be
* called with ESP_HIDD_VC_UNPLUG_EVT.
*
* @note If the connection exists, then HID Device will send a `VIRTUAL_CABLE_UNPLUG` control command to
* the peer HID Host, and the connection will be destroyed. If the connection does not exist, then HID

View File

@ -318,8 +318,9 @@ esp_err_t esp_bt_hid_host_register_callback(esp_hh_cb_t callback);
/**
* @brief This function initializes HID host. This function should be called after esp_bluedroid_enable() and
* esp_bluedroid_init() success, and should be called after esp_bt_hid_host_register_callback().
* When the operation is complete the callback function will be called with ESP_HIDH_INIT_EVT.
* esp_bluedroid_init()/esp_bluedroid_init_with_cfg() success, and should be called after
* esp_bt_hid_host_register_callback(). When the operation is complete the callback function will be called
* with ESP_HIDH_INIT_EVT.
*
* @return
* - ESP_OK: success
@ -329,7 +330,7 @@ esp_err_t esp_bt_hid_host_init(void);
/**
* @brief Closes the interface. This function should be called after esp_bluedroid_enable() and
* esp_bluedroid_init() success, and should be called after esp_bt_hid_host_init().
* esp_bluedroid_init()/esp_bluedroid_init_with_cfg() success, and should be called after esp_bt_hid_host_init().
* When the operation is complete the callback function will be called with ESP_HIDH_DEINIT_EVT.
*
* @return - ESP_OK: success

View File

@ -75,10 +75,8 @@ static void bta_dm_acl_link_stat_cback(tBTM_ACL_LINK_STAT_EVENT_DATA *p_data);
static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
/* Extended Inquiry Response */
#if (BT_SSP_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data);
#endif /* (BT_SSP_INCLUDED == TRUE) */
#if (CLASSIC_BT_INCLUDED == TRUE)
static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data);
static void bta_dm_set_eir (char *local_name);
#endif
#if (SDP_INCLUDED == TRUE)
@ -230,7 +228,7 @@ const tBTM_APPL_INFO bta_security = {
&bta_dm_new_link_key_cback,
&bta_dm_authentication_complete_cback,
&bta_dm_bond_cancel_complete_cback,
#if (BT_SSP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
&bta_dm_sp_cback,
#else
NULL,
@ -1406,7 +1404,7 @@ static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
void bta_dm_confirm(tBTA_DM_MSG *p_data)
{
tBTM_STATUS res = BTM_NOT_AUTHORIZED;
@ -1416,7 +1414,6 @@ void bta_dm_confirm(tBTA_DM_MSG *p_data)
}
BTM_ConfirmReqReply(res, p_data->confirm.bd_addr);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
@ -1428,7 +1425,6 @@ void bta_dm_confirm(tBTA_DM_MSG *p_data)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE && BT_SSP_INCLUDED)
void bta_dm_key_req(tBTA_DM_MSG *p_data)
{
tBTM_STATUS res = BTM_NOT_AUTHORIZED;
@ -1438,7 +1434,7 @@ void bta_dm_key_req(tBTA_DM_MSG *p_data)
}
BTM_PasskeyReqReply(res, p_data->key_req.bd_addr, p_data->key_req.passkey);
}
#endif ///SMP_INCLUDED == TRUE && BT_SSP_INCLUDED
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
**
@ -2967,7 +2963,6 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA
#if (CLASSIC_BT_INCLUDED == TRUE)
#if (BT_SSP_INCLUDED == TRUE)
/*******************************************************************************
**
** Function bta_dm_pinname_cback
@ -3019,7 +3014,6 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA
bta_dm_cb.p_sec_cback(event, &sec_event);
}
}
#endif /// BT_SSP_INCLUDED == TRUE
/*******************************************************************************
**
@ -3142,7 +3136,7 @@ static UINT8 bta_dm_authentication_complete_cback(BD_ADDR bd_addr, DEV_CLASS dev
return BTM_SUCCESS;
}
#if (BT_SSP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
**
** Function bta_dm_sp_cback
@ -3166,11 +3160,9 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data)
/* TODO_SP */
switch (event) {
case BTM_SP_IO_REQ_EVT:
#if (BT_SSP_INCLUDED == TRUE)
/* translate auth_req */
bta_dm_co_io_req(p_data->io_req.bd_addr, &p_data->io_req.io_cap,
&p_data->io_req.oob_data, &p_data->io_req.auth_req, p_data->io_req.is_orig);
#endif
#if BTM_OOB_INCLUDED == FALSE
status = BTM_SUCCESS;
#endif
@ -3178,10 +3170,8 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data)
APPL_TRACE_EVENT("io mitm: %d oob_data:%d", p_data->io_req.auth_req, p_data->io_req.oob_data);
break;
case BTM_SP_IO_RSP_EVT:
#if (BT_SSP_INCLUDED == TRUE)
bta_dm_co_io_rsp(p_data->io_rsp.bd_addr, p_data->io_rsp.io_cap,
p_data->io_rsp.oob_data, p_data->io_rsp.auth_req );
#endif
break;
case BTM_SP_CFM_REQ_EVT:
@ -3193,12 +3183,10 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data)
sec_event.cfm_req.rmt_io_caps = p_data->cfm_req.rmt_io_caps;
/* continue to next case */
#if (BT_SSP_INCLUDED == TRUE)
/* Passkey entry mode, mobile device with output capability is very
unlikely to receive key request, so skip this event */
case BTM_SP_KEY_REQ_EVT:
case BTM_SP_KEY_NOTIF_EVT:
#endif
if (BTM_SP_CFM_REQ_EVT == event) {
/* Due to the switch case falling through below to BTM_SP_KEY_NOTIF_EVT,
call remote name request using values from cfm_req */
@ -3315,7 +3303,7 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data)
APPL_TRACE_EVENT("dm status: %d", status);
return status;
}
#endif /* (BT_SSP_INCLUDED == TRUE) */
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
#endif ///SMP_INCLUDED == TRUE
@ -4741,7 +4729,6 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
memset(&sec_event, 0, sizeof(tBTA_DM_SEC));
switch (event) {
case BTM_LE_IO_REQ_EVT: {
// #if (BT_SSP_INCLUDED == TRUE)
bta_dm_co_ble_io_req(bda,
&p_data->io_req.io_cap,
&p_data->io_req.oob_data,
@ -4749,7 +4736,6 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
&p_data->io_req.max_key_size,
&p_data->io_req.init_keys,
&p_data->io_req.resp_keys);
// #endif
#if BTM_OOB_INCLUDED == FALSE
status = BTM_SUCCESS;
#endif

View File

@ -802,7 +802,7 @@ void BTA_DmSecureConnectionCreateOobData(void)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
void BTA_DmConfirm(BD_ADDR bd_addr, BOOLEAN accept)
{
tBTA_DM_API_CONFIRM *p_msg;
@ -825,7 +825,6 @@ void BTA_DmConfirm(BD_ADDR bd_addr, BOOLEAN accept)
** Returns void
**
*******************************************************************************/
#if (BT_SSP_INCLUDED == TRUE)
void BTA_DmPasskeyReqReply(BOOLEAN accept, BD_ADDR bd_addr, UINT32 passkey)
{
tBTA_DM_API_KEY_REQ *p_msg;
@ -837,8 +836,7 @@ void BTA_DmPasskeyReqReply(BOOLEAN accept, BD_ADDR bd_addr, UINT32 passkey)
bta_sys_sendmsg(p_msg);
}
}
#endif ///BT_SSP_INCLUDED == TRUE
#endif ///SMP_INCLUDED == TRUE
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
**
** Function BTA_DmAddDevice

View File

@ -54,14 +54,8 @@ tBTE_APPL_CFG bte_appl_cfg = {
};
#endif
#if (defined CLASSIC_BT_INCLUDED && CLASSIC_BT_INCLUDED == TRUE && BT_SSP_INCLUDED == TRUE)
#include "common/bte_appl.h"
#if (defined CLASSIC_BT_INCLUDED && CLASSIC_BT_INCLUDED == TRUE)
#include "btm_int.h"
tBTE_BT_APPL_CFG bte_bt_appl_cfg = {
0, //Todo, Authentication requirements
BTM_LOCAL_IO_CAPS,
NULL, //Todo, OOB data
};
#endif
/*******************************************************************************
@ -97,21 +91,22 @@ BOOLEAN bta_dm_co_get_compress_memory(tBTA_SYS_ID id, UINT8 **memory_p, UINT32 *
** - other : failed
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
esp_err_t bta_dm_co_bt_set_io_cap(UINT8 bt_io_cap)
{
esp_err_t ret = ESP_BT_STATUS_SUCCESS;
#if (BT_SSP_INCLUDED == TRUE)
if(bt_io_cap < BTM_IO_CAP_MAX ) {
bte_bt_appl_cfg.bt_io_cap = bt_io_cap;
btm_cb.devcb.loc_io_caps = bt_io_cap;
ret = ESP_BT_STATUS_SUCCESS;
} else {
ret = ESP_BT_STATUS_FAIL;
APPL_TRACE_ERROR("%s error:Invalid io cap value.",__func__);
}
#endif ///BT_SSP_INCLUDED == TRUE
return ret;
}
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
/*******************************************************************************
**

View File

@ -90,12 +90,12 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
#endif /* #if (BTA_DM_QOS_INCLUDED == TRUE) */
/* simple pairing events */
#if (SMP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
bta_dm_confirm, /* BTA_DM_API_CONFIRM_EVT */
#if (BT_SSP_INCLUDED == TRUE)
bta_dm_key_req, /* BTA_DM_API_KEY_REQ_EVT */
#endif ///BT_SSP_INCLUDED == TRUE
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
bta_dm_set_encryption, /* BTA_DM_API_SET_ENCRYPTION_EVT */
#endif ///SMP_INCLUDED == TRUE
#endif /* (SMP_INCLUDED == TRUE) */
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
bta_dm_loc_oob, /* BTA_DM_API_LOC_OOB_EVT */
bta_dm_oob_reply, /* BTA_DM_API_OOB_REPLY_EVT */

View File

@ -85,13 +85,13 @@ enum {
BTA_DM_API_QOS_SET_EVT,
#endif /* #if (BTA_DM_QOS_INCLUDED == TRUE) */
#if (SMP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
/* simple pairing events */
BTA_DM_API_CONFIRM_EVT,
#if (BT_SSP_INCLUDED == TRUE)
BTA_DM_API_KEY_REQ_EVT,
#endif ///BT_SSP_INCLUDED == TRUE
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
BTA_DM_API_SET_ENCRYPTION_EVT,
#endif ///SMP_INCLUDED == TRUE
#endif /* (SMP_INCLUDED == TRUE) */
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
BTA_DM_API_LOC_OOB_EVT,
BTA_DM_API_OOB_REPLY_EVT,

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -451,10 +451,9 @@ static void btc_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req)
#endif /// BTC_GAP_BT_INCLUDED == TRUE
}
#if (BT_SSP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
static void btc_dm_sp_cfm_req_evt(tBTA_DM_SP_CFM_REQ *p_cfm_req)
{
#if (BTC_GAP_BT_INCLUDED == TRUE)
if (p_cfm_req->just_works) {
// just work, not show to users.
BTA_DmConfirm(p_cfm_req->bd_addr, true);
@ -483,12 +482,10 @@ static void btc_dm_sp_cfm_req_evt(tBTA_DM_SP_CFM_REQ *p_cfm_req)
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
}
#endif /// BTC_GAP_BT_INCLUDED == TRUE
}
static void btc_dm_sp_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_key_notif)
{
#if (BTC_GAP_BT_INCLUDED == TRUE)
esp_bt_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t *msg;
@ -511,12 +508,10 @@ static void btc_dm_sp_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_key_notif)
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
}
#endif /// BTC_GAP_BT_INCLUDED == TRUE
}
static void btc_dm_sp_key_req_evt(tBTA_DM_SP_KEY_REQ *p_key_req)
{
#if (BTC_GAP_BT_INCLUDED == TRUE)
esp_bt_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t *msg;
@ -538,9 +533,8 @@ static void btc_dm_sp_key_req_evt(tBTA_DM_SP_KEY_REQ *p_key_req)
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
}
#endif /// BTC_GAP_BT_INCLUDED == TRUE
}
#endif /// BT_SSP_INCLUDED == TRUE
#endif /// CLASSIC_BT_INCLUDED == TRUE
static void btc_dm_dev_unpaired_evt(tBTA_DM_LINK_DOWN *p_link_down)
{
@ -773,7 +767,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
case BTA_DM_BOND_CANCEL_CMPL_EVT:
BTC_TRACE_DEBUG("BTA_DM_BOND_CANCEL_CMPL_EVT");
break;
#if (BT_SSP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
case BTA_DM_SP_CFM_REQ_EVT:
btc_dm_sp_cfm_req_evt(&p_data->cfm_req);
break;
@ -783,14 +777,15 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
case BTA_DM_SP_KEY_REQ_EVT:
btc_dm_sp_key_req_evt(&p_data->key_req);
break;
case BTA_DM_SP_RMT_OOB_EVT:
BTC_TRACE_DEBUG("BTA_DM_SP_RMT_OOB_EVT");
break;
case BTA_DM_SP_KEYPRESS_EVT:
BTC_TRACE_DEBUG("BTA_DM_SP_KEYPRESS_EVT");
break;
#endif ///BT_SSP_INCLUDED == TRUE
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
#if BTM_OOB_INCLUDED == TRUE
case BTA_DM_SP_RMT_OOB_EVT:
BTC_TRACE_DEBUG("BTA_DM_SP_RMT_OOB_EVT");
break;
#endif /* BTM_OOB_INCLUDED == TRUE */
case BTA_DM_ACL_LINK_STAT_EVT: {
btc_dm_acl_link_stat(&p_data->acl_link_stat);
break;

View File

@ -652,7 +652,6 @@ static void btc_gap_bt_pin_reply(btc_gap_bt_args_t *arg){
BTA_DmPinReply(arg->pin_reply.bda.address, arg->pin_reply.accept, arg->pin_reply.pin_code_len, arg->pin_reply.pin_code);
}
#if (BT_SSP_INCLUDED == TRUE)
static esp_err_t btc_gap_bt_set_security_param(btc_gap_bt_args_t *arg)
{
esp_err_t ret;
@ -681,8 +680,6 @@ static void btc_gap_bt_ssp_confirm(btc_gap_bt_args_t *arg)
BTA_DmConfirm(arg->confirm_reply.bda.address, arg->confirm_reply.accept);
}
#endif ///BT_SSP_INCLUDED == TRUE
static void btc_gap_bt_config_eir(btc_gap_bt_args_t *arg)
{
tBTA_DM_EIR_CONF eir_config;
@ -848,7 +845,6 @@ void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
case BTC_GAP_BT_ACT_SET_PAGE_TIMEOUT:
case BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT:
break;
#if (BT_SSP_INCLUDED == TRUE)
case BTC_GAP_BT_ACT_PASSKEY_REPLY:
case BTC_GAP_BT_ACT_CONFIRM_REPLY:
break;
@ -865,7 +861,6 @@ void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
}
break;
}
#endif ///BT_SSP_INCLUDED == TRUE
case BTC_GAP_BT_ACT_CONFIG_EIR:{
btc_gap_bt_args_t *src = (btc_gap_bt_args_t *)p_src;
@ -916,7 +911,6 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
case BTC_GAP_BT_ACT_SET_PAGE_TIMEOUT:
case BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT:
break;
#if (BT_SSP_INCLUDED == TRUE)
case BTC_GAP_BT_ACT_PASSKEY_REPLY:
case BTC_GAP_BT_ACT_CONFIRM_REPLY:
break;
@ -925,7 +919,6 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
osi_free(arg->set_security_param.value);
}
break;
#endif ///BT_SSP_INCLUDED == TRUE
case BTC_GAP_BT_ACT_CONFIG_EIR:
if (arg->config_eir.eir_data.p_manufacturer_data) {
@ -986,7 +979,6 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
btc_gap_bt_pin_reply(arg);
break;
}
#if (BT_SSP_INCLUDED == TRUE)
case BTC_GAP_BT_ACT_SET_SECURITY_PARAM:{
btc_gap_bt_set_security_param(arg);
break;
@ -999,7 +991,6 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
btc_gap_bt_ssp_confirm(arg);
break;
}
#endif ///BT_SSP_INCLUDED == TRUE
case BTC_GAP_BT_ACT_CONFIG_EIR: {
btc_gap_bt_config_eir(arg);
break;
@ -1069,11 +1060,9 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
case BTC_GAP_BT_QOS_EVT:
case BTC_GAP_BT_SET_PAGE_TO_EVT:
case BTC_GAP_BT_GET_PAGE_TO_EVT:
#if (BT_SSP_INCLUDED == TRUE)
case BTC_GAP_BT_CFM_REQ_EVT:
case BTC_GAP_BT_KEY_NOTIF_EVT:
case BTC_GAP_BT_KEY_REQ_EVT:
#endif ///BT_SSP_INCLUDED == TRUE
#if (BTC_DM_PM_INCLUDED == TRUE)
case BTC_GAP_BT_MODE_CHG_EVT:
#endif /// BTC_DM_PM_INCLUDED == TRUE
@ -1115,7 +1104,6 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
btc_gap_bt_cb_to_app(ESP_BT_GAP_PIN_REQ_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
break;
}
#if (BT_SSP_INCLUDED == TRUE)
case BTC_GAP_BT_CFM_REQ_EVT:{
btc_gap_bt_cb_to_app(ESP_BT_GAP_CFM_REQ_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
break;
@ -1128,7 +1116,6 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
btc_gap_bt_cb_to_app(ESP_BT_GAP_KEY_REQ_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
break;
}
#endif ///BT_SSP_INCLUDED == TRUE
case BTC_GAP_BT_SET_AFH_CHANNELS_EVT:{
btc_gap_bt_cb_to_app(ESP_BT_GAP_SET_AFH_CHANNELS_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
break;

View File

@ -88,13 +88,6 @@
#define UC_BT_HID_DEVICE_ENABLED FALSE
#endif
//SSP
#ifdef CONFIG_BT_SSP_ENABLED
#define UC_BT_SSP_ENABLED CONFIG_BT_SSP_ENABLED
#else
#define UC_BT_SSP_ENABLED FALSE
#endif
//BQB(BT)
#ifdef CONFIG_BT_CLASSIC_BQB_ENABLED
#define UC_BT_CLASSIC_BQB_ENABLED CONFIG_BT_CLASSIC_BQB_ENABLED

View File

@ -134,10 +134,6 @@
#endif
#endif /* UC_BT_HFP_CLIENT_ENABLED */
#if UC_BT_SSP_ENABLED
#define BT_SSP_INCLUDED TRUE
#endif /* UC_BT_SSP_ENABLED */
#if UC_BT_HID_ENABLED
#define BT_HID_INCLUDED TRUE
#endif /* UC_BT_HID_ENABLED */
@ -1431,19 +1427,6 @@
#endif
#endif
/******************************************************************************
**
** BT_SSP
**
******************************************************************************/
#ifndef BT_SSP_INCLUDED
#define BT_SSP_INCLUDED FALSE
#endif
#if BT_SSP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == FALSE
#error "Can't have SSP without CLASSIC BT"
#endif
/******************************************************************************
**
** SDP

View File

@ -39,14 +39,3 @@ typedef struct {
} tBTE_APPL_CFG;
extern tBTE_APPL_CFG bte_appl_cfg;
typedef struct {
#if ((CLASSIC_BT_INCLUDED == TRUE) && (BT_SSP_INCLUDED == TRUE))
UINT8 bt_auth_req;
UINT8 bt_io_cap;
UINT8 *bt_oob_auth_data;
#endif
} tBTE_BT_APPL_CFG;
extern tBTE_BT_APPL_CFG bte_bt_appl_cfg;

View File

@ -0,0 +1,21 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdbool.h>
#include "bt_common.h"
struct bluedroid_config {
bool (*get_ssp_enabled)(void);
};
bt_status_t bluedriod_config_init(esp_bluedroid_config_t *cfg);
void bluedriod_config_deinit(void);
const struct bluedroid_config *bluedriod_config_get(void);

View File

@ -0,0 +1,55 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include "osi/allocator.h"
#include "esp_bt_main.h"
#include "config/stack_config.h"
struct stack_config_env_tag {
esp_bluedroid_config_t cfg;
struct bluedroid_config interface;
};
static struct stack_config_env_tag *s_stack_config_env = NULL;
static bool get_ssp_enabled(void)
{
assert(s_stack_config_env);
esp_bluedroid_config_t *cfg = &s_stack_config_env->cfg;
return cfg->ssp_en;
}
bt_status_t bluedriod_config_init(esp_bluedroid_config_t *cfg)
{
s_stack_config_env = osi_calloc(sizeof(struct stack_config_env_tag));
if (!s_stack_config_env) {
return BT_STATUS_NOMEM;
}
memcpy(&s_stack_config_env->cfg, cfg, sizeof(esp_bluedroid_config_t));
struct bluedroid_config *interface = &s_stack_config_env->interface;
interface->get_ssp_enabled = get_ssp_enabled;
return BT_STATUS_SUCCESS;
}
void bluedriod_config_deinit(void)
{
if (s_stack_config_env) {
osi_free(s_stack_config_env);
s_stack_config_env = NULL;
}
}
const struct bluedroid_config *bluedriod_config_get(void)
{
assert(s_stack_config_env);
return &s_stack_config_env->interface;
}

View File

@ -29,6 +29,7 @@
#include "stack/btm_ble_api.h"
#include "device/version.h"
#include "osi/future.h"
#include "config/stack_config.h"
#if (BLE_50_FEATURE_SUPPORT == TRUE)
const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\xff\xff\xff" };
#else
@ -172,13 +173,10 @@ static void start_up(void)
// Inform the controller what page 0 features we support, based on what
// it told us it supports. We need to do this first before we request the
// next page, because the controller's response for page 1 may be
// dependent on what we configure from page 0
#if (BT_SSP_INCLUDED == TRUE)
controller_param.simple_pairing_supported = HCI_SIMPLE_PAIRING_SUPPORTED(controller_param.features_classic[0].as_array);
#else
controller_param.simple_pairing_supported = false;
#endif
// dependent on what we configure from page 0 and host SSP configuration
controller_param.simple_pairing_supported = HCI_SIMPLE_PAIRING_SUPPORTED(
controller_param.features_classic[0].as_array) &&
(bluedriod_config_get()->get_ssp_enabled());
if (controller_param.simple_pairing_supported) {
response = AWAIT_COMMAND(controller_param.packet_factory->make_write_simple_pairing_mode(HCI_SP_MODE_ENABLED));
controller_param.packet_parser->parse_generic_command_complete(response);

View File

@ -1554,7 +1554,7 @@ void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr)
** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
**
*******************************************************************************/
#if (BT_SSP_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey)
{
#if (BT_USE_TRACES == TRUE && SMP_INCLUDED == TRUE)
@ -1602,7 +1602,7 @@ void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey)
btsnd_hcic_user_passkey_reply (bd_addr, passkey);
}
}
#endif ///BT_SSP_INCLUDED == TRUE && SMP_INCLUDED == TRUE
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
/*******************************************************************************
**
@ -1618,7 +1618,7 @@ void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey)
** type - notification type
**
*******************************************************************************/
#if (BT_SSP_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type)
{
/* This API only make sense between PASSKEY_REQ and SP complete */
@ -1626,7 +1626,7 @@ void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type)
btsnd_hcic_send_keypress_notif (bd_addr, type);
}
}
#endif ///BT_SSP_INCLUDED == TRUE && SMP_INCLUDED == TRUE
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
/*******************************************************************************
@ -3515,6 +3515,7 @@ void btm_io_capabilities_rsp (UINT8 *p)
** Returns void
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p)
{
tBTM_STATUS status = BTM_ERR_PROCESSING;
@ -3576,12 +3577,10 @@ void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p)
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE);
break;
#if (BT_SSP_INCLUDED == TRUE)
case BTM_SP_KEY_REQ_EVT:
/* HCI_USER_PASSKEY_REQUEST_EVT */
btm_sec_change_pairing_state (BTM_PAIR_STATE_KEY_ENTRY);
break;
#endif
}
if (btm_cb.api.p_sp_callback) {
@ -3598,12 +3597,9 @@ void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p)
if (event == BTM_SP_CFM_REQ_EVT) {
BTM_TRACE_DEBUG ("calling BTM_ConfirmReqReply with status: %d\n", status);
BTM_ConfirmReqReply (status, p_bda);
}
#if (BT_SSP_INCLUDED == TRUE)
else if (event == BTM_SP_KEY_REQ_EVT) {
} else if (event == BTM_SP_KEY_REQ_EVT) {
BTM_PasskeyReqReply(status, p_bda, 0);
}
#endif
return;
}
/* Something bad. we can only fail this connection */
@ -3621,16 +3617,11 @@ void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p)
if (NULL != (p_dev_rec = btm_find_dev (p_bda)) ) {
btm_sec_disconnect (p_dev_rec->hci_handle, HCI_ERR_AUTH_FAILURE);
}
}
#if (BT_SSP_INCLUDED == TRUE)
else {
} else {
btsnd_hcic_user_passkey_neg_reply(p_bda);
}
#endif
}
/*******************************************************************************
**
** Function btm_keypress_notif_evt
@ -3727,6 +3718,7 @@ void btm_simple_pair_complete (UINT8 *p)
}
}
}
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
#endif ///SMP_INCLUDED == TRUE
@ -4934,12 +4926,12 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
/* btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); */
break;
#if (BT_SSP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
case BTM_PAIR_STATE_KEY_ENTRY:
btsnd_hcic_user_passkey_neg_reply(p_cb->pairing_bda);
/* btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); */
break;
#endif /* !BTM_IO_CAP_NONE */
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
#if BTM_OOB_INCLUDED == TRUE
case BTM_PAIR_STATE_WAIT_LOCAL_IOCAPS:

View File

@ -1185,9 +1185,11 @@ void btm_sec_rmt_name_request_complete (UINT8 *bd_addr, UINT8 *bd_name, UINT8 s
void btm_sec_rmt_host_support_feat_evt (UINT8 *p);
void btm_io_capabilities_req (UINT8 *p);
void btm_io_capabilities_rsp (UINT8 *p);
#if (CLASSIC_BT_INCLUDED == TRUE)
void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p);
void btm_keypress_notif_evt (UINT8 *p);
void btm_simple_pair_complete (UINT8 *p);
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_type);
void btm_sec_link_key_request (UINT8 *p_bda);
void btm_sec_pin_code_request (UINT8 *p_bda);

View File

@ -97,22 +97,20 @@ static void btu_hcif_page_scan_rep_mode_chng_evt (void);
static void btu_hcif_esco_connection_comp_evt(UINT8 *p);
static void btu_hcif_esco_connection_chg_evt(UINT8 *p);
/* Simple Pairing Events */
static void btu_hcif_host_support_evt (UINT8 *p);
#if (SMP_INCLUDED == TRUE)
/* Simple Pairing Events */
#if (CLASSIC_BT_INCLUDED == TRUE)
static void btu_hcif_io_cap_request_evt (UINT8 *p);
static void btu_hcif_io_cap_response_evt (UINT8 *p);
static void btu_hcif_user_conf_request_evt (UINT8 *p);
static void btu_hcif_user_passkey_request_evt (UINT8 *p);
static void btu_hcif_simple_pair_complete_evt (UINT8 *p);
static void btu_hcif_user_passkey_notif_evt (UINT8 *p);
static void btu_hcif_keypress_notif_evt (UINT8 *p);
#endif ///SMP_INCLUDED == TRUE
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
static void btu_hcif_rem_oob_request_evt (UINT8 *p);
#endif
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_simple_pair_complete_evt (UINT8 *p);
#endif ///SMP_INCLUDED == TRUE
static void btu_hcif_link_supv_to_changed_evt (UINT8 *p);
#if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
static void btu_hcif_enhanced_flush_complete_evt (void);
@ -307,7 +305,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
case HCI_RMT_HOST_SUP_FEAT_NOTIFY_EVT:
btu_hcif_host_support_evt (p);
break;
#if (SMP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
case HCI_IO_CAPABILITY_REQUEST_EVT:
btu_hcif_io_cap_request_evt (p);
break;
@ -320,13 +318,13 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
case HCI_USER_PASSKEY_REQUEST_EVT:
btu_hcif_user_passkey_request_evt (p);
break;
#endif ///SMP_INCLUDED == TRUE
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
case HCI_REMOTE_OOB_DATA_REQUEST_EVT:
btu_hcif_rem_oob_request_evt (p);
break;
#endif
#if (SMP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
case HCI_SIMPLE_PAIRING_COMPLETE_EVT:
btu_hcif_simple_pair_complete_evt (p);
break;
@ -336,7 +334,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
case HCI_KEYPRESS_NOTIFY_EVT:
btu_hcif_keypress_notif_evt (p);
break;
#endif ///SMP_INCLUDED == TRUE
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
case HCI_LINK_SUPER_TOUT_CHANGED_EVT:
btu_hcif_link_supv_to_changed_evt (p);
break;
@ -1848,7 +1846,7 @@ static void btu_hcif_host_support_evt (UINT8 *p)
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED == TRUE)
static void btu_hcif_io_cap_request_evt (UINT8 *p)
{
btm_io_capabilities_req(p);
@ -1898,6 +1896,20 @@ static void btu_hcif_user_passkey_request_evt (UINT8 *p)
btm_proc_sp_req_evt(BTM_SP_KEY_REQ_EVT, p);
}
/*******************************************************************************
**
** Function btu_hcif_simple_pair_complete_evt
**
** Description Process event HCI_SIMPLE_PAIRING_COMPLETE_EVT
**
** Returns void
**
*******************************************************************************/
static void btu_hcif_simple_pair_complete_evt (UINT8 *p)
{
btm_simple_pair_complete(p);
}
/*******************************************************************************
**
** Function btu_hcif_user_passkey_notif_evt
@ -1925,8 +1937,7 @@ static void btu_hcif_keypress_notif_evt (UINT8 *p)
{
btm_keypress_notif_evt(p);
}
#endif ///SMP_INCLUDED == TRUE
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
/*******************************************************************************
**
@ -1944,22 +1955,6 @@ static void btu_hcif_rem_oob_request_evt (UINT8 *p)
}
#endif
/*******************************************************************************
**
** Function btu_hcif_simple_pair_complete_evt
**
** Description Process event HCI_SIMPLE_PAIRING_COMPLETE_EVT
**
** Returns void
**
*******************************************************************************/
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_simple_pair_complete_evt (UINT8 *p)
{
btm_simple_pair_complete(p);
}
#endif ///SMP_INCLUDED == TRUE
/*******************************************************************************
**
** Function btu_hcif_link_supv_to_changed_evt

View File

@ -233,7 +233,8 @@ esp_err_t simple_ble_start(simple_ble_cfg_t *cfg)
return ret;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(TAG, "%s init bluetooth failed %d", __func__, ret);
return ret;

View File

@ -638,7 +638,8 @@ void app_main(void)
}
ESP_LOGI(BLE_ANCS_TAG, "%s init bluetooth", __func__);
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(BLE_ANCS_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -649,7 +649,8 @@ void app_main(void)
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(EXAMPLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -154,7 +154,8 @@ void esp_eddystone_appRegister(void)
void esp_eddystone_init(void)
{
esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
esp_bluedroid_init_with_cfg(&bluedroid_cfg);
esp_bluedroid_enable();
esp_eddystone_appRegister();
}

View File

@ -216,7 +216,8 @@ void app_main(void)
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(HID_DEMO_TAG, "%s init bluedroid failed", __func__);
return;

View File

@ -156,7 +156,8 @@ void ble_ibeacon_appRegister(void)
void ble_ibeacon_init(void)
{
esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
esp_bluedroid_init_with_cfg(&bluedroid_cfg);
esp_bluedroid_enable();
ble_ibeacon_appRegister();
}

View File

@ -625,7 +625,8 @@ void app_main(void)
}
ESP_LOGI(GATTC_TAG, "%s init bluetooth", __func__);
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -686,7 +686,8 @@ void app_main(void)
}
ESP_LOGI(GATTS_TABLE_TAG, "%s init bluetooth", __func__);
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -568,7 +568,8 @@ void app_main(void)
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed, error code = %x", __func__, ret);
return;

View File

@ -672,7 +672,8 @@ void app_main(void)
ESP_LOGE(GATTS_TAG, "%s enable controller failed", __func__);
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTS_TAG, "%s init bluetooth failed", __func__);
return;

View File

@ -469,7 +469,8 @@ void app_main(void)
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -60,7 +60,8 @@ void app_main()
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed, error code = %x", __func__, ret);
return;
@ -136,7 +137,8 @@ There are four Bluetooth modes supported:
After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using:
```c
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
ret = esp_bluedroid_enable();
```
The main function ends by registering the GAP and GATT event handlers, as well as the Application Profile and set the maximum supported MTU size.

View File

@ -545,7 +545,8 @@ void app_main(void)
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -531,7 +531,8 @@ void app_main(void)
}
ESP_LOGI(GATTS_TABLE_TAG, "%s init bluetooth", __func__);
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -702,7 +702,8 @@ void app_main(void)
ESP_LOGE(GATTS_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTS_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -62,7 +62,8 @@ The entry point to this example is the app_main() function:
ESP_LOGE(GATTS_TAG, "%s enable controller failed", __func__);
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTS_TAG, "%s init bluetooth failed", __func__);
return;
@ -131,7 +132,8 @@ There are four Bluetooth modes supported:
After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using:
```c
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
ret = esp_bluedroid_enable();
```
The Bluetooth stack is up and running at this point in the program flow, however the functionality of the application has not been defined yet. The functionality is defined by reacting to events such as what happens when another device tries to read or write parameters and establish a connection. The two main managers of events are the GAP and GATT event handlers. The application needs to register a callback function for each event handler in order to let the application know which functions are going to handle the GAP and GATT events:

View File

@ -538,7 +538,8 @@ void app_main(void)
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -101,7 +101,8 @@ void app_main()
}
ESP_LOGI(GATTS_TABLE_TAG, "%s init bluetooth", __func__);
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed", __func__);
return;

View File

@ -930,7 +930,8 @@ void app_main(void)
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -582,7 +582,8 @@ void app_main(void)
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -486,7 +486,8 @@ void app_main(void)
}
ESP_LOGI(GATTS_TABLE_TAG, "%s init bluetooth", __func__);
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(GATTS_TABLE_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -213,7 +213,8 @@ void app_main(void)
ESP_LOGE(LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -65,7 +65,8 @@ void app_main(void)
ESP_LOGE(LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;
@ -144,7 +145,8 @@ There are four Bluetooth modes supported:
After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using:
```c
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
ret = esp_bluedroid_enable();
```
The Bluetooth stack is up and running at this point in the program flow, however the functionality of the application has not been defined yet. The functionality is defined by reacting to events

View File

@ -164,7 +164,8 @@ void app_main(void)
ESP_LOGE(LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -66,7 +66,8 @@ void app_main(void)
ESP_LOGE(LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;
@ -151,8 +152,9 @@ There are four Bluetooth modes supported:
After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using:
```c
ret = esp_bluedroid_init();
ret = esp_bluedroid_enable();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
ret = esp_bluedroid_enable();
```
The Bluetooth stack is up and running at this point in the program flow, however the functionality of the application has not been defined yet. The functionality is defined by reacting to events such as what happens when another device tries to read or write parameters and establish a connection. The two main managers of events are the GAP and GATT event handlers. The application needs to register a callback function for each event handler in order to let the application know which functions are going to handle the GAP and GATT events:

View File

@ -159,7 +159,8 @@ void app_main(void)
ESP_LOGE(LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -86,7 +86,8 @@ void app_main(void)
ESP_LOGE(LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;
@ -151,7 +152,8 @@ There are four Bluetooth modes supported:
After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using:
```c
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
ret = esp_bluedroid_enable();
```
The main function ends by registering the GAP and GATT event handlers, as well as the Application Profile and set the maximum supported MTU size.

View File

@ -1,4 +1,11 @@
menu "A2DP Example Configuration"
config EXAMPLE_A2DP_SINK_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
choice EXAMPLE_A2DP_SINK_OUTPUT
prompt "A2DP Sink Output"

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -62,7 +62,7 @@ static void bt_app_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
break;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_A2DP_SINK_SSP_ENABLED == true)
/* when Security Simple Pairing user confirmation requested, this event comes */
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(BT_AV_TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
@ -168,16 +168,22 @@ void app_main(void)
ESP_LOGE(BT_AV_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(err));
return;
}
if ((err = esp_bluedroid_init()) != ESP_OK) {
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_A2DP_SINK_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((err = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(err));
return;
}
if ((err = esp_bluedroid_enable()) != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s enable bluedroid failed: %s", __func__, esp_err_to_name(err));
return;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_A2DP_SINK_SSP_ENABLED == true)
/* set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;

View File

@ -66,16 +66,20 @@ if (esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT) != OK) {
After the initialization of the Bluetooth Controller, the Bluedroid Stack, which includes the common definitions and APIs for Classic Bluetooth is initialized and enabled by using:
```c
/* initialize Bluedroid Host */
if (esp_bluedroid_init() != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s initialize bluedroid failed", __func__);
return;
}
/* enable Bluedroid Host */
if (esp_bluedroid_enable() != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s enable bluedroid failed", __func__);
return;
}
/* initialize Bluedroid Host */
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_A2DP_SINK_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((err = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(err));
return;
}
/* enable Bluedroid Host */
if (esp_bluedroid_enable() != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s enable bluedroid failed", __func__);
return;
}
```
The Classic Bluetooth uses an asynchronous programming paradigm. The entire Bluedroid stack sees the use of events, event handlers, callbacks and state machines. Most APIs are implemented by posting specific type of events to the work queue of Bluedroid Stack. Threads(FreeRTOS) tasks inside Bluedroid then process the events with specific handlers, according to the internal state. When the operations are completed, Bluedroid stack invokes the callback function which is registered by application, to report some other events and information.
@ -136,7 +140,7 @@ The main function installs I2S to play the audio. A loudspeaker, additional ADC
The main function continues to set up paring parameters including Secure Simple Pairing and Legacy Pairing.
```c
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_A2DP_SINK_SSP_ENABLED == true)
/* set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;

View File

@ -0,0 +1,9 @@
menu "A2DP Example Configuration"
config EXAMPLE_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
endmenu

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -267,7 +267,7 @@ static void bt_app_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
break;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* when Security Simple Pairing user confirmation requested, this event comes */
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(BT_AV_TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
@ -750,16 +750,22 @@ void app_main(void)
ESP_LOGE(BT_AV_TAG, "%s enable controller failed", __func__);
return;
}
if (esp_bluedroid_init() != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s initialize bluedroid failed", __func__);
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
if (esp_bluedroid_enable() != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s enable bluedroid failed", __func__);
return;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;

View File

@ -63,16 +63,20 @@ if (esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT) != OK) {
After the initialization of the Bluetooth Controller, the Bluedroid stack, which includes the common definitions and APIs for Classic Bluetooth is initialized and enabled by using:
```c
/* initialize Bluedroid Host */
if (esp_bluedroid_init() != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s initialize bluedroid failed", __func__);
return;
}
/* Enable Bluedroid Host */
if (esp_bluedroid_enable() != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s enable bluedroid failed", __func__);
return;
}
/* initialize Bluedroid Host */
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
/* Enable Bluedroid Host */
if (esp_bluedroid_enable() != ESP_OK) {
ESP_LOGE(BT_AV_TAG, "%s enable bluedroid failed", __func__);
return;
}
```
The Classic Bluetooth uses an asynchronous programming paradigm. The entire Bluedroid stack sees the use of events, event handlers, callbacks and state machines. Most APIs are implemented by posting specific type of events to the work queue of Bluedroid Stack. Threads(FreeRTOS) tasks inside Bluedroid then process the events with specific handlers, according to the internal state. When the operations are completed, Bluedroid stack invokes the callback function which is registered by application, to report some other events and information.
@ -84,7 +88,7 @@ For example, after executing `esp_bt_gap_start_discovery()`, an event of `ESP_BT
The main function continues to set up paring parameters including Secure Simple Pairing and Legacy Pairing.
```c
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;

View File

@ -118,7 +118,8 @@ There are four Bluetooth modes supported:
After the initialization of the Bluetooth controller, the Bluedroid stack, which includes the common definitions and APIs for both Bluetooth Classic and BLE, is initialized and enabled by using:
```c
if ((ret = esp_bluedroid_init()) != ESP_OK) {
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(GAP_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}

View File

@ -293,7 +293,8 @@ void app_main(void)
return;
}
if ((ret = esp_bluedroid_init()) != ESP_OK) {
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(GAP_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}

View File

@ -0,0 +1,9 @@
menu "HID Example Configuration"
config EXAMPLE_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
endmenu

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -199,7 +199,7 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
break;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
esp_bt_gap_ssp_confirm_reply(param->cfm_req.bda, true);
@ -411,8 +411,12 @@ void app_main(void)
return;
}
if ((ret = esp_bluedroid_init()) != ESP_OK) {
ESP_LOGE(TAG, "initialize bluedroid failed: %s", esp_err_to_name(ret));
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
@ -458,7 +462,7 @@ void app_main(void)
ESP_LOGI(TAG, "starting hid device");
esp_bt_hid_device_init();
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* Set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_NONE;

View File

@ -0,0 +1,9 @@
menu "L2CAP Example Configuration"
config EXAMPLE_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
endmenu

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -176,7 +176,7 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
break;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* when Security Simple Pairing user confirmation requested, this event comes */
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(L2CAP_TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
@ -402,7 +402,11 @@ void app_main(void)
return;
}
if ((ret = esp_bluedroid_init()) != ESP_OK) {
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(L2CAP_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
@ -439,7 +443,7 @@ void app_main(void)
return;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* Set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;

View File

@ -11,7 +11,7 @@ The `BT_Profile_StackA` and `BT_Profile_StackB` in the above diagram represent t
Both projects `BT_L2CAP_Server`([bt_l2cap_server](../../bt_l2cap_server)) and `BT_L2CAP_Client` have the same initialization process but are independent of each other. The entry point to the example is the `app_main()` function, and the main function starts by initializing the non-volatile storage library. Then, the L2CAP initialization both the `Server` and `Client` can be divided into the following steps:
- Step1: esp_bt_controller_init()
- Step2: esp_bt_controller_enable()
- Step3: esp_bluedroid_init()
- Step3: esp_bluedroid_init_with_cfg()
- Step4: esp_bluedroid_enable()
- Step5: esp_bt_gap_register_callback()

View File

@ -0,0 +1,9 @@
menu "L2CAP Example Configuration"
config EXAMPLE_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
endmenu

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -90,7 +90,7 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
break;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* when Security Simple Pairing user confirmation requested, this event comes */
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(L2CAP_TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
@ -305,7 +305,11 @@ void app_main(void)
return;
}
if ((ret = esp_bluedroid_init()) != ESP_OK) {
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(L2CAP_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
@ -342,7 +346,7 @@ void app_main(void)
return;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* Set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;

View File

@ -30,9 +30,9 @@ and
`Component config --> Bluetooth --> Bluetooth --> Bluetooth controller --> BR/EDR ACL Max Connections`
4. SSP is enabled as default in this example. If you prefer the legacy pairing, you can disable it in the following path.
4. SSP is enabled as default in this example. If you prefer the legacy pairing, you shall disable it in the following path.
`Component config --> Bluetooth--> Bluedroid Options --> Secure Simple Pair`.
`SPP Example Configuration --> Secure Simple Pair`.
### Build and Flash

View File

@ -0,0 +1,9 @@
menu "SPP Example Configuration"
config EXAMPLE_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
endmenu

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -174,7 +174,7 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
break;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(SPP_TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
esp_bt_gap_ssp_confirm_reply(param->cfm_req.bda, true);
@ -223,16 +223,15 @@ void app_main(void)
return;
}
if ((ret = esp_bluedroid_init()) != ESP_OK) {
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
if ((ret = esp_bluedroid_enable()) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s enable bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
if ((ret = esp_bt_gap_register_callback(esp_bt_gap_cb)) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s gap register failed: %s", __func__, esp_err_to_name(ret));
return;
@ -253,7 +252,7 @@ void app_main(void)
return;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* Set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;

View File

@ -21,9 +21,9 @@ idf.py menuconfig
`Component config --> Bluetooth --> Bluedroid Options --> SPP`.
3. SSP is enabled as default in this example. If you prefer the legacy pairing, you can disable it in the following path.
3. SSP is enabled as default in this example. If you prefer the legacy pairing, you shall disable it in the following path.
`Component config --> Bluetooth--> Bluedroid Options --> Secure Simple Pair`.
`SPP Example Configuration --> Secure Simple Pair`.
### Build and Flash

View File

@ -0,0 +1,9 @@
menu "SPP Example Configuration"
config EXAMPLE_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
endmenu

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -302,7 +302,7 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
break;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(SPP_TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
ESP_LOGW(SPP_TAG, "To confirm the value, type `spp ok;`");
@ -355,7 +355,11 @@ void app_main(void)
return;
}
if ((ret = esp_bluedroid_init()) != ESP_OK) {
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
@ -370,7 +374,7 @@ void app_main(void)
return;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* Set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IN;

View File

@ -30,9 +30,9 @@ and
`Component config --> Bluetooth --> Bluetooth --> Bluetooth controller --> BR/EDR ACL Max Connections`
4. SSP is enabled as default in this example. If you prefer the legacy pairing, you can disable it in the following path.
4. SSP is enabled as default in this example. If you prefer the legacy pairing, you shall disable it in the following path.
`Component config --> Bluetooth--> Bluedroid Options --> Secure Simple Pair`.
`SPP Example Configuration --> Secure Simple Pair`.
### Build and Flash

View File

@ -0,0 +1,9 @@
menu "SPP Example Configuration"
config EXAMPLE_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
endmenu

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -186,7 +186,7 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
break;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(SPP_TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
esp_bt_gap_ssp_confirm_reply(param->cfm_req.bda, true);
@ -234,8 +234,12 @@ void app_main(void)
return;
}
if (esp_bluedroid_init() != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s initialize bluedroid failed", __func__);
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
@ -244,7 +248,7 @@ void app_main(void)
return;
}
if (esp_bt_gap_register_callback(esp_bt_gap_cb) != ESP_OK) {
if ((ret = esp_bt_gap_register_callback(esp_bt_gap_cb)) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s gap register failed: %s", __func__, esp_err_to_name(ret));
return;
}
@ -262,7 +266,7 @@ void app_main(void)
return;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* Set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;

View File

@ -21,10 +21,9 @@ idf.py menuconfig
`Component config --> Bluetooth --> Bluedroid Options --> SPP`.
3. SSP is enabled as default in this example. If you prefer the legacy pairing, you can disable it in the following path.
`Component config --> Bluetooth--> Bluedroid Options --> Secure Simple Pair`.
3. SSP is enabled as default in this example. If you prefer the legacy pairing, you shall disable it in the following path.
`SPP Example Configuration --> Secure Simple Pair`.
### Build and Flash

View File

@ -0,0 +1,9 @@
menu "SPP Example Configuration"
config EXAMPLE_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
endmenu

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -264,7 +264,7 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
break;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(SPP_TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
esp_bt_gap_ssp_confirm_reply(param->cfm_req.bda, true);
@ -317,8 +317,12 @@ void app_main(void)
return;
}
if (esp_bluedroid_init() != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s initialize bluedroid failed", __func__);
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
@ -345,7 +349,7 @@ void app_main(void)
return;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* Set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -82,21 +82,21 @@ void app_main(void)
ESP_ERROR_CHECK(ret);
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE));
esp_err_t err;
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
if ((err = esp_bt_controller_init(&bt_cfg)) != ESP_OK) {
if ((ret = esp_bt_controller_init(&bt_cfg)) != ESP_OK) {
ESP_LOGE(BT_HF_TAG, "%s initialize controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
if ((err = esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT)) != ESP_OK) {
if ((ret = esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT)) != ESP_OK) {
ESP_LOGE(BT_HF_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
if ((err = esp_bluedroid_init()) != ESP_OK) {
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(BT_HF_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
if ((err = esp_bluedroid_enable()) != ESP_OK) {
if ((ret = esp_bluedroid_enable()) != ESP_OK) {
ESP_LOGE(BT_HF_TAG, "%s enable bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}

View File

@ -0,0 +1,9 @@
menu "HFP Example Configuration"
config EXAMPLE_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
endmenu

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -116,7 +116,7 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
break;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(BT_HF_TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
esp_bt_gap_ssp_confirm_reply(param->cfm_req.bda, true);
@ -161,24 +161,27 @@ void app_main(void)
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE));
esp_err_t err;
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
if ((err = esp_bt_controller_init(&bt_cfg)) != ESP_OK) {
if ((ret = esp_bt_controller_init(&bt_cfg)) != ESP_OK) {
ESP_LOGE(BT_HF_TAG, "%s initialize controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
if ((err = esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT)) != ESP_OK) {
if ((ret = esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT)) != ESP_OK) {
ESP_LOGE(BT_HF_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret));
return;
}
if ((err = esp_bluedroid_init()) != ESP_OK) {
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(BT_HF_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
if ((err = esp_bluedroid_enable()) != ESP_OK) {
if ((ret = esp_bluedroid_enable()) != ESP_OK) {
ESP_LOGE(BT_HF_TAG, "%s enable bluedroid failed: %s", __func__, esp_err_to_name(ret));
return;
}
@ -236,6 +239,13 @@ static void bt_hf_client_hdl_stack_evt(uint16_t event, void *p_param)
esp_hf_client_register_callback(bt_app_hf_client_cb);
esp_hf_client_init();
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
/* Set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;
esp_bt_gap_set_security_param(param_type, &iocap, sizeof(uint8_t));
#endif
esp_bt_pin_type_t pin_type = ESP_BT_PIN_TYPE_FIXED;
esp_bt_pin_code_t pin_code;
pin_code[0] = '0';

View File

@ -1,4 +1,11 @@
menu "A2DP Example Configuration"
config EXAMPLE_A2DP_SINK_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
choice EXAMPLE_A2DP_SINK_OUTPUT
prompt "A2DP Sink Output"

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -634,7 +634,7 @@ static void bt_app_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
break;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_A2DP_SINK_SSP_ENABLED == true)
/* when Security Simple Pairing user confirmation requested, this event comes */
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(BT_BLE_COEX_TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
@ -718,20 +718,27 @@ void app_main(void)
ESP_LOGE(BT_BLE_COEX_TAG, "%s initialize controller failed: %s", __func__, esp_err_to_name(err));
return;
}
if ((err = esp_bt_controller_enable(ESP_BT_MODE_BTDM)) != ESP_OK) {
ESP_LOGE(BT_BLE_COEX_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(err));
return;
}
if ((err = esp_bluedroid_init()) != ESP_OK) {
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_A2DP_SINK_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
if ((err = esp_bluedroid_init_with_cfg(&bluedroid_cfg)) != ESP_OK) {
ESP_LOGE(BT_BLE_COEX_TAG, "%s initialize bluedroid failed: %s", __func__, esp_err_to_name(err));
return;
}
if ((err = esp_bluedroid_enable()) != ESP_OK) {
ESP_LOGE(BT_BLE_COEX_TAG, "%s enable bluedroid failed: %s", __func__, esp_err_to_name(err));
return;
}
#if (CONFIG_BT_SSP_ENABLED == true)
#if (CONFIG_EXAMPLE_A2DP_SINK_SSP_ENABLED == true)
/* set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;

View File

@ -983,7 +983,8 @@ void app_main(void)
return;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(COEX_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;

View File

@ -30,7 +30,8 @@
esp_err_t esp_blufi_host_init(void)
{
int ret;
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
BLUFI_ERROR("%s init bluedroid failed: %s\n", __func__, esp_err_to_name(ret));
return ESP_FAIL;

View File

@ -241,7 +241,8 @@ void bt_test_init(void)
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_bt_controller_init(&bt_cfg));
ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BLE));
ESP_ERROR_CHECK(esp_bluedroid_init());
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_bluedroid_init_with_cfg(&bluedroid_cfg));
ESP_ERROR_CHECK(esp_bluedroid_enable());
}

View File

@ -172,8 +172,9 @@ This demo calls the `bluetooth_init` function to:
After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using:
```c
ret = esp_bluedroid_init();
```
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
ret = esp_bluedroid_enable();
```

View File

@ -61,7 +61,8 @@ esp_err_t bluetooth_init(void)
ESP_LOGE(TAG, "%s enable controller failed", __func__);
return ret;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(TAG, "%s init bluetooth failed", __func__);
return ret;

View File

@ -0,0 +1,9 @@
menu "HID Example Configuration"
config EXAMPLE_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
endmenu

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -397,9 +397,37 @@ static void bt_gap_event_handler(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_para
handle_bt_device_result(&param->disc_res);
break;
}
case ESP_BT_GAP_KEY_NOTIF_EVT:
ESP_LOGI(TAG, "BT GAP KEY_NOTIF passkey:%"PRIu32, param->key_notif.passkey);
case ESP_BT_GAP_PIN_REQ_EVT: {
ESP_LOGI(TAG, "BT GAP PIN_REQ_EVT min_16_digit:%d", param->pin_req.min_16_digit);
if (param->pin_req.min_16_digit) {
ESP_LOGI(TAG, "Input pin code: 0000 0000 0000 0000");
esp_bt_pin_code_t pin_code = {0};
esp_bt_gap_pin_reply(param->pin_req.bda, true, 16, pin_code);
} else {
ESP_LOGI(TAG, "Input pin code: 1234");
esp_bt_pin_code_t pin_code;
pin_code[0] = '1';
pin_code[1] = '2';
pin_code[2] = '3';
pin_code[3] = '4';
esp_bt_gap_pin_reply(param->pin_req.bda, true, 4, pin_code);
}
break;
}
#if (CONFIG_EXAMPLE_SSP_ENABLED == true)
case ESP_BT_GAP_CFM_REQ_EVT:
ESP_LOGI(TAG, "BT GAP CFM_REQ_EVT Please compare the numeric value: %" PRIu32,
param->cfm_req.num_val);
esp_bt_gap_ssp_confirm_reply(param->cfm_req.bda, true);
break;
case ESP_BT_GAP_KEY_NOTIF_EVT:
ESP_LOGI(TAG, "BT GAP KEY_NOTIF_EVT passkey:%" PRIu32, param->key_notif.passkey);
break;
case ESP_BT_GAP_KEY_REQ_EVT:
ESP_LOGI(TAG, "BT GAP KEY_REQ_EVT Please enter passkey!");
break;
#endif
case ESP_BT_GAP_MODE_CHG_EVT:
ESP_LOGI(TAG, "BT GAP MODE_CHG_EVT mode:%d", param->mode_chg.mode);
break;
@ -412,7 +440,7 @@ static void bt_gap_event_handler(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_para
static esp_err_t init_bt_gap(void)
{
esp_err_t ret;
#if (CONFIG_BT_SSP_ENABLED)
#if (CONFIG_EXAMPLE_SSP_ENABLED)
/* Set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_NONE;
@ -714,7 +742,11 @@ static esp_err_t init_low_level(uint8_t mode)
return ret;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(TAG, "esp_bluedroid_init failed: %d", ret);
return ret;

View File

@ -0,0 +1,9 @@
menu "HID Example Configuration"
config EXAMPLE_SSP_ENABLED
bool "Secure Simple Pairing"
depends on BT_CLASSIC_ENABLED
default y
help
This enables the Secure Simple Pairing. If disable this option,
Bluedroid will only support Legacy Pairing
endmenu

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -400,21 +400,24 @@ static void bt_gap_event_handler(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_para
handle_bt_device_result(&param->disc_res);
break;
}
#if (CONFIG_BT_SSP_ENABLED)
#if (CONFIG_EXAMPLE_SSP_ENABLED)
case ESP_BT_GAP_KEY_NOTIF_EVT:
ESP_LOGI(TAG, "BT GAP KEY_NOTIF passkey:%"PRIu32, param->key_notif.passkey);
break;
case ESP_BT_GAP_CFM_REQ_EVT: {
ESP_LOGI(TAG, "ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
ESP_LOGI(TAG, "BT GAP CFM_REQ_EVT Please compare the numeric value: %"PRIu32, param->cfm_req.num_val);
esp_bt_gap_ssp_confirm_reply(param->cfm_req.bda, true);
break;
}
case ESP_BT_GAP_KEY_REQ_EVT:
ESP_LOGI(TAG, "BT GAP KEY_REQ_EVT Please enter passkey!");
break;
#endif
case ESP_BT_GAP_MODE_CHG_EVT:
ESP_LOGI(TAG, "BT GAP MODE_CHG_EVT mode:%d", param->mode_chg.mode);
break;
case ESP_BT_GAP_PIN_REQ_EVT: {
ESP_LOGI(TAG, "ESP_BT_GAP_PIN_REQ_EVT min_16_digit:%d", param->pin_req.min_16_digit);
ESP_LOGI(TAG, "BT GAP PIN_REQ_EVT min_16_digit:%d", param->pin_req.min_16_digit);
if (param->pin_req.min_16_digit) {
ESP_LOGI(TAG, "Input pin code: 0000 0000 0000 0000");
esp_bt_pin_code_t pin_code = {0};
@ -439,7 +442,7 @@ static void bt_gap_event_handler(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_para
static esp_err_t init_bt_gap(void)
{
esp_err_t ret;
#if (CONFIG_BT_SSP_ENABLED)
#if (CONFIG_EXAMPLE_SSP_ENABLED)
/* Set default parameters for Secure Simple Pairing */
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
esp_bt_io_cap_t iocap = ESP_BT_IO_CAP_IO;
@ -737,7 +740,11 @@ static esp_err_t init_low_level(uint8_t mode)
return ret;
}
ret = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
#if (CONFIG_EXAMPLE_SSP_ENABLED == false)
bluedroid_cfg.ssp_en = false;
#endif
ret = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (ret) {
ESP_LOGE(TAG, "esp_bluedroid_init failed: %d", ret);
return ret;

View File

@ -36,7 +36,8 @@ esp_err_t esp_ble_helper_init(void)
ESP_LOGE(TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(err));
return err;
}
err = esp_bluedroid_init();
esp_bluedroid_config_t bluedroid_cfg = BT_BLUEDROID_INIT_CONFIG_DEFAULT();
err = esp_bluedroid_init_with_cfg(&bluedroid_cfg);
if (err) {
ESP_LOGE(TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(err));
return err;