feat(bt): support Set_Min_Key_Size HCI for esp32s31

This commit is contained in:
yangfeng
2026-09-17 14:32:05 +08:00
parent a848cb6534
commit a7e113d0f6
26 changed files with 116 additions and 208 deletions
+25 -5
View File
@@ -64,24 +64,44 @@ config BT_CLASSIC_ENABLE_POWER_CTRL_VSC
Enable Espressif Vendor-specific HCI commands for power control of Classic Bluetooth
choice BT_ENC_KEY_SIZE_CTRL_ENABLED
prompt "configure encryption key size"
prompt "configure encryption key size (Deprecated)"
warning "This option is deprecated and will be removed in a future release"
depends on BT_CLASSIC_ENABLED
default BT_ENC_KEY_SIZE_CTRL_VSC
help
This chooses the support status of configuring encryption key size
Deprecated: This option is deprecated and will be removed in a future release.
config BT_ENC_KEY_SIZE_CTRL_STD
depends on (BT_CONTROLLER_DISABLED || (BT_CONTROLLER_ENABLED && SOC_BT_H2C_ENC_KEY_CTRL_ENH_STD_SUPPORTED))
bool "Supported by standard HCI command"
bool "Supported by standard HCI command (Deprecated)"
warning "This option is deprecated and will be removed in a future release"
help
Deprecated: This option is deprecated and will be removed in a future release.
config BT_ENC_KEY_SIZE_CTRL_VSC
depends on (BT_CONTROLLER_DISABLED || (BT_CONTROLLER_ENABLED && SOC_BT_H2C_ENC_KEY_CTRL_ENH_VSC_SUPPORTED))
bool "Supported by Vendor-specific HCI command"
warning "This option is deprecated and will be removed in a future release"
bool "Supported by Vendor-specific HCI command (Deprecated)"
help
Deprecated: This option is deprecated and will be removed in a future release.
config BT_ENC_KEY_SIZE_CTRL_NONE
bool "Not supported"
bool "Not supported (Deprecated)"
warning "This option is deprecated and will be removed in a future release"
help
Deprecated: This option is deprecated and will be removed in a future release.
endchoice
config BT_CLASSIC_ENABLE_ENC_KEY_SIZE_CTRL_VSC
bool "Supported by Vendor-specific HCI command to set min encryption key size"
depends on (BT_CONTROLLER_DISABLED || (BT_CONTROLLER_ENABLED && SOC_BT_H2C_ENC_KEY_CTRL_ENH_VSC_SUPPORTED))
default y if BT_ENC_KEY_SIZE_CTRL_VSC # for backward compatibility
default n if BT_CONTROLLER_DISABLED
default y
help
This enables vendor-specific command as a fallback
when the standard command is not supported.
config BT_CLASSIC_BQB_ENABLED
bool "Host Qualitifcation support for Classic Bluetooth"
depends on BT_CLASSIC_ENABLED
@@ -659,7 +659,6 @@ esp_err_t esp_bt_gap_set_acl_pkt_types(esp_bd_addr_t remote_bda, uint16_t pkt_ty
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
esp_err_t esp_bt_gap_set_min_enc_key_size(uint8_t key_size)
{
btc_msg_t msg = {0};
@@ -678,7 +677,6 @@ esp_err_t esp_bt_gap_set_min_enc_key_size(uint8_t key_size)
arg.set_min_enc_key_size.key_size = key_size;
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* #if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE) */
esp_err_t esp_bt_gap_set_device_name(const char *name)
{
@@ -1028,12 +1028,10 @@ void bta_dm_set_acl_pkt_types (tBTA_DM_MSG *p_data)
** Returns void
**
*******************************************************************************/
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
void bta_dm_set_min_enc_key_size (tBTA_DM_MSG *p_data)
{
BTM_SetMinEncKeySize(p_data->set_min_enc_key_size.key_size, p_data->set_min_enc_key_size.set_min_enc_key_size_cb);
}
#endif
#endif
/*******************************************************************************
@@ -398,7 +398,6 @@ void BTA_DmSetAclPktTypes(BD_ADDR remote_addr, UINT16 pkt_types, tBTM_CMPL_CB *p
** Returns void
**
*******************************************************************************/
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
void BTA_DmSetMinEncKeySize(UINT8 key_size, tBTM_CMPL_CB *p_cb)
{
tBTA_DM_API_SET_MIN_ENC_KEY_SIZE *p_msg;
@@ -411,7 +410,6 @@ void BTA_DmSetMinEncKeySize(UINT8 key_size, tBTM_CMPL_CB *p_cb)
bta_sys_sendmsg(p_msg);
}
}
#endif
#endif /// CLASSIC_BT_INCLUDED == TRUE
#if (SDP_INCLUDED == TRUE)
@@ -82,9 +82,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_set_page_timeout, /* BTA_DM_API_PAGE_TO_SET_EVT */
bta_dm_get_page_timeout, /* BTA_DM_API_PAGE_TO_GET_EVT */
bta_dm_set_acl_pkt_types, /* BTA_DM_API_SET_ACL_PKT_TYPES_EVT */
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
bta_dm_set_min_enc_key_size, /* BTA_DM_API_SET_MIN_ENC_KEY_SIZE_EVT */
#endif
bta_dm_set_afh_channels, /* BTA_DM_API_SET_AFH_CHANNELS_EVT */
#if (SDP_INCLUDED == TRUE)
@@ -72,9 +72,7 @@ enum {
BTA_DM_API_PAGE_TO_SET_EVT,
BTA_DM_API_PAGE_TO_GET_EVT,
BTA_DM_API_SET_ACL_PKT_TYPES_EVT,
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
BTA_DM_API_SET_MIN_ENC_KEY_SIZE_EVT,
#endif
BTA_DM_API_SET_AFH_CHANNELS_EVT,
#if (SDP_INCLUDED == TRUE)
BTA_DM_API_GET_REMOTE_NAME_EVT,
@@ -447,14 +445,12 @@ typedef struct {
tBTM_CMPL_CB *set_acl_pkt_types_cb;
} tBTA_DM_API_SET_ACL_PKT_TYPES;
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
/* data type for BTA_DM_API_SET_MIN_ENC_KEY_SIZE_EVT */
typedef struct {
BT_HDR hdr;
UINT8 key_size;
tBTM_CMPL_CB *set_min_enc_key_size_cb;
} tBTA_DM_API_SET_MIN_ENC_KEY_SIZE;
#endif
/* data type for BTA_DM_API_GET_REMOTE_NAME_EVT */
typedef struct {
@@ -1792,9 +1788,7 @@ typedef union {
tBTA_DM_API_PAGE_TO_GET get_page_timeout;
tBTA_DM_API_SET_ACL_PKT_TYPES set_acl_pkt_types;
#endif /* CLASSIC_BT_INCLUDED */
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
tBTA_DM_API_SET_MIN_ENC_KEY_SIZE set_min_enc_key_size;
#endif
#if (SDP_INCLUDED == TRUE)
tBTA_DM_API_GET_REMOTE_NAME get_rmt_name;
#endif
@@ -2416,10 +2410,8 @@ extern void bta_dm_config_eir (tBTA_DM_MSG *p_data);
extern void bta_dm_set_page_timeout (tBTA_DM_MSG *p_data);
extern void bta_dm_get_page_timeout (tBTA_DM_MSG *p_data);
extern void bta_dm_set_acl_pkt_types (tBTA_DM_MSG *p_data);
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
extern void bta_dm_set_min_enc_key_size (tBTA_DM_MSG *p_data);
#endif
#endif
extern void bta_dm_set_afh_channels (tBTA_DM_MSG *p_data);
extern void bta_dm_read_rmt_name(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_channels (tBTA_DM_MSG *p_data);
@@ -434,9 +434,7 @@ typedef tBTM_GET_PAGE_TIMEOUT_RESULTS tBTA_GET_PAGE_TIMEOUT_RESULTS;
typedef tBTM_SET_ACL_PKT_TYPES_RESULTS tBTA_SET_ACL_PKT_TYPES_RESULTS;
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
typedef tBTM_SET_MIN_ENC_KEY_SIZE_RESULTS tBTA_SET_MIN_ENC_KEY_SIZE_RESULTS;
#endif
typedef tBTM_REMOTE_DEV_NAME tBTA_REMOTE_DEV_NAME;
@@ -2010,9 +2008,7 @@ void BTA_DmSetAclPktTypes(BD_ADDR remote_addr, UINT16 pkt_types, tBTM_CMPL_CB *p
** Returns void
**
*******************************************************************************/
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
void BTA_DmSetMinEncKeySize(UINT8 key_size, tBTM_CMPL_CB *p_cb);
#endif
#if (BLE_INCLUDED == TRUE)
/*******************************************************************************
@@ -991,7 +991,6 @@ static void btc_gap_set_acl_pkt_types(btc_gap_bt_args_t *arg)
btc_gap_bt_set_acl_pkt_types_cmpl_callback);
}
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
static void btc_gap_bt_set_min_enc_key_size_cmpl_callback(void *p_data)
{
tBTA_SET_MIN_ENC_KEY_SIZE_RESULTS *result = (tBTA_SET_MIN_ENC_KEY_SIZE_RESULTS *)p_data;
@@ -1014,7 +1013,6 @@ static void btc_gap_set_min_enc_key_size(btc_gap_bt_args_t *arg)
{
BTA_DmSetMinEncKeySize(arg->set_min_enc_key_size.key_size, btc_gap_bt_set_min_enc_key_size_cmpl_callback);
}
#endif
static void btc_gap_bt_read_remote_name_cmpl_callback(void *p_data)
{
@@ -1133,9 +1131,7 @@ void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
case BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT:
case BTC_GAP_BT_ACT_SET_ACL_PKT_TYPES:
case BTC_GAP_BT_ACT_GET_DEV_NAME:
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
case BTC_GAP_BT_ACT_SET_MIN_ENC_KEY_SIZE:
#endif
break;
case BTC_GAP_BT_ACT_PASSKEY_REPLY:
case BTC_GAP_BT_ACT_CONFIRM_REPLY:
@@ -1222,9 +1218,7 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
case BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT:
case BTC_GAP_BT_ACT_SET_ACL_PKT_TYPES:
case BTC_GAP_BT_ACT_GET_DEV_NAME:
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
case BTC_GAP_BT_ACT_SET_MIN_ENC_KEY_SIZE:
#endif
break;
case BTC_GAP_BT_ACT_PASSKEY_REPLY:
case BTC_GAP_BT_ACT_CONFIRM_REPLY:
@@ -1366,12 +1360,10 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
btc_gap_set_acl_pkt_types(arg);
break;
}
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
case BTC_GAP_BT_ACT_SET_MIN_ENC_KEY_SIZE: {
btc_gap_set_min_enc_key_size(arg);
break;
}
#endif
case BTC_GAP_BT_ACT_SET_DEV_NAME: {
BTA_DmSetDeviceName(arg->bt_set_dev_name.device_name, BT_DEVICE_TYPE_BREDR);
break;
@@ -1436,9 +1428,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
#if (BTC_DM_PM_INCLUDED == TRUE)
case BTC_GAP_BT_MODE_CHG_EVT:
#endif /// BTC_DM_PM_INCLUDED == TRUE
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
case BTC_GAP_BT_SET_MIN_ENC_KEY_SIZE_EVT:
#endif /// ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE
break;
case BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT: {
char *name = ((esp_bt_gap_cb_param_t *)msg->arg)->get_dev_name_cmpl.name;
@@ -1557,12 +1547,10 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
btc_gap_bt_cb_to_app(ESP_BT_GAP_ACL_PKT_TYPE_CHANGED_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
break;
}
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
case BTC_GAP_BT_SET_MIN_ENC_KEY_SIZE_EVT: {
btc_gap_bt_cb_to_app(ESP_BT_GAP_SET_MIN_ENC_KEY_SIZE_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
break;
}
#endif
case BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT: {
btc_gap_bt_cb_to_app(ESP_BT_GAP_GET_DEV_NAME_CMPL_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
break;
@@ -41,9 +41,7 @@ typedef enum {
BTC_GAP_BT_SET_PAGE_TO_EVT,
BTC_GAP_BT_GET_PAGE_TO_EVT,
BTC_GAP_BT_SET_ACL_PKT_TYPES_EVT,
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
BTC_GAP_BT_SET_MIN_ENC_KEY_SIZE_EVT,
#endif
BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT,
}btc_gap_bt_evt_t;
@@ -75,9 +73,7 @@ typedef enum {
BTC_GAP_BT_ACT_SET_PAGE_TIMEOUT,
BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT,
BTC_GAP_BT_ACT_SET_ACL_PKT_TYPES,
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
BTC_GAP_BT_ACT_SET_MIN_ENC_KEY_SIZE,
#endif
BTC_GAP_BT_ACT_SET_DEV_NAME,
BTC_GAP_BT_ACT_GET_DEV_NAME,
} btc_gap_bt_act_t;
@@ -211,12 +207,10 @@ typedef union {
uint16_t pkt_types;
} set_acl_pkt_types;
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
// BTC_GAP_BT_ACT_SET_MIN_ENC_KEY_SIZE
struct set_min_enc_key_size_args {
uint8_t key_size;
} set_min_enc_key_size;
#endif
// BTC_GAP_BT_ACT_SET_DEV_NAME
struct bt_set_dev_name_args {
@@ -166,13 +166,11 @@
#define UC_BT_CLASSIC_BQB_ENABLED FALSE
#endif
//Set Encryption Key Size(BT)
#ifdef CONFIG_BT_ENC_KEY_SIZE_CTRL_STD
#define UC_BT_ENC_KEY_SIZE_CTRL_MODE 1
#elif CONFIG_BT_ENC_KEY_SIZE_CTRL_VSC
#define UC_BT_ENC_KEY_SIZE_CTRL_MODE 2
// Vendor-specific HCI for Classic Bluetooth encryption key size
#ifdef CONFIG_BT_CLASSIC_ENABLE_ENC_KEY_SIZE_CTRL_VSC
#define UC_BT_CLASSIC_ENABLE_ENC_KEY_SIZE_CTRL_VSC CONFIG_BT_CLASSIC_ENABLE_ENC_KEY_SIZE_CTRL_VSC
#else
#define UC_BT_ENC_KEY_SIZE_CTRL_MODE 0
#define UC_BT_CLASSIC_ENABLE_ENC_KEY_SIZE_CTRL_VSC FALSE
#endif
//Enable Classic Bluetooth power control vsc
@@ -75,11 +75,7 @@
#define BR_EDR_MAX_RECONNECT_ON_COLLISION UC_BT_CLASSIC_MAX_RECONNECT_ON_COLLISION
#define ENC_KEY_SIZE_CTRL_MODE_NONE 0
#define ENC_KEY_SIZE_CTRL_MODE_STD 1
#define ENC_KEY_SIZE_CTRL_MODE_VSC 2
#define ENC_KEY_SIZE_CTRL_MODE UC_BT_ENC_KEY_SIZE_CTRL_MODE
#define ESP_BT_CLASSIC_ENABLE_ENC_KEY_SIZE_CTRL_VSC UC_BT_CLASSIC_ENABLE_ENC_KEY_SIZE_CTRL_VSC
#define ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC UC_BT_CLASSIC_ENABLE_POWER_CTRL_VSC
#if (UC_BT_A2DP_ENABLED == TRUE)
@@ -571,6 +571,12 @@ static bool supports_reading_remote_extended_features(void)
return HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(controller_param.supported_commands);
}
static bool supports_set_min_enc_key_size(void)
{
assert(controller_param.readable);
return HCI_SET_MIN_ENC_KEY_SIZE_SUPPORTED(controller_param.supported_commands);
}
static bool supports_interlaced_inquiry_scan(void)
{
assert(controller_param.readable);
@@ -753,6 +759,7 @@ static const controller_t interface = {
supports_secure_connections,
supports_simultaneous_le_bredr,
supports_reading_remote_extended_features,
supports_set_min_enc_key_size,
supports_interlaced_inquiry_scan,
supports_interlaced_page_scan,
supports_rssi_with_inquiry_results,
@@ -48,6 +48,7 @@ typedef struct controller_t {
bool (*supports_secure_connections)(void);
bool (*supports_simultaneous_le_bredr)(void);
bool (*supports_reading_remote_extended_features)(void);
bool (*supports_set_min_enc_key_size)(void);
bool (*supports_interlaced_inquiry_scan)(void);
bool (*supports_interlaced_page_scan)(void);
bool (*supports_rssi_with_inquiry_results)(void);
@@ -998,7 +998,6 @@ tBTM_STATUS BTM_WritePageTimeout(UINT16 timeout, tBTM_CMPL_CB *p_cb)
return (BTM_CMD_STARTED);
}
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
void btm_set_min_enc_key_size_complete(const UINT8 *p)
{
tBTM_SET_MIN_ENC_KEY_SIZE_RESULTS results;
@@ -1014,33 +1013,49 @@ void btm_set_min_enc_key_size_complete(const UINT8 *p)
tBTM_STATUS BTM_SetMinEncKeySize(UINT8 key_size, tBTM_CMPL_CB *p_cb)
{
BTM_TRACE_EVENT ("BTM: BTM_SetMinEncKeySize: key_size: %d.", key_size);
btm_cb.devcb.p_set_min_enc_key_size_cmpl_cb = p_cb;
tBTM_STATUS status = BTM_NO_RESOURCES;
#if (ENC_KEY_SIZE_CTRL_MODE == ENC_KEY_SIZE_CTRL_MODE_VSC)
/* Send the HCI command */
UINT8 param[1];
UINT8 *p = (UINT8 *)param;
UINT8_TO_STREAM(p, key_size);
status = BTM_VendorSpecificCommand(HCI_VENDOR_BT_SET_MIN_ENC_KEY_SIZE, 1, param, NULL);
#else
if (btsnd_hcic_set_min_enc_key_size(key_size)) {
status = BTM_SUCCESS;
BTM_TRACE_EVENT ("BTM: BTM_SetMinEncKeySize: key_size: %d.", key_size);
if (!BTM_IsDeviceUp()) {
status = BTM_WRONG_MODE;
goto done;
}
btm_cb.devcb.p_set_min_enc_key_size_cmpl_cb = p_cb;
if (controller_get_interface()->supports_set_min_enc_key_size()) {
if (btsnd_hcic_set_min_enc_key_size(key_size)) {
status = BTM_SUCCESS;
}
} else {
#if (ESP_BT_CLASSIC_ENABLE_ENC_KEY_SIZE_CTRL_VSC == TRUE)
UINT8 param[1];
UINT8 *p = (UINT8 *)param;
UINT8_TO_STREAM(p, key_size);
status = BTM_VendorSpecificCommand(HCI_VENDOR_BT_SET_MIN_ENC_KEY_SIZE, 1, param, NULL);
#else
status = BTM_MODE_UNSUPPORTED;
#endif
}
done:
if (status != BTM_SUCCESS) {
if (p_cb) {
btm_cb.devcb.p_set_min_enc_key_size_cmpl_cb = NULL;
tBTM_SET_MIN_ENC_KEY_SIZE_RESULTS results = {0};
results.hci_status = HCI_ERR_MEMORY_FULL;
if (status == BTM_MODE_UNSUPPORTED) {
results.hci_status = HCI_ERR_UNSUPPORTED_VALUE;
} else if (status == BTM_WRONG_MODE) {
results.hci_status = HCI_ERR_UNSPECIFIED;
} else {
results.hci_status = HCI_ERR_MEMORY_FULL;
}
(*p_cb)(&results);
}
}
return status;
}
#endif
/*******************************************************************************
**
@@ -1276,9 +1276,7 @@ void btm_delete_stored_link_key_complete (UINT8 *p, UINT16 evt_len);
void btm_report_device_status (tBTM_DEV_STATUS status);
void btm_set_afh_channels_complete (UINT8 *p);
void btm_ble_set_channels_complete (UINT8 *p);
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
void btm_set_min_enc_key_size_complete(const UINT8 *p);
#endif
void btm_set_page_timeout_complete (const UINT8 *p);
void btm_page_to_setup_timeout (void *p_tle);
@@ -1371,12 +1371,10 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
case HCI_WRITE_PAGE_TOUT:
btm_set_page_timeout_complete(p);
break;
#if (ENC_KEY_SIZE_CTRL_MODE == ENC_KEY_SIZE_CTRL_MODE_STD)
case HCI_SET_MIN_ENC_KEY_SIZE:
btm_set_min_enc_key_size_complete(p);
break;
#endif
#if (ENC_KEY_SIZE_CTRL_MODE == ENC_KEY_SIZE_CTRL_MODE_VSC)
#if (ESP_BT_CLASSIC_ENABLE_ENC_KEY_SIZE_CTRL_VSC == TRUE)
case HCI_VENDOR_BT_SET_MIN_ENC_KEY_SIZE:
btm_set_min_enc_key_size_complete(p);
break;
@@ -1940,7 +1940,6 @@ BOOLEAN btsnd_hcic_set_afh_channels (AFH_CHANNELS channels)
return (TRUE);
}
#if (ENC_KEY_SIZE_CTRL_MODE == ENC_KEY_SIZE_CTRL_MODE_STD)
BOOLEAN btsnd_hcic_set_min_enc_key_size (UINT8 size)
{
BT_HDR *p;
@@ -1963,6 +1962,5 @@ BOOLEAN btsnd_hcic_set_min_enc_key_size (UINT8 size)
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
return (TRUE);
}
#endif
#endif /// CLASSIC_BT_INCLUDED == TRUE
@@ -906,14 +906,12 @@ typedef struct {
UINT16 pkt_types;
} tBTM_SET_ACL_PKT_TYPES_RESULTS;
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
/* Structure returned with set minimal encryption key size event (in tBTM_CMPL_CB callback function)
** in response to BTM_SetMinEncKeySize call.
*/
typedef struct {
UINT8 hci_status;
} tBTM_SET_MIN_ENC_KEY_SIZE_RESULTS;
#endif
/* Structure returned with set BLE channels event (in tBTM_CMPL_CB callback function)
** in response to BTM_BleSetChannels call.
@@ -2363,14 +2361,14 @@ tBTM_STATUS BTM_SetAclPktTypes(BD_ADDR remote_bda, UINT16 pkt_types, tBTM_CMPL_C
** Description Send HCI Set Minimum Encryption Key Size
**
** Returns
** BTM_SUCCESS Command sent.
** BTM_NO_RESOURCES If out of resources to send the command.
** BTM_SUCCESS Command sent.
** BTM_NO_RESOURCES If out of resources to send the command.
** BTM_WRONG_MODE If the controller is not ready.
** BTM_MODE_UNSUPPORTED If neither standard HCI nor VSC is available.
**
*******************************************************************************/
//extern
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
tBTM_STATUS BTM_SetMinEncKeySize(UINT8 key_size, tBTM_CMPL_CB *p_cb);
#endif
/*******************************************************************************
**
@@ -2957,4 +2957,9 @@ typedef struct {
#define HCI_SUPP_COMMANDS_LE_RC_CONN_PARAM_UPD_NEG_RPY_OFF 33
#define HCI_LE_RC_CONN_PARAM_UPD_NEG_RPY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_LE_RC_CONN_PARAM_UPD_NEG_RPY_OFF] & HCI_SUPP_COMMANDS_RLE_RC_CONN_PARAM_UPD_NEG_RPY_MASK)
/* Supported Commands (Byte 45) - HCI_Set_Min_Encryption_Key_Size (bit 7) */
#define HCI_SUPP_COMMANDS_SET_MIN_ENC_KEY_SIZE_MASK 0x80
#define HCI_SUPP_COMMANDS_SET_MIN_ENC_KEY_SIZE_OFF 45
#define HCI_SET_MIN_ENC_KEY_SIZE_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_SET_MIN_ENC_KEY_SIZE_OFF] & HCI_SUPP_COMMANDS_SET_MIN_ENC_KEY_SIZE_MASK)
#endif
@@ -21,6 +21,19 @@ extern "C" {
// Application developers **should not** call the init functions in their applications.
//
/**
* @brief Set Classic Bluetooth minimum encryption key size (OCF: 0x0182)
*
* @note The init function is `bt_stack_enableSecCtrlVsCmd(true)`
*/
#define ESP_BT_VS_SET_MIN_ENC_KEY_SIZE_OCF (0x0182)
/**
* @brief Set bt minimum encryption key size cmd parameters
*/
struct bt_hci_vs_set_min_enc_key_size {
uint8_t size; /*!< the minimum encryption key size */
};
/**
* @brief This event indicates legacy authentication is completed by remote device (EVTCODE: 0xFF, SUBCODE: 0x03)
*
@@ -1783,6 +1783,10 @@ config SOC_BLE_PERIODIC_ADV_WITH_RESPONSE
bool
default y
config SOC_BT_H2C_ENC_KEY_CTRL_ENH_VSC_SUPPORTED
bool
default y
config SOC_I2S_HW_VERSION_2
bool
default y
@@ -663,6 +663,7 @@
#define SOC_BLE_CTE_SUPPORTED (1) /*!< Support Bluetooth LE Constant Tone Extension (CTE) */
#define SOC_BLE_SUBRATE_SUPPORTED (1) /*!< Support Bluetooth LE Connection Subrating */
#define SOC_BLE_PERIODIC_ADV_WITH_RESPONSE (1) /*!< Support Bluetooth LE Periodic Advertising with Response (PAwR) */
#define SOC_BT_H2C_ENC_KEY_CTRL_ENH_VSC_SUPPORTED (1) /*!< Support Bluetooth Classic encryption key size configuration through vendor-specific HCI command */
/*-------------------------- I2S CAPS ----------------------------------------*/
#define SOC_I2S_HW_VERSION_2 (1)