Skip to content

Commit

Permalink
Merge branch 'feat/support_ble_get_callback' into 'master'
Browse files Browse the repository at this point in the history
Feat/support ble get callback

See merge request espressif/esp-idf!28355
  • Loading branch information
Isl2017 committed Jan 22, 2024
2 parents 4486286 + ee4d4f1 commit f8a12ad
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/bt/controller/esp32/Kconfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ config BTDM_SCAN_DUPL_CACHE_SIZE
default 100
help
Maximum number of devices which can be recorded in scan duplicate filter.
When the maximum amount of device in the filter is reached, the cache will be refreshed.
When the maximum amount of device in the filter is reached, the oldest device will be refreshed.

config BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD
int "Duplicate scan list refresh period (seconds)"
Expand Down
5 changes: 5 additions & 0 deletions components/bt/host/bluedroid/api/esp_gap_ble_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback)
return (btc_profile_cb_set(BTC_PID_GAP_BLE, callback) == 0 ? ESP_OK : ESP_FAIL);
}

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);
}

#if (BLE_42_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data)
{
Expand Down
7 changes: 6 additions & 1 deletion components/bt/host/bluedroid/api/esp_gattc_api.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -29,6 +29,11 @@ esp_err_t esp_ble_gattc_register_callback(esp_gattc_cb_t callback)
return ESP_OK;
}

esp_gattc_cb_t esp_ble_gattc_get_callback(void)
{
return (esp_gattc_cb_t) btc_profile_cb_get(BTC_PID_GATTC);
}

esp_err_t esp_ble_gattc_app_register(uint16_t app_id)
{
btc_msg_t msg = {0};
Expand Down
5 changes: 5 additions & 0 deletions components/bt/host/bluedroid/api/esp_gatts_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ esp_err_t esp_ble_gatts_register_callback(esp_gatts_cb_t callback)
return (btc_profile_cb_set(BTC_PID_GATTS, callback) == 0 ? ESP_OK : ESP_FAIL);
}

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_app_register(uint16_t app_id)
{
btc_msg_t msg = {0};
Expand Down
21 changes: 17 additions & 4 deletions components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -459,7 +459,10 @@ typedef enum {
typedef enum {
BLE_SCAN_DUPLICATE_DISABLE = 0x0, /*!< the Link Layer should generate advertising reports to the host for each packet received */
BLE_SCAN_DUPLICATE_ENABLE = 0x1, /*!< the Link Layer should filter out duplicate advertising reports to the Host */
BLE_SCAN_DUPLICATE_MAX = 0x2, /*!< 0x02 – 0xFF, Reserved for future use */
#if (BLE_50_FEATURE_SUPPORT == TRUE)
BLE_SCAN_DUPLICATE_ENABLE_RESET, /*!< Duplicate filtering enabled, reset for each scan period, only supported in BLE 5.0. */
#endif
BLE_SCAN_DUPLICATE_MAX /*!< Reserved for future use. */
} esp_ble_scan_duplicate_t;
#if (BLE_42_FEATURE_SUPPORT == TRUE)
/// Ble scan parameters
Expand Down Expand Up @@ -1489,6 +1492,15 @@ typedef void (* esp_gap_ble_cb_t)(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_p
*/
esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback);

/**
* @brief This function is called to get the current gap callback
*
* @return
* - esp_gap_ble_cb_t : callback function
*
*/
esp_gap_ble_cb_t esp_ble_gap_get_callback(void);

#if (BLE_42_FEATURE_SUPPORT == TRUE)
/**
* @brief This function is called to override the BTA default ADV parameters.
Expand Down Expand Up @@ -2288,8 +2300,9 @@ esp_err_t esp_ble_gap_set_ext_scan_params(const esp_ble_ext_scan_params_t *param
/**
* @brief This function is used to enable scanning.
*
* @param[in] duration : Scan duration
* @param[in] period : Time interval from when the Controller started its last Scan Duration until it begins the subsequent Scan Duration.
* @param[in] duration Scan duration time, where Time = N * 10 ms. Range: 0x0001 to 0xFFFF.
* @param[in] period Time interval from when the Controller started its last Scan Duration until it begins the subsequent Scan Duration.
* Time = N * 1.28 sec. Range: 0x0001 to 0xFFFF.
*
* @return - ESP_OK : success
* - other : failed
Expand Down
11 changes: 10 additions & 1 deletion components/bt/host/bluedroid/api/include/api/esp_gattc_api.h
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -273,6 +273,15 @@ typedef void (* esp_gattc_cb_t)(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_
*/
esp_err_t esp_ble_gattc_register_callback(esp_gattc_cb_t callback);

/**
* @brief This function is called to get the current application callbacks
* with BTA GATTC module.
*
* @return
* - esp_gattC_cb_t : current callback
*
*/
esp_gattc_cb_t esp_ble_gattc_get_callback(void);

/**
* @brief This function is called to register application callbacks
Expand Down
10 changes: 10 additions & 0 deletions components/bt/host/bluedroid/api/include/api/esp_gatts_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ typedef void (* esp_gatts_cb_t)(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_
*/
esp_err_t esp_ble_gatts_register_callback(esp_gatts_cb_t callback);

/**
* @brief This function is called to get the current application callbacks
* with BTA GATTS module.
*
* @return
* - esp_gatts_cb_t : current callback
*
*/
esp_gatts_cb_t esp_ble_gatts_get_callback(void);

/**
* @brief This function is called to register application identifier
*
Expand Down

0 comments on commit f8a12ad

Please sign in to comment.