Bluetooth: controller: Use HCI defines for constants
Use HCI defines for PHY, and RSSI constants. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
20939b7b11
commit
d80d79e7f9
9 changed files with 42 additions and 34 deletions
|
@ -1967,6 +1967,8 @@ struct bt_hci_evt_le_conn_complete {
|
||||||
uint8_t clock_accuracy;
|
uint8_t clock_accuracy;
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
|
#define BT_HCI_LE_RSSI_NOT_AVAILABLE 0x7F
|
||||||
|
|
||||||
#define BT_HCI_EVT_LE_ADVERTISING_REPORT 0x02
|
#define BT_HCI_EVT_LE_ADVERTISING_REPORT 0x02
|
||||||
struct bt_hci_evt_le_advertising_info {
|
struct bt_hci_evt_le_advertising_info {
|
||||||
uint8_t evt_type;
|
uint8_t evt_type;
|
||||||
|
|
|
@ -1916,12 +1916,12 @@ static void le_set_phy(struct net_buf *buf, struct net_buf **evt)
|
||||||
handle = sys_le16_to_cpu(cmd->handle);
|
handle = sys_le16_to_cpu(cmd->handle);
|
||||||
phy_opts = sys_le16_to_cpu(cmd->phy_opts);
|
phy_opts = sys_le16_to_cpu(cmd->phy_opts);
|
||||||
|
|
||||||
mask_phys = 0x01;
|
mask_phys = BT_HCI_LE_PHY_PREFER_1M;
|
||||||
if (IS_ENABLED(CONFIG_BT_CTLR_PHY_2M)) {
|
if (IS_ENABLED(CONFIG_BT_CTLR_PHY_2M)) {
|
||||||
mask_phys |= BIT(1);
|
mask_phys |= BT_HCI_LE_PHY_PREFER_2M;
|
||||||
}
|
}
|
||||||
if (IS_ENABLED(CONFIG_BT_CTLR_PHY_CODED)) {
|
if (IS_ENABLED(CONFIG_BT_CTLR_PHY_CODED)) {
|
||||||
mask_phys |= BIT(2);
|
mask_phys |= BT_HCI_LE_PHY_PREFER_CODED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd->all_phys & BT_HCI_LE_PHY_TX_ANY) {
|
if (cmd->all_phys & BT_HCI_LE_PHY_TX_ANY) {
|
||||||
|
@ -3986,7 +3986,7 @@ static void le_ext_adv_legacy_report(struct pdu_data *pdu_data,
|
||||||
adv_info->prim_phy = BT_HCI_LE_EXT_SCAN_PHY_1M;
|
adv_info->prim_phy = BT_HCI_LE_EXT_SCAN_PHY_1M;
|
||||||
adv_info->sec_phy = 0U;
|
adv_info->sec_phy = 0U;
|
||||||
adv_info->sid = 0xff;
|
adv_info->sid = 0xff;
|
||||||
adv_info->tx_power = 0x7f;
|
adv_info->tx_power = BT_HCI_LE_ADV_TX_POWER_NO_PREF;
|
||||||
adv_info->rssi = rssi;
|
adv_info->rssi = rssi;
|
||||||
adv_info->interval = 0U;
|
adv_info->interval = 0U;
|
||||||
|
|
||||||
|
@ -4011,6 +4011,7 @@ static void le_ext_adv_report(struct pdu_data *pdu_data,
|
||||||
{
|
{
|
||||||
struct bt_hci_evt_le_ext_advertising_info *adv_info;
|
struct bt_hci_evt_le_ext_advertising_info *adv_info;
|
||||||
struct bt_hci_evt_le_ext_advertising_report *sep;
|
struct bt_hci_evt_le_ext_advertising_report *sep;
|
||||||
|
int8_t tx_pwr = BT_HCI_LE_ADV_TX_POWER_NO_PREF;
|
||||||
struct pdu_adv *adv = (void *)pdu_data;
|
struct pdu_adv *adv = (void *)pdu_data;
|
||||||
struct node_rx_pdu *node_rx_curr;
|
struct node_rx_pdu *node_rx_curr;
|
||||||
struct node_rx_pdu *node_rx_next;
|
struct node_rx_pdu *node_rx_next;
|
||||||
|
@ -4024,7 +4025,6 @@ static void le_ext_adv_report(struct pdu_data *pdu_data,
|
||||||
uint8_t data_status = 0U;
|
uint8_t data_status = 0U;
|
||||||
uint8_t data_len = 0U;
|
uint8_t data_len = 0U;
|
||||||
uint8_t evt_type = 0U;
|
uint8_t evt_type = 0U;
|
||||||
int8_t tx_pwr = 0x7f;
|
|
||||||
uint8_t *data = NULL;
|
uint8_t *data = NULL;
|
||||||
uint8_t sec_phy = 0U;
|
uint8_t sec_phy = 0U;
|
||||||
uint8_t info_len;
|
uint8_t info_len;
|
||||||
|
@ -4244,7 +4244,8 @@ no_ext_hdr:
|
||||||
|
|
||||||
if (!node_rx_next) {
|
if (!node_rx_next) {
|
||||||
if (sec_phy_curr) {
|
if (sec_phy_curr) {
|
||||||
data_status = BIT(1);
|
data_status =
|
||||||
|
BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_INCOMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -4270,11 +4271,14 @@ no_ext_hdr:
|
||||||
/* if data cannot fit the event, mark it as incomplete */
|
/* if data cannot fit the event, mark it as incomplete */
|
||||||
if (data_len > data_max_len) {
|
if (data_len > data_max_len) {
|
||||||
data_len = data_max_len;
|
data_len = data_max_len;
|
||||||
data_status = BIT(0);
|
data_status =
|
||||||
|
BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_PARTIAL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Data incomplete and no more to come */
|
/* Data incomplete and no more to come */
|
||||||
if (!(adv_addr || (adi && ((tx_pwr != 0x7f) || data)))) {
|
if (!(adv_addr ||
|
||||||
|
(adi && ((tx_pwr != BT_HCI_LE_ADV_TX_POWER_NO_PREF) ||
|
||||||
|
data)))) {
|
||||||
goto le_ext_adv_report_invalid;
|
goto le_ext_adv_report_invalid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4290,7 +4294,7 @@ no_ext_hdr:
|
||||||
|
|
||||||
/* Set directed advertising bit */
|
/* Set directed advertising bit */
|
||||||
if ((evt_type == BT_HCI_LE_ADV_EVT_TYPE_CONN) && direct_addr) {
|
if ((evt_type == BT_HCI_LE_ADV_EVT_TYPE_CONN) && direct_addr) {
|
||||||
evt_type |= BIT(2);
|
evt_type |= BT_HCI_LE_ADV_EVT_TYPE_DIRECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Set scan response bit */
|
/* TODO: Set scan response bit */
|
||||||
|
@ -4365,21 +4369,21 @@ static void le_adv_ext_1M_report(struct pdu_data *pdu_data,
|
||||||
struct node_rx_pdu *node_rx,
|
struct node_rx_pdu *node_rx,
|
||||||
struct net_buf *buf)
|
struct net_buf *buf)
|
||||||
{
|
{
|
||||||
le_adv_ext_report(pdu_data, node_rx, buf, BIT(0));
|
le_adv_ext_report(pdu_data, node_rx, buf, BT_HCI_LE_EXT_SCAN_PHY_1M);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void le_adv_ext_2M_report(struct pdu_data *pdu_data,
|
static void le_adv_ext_2M_report(struct pdu_data *pdu_data,
|
||||||
struct node_rx_pdu *node_rx,
|
struct node_rx_pdu *node_rx,
|
||||||
struct net_buf *buf)
|
struct net_buf *buf)
|
||||||
{
|
{
|
||||||
le_adv_ext_report(pdu_data, node_rx, buf, BIT(1));
|
le_adv_ext_report(pdu_data, node_rx, buf, BT_HCI_LE_EXT_SCAN_PHY_2M);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void le_adv_ext_coded_report(struct pdu_data *pdu_data,
|
static void le_adv_ext_coded_report(struct pdu_data *pdu_data,
|
||||||
struct node_rx_pdu *node_rx,
|
struct node_rx_pdu *node_rx,
|
||||||
struct net_buf *buf)
|
struct net_buf *buf)
|
||||||
{
|
{
|
||||||
le_adv_ext_report(pdu_data, node_rx, buf, BIT(2));
|
le_adv_ext_report(pdu_data, node_rx, buf, BT_HCI_LE_EXT_SCAN_PHY_CODED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void le_scan_timeout(struct pdu_data *pdu_data,
|
static void le_scan_timeout(struct pdu_data *pdu_data,
|
||||||
|
@ -4434,13 +4438,13 @@ static void le_per_adv_sync_report(struct pdu_data *pdu_data,
|
||||||
struct net_buf *buf)
|
struct net_buf *buf)
|
||||||
{
|
{
|
||||||
struct bt_hci_evt_le_per_advertising_report *sep;
|
struct bt_hci_evt_le_per_advertising_report *sep;
|
||||||
|
int8_t tx_pwr = BT_HCI_LE_ADV_TX_POWER_NO_PREF;
|
||||||
struct pdu_adv *adv = (void *)pdu_data;
|
struct pdu_adv *adv = (void *)pdu_data;
|
||||||
struct node_rx_pdu *node_rx_curr;
|
struct node_rx_pdu *node_rx_curr;
|
||||||
struct node_rx_pdu *node_rx_next;
|
struct node_rx_pdu *node_rx_next;
|
||||||
uint8_t total_data_len = 0U;
|
uint8_t total_data_len = 0U;
|
||||||
uint8_t data_status = 0U;
|
uint8_t data_status = 0U;
|
||||||
uint8_t data_len = 0U;
|
uint8_t data_len = 0U;
|
||||||
int8_t tx_pwr = 0x7f;
|
|
||||||
uint8_t *data = NULL;
|
uint8_t *data = NULL;
|
||||||
int8_t rssi;
|
int8_t rssi;
|
||||||
|
|
||||||
|
@ -4570,7 +4574,8 @@ no_ext_hdr:
|
||||||
|
|
||||||
if (!node_rx_next) {
|
if (!node_rx_next) {
|
||||||
if (sec_phy_curr) {
|
if (sec_phy_curr) {
|
||||||
data_status = BIT(1);
|
data_status =
|
||||||
|
BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_INCOMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -4595,11 +4600,12 @@ no_ext_hdr:
|
||||||
/* if data cannot fit the event, mark it as incomplete */
|
/* if data cannot fit the event, mark it as incomplete */
|
||||||
if (data_len > data_max_len) {
|
if (data_len > data_max_len) {
|
||||||
data_len = data_max_len;
|
data_len = data_max_len;
|
||||||
data_status = BIT(0);
|
data_status =
|
||||||
|
BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_PARTIAL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Data incomplete and no more to come */
|
/* Data incomplete and no more to come */
|
||||||
if ((tx_pwr == 0x7f) && !data) {
|
if ((tx_pwr == BT_HCI_LE_ADV_TX_POWER_NO_PREF) && !data) {
|
||||||
goto le_per_adv_report_invalid;
|
goto le_per_adv_report_invalid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,8 +344,8 @@ int lll_adv_scan_req_report(struct lll_adv *lll, struct pdu_adv *pdu_adv_rx,
|
||||||
pdu_len = offsetof(struct pdu_adv, payload) + pdu_adv_rx->len;
|
pdu_len = offsetof(struct pdu_adv, payload) + pdu_adv_rx->len;
|
||||||
memcpy(pdu_adv, pdu_adv_rx, pdu_len);
|
memcpy(pdu_adv, pdu_adv_rx, pdu_len);
|
||||||
|
|
||||||
node_rx->hdr.rx_ftr.rssi = (rssi_ready) ? (radio_rssi_get() & 0x7f) :
|
node_rx->hdr.rx_ftr.rssi = (rssi_ready) ? radio_rssi_get() :
|
||||||
0x7f;
|
BT_HCI_LE_RSSI_NOT_AVAILABLE;
|
||||||
#if defined(CONFIG_BT_CTLR_PRIVACY)
|
#if defined(CONFIG_BT_CTLR_PRIVACY)
|
||||||
node_rx->hdr.rx_ftr.rl_idx = rl_idx;
|
node_rx->hdr.rx_ftr.rl_idx = rl_idx;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1197,9 +1197,8 @@ static int isr_rx_scan_report(struct lll_scan *lll, uint8_t rssi_ready,
|
||||||
node_rx->hdr.type = NODE_RX_TYPE_REPORT;
|
node_rx->hdr.type = NODE_RX_TYPE_REPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
node_rx->hdr.rx_ftr.rssi = (rssi_ready) ?
|
node_rx->hdr.rx_ftr.rssi = (rssi_ready) ? radio_rssi_get() :
|
||||||
(radio_rssi_get() & 0x7f)
|
BT_HCI_LE_RSSI_NOT_AVAILABLE;
|
||||||
: 0x7f;
|
|
||||||
#if defined(CONFIG_BT_CTLR_PRIVACY)
|
#if defined(CONFIG_BT_CTLR_PRIVACY)
|
||||||
/* save the resolving list index. */
|
/* save the resolving list index. */
|
||||||
node_rx->hdr.rx_ftr.rl_idx = rl_idx;
|
node_rx->hdr.rx_ftr.rl_idx = rl_idx;
|
||||||
|
|
|
@ -311,7 +311,8 @@ static int isr_rx_pdu(struct lll_scan_aux *lll, uint8_t rssi_ready)
|
||||||
ftr->radio_end_us = radio_tmr_end_get() -
|
ftr->radio_end_us = radio_tmr_end_get() -
|
||||||
radio_rx_chain_delay_get(lll->phy, 1);
|
radio_rx_chain_delay_get(lll->phy, 1);
|
||||||
|
|
||||||
ftr->rssi = (rssi_ready) ? (radio_rssi_get() & 0x7f) : 0x7f;
|
ftr->rssi = (rssi_ready) ? radio_rssi_get() :
|
||||||
|
BT_HCI_LE_RSSI_NOT_AVAILABLE;
|
||||||
|
|
||||||
#if defined(CONFIG_BT_CTLR_PRIVACY)
|
#if defined(CONFIG_BT_CTLR_PRIVACY)
|
||||||
/* TODO: Use correct rl_idx value when privacy support is added */
|
/* TODO: Use correct rl_idx value when privacy support is added */
|
||||||
|
|
|
@ -285,8 +285,8 @@ static void isr_rx(void *param)
|
||||||
|
|
||||||
ftr = &(node_rx->hdr.rx_ftr);
|
ftr = &(node_rx->hdr.rx_ftr);
|
||||||
ftr->param = lll;
|
ftr->param = lll;
|
||||||
ftr->rssi = (rssi_ready) ? (radio_rssi_get() & 0x7f) :
|
ftr->rssi = (rssi_ready) ? radio_rssi_get() :
|
||||||
0x7f;
|
BT_HCI_LE_RSSI_NOT_AVAILABLE;
|
||||||
ftr->ticks_anchor = radio_tmr_start_get();
|
ftr->ticks_anchor = radio_tmr_start_get();
|
||||||
ftr->radio_end_us = radio_tmr_end_get() -
|
ftr->radio_end_us = radio_tmr_end_get() -
|
||||||
radio_rx_chain_delay_get(lll->phy,
|
radio_rx_chain_delay_get(lll->phy,
|
||||||
|
|
|
@ -436,7 +436,7 @@ uint8_t ll_adv_params_set(uint16_t interval, uint8_t adv_type,
|
||||||
|
|
||||||
_tx_pwr = 0;
|
_tx_pwr = 0;
|
||||||
if (tx_pwr) {
|
if (tx_pwr) {
|
||||||
if (*tx_pwr != 0x7F) {
|
if (*tx_pwr != BT_HCI_LE_ADV_TX_POWER_NO_PREF) {
|
||||||
_tx_pwr = *tx_pwr;
|
_tx_pwr = *tx_pwr;
|
||||||
} else {
|
} else {
|
||||||
*tx_pwr = _tx_pwr;
|
*tx_pwr = _tx_pwr;
|
||||||
|
@ -806,9 +806,9 @@ uint8_t ll_adv_enable(uint8_t enable)
|
||||||
#endif /* CONFIG_BT_CTLR_PHY */
|
#endif /* CONFIG_BT_CTLR_PHY */
|
||||||
|
|
||||||
#if defined(CONFIG_BT_CTLR_CONN_RSSI)
|
#if defined(CONFIG_BT_CTLR_CONN_RSSI)
|
||||||
conn_lll->rssi_latest = 0x7F;
|
conn_lll->rssi_latest = BT_HCI_LE_RSSI_NOT_AVAILABLE;
|
||||||
#if defined(CONFIG_BT_CTLR_CONN_RSSI_EVENT)
|
#if defined(CONFIG_BT_CTLR_CONN_RSSI_EVENT)
|
||||||
conn_lll->rssi_reported = 0x7F;
|
conn_lll->rssi_reported = BT_HCI_LE_RSSI_NOT_AVAILABLE;
|
||||||
conn_lll->rssi_sample_count = 0;
|
conn_lll->rssi_sample_count = 0;
|
||||||
#endif /* CONFIG_BT_CTLR_CONN_RSSI_EVENT */
|
#endif /* CONFIG_BT_CTLR_CONN_RSSI_EVENT */
|
||||||
#endif /* CONFIG_BT_CTLR_CONN_RSSI */
|
#endif /* CONFIG_BT_CTLR_CONN_RSSI */
|
||||||
|
|
|
@ -189,9 +189,9 @@ uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window,
|
||||||
#endif /* CONFIG_BT_CTLR_PHY */
|
#endif /* CONFIG_BT_CTLR_PHY */
|
||||||
|
|
||||||
#if defined(CONFIG_BT_CTLR_CONN_RSSI)
|
#if defined(CONFIG_BT_CTLR_CONN_RSSI)
|
||||||
conn_lll->rssi_latest = 0x7F;
|
conn_lll->rssi_latest = BT_HCI_LE_RSSI_NOT_AVAILABLE;
|
||||||
#if defined(CONFIG_BT_CTLR_CONN_RSSI_EVENT)
|
#if defined(CONFIG_BT_CTLR_CONN_RSSI_EVENT)
|
||||||
conn_lll->rssi_reported = 0x7F;
|
conn_lll->rssi_reported = BT_HCI_LE_RSSI_NOT_AVAILABLE;
|
||||||
conn_lll->rssi_sample_count = 0;
|
conn_lll->rssi_sample_count = 0;
|
||||||
#endif /* CONFIG_BT_CTLR_CONN_RSSI_EVENT */
|
#endif /* CONFIG_BT_CTLR_CONN_RSSI_EVENT */
|
||||||
#endif /* CONFIG_BT_CTLR_CONN_RSSI */
|
#endif /* CONFIG_BT_CTLR_CONN_RSSI */
|
||||||
|
|
|
@ -103,14 +103,14 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx)
|
||||||
aux = NULL;
|
aux = NULL;
|
||||||
scan = (void *)HDR_LLL2EVT(ftr->param);
|
scan = (void *)HDR_LLL2EVT(ftr->param);
|
||||||
sync = scan->per_scan.sync;
|
sync = scan->per_scan.sync;
|
||||||
phy = BIT(0);
|
phy = BT_HCI_LE_EXT_SCAN_PHY_1M;
|
||||||
break;
|
break;
|
||||||
case NODE_RX_TYPE_EXT_CODED_REPORT:
|
case NODE_RX_TYPE_EXT_CODED_REPORT:
|
||||||
lll = NULL;
|
lll = NULL;
|
||||||
aux = NULL;
|
aux = NULL;
|
||||||
scan = (void *)HDR_LLL2EVT(ftr->param);
|
scan = (void *)HDR_LLL2EVT(ftr->param);
|
||||||
sync = scan->per_scan.sync;
|
sync = scan->per_scan.sync;
|
||||||
phy = BIT(2);
|
phy = BT_HCI_LE_EXT_SCAN_PHY_CODED;
|
||||||
break;
|
break;
|
||||||
case NODE_RX_TYPE_EXT_AUX_REPORT:
|
case NODE_RX_TYPE_EXT_AUX_REPORT:
|
||||||
lll = ftr->param;
|
lll = ftr->param;
|
||||||
|
@ -122,13 +122,13 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx)
|
||||||
sync = scan->per_scan.sync;
|
sync = scan->per_scan.sync;
|
||||||
phy = lll->phy;
|
phy = lll->phy;
|
||||||
switch (phy) {
|
switch (phy) {
|
||||||
case BIT(0):
|
case BT_HCI_LE_EXT_SCAN_PHY_1M:
|
||||||
rx->type = NODE_RX_TYPE_EXT_1M_REPORT;
|
rx->type = NODE_RX_TYPE_EXT_1M_REPORT;
|
||||||
break;
|
break;
|
||||||
case BIT(1):
|
case BT_HCI_LE_EXT_SCAN_PHY_2M:
|
||||||
rx->type = NODE_RX_TYPE_EXT_2M_REPORT;
|
rx->type = NODE_RX_TYPE_EXT_2M_REPORT;
|
||||||
break;
|
break;
|
||||||
case BIT(2):
|
case BT_HCI_LE_EXT_SCAN_PHY_CODED:
|
||||||
rx->type = NODE_RX_TYPE_EXT_CODED_REPORT;
|
rx->type = NODE_RX_TYPE_EXT_CODED_REPORT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue