Component/bt: add esp_ble_gap_get_local_used_addr() API
This commit is contained in:
parent
da27816314
commit
8a78860b16
4 changed files with 68 additions and 1 deletions
|
@ -268,6 +268,18 @@ esp_err_t esp_ble_gap_set_device_name(const char *name)
|
||||||
return esp_bt_dev_set_device_name(name);
|
return esp_bt_dev_set_device_name(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_ble_gap_get_local_used_addr(esp_bd_addr_t local_used_addr, uint8_t * addr_type)
|
||||||
|
{
|
||||||
|
if(esp_bluedroid_get_status() != (ESP_BLUEDROID_STATUS_ENABLED)) {
|
||||||
|
LOG_ERROR("%s, bluedroid status error", __func__);
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
|
if(!BTM_BleGetCurrentAddress(local_used_addr, addr_type)) {
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *length)
|
uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *length)
|
||||||
{
|
{
|
||||||
if (((type < ESP_BLE_AD_TYPE_FLAG) || (type > ESP_BLE_AD_TYPE_128SERVICE_DATA)) &&
|
if (((type < ESP_BLE_AD_TYPE_FLAG) || (type > ESP_BLE_AD_TYPE_128SERVICE_DATA)) &&
|
||||||
|
|
|
@ -830,7 +830,18 @@ esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_ble_gap_set_device_name(const char *name);
|
esp_err_t esp_ble_gap_set_device_name(const char *name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function is called to get local used address and adress type.
|
||||||
|
* uint8_t *esp_bt_dev_get_address(void) get the public address
|
||||||
|
*
|
||||||
|
* @param[in] local_used_addr - current local used ble address (six bytes)
|
||||||
|
* @param[in] addr_type - ble address type
|
||||||
|
*
|
||||||
|
* @return - ESP_OK : success
|
||||||
|
* - other : failed
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
esp_err_t esp_ble_gap_get_local_used_addr(esp_bd_addr_t local_used_addr, uint8_t * addr_type);
|
||||||
/**
|
/**
|
||||||
* @brief This function is called to get ADV data for a specific type.
|
* @brief This function is called to get ADV data for a specific type.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1588,6 +1588,37 @@ BOOLEAN BTM_BleSetRandAddress(BD_ADDR rand_addr)
|
||||||
return set_flag;
|
return set_flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
** Function BTM_BleGetCurrentAddress
|
||||||
|
**
|
||||||
|
** Description This function is called to get local used BLE address.
|
||||||
|
**
|
||||||
|
** Parameters: None.
|
||||||
|
**
|
||||||
|
** Returns success or fail
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type)
|
||||||
|
{
|
||||||
|
if(addr == NULL || addr_type == NULL) {
|
||||||
|
BTM_TRACE_ERROR("%s addr or addr_type is NULL\n", __func__);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if(btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM) {
|
||||||
|
*addr_type = BLE_ADDR_RANDOM;
|
||||||
|
memcpy(addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, BD_ADDR_LEN);
|
||||||
|
} else if(btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_PUBLIC) {
|
||||||
|
*addr_type = BLE_ADDR_PUBLIC;
|
||||||
|
memcpy(addr, &controller_get_interface()->get_address()->address, BD_ADDR_LEN);
|
||||||
|
} else {
|
||||||
|
BTM_TRACE_ERROR("%s\n", __func__);
|
||||||
|
memset(addr, 0, BD_ADDR_LEN);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function BTM_CheckAdvData
|
** Function BTM_CheckAdvData
|
||||||
|
|
|
@ -1541,6 +1541,19 @@ void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback);
|
||||||
//extern
|
//extern
|
||||||
UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length);
|
UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length);
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
** Function BTM_BleGetCurrentAddress
|
||||||
|
**
|
||||||
|
** Description This function is called to get local used BLE address.
|
||||||
|
**
|
||||||
|
** Parameters: None.
|
||||||
|
**
|
||||||
|
** Returns success or fail
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type);
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function BTM__BLEReadDiscoverability
|
** Function BTM__BLEReadDiscoverability
|
||||||
|
|
Loading…
Reference in a new issue