diff --git a/components/bt/common/btc/core/btc_manage.c b/components/bt/common/btc/core/btc_manage.c index 52aa837b99..1377bfd6c7 100644 --- a/components/bt/common/btc/core/btc_manage.c +++ b/components/bt/common/btc/core/btc_manage.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -10,8 +10,10 @@ #if BTC_DYNAMIC_MEMORY == FALSE void *btc_profile_cb_tab[BTC_PID_NUM] = {}; +void *btc_profile_ptr_tab[BTC_PID_NUM] = {}; #else void **btc_profile_cb_tab; +void **btc_profile_ptr_tab; #endif void esp_profile_cb_reset(void) @@ -20,6 +22,7 @@ void esp_profile_cb_reset(void) for (i = 0; i < BTC_PID_NUM; i++) { btc_profile_cb_tab[i] = NULL; + btc_profile_ptr_tab[i] = NULL; } } @@ -42,3 +45,23 @@ void *btc_profile_cb_get(btc_pid_t profile_id) return btc_profile_cb_tab[profile_id]; } + +int btc_profile_ptr_set(btc_pid_t profile_id, void *ptr) +{ + if (profile_id < 0 || profile_id >= BTC_PID_NUM) { + return -1; + } + + btc_profile_ptr_tab[profile_id] = ptr; + + return 0; +} + +void *btc_profile_ptr_get(btc_pid_t profile_id) +{ + if (profile_id < 0 || profile_id >= BTC_PID_NUM) { + return NULL; + } + + return btc_profile_ptr_tab[profile_id]; +} diff --git a/components/bt/common/btc/core/btc_task.c b/components/bt/common/btc/core/btc_task.c index 0f2b6bc0b7..7072a030aa 100644 --- a/components/bt/common/btc/core/btc_task.c +++ b/components/bt/common/btc/core/btc_task.c @@ -295,8 +295,8 @@ static bt_status_t btc_task_post(btc_msg_t *msg, uint32_t timeout) /** * transfer an message to another module in the different task. * @param msg message - * @param arg paramter - * @param arg_len length of paramter + * @param arg parameter + * @param arg_len length of parameter * @param copy_func deep copy function * @param free_func deep free function * @return BT_STATUS_SUCCESS: success @@ -342,7 +342,7 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg } /** - * transfer an message to another module in tha same task. + * transfer an message to another module in the same task. * @param msg message * @return BT_STATUS_SUCCESS: success * others: fail @@ -380,6 +380,11 @@ static void btc_deinit_mem(void) { btc_profile_cb_tab = NULL; } + if (btc_profile_ptr_tab) { + osi_free(btc_profile_ptr_tab); + btc_profile_ptr_tab = NULL; + } + #if (BLE_INCLUDED == TRUE) if (gl_bta_adv_data_ptr) { osi_free(gl_bta_adv_data_ptr); @@ -442,6 +447,11 @@ static bt_status_t btc_init_mem(void) { } memset((void *)btc_profile_cb_tab, 0, sizeof(void *) * BTC_PID_NUM); + if ((btc_profile_ptr_tab = (void **)osi_malloc(sizeof(void *) * BTC_PID_NUM)) == NULL) { + goto error_exit; + } + memset((void *)btc_profile_ptr_tab, 0, sizeof(void *) * BTC_PID_NUM); + #if (BLE_INCLUDED == TRUE) if ((gl_bta_adv_data_ptr = (tBTA_BLE_ADV_DATA *)osi_malloc(sizeof(tBTA_BLE_ADV_DATA))) == NULL) { goto error_exit; diff --git a/components/bt/common/btc/include/btc/btc_manage.h b/components/bt/common/btc/include/btc/btc_manage.h index b55c1a3a85..526d9982b7 100644 --- a/components/bt/common/btc/include/btc/btc_manage.h +++ b/components/bt/common/btc/include/btc/btc_manage.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -11,8 +11,10 @@ #if BTC_DYNAMIC_MEMORY == FALSE extern void *btc_profile_cb_tab[BTC_PID_NUM]; +extern void *btc_profile_ptr_tab[BTC_PID_NUM]; #else extern void **btc_profile_cb_tab; +extern void **btc_profile_ptr_tab; #endif /* reset gatt callback table */ void esp_profile_cb_reset(void); @@ -20,4 +22,7 @@ void esp_profile_cb_reset(void); int btc_profile_cb_set(btc_pid_t profile_id, void *cb); void *btc_profile_cb_get(btc_pid_t profile_id); +int btc_profile_ptr_set(btc_pid_t profile_id, void *ptr); +void *btc_profile_ptr_get(btc_pid_t profile_id); + #endif /* __BTC_MANAGE_H__ */ diff --git a/components/bt/host/bluedroid/api/esp_gap_ble_api.c b/components/bt/host/bluedroid/api/esp_gap_ble_api.c index 1d2267e8bc..7e39fca7ee 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -27,6 +27,18 @@ esp_gap_ble_cb_t esp_ble_gap_get_callback(void) return (esp_gap_ble_cb_t) btc_profile_cb_get(BTC_PID_GAP_BLE); } +esp_err_t esp_ble_gap_register_ptr(void *ptr) +{ + ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); + + return (btc_profile_ptr_set(BTC_PID_GAP_BLE, ptr) == 0 ? ESP_OK : ESP_FAIL); +} + +void *esp_ble_gap_get_ptr(void) +{ + return btc_profile_ptr_get(BTC_PID_GAP_BLE); +} + #if (BLE_42_FEATURE_SUPPORT == TRUE) esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data) { diff --git a/components/bt/host/bluedroid/api/esp_gatts_api.c b/components/bt/host/bluedroid/api/esp_gatts_api.c index 66fa5c6617..b500a1e23f 100644 --- a/components/bt/host/bluedroid/api/esp_gatts_api.c +++ b/components/bt/host/bluedroid/api/esp_gatts_api.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -34,6 +34,18 @@ esp_gatts_cb_t esp_ble_gatts_get_callback(void) return (esp_gatts_cb_t) btc_profile_cb_get(BTC_PID_GATTS); } +esp_err_t esp_ble_gatts_register_ptr(void *ptr) +{ + ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); + + return (btc_profile_ptr_set(BTC_PID_GATTS, ptr) == 0 ? ESP_OK : ESP_FAIL); +} + +void *esp_ble_gatts_get_ptr(void) +{ + return btc_profile_ptr_get(BTC_PID_GATTS); +} + esp_err_t esp_ble_gatts_app_register(uint16_t app_id) { btc_msg_t msg = {0}; @@ -272,7 +284,7 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id, } if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) { - LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); + LOG_DEBUG("%s, the l2cap channel is congest.", __func__); return ESP_FAIL; } diff --git a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h index 75fd3419e6..b6ebbe9714 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h @@ -1583,6 +1583,27 @@ esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback); */ esp_gap_ble_cb_t esp_ble_gap_get_callback(void); +/** + * @brief This function is called to register user pointer + * + * @param[in] ptr: user pointer to set + * + * @return + * - ESP_OK : success + * - other : failed + * + */ +esp_err_t esp_ble_gap_register_ptr(void *ptr); + +/** + * @brief This function is called to get the current gap user pointer + * + * @return + * - current user pointer (may be NULL if not set) + * + */ +void *esp_ble_gap_get_ptr(void); + #if (BLE_42_FEATURE_SUPPORT == TRUE) /** * @brief This function is called to override the BTA default ADV parameters. diff --git a/components/bt/host/bluedroid/api/include/api/esp_gatts_api.h b/components/bt/host/bluedroid/api/include/api/esp_gatts_api.h index 0eb7ddd98b..ac1526bf66 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gatts_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gatts_api.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -305,6 +305,27 @@ esp_err_t esp_ble_gatts_register_callback(esp_gatts_cb_t callback); */ esp_gatts_cb_t esp_ble_gatts_get_callback(void); +/** + * @brief This function is called to register application user pointer + * with BTA GATTS module. + * + * @return + * - ESP_OK : success + * - other : failed + * + */ +esp_err_t esp_ble_gatts_register_ptr(void *ptr); + +/** + * @brief This function is called to get the current application user pointer + * with BTA GATTS module. + * + * @return + * - current user pointer (may be NULL if not set) + * + */ +void *esp_ble_gatts_get_ptr(void); + /** * @brief This function is called to register application identifier * diff --git a/tools/ci/check_public_headers_exceptions.txt b/tools/ci/check_public_headers_exceptions.txt index bb81391912..31ba84d1e8 100644 --- a/tools/ci/check_public_headers_exceptions.txt +++ b/tools/ci/check_public_headers_exceptions.txt @@ -20,10 +20,7 @@ components/log/include/esp_log_internal.h # LWIP: sockets.h uses #include_next<>, which doesn't work correctly with the checker # memp_std.h is supposed to be included multiple times with different settings -components/lwip/lwip/src/include/lwip/priv/memp_std.h components/lwip/include/lwip/sockets.h -components/lwip/lwip/src/include/lwip/prot/nd6.h -components/lwip/lwip/src/include/netif/ppp/ components/spi_flash/include/spi_flash_chip_issi.h components/spi_flash/include/spi_flash_chip_mxic.h @@ -58,13 +55,9 @@ components/json/cJSON/ components/spiffs/include/spiffs_config.h -components/unity/unity/src/unity_internals.h -components/unity/unity/extras/ components/unity/include/unity_config.h components/unity/include/unity_test_runner.h -components/cmock/CMock/src/cmock.h -components/cmock/CMock/src/cmock_internals.h components/openthread/openthread/