nimble/ll: Use scanp name consistently

Use 'scanp' name for ble_ll_scan_params variables consistently.
This commit is contained in:
Andrzej Kaczmarek
2019-12-17 16:57:37 +01:00
parent 491a37e31f
commit 31badecefe
2 changed files with 74 additions and 74 deletions
@@ -179,12 +179,12 @@ struct ble_ll_scan_sm
uint8_t ext_scanning; uint8_t ext_scanning;
#endif #endif
struct ble_ll_scan_params *scanp;
struct ble_ll_scan_params *scanp_next;
uint8_t restart_timer_needed; uint8_t restart_timer_needed;
struct ble_ll_aux_data *cur_aux_data; struct ble_ll_aux_data *cur_aux_data;
struct ble_ll_scan_params phy_data[BLE_LL_SCAN_PHY_NUMBER];
struct ble_ll_scan_params *scanp;
struct ble_ll_scan_params *scanp_next;
struct ble_ll_scan_params scanp_phys[BLE_LL_SCAN_PHY_NUMBER];
}; };
/* Scan types */ /* Scan types */
+70 -70
View File
@@ -974,21 +974,21 @@ static void
ble_ll_get_chan_to_scan(struct ble_ll_scan_sm *scansm, uint8_t *chan, ble_ll_get_chan_to_scan(struct ble_ll_scan_sm *scansm, uint8_t *chan,
int *phy) int *phy)
{ {
struct ble_ll_scan_params *scanphy = scansm->scanp; struct ble_ll_scan_params *scanp = scansm->scanp;
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
struct ble_ll_aux_data *aux_data = scansm->cur_aux_data; struct ble_ll_aux_data *aux_data = scansm->cur_aux_data;
if (!scansm->ext_scanning || !aux_data || !aux_data->scanning) { if (!scansm->ext_scanning || !aux_data || !aux_data->scanning) {
*chan = scanphy->scan_chan; *chan = scanp->scan_chan;
*phy = scanphy->phy; *phy = scanp->phy;
return; return;
} }
*chan = aux_data->chan; *chan = aux_data->chan;
*phy = aux_data->aux_phy; *phy = aux_data->aux_phy;
#else #else
*chan = scanphy->scan_chan; *chan = scanp->scan_chan;
*phy = scanphy->phy; *phy = scanp->phy;
#endif #endif
} }
/** /**
@@ -1004,7 +1004,7 @@ static int
ble_ll_scan_start(struct ble_ll_scan_sm *scansm, struct ble_ll_sched_item *sch) ble_ll_scan_start(struct ble_ll_scan_sm *scansm, struct ble_ll_sched_item *sch)
{ {
int rc; int rc;
struct ble_ll_scan_params *scanphy = scansm->scanp; struct ble_ll_scan_params *scanp = scansm->scanp;
uint8_t scan_chan; uint8_t scan_chan;
#if (BLE_LL_BT5_PHY_SUPPORTED == 1) #if (BLE_LL_BT5_PHY_SUPPORTED == 1)
uint8_t phy_mode; uint8_t phy_mode;
@@ -1066,14 +1066,14 @@ ble_ll_scan_start(struct ble_ll_scan_sm *scansm, struct ble_ll_sched_item *sch)
rc = 0; rc = 0;
/* Enable/disable whitelisting */ /* Enable/disable whitelisting */
if (scanphy->scan_filt_policy & 1) { if (scanp->scan_filt_policy & 1) {
ble_ll_whitelist_enable(); ble_ll_whitelist_enable();
} else { } else {
ble_ll_whitelist_disable(); ble_ll_whitelist_disable();
} }
/* Set link layer state to scanning */ /* Set link layer state to scanning */
if (scanphy->scan_type == BLE_SCAN_TYPE_INITIATE) { if (scanp->scan_type == BLE_SCAN_TYPE_INITIATE) {
ble_ll_state_set(BLE_LL_STATE_INITIATING); ble_ll_state_set(BLE_LL_STATE_INITIATING);
} else { } else {
ble_ll_state_set(BLE_LL_STATE_SCANNING); ble_ll_state_set(BLE_LL_STATE_SCANNING);
@@ -1528,13 +1528,13 @@ ble_ll_scan_rx_isr_start(uint8_t pdu_type, uint16_t *rxflags)
{ {
int rc; int rc;
struct ble_ll_scan_sm *scansm; struct ble_ll_scan_sm *scansm;
struct ble_ll_scan_params *scanphy; struct ble_ll_scan_params *scanp;
rc = 0; rc = 0;
scansm = &g_ble_ll_scan_sm; scansm = &g_ble_ll_scan_sm;
scanphy = scansm->scanp; scanp = scansm->scanp;
switch (scanphy->scan_type) { switch (scanp->scan_type) {
case BLE_SCAN_TYPE_ACTIVE: case BLE_SCAN_TYPE_ACTIVE:
/* If adv ind or scan ind, we may send scan request */ /* If adv ind or scan ind, we may send scan request */
if ((pdu_type == BLE_ADV_PDU_TYPE_ADV_IND) || if ((pdu_type == BLE_ADV_PDU_TYPE_ADV_IND) ||
@@ -2083,7 +2083,7 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
uint8_t *rxbuf; uint8_t *rxbuf;
struct ble_mbuf_hdr *ble_hdr; struct ble_mbuf_hdr *ble_hdr;
struct ble_ll_scan_sm *scansm; struct ble_ll_scan_sm *scansm;
struct ble_ll_scan_params *scanphy; struct ble_ll_scan_params *scanp;
int ext_adv_mode = -1; int ext_adv_mode = -1;
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
uint8_t phy_mode; uint8_t phy_mode;
@@ -2097,7 +2097,7 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
/* Get scanning state machine */ /* Get scanning state machine */
scansm = &g_ble_ll_scan_sm; scansm = &g_ble_ll_scan_sm;
scanphy = scansm->scanp; scanp = scansm->scanp;
/* /*
* The reason we do something different here (as opposed to failed CRC) is * The reason we do something different here (as opposed to failed CRC) is
@@ -2199,7 +2199,7 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
} }
if ((ext_adv_mode == BLE_LL_EXT_ADV_MODE_SCAN) && if ((ext_adv_mode == BLE_LL_EXT_ADV_MODE_SCAN) &&
(scanphy->scan_type == BLE_SCAN_TYPE_ACTIVE)) { (scanp->scan_type == BLE_SCAN_TYPE_ACTIVE)) {
chk_send_req = 1; chk_send_req = 1;
} }
chk_wl = 1; chk_wl = 1;
@@ -2207,7 +2207,7 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
#endif #endif
case BLE_ADV_PDU_TYPE_ADV_IND: case BLE_ADV_PDU_TYPE_ADV_IND:
case BLE_ADV_PDU_TYPE_ADV_SCAN_IND: case BLE_ADV_PDU_TYPE_ADV_SCAN_IND:
if (scanphy->scan_type == BLE_SCAN_TYPE_ACTIVE) { if (scanp->scan_type == BLE_SCAN_TYPE_ACTIVE) {
chk_send_req = 1; chk_send_req = 1;
} }
chk_wl = 1; chk_wl = 1;
@@ -2225,7 +2225,7 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
adv_addr = adva; adv_addr = adva;
adv_addr_type = adva_type; adv_addr_type = adva_type;
if ((scanphy->scan_filt_policy & 1) == 0) { if ((scanp->scan_filt_policy & 1) == 0) {
chk_wl = 0; chk_wl = 0;
} }
resolved = 0; resolved = 0;
@@ -3435,7 +3435,7 @@ ble_ll_scan_set_enable(uint8_t enable, uint8_t filter_dups, uint16_t period,
int rc; int rc;
struct ble_ll_scan_sm *scansm; struct ble_ll_scan_sm *scansm;
struct ble_ll_scan_params *scanp; struct ble_ll_scan_params *scanp;
struct ble_ll_scan_params *scanphy; struct ble_ll_scan_params *scanp_phy;
int i; int i;
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
uint32_t period_ticks = 0; uint32_t period_ticks = 0;
@@ -3493,9 +3493,9 @@ ble_ll_scan_set_enable(uint8_t enable, uint8_t filter_dups, uint16_t period,
if (scansm->scan_enabled) { if (scansm->scan_enabled) {
/* Controller does not allow initiating and scanning.*/ /* Controller does not allow initiating and scanning.*/
for (i = 0; i < BLE_LL_SCAN_PHY_NUMBER; i++) { for (i = 0; i < BLE_LL_SCAN_PHY_NUMBER; i++) {
scanphy = &scansm->phy_data[i]; scanp_phy = &scansm->scanp_phys[i];
if (scanphy->configured && if (scanp_phy->configured &&
scanphy->scan_type == BLE_SCAN_TYPE_INITIATE) { scanp_phy->scan_type == BLE_SCAN_TYPE_INITIATE) {
return BLE_ERR_CMD_DISALLOWED; return BLE_ERR_CMD_DISALLOWED;
} }
} }
@@ -3526,27 +3526,27 @@ ble_ll_scan_set_enable(uint8_t enable, uint8_t filter_dups, uint16_t period,
scansm->scanp_next = NULL; scansm->scanp_next = NULL;
for (i = 0; i < BLE_LL_SCAN_PHY_NUMBER; i++) { for (i = 0; i < BLE_LL_SCAN_PHY_NUMBER; i++) {
scanphy = &scansm->phy_data[i]; scanp_phy = &scansm->scanp_phys[i];
scanp = &g_ble_ll_scan_params[i]; scanp = &g_ble_ll_scan_params[i];
if (!scanp->configured) { if (!scanp->configured) {
continue; continue;
} }
scanphy->configured = scanp->configured; scanp_phy->configured = scanp->configured;
scanphy->scan_type = scanp->scan_type; scanp_phy->scan_type = scanp->scan_type;
scanphy->timing = scanp->timing; scanp_phy->timing = scanp->timing;
scanphy->scan_filt_policy = scanp->scan_filt_policy; scanp_phy->scan_filt_policy = scanp->scan_filt_policy;
scanphy->own_addr_type = scanp->own_addr_type; scanp_phy->own_addr_type = scanp->own_addr_type;
if (!scansm->scanp) { if (!scansm->scanp) {
scansm->scanp = scanphy; scansm->scanp = scanp_phy;
/* Take own_addr_type from the first configured PHY. /* Take own_addr_type from the first configured PHY.
* Note: All configured PHYs shall have the same own_addr_type * Note: All configured PHYs shall have the same own_addr_type
*/ */
scansm->own_addr_type = scanphy->own_addr_type; scansm->own_addr_type = scanp_phy->own_addr_type;
} else { } else {
scansm->scanp_next = scanphy; scansm->scanp_next = scanp_phy;
} }
} }
@@ -3556,18 +3556,18 @@ ble_ll_scan_set_enable(uint8_t enable, uint8_t filter_dups, uint16_t period,
* Parameters defaults. * Parameters defaults.
*/ */
if (!scansm->scanp) { if (!scansm->scanp) {
scansm->scanp = &scansm->phy_data[PHY_UNCODED]; scansm->scanp = &scansm->scanp_phys[PHY_UNCODED];
scansm->own_addr_type = BLE_ADDR_PUBLIC; scansm->own_addr_type = BLE_ADDR_PUBLIC;
scanphy = scansm->scanp; scanp_phy = scansm->scanp;
scanphy->configured = 1; scanp_phy->configured = 1;
scanphy->scan_type = BLE_SCAN_TYPE_PASSIVE; scanp_phy->scan_type = BLE_SCAN_TYPE_PASSIVE;
scanphy->timing.interval = scanp_phy->timing.interval =
ble_ll_scan_time_hci_to_ticks(BLE_HCI_SCAN_ITVL_DEF); ble_ll_scan_time_hci_to_ticks(BLE_HCI_SCAN_ITVL_DEF);
scanphy->timing.window = scanp_phy->timing.window =
ble_ll_scan_time_hci_to_ticks(BLE_HCI_SCAN_WINDOW_DEF); ble_ll_scan_time_hci_to_ticks(BLE_HCI_SCAN_WINDOW_DEF);
scanphy->scan_filt_policy = BLE_HCI_SCAN_FILT_NO_WL; scanp_phy->scan_filt_policy = BLE_HCI_SCAN_FILT_NO_WL;
scanphy->own_addr_type = BLE_ADDR_PUBLIC; scanp_phy->own_addr_type = BLE_ADDR_PUBLIC;
} }
rc = ble_ll_scan_sm_start(scansm); rc = ble_ll_scan_sm_start(scansm);
@@ -3621,11 +3621,11 @@ ble_ll_scan_can_chg_whitelist(void)
{ {
int rc; int rc;
struct ble_ll_scan_sm *scansm; struct ble_ll_scan_sm *scansm;
struct ble_ll_scan_params *params; struct ble_ll_scan_params *scanp;
scansm = &g_ble_ll_scan_sm; scansm = &g_ble_ll_scan_sm;
params = scansm->scanp; scanp = scansm->scanp;
if (scansm->scan_enabled && (params->scan_filt_policy & 1)) { if (scansm->scan_enabled && (scanp->scan_filt_policy & 1)) {
rc = 0; rc = 0;
} else { } else {
rc = 1; rc = 1;
@@ -3639,7 +3639,7 @@ ble_ll_scan_initiator_start(struct hci_create_conn *hcc,
struct ble_ll_scan_sm **sm) struct ble_ll_scan_sm **sm)
{ {
struct ble_ll_scan_sm *scansm; struct ble_ll_scan_sm *scansm;
struct ble_ll_scan_params *scanphy; struct ble_ll_scan_params *scanp;
int rc; int rc;
scansm = &g_ble_ll_scan_sm; scansm = &g_ble_ll_scan_sm;
@@ -3647,14 +3647,14 @@ ble_ll_scan_initiator_start(struct hci_create_conn *hcc,
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
scansm->ext_scanning = 0; scansm->ext_scanning = 0;
#endif #endif
scansm->scanp = &scansm->phy_data[PHY_UNCODED]; scansm->scanp = &scansm->scanp_phys[PHY_UNCODED];
scansm->scanp_next = NULL; scansm->scanp_next = NULL;
scanphy = scansm->scanp; scanp = scansm->scanp;
scanphy->scan_filt_policy = hcc->filter_policy; scanp->scan_filt_policy = hcc->filter_policy;
scanphy->timing.interval = ble_ll_scan_time_hci_to_ticks(hcc->scan_itvl); scanp->timing.interval = ble_ll_scan_time_hci_to_ticks(hcc->scan_itvl);
scanphy->timing.window = ble_ll_scan_time_hci_to_ticks(hcc->scan_window); scanp->timing.window = ble_ll_scan_time_hci_to_ticks(hcc->scan_window);
scanphy->scan_type = BLE_SCAN_TYPE_INITIATE; scanp->scan_type = BLE_SCAN_TYPE_INITIATE;
rc = ble_ll_scan_sm_start(scansm); rc = ble_ll_scan_sm_start(scansm);
if (sm == NULL) { if (sm == NULL) {
@@ -3676,8 +3676,8 @@ ble_ll_scan_ext_initiator_start(struct hci_ext_create_conn *hcc,
struct ble_ll_scan_sm **sm) struct ble_ll_scan_sm **sm)
{ {
struct ble_ll_scan_sm *scansm; struct ble_ll_scan_sm *scansm;
struct ble_ll_scan_params *uncoded; struct ble_ll_scan_params *scanp_uncoded;
struct ble_ll_scan_params *coded; struct ble_ll_scan_params *scanp_coded;
struct hci_ext_conn_params *params; struct hci_ext_conn_params *params;
int rc; int rc;
@@ -3689,41 +3689,41 @@ ble_ll_scan_ext_initiator_start(struct hci_ext_create_conn *hcc,
if (hcc->init_phy_mask & BLE_PHY_MASK_1M) { if (hcc->init_phy_mask & BLE_PHY_MASK_1M) {
params = &hcc->params[0]; params = &hcc->params[0];
uncoded = &scansm->phy_data[PHY_UNCODED]; scanp_uncoded = &scansm->scanp_phys[PHY_UNCODED];
uncoded->timing.interval = ble_ll_scan_time_hci_to_ticks(params->scan_itvl); scanp_uncoded->timing.interval = ble_ll_scan_time_hci_to_ticks(params->scan_itvl);
uncoded->timing.window = ble_ll_scan_time_hci_to_ticks(params->scan_window); scanp_uncoded->timing.window = ble_ll_scan_time_hci_to_ticks(params->scan_window);
uncoded->scan_type = BLE_SCAN_TYPE_INITIATE; scanp_uncoded->scan_type = BLE_SCAN_TYPE_INITIATE;
uncoded->scan_filt_policy = hcc->filter_policy; scanp_uncoded->scan_filt_policy = hcc->filter_policy;
scansm->scanp = uncoded; scansm->scanp = scanp_uncoded;
} }
if (hcc->init_phy_mask & BLE_PHY_MASK_CODED) { if (hcc->init_phy_mask & BLE_PHY_MASK_CODED) {
params = &hcc->params[2]; params = &hcc->params[2];
coded = &scansm->phy_data[PHY_CODED]; scanp_coded = &scansm->scanp_phys[PHY_CODED];
coded->timing.interval = ble_ll_scan_time_hci_to_ticks(params->scan_itvl); scanp_coded->timing.interval = ble_ll_scan_time_hci_to_ticks(params->scan_itvl);
coded->timing.window = ble_ll_scan_time_hci_to_ticks(params->scan_window); scanp_coded->timing.window = ble_ll_scan_time_hci_to_ticks(params->scan_window);
coded->scan_type = BLE_SCAN_TYPE_INITIATE; scanp_coded->scan_type = BLE_SCAN_TYPE_INITIATE;
coded->scan_filt_policy = hcc->filter_policy; scanp_coded->scan_filt_policy = hcc->filter_policy;
if (scansm->scanp) { if (scansm->scanp) {
scansm->scanp_next = coded; scansm->scanp_next = scanp_coded;
} else { } else {
scansm->scanp = coded; scansm->scanp = scanp_coded;
} }
} }
/* if any of PHYs is configured for continuous scan we alter interval to /* if any of PHYs is configured for continuous scan we alter interval to
* fit other PHY * fit other PHY
*/ */
if (scansm->scanp && scansm->scanp_next && coded->configured && if (scansm->scanp && scansm->scanp_next && scanp_coded->configured &&
uncoded->configured) { scanp_uncoded->configured) {
if (coded->timing.interval == coded->timing.window) { if (scanp_coded->timing.interval == scanp_coded->timing.window) {
coded->timing.interval += uncoded->timing.window; scanp_coded->timing.interval += scanp_uncoded->timing.window;
} }
if (uncoded->timing.interval == uncoded->timing.window) { if (scanp_uncoded->timing.interval == scanp_uncoded->timing.window) {
uncoded->timing.interval += coded->timing.window; scanp_uncoded->timing.interval += scanp_coded->timing.window;
} }
} }
@@ -3836,9 +3836,9 @@ ble_ll_scan_common_init(void)
ble_ll_scan_time_hci_to_ticks(BLE_HCI_SCAN_WINDOW_DEF); ble_ll_scan_time_hci_to_ticks(BLE_HCI_SCAN_WINDOW_DEF);
} }
scansm->phy_data[PHY_UNCODED].phy = BLE_PHY_1M; scansm->scanp_phys[PHY_UNCODED].phy = BLE_PHY_1M;
#if (BLE_LL_SCAN_PHY_NUMBER == 2) #if (BLE_LL_SCAN_PHY_NUMBER == 2)
scansm->phy_data[PHY_CODED].phy = BLE_PHY_CODED; scansm->scanp_phys[PHY_CODED].phy = BLE_PHY_CODED;
#endif #endif
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)