Commit e24df527 authored by Vinayak Kariappa Chettimada's avatar Vinayak Kariappa Chettimada Committed by Anas Nashif
Browse files

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: default avatarVinayak Kariappa Chettimada <vich@nordicsemi.no>
parent a3e8f83e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)
+2 −1
Original line number Diff line number Diff line
@@ -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);
+25 −21
Original line number Diff line number Diff line
@@ -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));
+2 −2
Original line number Diff line number Diff line
@@ -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);
		}
	}

+0 −10
Original line number Diff line number Diff line
@@ -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 */
Loading