GengYuchao 3 лет назад
Родитель
Сommit
07a470bccc

+ 4 - 4
components/bt/controller/esp32c2/bt.c

@@ -121,6 +121,10 @@ extern void r_ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg, v
 extern void r_ble_rtc_wake_up_state_clr(void);
 extern int os_msys_init(void);
 extern void os_msys_buf_free(void);
+extern int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x,
+                                const uint8_t *peer_pub_key_y,
+                                const uint8_t *our_priv_key, uint8_t *out_dhkey);
+extern int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv);
 
 /* Local Function Declaration
  *********************************************************************
@@ -145,10 +149,6 @@ static void osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param
 static uint32_t osi_random_wrapper(void);
 static void esp_reset_rpa_moudle(void);
 
-extern int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x,
-                                const uint8_t *peer_pub_key_y,
-                                const uint8_t *our_priv_key, uint8_t *out_dhkey);
-extern int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv);
 /* Local variable definition
  ***************************************************************************
  */

+ 24 - 2
components/bt/controller/esp32h2/bt.c

@@ -57,6 +57,9 @@
 #define OSI_COEX_VERSION              0x00010006
 #define OSI_COEX_MAGIC_VALUE          0xFADEBEAD
 
+#define EXT_FUNC_VERSION             0x20220125
+#define EXT_FUNC_MAGIC_VALUE         0xA5A5A5A5
+
 /* Types definition
  ************************************************************************
  */
@@ -86,6 +89,9 @@ struct ext_funcs_t {
     void (* _task_delete)(void *task_handle);
     void (*_osi_assert)(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2);
     uint32_t (* _os_random)(void);
+    int (* _ecc_gen_key_pair)(uint8_t *pub, uint8_t *priv);
+    int (* _ecc_gen_dh_key)(const uint8_t *remote_pub_key_x, const uint8_t *remote_pub_key_y, const uint8_t *local_priv_key, uint8_t *dhkey);
+    int (* _esp_reset_rpa_moudle)(void);
     uint32_t magic;
 };
 
@@ -118,6 +124,10 @@ extern void r_ble_ll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg, vo
 extern int os_msys_init(void);
 extern void os_msys_buf_free(void);
 extern void bt_bb_set_le_tx_on_delay(uint32_t delay_us);
+extern int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x,
+                                const uint8_t *peer_pub_key_y,
+                                const uint8_t *our_priv_key, uint8_t *out_dhkey);
+extern int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv);
 
 /* Local Function Declaration
  *********************************************************************
@@ -141,6 +151,9 @@ static int esp_intr_free_wrapper(void **ret_handle);
 static void osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2);
 static uint32_t osi_random_wrapper(void);
 
+static int esp_reset_rpa_moudle(void);
+
+
 /* Local variable definition
  ***************************************************************************
  */
@@ -177,7 +190,7 @@ static const struct osi_coex_funcs_t s_osi_coex_funcs_ro = {
 };
 
 struct ext_funcs_t ext_funcs_ro = {
-    .ext_version = 0xE0000001,
+    .ext_version = EXT_FUNC_VERSION,
     ._esp_intr_alloc = esp_intr_alloc_wrapper,
     ._esp_intr_free = esp_intr_free_wrapper,
     ._malloc = bt_osi_mem_malloc_internal,
@@ -194,9 +207,18 @@ struct ext_funcs_t ext_funcs_ro = {
     ._task_delete = task_delete_wrapper,
     ._osi_assert = osi_assert_wrapper,
     ._os_random = osi_random_wrapper,
-    .magic = 0xA5A5A5A5,
+    ._ecc_gen_key_pair = ble_sm_alg_gen_key_pair,
+    ._ecc_gen_dh_key = ble_sm_alg_gen_dhkey,
+    ._esp_reset_rpa_moudle = esp_reset_rpa_moudle,
+    .magic = EXT_FUNC_MAGIC_VALUE,
 };
 
+static int IRAM_ATTR esp_reset_rpa_moudle(void)
+{
+    // periph_module_reset(PERIPH_MODEM_RPA_MODULE);
+    return 0;
+}
+
 static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2)
 {
     ESP_LOGE(NIMBLE_PORT_LOG_TAG, "BLE assert: line %d in function %s, param: 0x%x, 0x%x", ln, fn, param1, param2);

+ 1 - 1
components/bt/controller/lib_esp32h2/esp32h2-bt-lib

@@ -1 +1 @@
-Subproject commit 4956cf810cc7ef32fab78d814ce1e531e71967da
+Subproject commit 3f1e686429aad90d3b8ace0da9aab59a2a805a12

+ 5 - 2
components/bt/include/esp32h2/include/esp_bt.h

@@ -119,9 +119,8 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_
 esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
 
 
-#define CONFIG_VERSION  0x02109228
+#define CONFIG_VERSION  0x20220409
 #define CONFIG_MAGIC    0x5A5AA5A5
-
 /**
  * @brief Controller config options, depend on config mask.
  *        Config mask indicate which functions enabled, this means
@@ -170,8 +169,12 @@ typedef struct {
     uint8_t ble_hci_uart_uart_parity;
     uint8_t enable_tx_cca;
     uint8_t cca_rssi_thresh;
+    uint8_t cca_drop_mode;
+    int8_t  cca_low_tx_pwr;
     uint8_t sleep_en;
     uint8_t coex_phy_coded_tx_rx_time_limit;
+    uint8_t dis_scan_backoff;
+    uint8_t scan_classify_filter_enable;
     uint32_t config_magic;
 } esp_bt_controller_config_t;
 

+ 7 - 1
components/bt/include/esp32h2/include/esp_bt_cfg.h

@@ -10,6 +10,7 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include "esp_err.h"
+#include "sdkconfig.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -192,7 +193,12 @@ extern "C" {
 
 #define BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N     (3000)
 
-#define RTC_FREQ_N                          (32000) /* in Hz */
+#if CONFIG_RTC_CLK_SRC_EXT_CRYS
+#define RTC_FREQ_N                          (32768) /* in Hz */
+#else
+#pragma message "RTC clock source not available"
+#endif
+
 
 #define BLE_LL_TX_PWR_DBM_N                 (0)