Bluetooth: Controller: Separate address get and read functions
Have separate Bluetooth Device address get and read functions, remove use of function just to return Extended Advertising Random address and replace with simple assignment statement. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
d7cfb5473b
commit
aa4b75b58c
10 changed files with 36 additions and 45 deletions
|
@ -852,7 +852,7 @@ static void read_bd_addr(struct net_buf *buf, struct net_buf **evt)
|
|||
|
||||
rp->status = 0x00;
|
||||
|
||||
ll_addr_get(0, &rp->bdaddr.val[0]);
|
||||
(void)ll_addr_read(0, &rp->bdaddr.val[0]);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_HCI_CODEC_AND_DELAY_INFO)
|
||||
|
|
|
@ -15,8 +15,9 @@ void ll_reset(void);
|
|||
uint8_t ll_set_host_feature(uint8_t bit_number, uint8_t bit_value);
|
||||
uint64_t ll_feat_get(void);
|
||||
|
||||
uint8_t *ll_addr_get(uint8_t addr_type, uint8_t *p_bdaddr);
|
||||
uint8_t ll_addr_set(uint8_t addr_type, uint8_t const *const p_bdaddr);
|
||||
uint8_t *ll_addr_get(uint8_t addr_type);
|
||||
uint8_t *ll_addr_read(uint8_t addr_type, uint8_t *const bdaddr);
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_HCI_ADV_HANDLE_MAPPING)
|
||||
uint8_t ll_adv_set_by_hci_handle_get(uint8_t hci_handle, uint8_t *handle);
|
||||
|
|
|
@ -34,27 +34,6 @@
|
|||
static uint8_t pub_addr[BDADDR_SIZE];
|
||||
static uint8_t rnd_addr[BDADDR_SIZE];
|
||||
|
||||
uint8_t *ll_addr_get(uint8_t addr_type, uint8_t *bdaddr)
|
||||
{
|
||||
if (addr_type > 1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (addr_type) {
|
||||
if (bdaddr) {
|
||||
memcpy(bdaddr, rnd_addr, BDADDR_SIZE);
|
||||
}
|
||||
|
||||
return rnd_addr;
|
||||
}
|
||||
|
||||
if (bdaddr) {
|
||||
memcpy(bdaddr, pub_addr, BDADDR_SIZE);
|
||||
}
|
||||
|
||||
return pub_addr;
|
||||
}
|
||||
|
||||
uint8_t ll_addr_set(uint8_t addr_type, uint8_t const *const bdaddr)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_BT_BROADCASTER)) {
|
||||
|
@ -81,6 +60,31 @@ uint8_t ll_addr_set(uint8_t addr_type, uint8_t const *const bdaddr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint8_t *ll_addr_get(uint8_t addr_type)
|
||||
{
|
||||
if (addr_type > BT_ADDR_LE_RANDOM) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (addr_type) {
|
||||
return rnd_addr;
|
||||
}
|
||||
|
||||
return pub_addr;
|
||||
}
|
||||
|
||||
uint8_t *ll_addr_read(uint8_t addr_type, uint8_t *const bdaddr)
|
||||
{
|
||||
uint8_t *addr;
|
||||
|
||||
addr = ll_addr_get(addr_type);
|
||||
if (addr) {
|
||||
memcpy(bdaddr, addr, BDADDR_SIZE);
|
||||
}
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
void bt_ctlr_set_public_addr(const uint8_t *addr)
|
||||
{
|
||||
(void)memcpy(pub_addr, addr, sizeof(pub_addr));
|
||||
|
|
|
@ -2709,10 +2709,10 @@ static const uint8_t *adva_update(struct ll_adv_set *adv, struct pdu_adv *pdu)
|
|||
if (0) {
|
||||
#if defined(CONFIG_BT_CTLR_ADV_EXT)
|
||||
} else if (ll_adv_cmds_is_ext() && pdu->tx_addr) {
|
||||
own_id_addr = ull_adv_aux_random_addr_get(adv, NULL);
|
||||
own_id_addr = adv->rnd_addr;
|
||||
#endif
|
||||
} else {
|
||||
own_id_addr = ll_addr_get(pdu->tx_addr, NULL);
|
||||
own_id_addr = ll_addr_get(pdu->tx_addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -441,16 +441,6 @@ int ull_adv_aux_reset_finalize(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint8_t const *ull_adv_aux_random_addr_get(struct ll_adv_set const *const adv,
|
||||
uint8_t *const addr)
|
||||
{
|
||||
if (addr) {
|
||||
(void)memcpy(addr, adv->rnd_addr, BDADDR_SIZE);
|
||||
}
|
||||
|
||||
return adv->rnd_addr;
|
||||
}
|
||||
|
||||
uint8_t ull_adv_aux_chm_update(void)
|
||||
{
|
||||
/* For each created extended advertising set */
|
||||
|
|
|
@ -72,10 +72,6 @@ int ull_adv_aux_reset_finalize(void);
|
|||
/* Return the aux set handle given the aux set instance */
|
||||
uint8_t ull_adv_aux_handle_get(struct ll_adv_aux_set *aux);
|
||||
|
||||
/* Helper to read back random address */
|
||||
uint8_t const *ull_adv_aux_random_addr_get(struct ll_adv_set const *const adv,
|
||||
uint8_t *const addr);
|
||||
|
||||
/* Helper function to apply Channel Map Update for auxiliary PDUs */
|
||||
uint8_t ull_adv_aux_chm_update(void);
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window,
|
|||
const uint8_t *own_id_addr;
|
||||
|
||||
/* Do not connect twice to the same peer */
|
||||
own_id_addr = ll_addr_get(own_id_addr_type, NULL);
|
||||
own_id_addr = ll_addr_get(own_id_addr_type);
|
||||
if (ull_conn_peer_connected(own_id_addr_type, own_id_addr,
|
||||
peer_addr_type, peer_addr)) {
|
||||
return BT_HCI_ERR_CONN_ALREADY_EXISTS;
|
||||
|
|
|
@ -188,7 +188,7 @@ uint8_t ll_scan_enable(uint8_t enable)
|
|||
|
||||
if ((is_coded_phy && (own_addr_type & 0x1)) ||
|
||||
(!is_coded_phy && (scan->own_addr_type & 0x1))) {
|
||||
if (!mem_nz(ll_addr_get(1, NULL), BDADDR_SIZE)) {
|
||||
if (!mem_nz(ll_addr_get(BT_ADDR_LE_RANDOM), BDADDR_SIZE)) {
|
||||
return BT_HCI_ERR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ uint8_t ull_scan_enable(struct ll_scan_set *scan)
|
|||
uint32_t ret;
|
||||
|
||||
lll->init_addr_type = scan->own_addr_type;
|
||||
ll_addr_get(lll->init_addr_type, lll->init_addr);
|
||||
(void)ll_addr_read(lll->init_addr_type, lll->init_addr);
|
||||
lll->chan = 0U;
|
||||
lll->is_stop = 0U;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "bt.h"
|
||||
|
||||
int cmd_ll_addr_get(const struct shell *sh, size_t argc, char *argv[])
|
||||
int cmd_ll_addr_read(const struct shell *sh, size_t argc, char *argv[])
|
||||
{
|
||||
uint8_t addr_type;
|
||||
const char *str_type;
|
||||
|
@ -44,7 +44,7 @@ int cmd_ll_addr_get(const struct shell *sh, size_t argc, char *argv[])
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
(void)ll_addr_get(addr_type, addr.val);
|
||||
(void)ll_addr_read(addr_type, addr.val);
|
||||
bt_addr_to_str(&addr, str_addr, sizeof(str_addr));
|
||||
|
||||
shell_print(sh, "Current %s address: %s", str_type, str_addr);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#ifndef __LL_H
|
||||
#define __LL_H
|
||||
|
||||
int cmd_ll_addr_get(const struct shell *sh, size_t argc, char *argv[]);
|
||||
int cmd_ll_addr_read(const struct shell *sh, size_t argc, char *argv[]);
|
||||
|
||||
int cmd_advx(const struct shell *sh, size_t argc, char *argv[]);
|
||||
int cmd_scanx(const struct shell *sh, size_t argc, char *argv[]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue