mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-12 21:17:57 +00:00
feat(nimble): Added API to get local used address
This commit is contained in:
committed by
Rahul Tank
parent
0a482da982
commit
5a1245bcaa
@@ -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)
|
||||
|
||||
|
||||
@@ -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 *
|
||||
*****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user