feat(nimble): Added API to get local used address

This commit is contained in:
Abhinav Kudnar
2024-05-15 12:11:47 +05:30
committed by Rahul Tank
parent 0a482da982
commit 5a1245bcaa
2 changed files with 30 additions and 0 deletions
+9
View File
@@ -112,6 +112,15 @@ int ble_gap_wl_read_size(uint8_t *size);
*/
int ble_gap_host_check_status(void);
/**
* This API is called to get local used address and address type.
*
* @param addr On success, locally used address will be stored here.
*
* @return 0 on success; nonzero on failure.
*/
int ble_gap_get_local_used_addr(ble_addr_t *addr);
#if MYNEWT_VAL(BLE_HCI_VS)
#if MYNEWT_VAL(BLE_POWER_CONTROL)
+21
View File
@@ -805,6 +805,27 @@ ble_gap_set_prefered_le_phy(uint16_t conn_handle, uint8_t tx_phys_mask,
#endif
}
int ble_gap_get_local_used_addr(ble_addr_t *addr)
{
uint8_t own_addr_type = 0;
const uint8_t *out_id_addr;
int rc;
if (addr == NULL) {
return ESP_FAIL;
}
own_addr_type = ble_gap_slave[0].our_addr_type;
rc = ble_hs_id_addr(own_addr_type, &out_id_addr,NULL);
if (rc == 0) {
addr->type = own_addr_type;
memcpy(addr->val, out_id_addr, BLE_DEV_ADDR_LEN);
}
return rc;
}
/*****************************************************************************
* $misc *
*****************************************************************************/