mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(ble/bluedroid): add API to get local BLE IRK
(cherry picked from commit 3c68650d7e)
Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
This commit is contained in:
@@ -805,6 +805,28 @@ esp_err_t esp_ble_create_sc_oob_data(void)
|
|||||||
|
|
||||||
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_ble_gap_get_local_irk(uint8_t local_irk[16])
|
||||||
|
{
|
||||||
|
if (local_irk == NULL) {
|
||||||
|
ESP_LOGE(__func__, "local_irk is NULL");
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||||
|
ESP_LOGE(__func__, "Bluedroid is not enabled");
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use BTM API to safely retrieve local IRK */
|
||||||
|
if (BTM_GetLocalIRK(local_irk)) {
|
||||||
|
ESP_LOGD(__func__, "Local IRK retrieved successfully");
|
||||||
|
return ESP_OK;
|
||||||
|
} else {
|
||||||
|
ESP_LOGW(__func__, "Local IRK not available");
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif /* #if (SMP_INCLUDED == TRUE) */
|
#endif /* #if (SMP_INCLUDED == TRUE) */
|
||||||
|
|
||||||
esp_err_t esp_ble_gap_disconnect(esp_bd_addr_t remote_device)
|
esp_err_t esp_ble_gap_disconnect(esp_bd_addr_t remote_device)
|
||||||
|
|||||||
@@ -2081,6 +2081,7 @@ esp_err_t esp_ble_gap_set_resolvable_private_address_timeout(uint16_t rpa_timeou
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_ble_gap_add_device_to_resolving_list(esp_bd_addr_t peer_addr, uint8_t addr_type, uint8_t *peer_irk);
|
esp_err_t esp_ble_gap_add_device_to_resolving_list(esp_bd_addr_t peer_addr, uint8_t addr_type, uint8_t *peer_irk);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function clears the random address for the application
|
* @brief This function clears the random address for the application
|
||||||
*
|
*
|
||||||
@@ -2486,6 +2487,28 @@ esp_err_t esp_ble_sc_oob_req_reply(esp_bd_addr_t bd_addr, uint8_t p_c[16], uint8
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_ble_create_sc_oob_data(void);
|
esp_err_t esp_ble_create_sc_oob_data(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the local Identity Resolving Key (IRK).
|
||||||
|
*
|
||||||
|
* @note This API retrieves the local IRK stored in the device's security database.
|
||||||
|
* The IRK is used by the controller to generate and resolve Resolvable Private Addresses (RPA).
|
||||||
|
* The IRK length is always 16 bytes (ESP_BT_OCTET16_LEN).
|
||||||
|
*
|
||||||
|
* @note Usage Restrictions: Do NOT call this API during a disconnection event or while
|
||||||
|
* a BLE disconnection is in progress. Calling this API during disconnection may lead
|
||||||
|
* to undefined behavior or accessing invalid information.
|
||||||
|
*
|
||||||
|
* @param[out] local_irk: Buffer to hold the 16-byte IRK. The array notation [16] explicitly
|
||||||
|
* indicates the required buffer size (ESP_BT_OCTET16_LEN).
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - ESP_OK : success
|
||||||
|
* - ESP_ERR_INVALID_ARG : local_irk is NULL
|
||||||
|
* - ESP_ERR_INVALID_STATE : BLE stack not initialized or IRK not available
|
||||||
|
*/
|
||||||
|
esp_err_t esp_ble_gap_get_local_irk(uint8_t local_irk[16]);
|
||||||
|
|
||||||
#endif /* #if (SMP_INCLUDED == TRUE) */
|
#endif /* #if (SMP_INCLUDED == TRUE) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4870,4 +4870,16 @@ bool btm_ble_adv_pkt_post(pkt_linked_item_t *pkt)
|
|||||||
}
|
}
|
||||||
#endif // #if (BLE_42_SCAN_EN == TRUE)
|
#endif // #if (BLE_42_SCAN_EN == TRUE)
|
||||||
|
|
||||||
|
#if (SMP_INCLUDED == TRUE)
|
||||||
|
/* Retrieve local IRK safely */
|
||||||
|
bool BTM_GetLocalIRK(uint8_t *irk)
|
||||||
|
{
|
||||||
|
if (!irk) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(irk, btm_cb.devcb.id_keys.irk, sizeof(btm_cb.devcb.id_keys.irk));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif // (SMP_INCLUDED == TRUE)
|
||||||
#endif /* BLE_INCLUDED */
|
#endif /* BLE_INCLUDED */
|
||||||
|
|||||||
@@ -2561,6 +2561,20 @@ void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback);
|
|||||||
//extern
|
//extern
|
||||||
UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT16 adv_data_len, UINT8 type, UINT8 *p_length);
|
UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT16 adv_data_len, UINT8 type, UINT8 *p_length);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
**
|
||||||
|
** Function BTM_GetLocalIRK
|
||||||
|
**
|
||||||
|
** Description Get the local Identity Resolving Key (IRK) from the device control block.
|
||||||
|
**
|
||||||
|
** Parameters irk : output buffer (16 bytes) to copy IRK into
|
||||||
|
**
|
||||||
|
** Returns true if IRK is available, false otherwise
|
||||||
|
**
|
||||||
|
******************************************************************************/
|
||||||
|
bool BTM_GetLocalIRK(uint8_t *irk);
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function BTM_BleGetCurrentAddress
|
** Function BTM_BleGetCurrentAddress
|
||||||
|
|||||||
Reference in New Issue
Block a user