mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
feat(ble): add CONFIG_BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN config on ESP32-C5
This commit is contained in:
@@ -951,3 +951,11 @@ config BT_LE_CTRL_SLV_FAST_RX_CONN_DATA_EN
|
||||
When this option is enabled, the Controller continues receiving PDUs
|
||||
In the next connection event instead of entering latency
|
||||
After a data packet is received.
|
||||
|
||||
config BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN
|
||||
bool "Enables the automatic initiation of a data length update(Experimental)."
|
||||
default n
|
||||
help
|
||||
When this option is enabled, the Controller automatically initiates a data length update
|
||||
Using the appropriate data length parameters
|
||||
When a PHY update or a connection interval update occurs.
|
||||
|
||||
@@ -180,6 +180,7 @@ extern int r_ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_c
|
||||
extern char *ble_controller_get_compile_version(void);
|
||||
extern int esp_ble_register_bb_funcs(void);
|
||||
extern void esp_ble_unregister_bb_funcs(void);
|
||||
extern bool esp_ble_controller_lib_check(void);
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
@@ -218,6 +219,10 @@ static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
static bool esp_bt_check_wakeup_by_bt(void);
|
||||
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#if (CONFIG_BT_CONTROLLER_ONLY) && (CONFIG_BT_LE_SM_SC) && (!CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS)
|
||||
#include "tinycrypt/ecc.h"
|
||||
static int ecc_rand_func(uint8_t *dst, unsigned int len);
|
||||
#endif // (CONFIG_BT_CONTROLLER_ONLY) && (CONFIG_BT_LE_SM_SC) && (!CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS)
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
*/
|
||||
@@ -1121,6 +1126,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
if (!esp_ble_controller_lib_check()) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Controller lib version mismatch!");
|
||||
}
|
||||
|
||||
#if (CONFIG_BT_CONTROLLER_ONLY) && (CONFIG_BT_LE_SM_SC) && (!CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS)
|
||||
uECC_set_rng(ecc_rand_func);
|
||||
#endif // (CONFIG_BT_CONTROLLER_ONLY) && (CONFIG_BT_LE_SM_SC) && (!CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS)
|
||||
return ESP_OK;
|
||||
free_controller:
|
||||
hci_transport_deinit();
|
||||
@@ -1594,6 +1606,26 @@ static mbedtls_ecp_keypair keypair;
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
#include "tinycrypt/cmac_mode.h"
|
||||
#include "tinycrypt/ecc_dh.h"
|
||||
|
||||
/* Used by uECC to get random data */
|
||||
static int ecc_rand_func(uint8_t *dst, unsigned int len)
|
||||
{
|
||||
int offset_cnt = 0;
|
||||
uint8_t *u8ptr = dst;
|
||||
uint64_t random_64 = 0;
|
||||
|
||||
while(len > 0) {
|
||||
random64 = (uint64_t)esp_random();
|
||||
random64 = (random64 << 32)| (uint64_t)esp_random();;
|
||||
offset_cnt = len < sizeof(uint64_t) ? len : sizeof(uint64_t);
|
||||
memcpy(u8ptr, &random64, offset_cnt);
|
||||
len -= offset_cnt;
|
||||
u8ptr += offset_cnt;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
@@ -1685,11 +1717,11 @@ exit:
|
||||
}
|
||||
|
||||
#else
|
||||
if (uECC_valid_public_key(pk, &curve_secp256r1) < 0) {
|
||||
if (uECC_valid_public_key(pk, uECC_secp256r1()) < 0) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
}
|
||||
|
||||
rc = uECC_shared_secret(pk, priv, dh, &curve_secp256r1);
|
||||
rc = uECC_shared_secret(pk, priv, dh, uECC_secp256r1());
|
||||
if (rc == TC_CRYPTO_FAIL) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
}
|
||||
@@ -1765,7 +1797,7 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
return BLE_SM_KEY_ERR;
|
||||
}
|
||||
#else
|
||||
if (uECC_make_key(pk, priv, &curve_secp256r1) != TC_CRYPTO_SUCCESS) {
|
||||
if (uECC_make_key(pk, priv, uECC_secp256r1()) != TC_CRYPTO_SUCCESS) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
@@ -215,6 +215,13 @@ extern "C" {
|
||||
#define DEFAULT_BT_LE_CTRL_SLV_FAST_RX_CONN_DATA_EN (0)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(CONFIG_BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN)
|
||||
#define DEFAULT_BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN (CONFIG_BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
#define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
#else
|
||||
|
||||
@@ -1014,7 +1014,6 @@ static void ble_rtc_clk_init(esp_bt_controller_config_t *cfg)
|
||||
esp_bt_rtc_slow_clk_select(s_bt_lpclk_src);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
uint8_t mac[6];
|
||||
|
||||
@@ -159,7 +159,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
|
||||
*/
|
||||
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
|
||||
|
||||
#define CONFIG_VERSION 0x20251104
|
||||
#define CONFIG_VERSION 0x20251125
|
||||
#define CONFIG_MAGIC 0x5A5AA5A5
|
||||
|
||||
/**
|
||||
@@ -236,6 +236,7 @@ typedef struct {
|
||||
uint8_t conn_rsv_cnt; /*!< BLE conn state machine reserve count number */
|
||||
uint8_t priority_level_cfg; /*!< The option for priority level configuration */
|
||||
uint8_t slv_fst_rx_lat_en; /*!< The option for enabling slave fast PDU reception during latency. */
|
||||
uint8_t dl_itvl_phy_sync_en; /*!< The option for automatically initiate the data length update when phy update or connect interval update. */
|
||||
uint32_t config_magic; /*!< Magic number for configuration validation */
|
||||
} esp_bt_controller_config_t;
|
||||
|
||||
@@ -299,6 +300,7 @@ typedef struct {
|
||||
.conn_rsv_cnt = BLE_LL_CONN_SM_RESERVE_CNT_N, \
|
||||
.priority_level_cfg = BT_LL_CTRL_PRIO_LVL_CFG, \
|
||||
.slv_fst_rx_lat_en = DEFAULT_BT_LE_CTRL_SLV_FAST_RX_CONN_DATA_EN, \
|
||||
.dl_itvl_phy_sync_en = DEFAULT_BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN, \
|
||||
.config_magic = CONFIG_MAGIC, \
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user