Bluetooth: Use bt_id_get function to get count
Allow NULL pointer to be passed to bt_id_get function so that only count can be fetched. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
986db52e90
commit
92f5b68f2c
2 changed files with 11 additions and 3 deletions
|
@ -182,6 +182,10 @@ __deprecated int bt_set_id_addr(const bt_addr_le_t *addr);
|
|||
* identifier that some APIs expect (such as advertising parameters) is
|
||||
* simply the index of the identity in the @a addrs array.
|
||||
*
|
||||
* If @a addrs is passed as NULL, then returned @a count contains the
|
||||
* count of all available identities that can be retrieved with a
|
||||
* subsequent call to this function with non-NULL @a addrs parameter.
|
||||
*
|
||||
* @note Deleted identities may show up as BT_LE_ADDR_ANY in the returned
|
||||
* array.
|
||||
*
|
||||
|
|
|
@ -6716,10 +6716,14 @@ int bt_set_id_addr(const bt_addr_le_t *addr)
|
|||
|
||||
void bt_id_get(bt_addr_le_t *addrs, size_t *count)
|
||||
{
|
||||
if (addrs) {
|
||||
size_t to_copy = MIN(*count, bt_dev.id_count);
|
||||
|
||||
memcpy(addrs, bt_dev.id_addr, to_copy * sizeof(bt_addr_le_t));
|
||||
*count = to_copy;
|
||||
} else {
|
||||
*count = bt_dev.id_count;
|
||||
}
|
||||
}
|
||||
|
||||
static int id_find(const bt_addr_le_t *addr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue