You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ry...@apache.org on 2019/01/11 14:48:37 UTC
[mynewt-nimble] branch master updated (4e39d07 -> 291d1b4)
This is an automated email from the ASF dual-hosted git repository.
rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.
from 4e39d07 mesh: Remove unused define
new f10b048 nimble/ll: Improve extended scanner to report truncated report
new 8469d0b nimble/ll: Remove some trash comment
new eb19fd1 nimble/ll: Minor fix
new 5ace226 nimble/ll: Fix extended chaining scanning
new 468bb99 nimble/ll: Minor coding style fix
new 41362a4 nimble/ll: Cleaning patch in ext scanning
new 291d1b4 nimble/ll: Fix address types in the advertising report
The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
nimble/controller/include/controller/ble_ll_scan.h | 5 +-
nimble/controller/src/ble_ll_scan.c | 223 +++++++++++++--------
nimble/include/nimble/ble.h | 4 +
3 files changed, 145 insertions(+), 87 deletions(-)
[mynewt-nimble] 06/07: nimble/ll: Cleaning patch in ext scanning
Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 41362a4c717c0b00cca190b4545bbf8c5607022a
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Fri Jan 11 11:26:05 2019 +0100
nimble/ll: Cleaning patch in ext scanning
This patch does not change any functionality, just make uses of macros
to SET/CLEAR/CHECK flags in aux_data pointer
---
nimble/controller/include/controller/ble_ll_scan.h | 6 +--
nimble/controller/src/ble_ll_scan.c | 52 +++++++++++-----------
2 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/nimble/controller/include/controller/ble_ll_scan.h b/nimble/controller/include/controller/ble_ll_scan.h
index 82133b7..641acd6 100644
--- a/nimble/controller/include/controller/ble_ll_scan.h
+++ b/nimble/controller/include/controller/ble_ll_scan.h
@@ -97,9 +97,9 @@ struct ble_ll_scan_params
#define BLE_LL_AUX_TRUNCATED_SENT 0x40
#define BLE_LL_AUX_HAS_ADI 0x80
-#define BLE_LL_SET_AUX_FLAG(aux_data, flag) ((aux_data)->flags |= flag)
-#define BLE_LL_CLEAR_AUX_FLAG(aux_data, flag) ((aux_data)->flags &= ~flag)
-#define BLE_LL_CHECK_AUX_FLAG(aux_data, flag) (!!((aux_data)->flags & flag))
+#define BLE_LL_AUX_SET_FLAG(aux_data, flag) ((aux_data)->flags |= (flag))
+#define BLE_LL_AUX_CLEAR_FLAG(aux_data, flag) ((aux_data)->flags &= ~(flag))
+#define BLE_LL_AUX_CHECK_FLAG(aux_data, flag) ((aux_data)->flags & (flag))
struct ble_ll_aux_data {
uint8_t ref_cnt;
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index a2aafb1..4f25bd7 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -460,7 +460,7 @@ ble_ll_scan_send_truncated_if_chained(struct ble_ll_aux_data *aux_data)
BLE_LL_ASSERT(aux_data);
- if (!BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_CHAIN_BIT)) {
+ if (!BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_CHAIN_BIT)) {
/* if not chained, there is nothing to do here */
goto done;
}
@@ -478,14 +478,14 @@ ble_ll_scan_send_truncated_if_chained(struct ble_ll_aux_data *aux_data)
evt->event_len = sizeof(*evt) - BLE_HCI_EVENT_HDR_LEN;
evt->evt_type = aux_data->evt_type;
evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_TRUNCATED);
- BLE_LL_SET_AUX_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
+ BLE_LL_AUX_SET_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
- if (BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_HAS_ADDRA)) {
+ if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_HAS_ADDRA)) {
memcpy(evt->addr, aux_data->addr, 6);
evt->addr_type = aux_data->addr_type;
}
- if (BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_HAS_DIR_ADDRA)) {
+ if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_HAS_DIR_ADDRA)) {
memcpy(evt->dir_addr, aux_data->dir_addr, 6);
evt->dir_addr_type = aux_data->dir_addr_type;
}
@@ -504,7 +504,7 @@ ble_ll_scan_get_adi(struct ble_ll_aux_data *aux_data, uint16_t *adi)
return -1;
}
- if (!BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_HAS_ADI)) {
+ if (!BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_HAS_ADI)) {
return -1;
}
@@ -527,7 +527,7 @@ ble_ll_scan_end_adv_evt(struct ble_ll_aux_data *aux_data)
* (truncated was sent to the host) and we just need to drop last reference.
* Otherwise we should try to send truncated event to the host.
*/
- if (!BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT)) {
+ if (!BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT)) {
ble_ll_scan_send_truncated_if_chained(aux_data);
}
@@ -1860,7 +1860,7 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
/* This is last element in the chain.
* Clear incomplete flag
*/
- BLE_LL_CLEAR_AUX_FLAG(current_aux, BLE_LL_AUX_INCOMPLETE_BIT);
+ BLE_LL_AUX_CLEAR_FLAG(current_aux, BLE_LL_AUX_INCOMPLETE_BIT);
return 1;
}
@@ -1913,11 +1913,11 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
if (!(new_aux->evt_type & (BLE_HCI_ADV_SCAN_MASK))
&& (tmp_aux_data.adi != new_aux->adi)) {
STATS_INC(ble_ll_stats, aux_chain_err);
- new_aux->flags |= BLE_LL_AUX_INCOMPLETE_ERR_BIT;
+ BLE_LL_AUX_SET_FLAG(new_aux, BLE_LL_AUX_INCOMPLETE_ERR_BIT);
}
- new_aux->flags |= BLE_LL_AUX_CHAIN_BIT;
- new_aux->flags |= BLE_LL_AUX_INCOMPLETE_BIT;
+ BLE_LL_AUX_SET_FLAG(new_aux, BLE_LL_AUX_CHAIN_BIT);
+ BLE_LL_AUX_SET_FLAG(new_aux, BLE_LL_AUX_INCOMPLETE_BIT);
} else {
if (ble_ll_scan_ext_adv_init(&new_aux) < 0) {
/* Out of memory */
@@ -1953,7 +1953,7 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
new_aux = ble_hdr->rxinfo.user_data;
/* Clear incomplete flag */
- new_aux->flags &= ~BLE_LL_AUX_INCOMPLETE_BIT;
+ BLE_LL_AUX_CLEAR_FLAG(new_aux, BLE_LL_AUX_INCOMPLETE_BIT);
/* Current processing aux_ptr */
rc = 1;
@@ -1961,19 +1961,19 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
if (has_adi) {
new_aux->adi = tmp_aux_data.adi;
- BLE_LL_SET_AUX_FLAG(new_aux, BLE_LL_AUX_HAS_ADI);
+ BLE_LL_AUX_SET_FLAG(new_aux, BLE_LL_AUX_HAS_ADI);
}
if (has_addr) {
memcpy(new_aux->addr, tmp_aux_data.addr, 6);
new_aux->addr_type = tmp_aux_data.addr_type;
- new_aux->flags |= BLE_LL_AUX_HAS_ADDRA;
+ BLE_LL_AUX_SET_FLAG(new_aux, BLE_LL_AUX_HAS_ADDRA);
}
if (has_dir_addr) {
memcpy(new_aux->dir_addr, tmp_aux_data.dir_addr, 6);
new_aux->dir_addr_type = tmp_aux_data.dir_addr_type;
- new_aux->flags |= BLE_LL_AUX_HAS_DIR_ADDRA;
+ BLE_LL_AUX_SET_FLAG(new_aux, BLE_LL_AUX_HAS_DIR_ADDRA);
}
ble_hdr->rxinfo.user_data = new_aux;
@@ -2140,7 +2140,7 @@ ble_ll_scan_get_addr_from_ext_adv(uint8_t *rxbuf, struct ble_mbuf_hdr *ble_hdr,
if (aux_data) {
/* If address has been provided, we do have it already in aux_data.*/
- if (aux_data->flags & BLE_LL_AUX_HAS_ADDRA) {
+ if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_HAS_ADDRA)) {
*addr = aux_data->addr;
*addr_type = aux_data->addr_type;
}
@@ -2149,7 +2149,7 @@ ble_ll_scan_get_addr_from_ext_adv(uint8_t *rxbuf, struct ble_mbuf_hdr *ble_hdr,
return 0;
}
- if (aux_data->flags & BLE_LL_AUX_HAS_DIR_ADDRA) {
+ if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_HAS_DIR_ADDRA)) {
*inita = aux_data->dir_addr;
*inita_type = aux_data->dir_addr_type;
}
@@ -2689,9 +2689,9 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
if (offset < datalen) {
/* Need another event for next fragment of this PDU */
need_event = true;
- } else if (aux_data && BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
+ } else if (aux_data && BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
need_event = false;
- } else if (aux_data && BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_BIT)) {
+ } else if (aux_data && BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_BIT)) {
/* Need another event for next PDU in chain */
need_event = true;
}
@@ -2710,14 +2710,14 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_INCOMPLETE);
} else {
evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_TRUNCATED);
- BLE_LL_SET_AUX_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
+ BLE_LL_AUX_SET_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
rc = -1;
}
} else if (aux_data ) {
- if (BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
+ if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_TRUNCATED);
rc = -1;
- } else if (BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_BIT)) {
+ } else if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_BIT)) {
evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_INCOMPLETE);
} else {
rc = 0;
@@ -2924,7 +2924,7 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
}
/* If it is ignore it means event is already truncated, just unref aux */
- if (aux_data && BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_IGNORE_BIT)) {
+ if (aux_data && BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_IGNORE_BIT)) {
ble_ll_scan_aux_data_unref(aux_data);
goto scan_continue;
}
@@ -2936,7 +2936,7 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
/* We are here when could not schedule the aux ptr */
hdr->rxinfo.flags &= ~BLE_MBUF_HDR_F_AUX_PTR_WAIT;
/* Mark that chain is trimmed */
- aux_data->flags |= BLE_LL_AUX_INCOMPLETE_ERR_BIT;
+ BLE_LL_AUX_SET_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT);
/* Note: aux_data unref will be done when truncated is sent to the host or
* below if we failed to schedule for the very first aux packet.
*/
@@ -2950,8 +2950,8 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
* for aux packet. However, if we was not able to schedule for first aux packet,
* make sure to unref aux_data here
*/
- if (!BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_CHAIN_BIT)) {
- if (BLE_LL_CHECK_AUX_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
+ if (!BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_CHAIN_BIT)) {
+ if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
ble_ll_scan_aux_data_unref(aux_data);
}
goto scan_continue;
@@ -2976,7 +2976,7 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
ble_ll_scan_aux_data_unref(aux_data);
}
}
- aux_data->flags |= BLE_LL_AUX_IGNORE_BIT;
+ BLE_LL_AUX_SET_FLAG(aux_data, BLE_LL_AUX_IGNORE_BIT);
} else if ((rc == 0) && scansm->scan_filt_dups && aux_data && aux_data->adi) {
ble_ll_scan_add_dup_adv(ident_addr, ident_addr_type,
BLE_HCI_LE_SUBEV_EXT_ADV_RPT,
[mynewt-nimble] 01/07: nimble/ll: Improve extended scanner to
report truncated report
Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit f10b0487f9a8e7278dad7ab6e8fe897d0ace4270
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jan 10 12:25:19 2019 +0100
nimble/ll: Improve extended scanner to report truncated report
If Nimble was scheduled for aux packet but it received something else,
make sure to send report with Truncated status.
---
nimble/controller/src/ble_ll_scan.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 3748a4d..7c08227 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -2284,6 +2284,10 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
ble_hdr = BLE_MBUF_HDR_PTR(rxpdu);
+ /* Get pdu type, pointer to address and address "type" */
+ rxbuf = rxpdu->om_data;
+ pdu_type = rxbuf[0] & BLE_ADV_PDU_HDR_TYPE_MASK;
+
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
if (scansm->cur_aux_data) {
ble_hdr->rxinfo.user_data = scansm->cur_aux_data;
@@ -2293,6 +2297,13 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_AUX_INVALID;
goto scan_rx_isr_exit;
}
+
+ /* If we were expecting aux/chain and it not arrived,
+ * lets just exit here.
+ */
+ if (pdu_type != BLE_ADV_PDU_TYPE_ADV_EXT_IND) {
+ goto scan_rx_isr_exit;
+ }
}
#endif
@@ -2304,10 +2315,6 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
goto scan_rx_isr_exit;
}
- /* Get pdu type, pointer to address and address "type" */
- rxbuf = rxpdu->om_data;
- pdu_type = rxbuf[0] & BLE_ADV_PDU_HDR_TYPE_MASK;
-
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
if (pdu_type == BLE_ADV_PDU_TYPE_ADV_EXT_IND) {
if (!scansm->ext_scanning) {
@@ -2783,6 +2790,17 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
goto scan_continue;
}
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
+ if (aux_data && ptype != BLE_ADV_PDU_TYPE_ADV_EXT_IND) {
+ /* LL was scheduled for aux but received something different.
+ * Let's just ignore received event and send truncated for
+ * previous report if needed.
+ */
+ evt_possibly_truncated = 1;
+ goto scan_continue;
+ }
+#endif
+
if ((ptype == BLE_ADV_PDU_TYPE_SCAN_REQ) || (ptype == BLE_ADV_PDU_TYPE_CONNECT_REQ)) {
goto scan_continue;
}
[mynewt-nimble] 05/07: nimble/ll: Minor coding style fix
Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 468bb994319efa1b9c6b66b65229b02344ab27f2
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Fri Jan 11 11:08:48 2019 +0100
nimble/ll: Minor coding style fix
---
nimble/controller/src/ble_ll_scan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index a0b151a..a2aafb1 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -2931,7 +2931,7 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
/* Let's see if that packet contains aux ptr*/
if (BLE_MBUF_HDR_WAIT_AUX(hdr)) {
- BLE_LL_ASSERT(aux_data);
+ BLE_LL_ASSERT(aux_data);
if (ble_ll_sched_aux_scan(hdr, scansm, hdr->rxinfo.user_data)) {
/* We are here when could not schedule the aux ptr */
hdr->rxinfo.flags &= ~BLE_MBUF_HDR_F_AUX_PTR_WAIT;
[mynewt-nimble] 07/07: nimble/ll: Fix address types in the
advertising report
Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 291d1b4b626a91828893e1b499085428966c5dc4
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Fri Jan 11 13:26:59 2019 +0100
nimble/ll: Fix address types in the advertising report
This patch makes sure that corret address type is used in the
advertising report when RPA addresses has been used over the air.
This fixes LL/DDI/SCN/BV-33-C
---
nimble/controller/src/ble_ll_scan.c | 41 ++++++++++++++++++++++++++++---------
nimble/include/nimble/ble.h | 4 ++++
2 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 4f25bd7..dca7031 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -929,14 +929,15 @@ ble_ll_scan_send_adv_report(uint8_t pdu_type, uint8_t *adva, uint8_t adva_type,
}
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
+ /* If RPA has been used, make sure we use correct address types
+ * in the advertising report.
+ */
if (BLE_MBUF_HDR_RESOLVED(hdr)) {
- /*
- * NOTE: this looks a bit odd, but the resolved address types
- * are 2 greater than the unresolved ones in the spec, so
- * we just add 2 here.
- */
adva_type += 2;
}
+ if (BLE_MBUF_HDR_INITA_RESOLVED(hdr)) {
+ inita_type += 2;
+ }
#endif
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
@@ -2412,9 +2413,11 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
peer = g_ble_ll_resolv_list[index].rl_identity_addr;
peer_addr_type = g_ble_ll_resolv_list[index].rl_addr_type;
resolved = 1;
- if (ble_ll_is_rpa(inita, inita_type) &&
- !ble_ll_resolv_rpa(inita, g_ble_ll_resolv_list[index].rl_local_irk)) {
- goto scan_rx_isr_exit;
+ if (ble_ll_is_rpa(inita, inita_type)) {
+ if (!ble_ll_resolv_rpa(inita, g_ble_ll_resolv_list[index].rl_local_irk)) {
+ goto scan_rx_isr_exit;
+ }
+ ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_INITA_RESOLVED;
}
} else {
if (chk_wl) {
@@ -2426,13 +2429,19 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
}
}
} else if (chk_send_req && inita && ble_ll_is_rpa(inita, inita_type)) {
- /* If remove is identity address but InitA is RPA, make sure we can resolve it.
+ /* If remote is identity address but InitA is RPA, make sure we can resolve it.
* If not, nothing more to do here
*/
rl = ble_ll_resolv_list_find(peer, peer_addr_type);
- if (!rl || !ble_ll_resolv_rpa(inita, rl->rl_local_irk)) {
+ if (!rl) {
+ goto scan_rx_isr_exit;
+ }
+
+ if (!ble_ll_resolv_rpa(inita, rl->rl_local_irk)) {
goto scan_rx_isr_exit;
}
+
+ ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_INITA_RESOLVED;
}
}
#else
@@ -2658,6 +2667,18 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
}
}
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
+ /* If RPA has been used, make sure we use correct address types
+ * in the advertising report.
+ */
+ if (BLE_MBUF_HDR_RESOLVED(hdr)) {
+ adva_type += 2;
+ }
+ if (BLE_MBUF_HDR_INITA_RESOLVED(hdr)) {
+ inita_type += 2;
+ }
+#endif
+
datalen = ble_ll_scan_parse_ext_hdr(om, adva, adva_type, inita, inita_type, hdr, evt);
if (datalen < 0) {
/* XXX what should we do here? send some trimmed event? */
diff --git a/nimble/include/nimble/ble.h b/nimble/include/nimble/ble.h
index d76603b..703c6dc 100644
--- a/nimble/include/nimble/ble.h
+++ b/nimble/include/nimble/ble.h
@@ -76,6 +76,7 @@ struct ble_mbuf_hdr_rxinfo
};
/* Flag definitions for rxinfo */
+#define BLE_MBUF_HDR_F_INITA_RESOLVED (0x2000)
#define BLE_MBUF_HDR_F_EXT_ADV_SEC (0x1000)
#define BLE_MBUF_HDR_F_EXT_ADV (0x0800)
#define BLE_MBUF_HDR_F_RESOLVED (0x0400)
@@ -134,6 +135,9 @@ struct ble_mbuf_hdr
#define BLE_MBUF_HDR_RESOLVED(hdr) \
(!!((hdr)->rxinfo.flags & BLE_MBUF_HDR_F_RESOLVED))
+#define BLE_MBUF_HDR_INITA_RESOLVED(hdr) \
+ (!!((hdr)->rxinfo.flags & BLE_MBUF_HDR_F_INITA_RESOLVED))
+
#define BLE_MBUF_HDR_RX_STATE(hdr) \
((uint8_t)((hdr)->rxinfo.flags & BLE_MBUF_HDR_F_RXSTATE_MASK))
[mynewt-nimble] 04/07: nimble/ll: Fix extended chaining scanning
Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 5ace22629d5ab0961019db4586f87b0ae2c3c3cd
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Fri Jan 11 10:46:06 2019 +0100
nimble/ll: Fix extended chaining scanning
This patch fix scanning for the advertising events where
last chain packet has extended header len 0
---
nimble/controller/include/controller/ble_ll_scan.h | 1 +
nimble/controller/src/ble_ll_scan.c | 101 ++++++++++++---------
2 files changed, 59 insertions(+), 43 deletions(-)
diff --git a/nimble/controller/include/controller/ble_ll_scan.h b/nimble/controller/include/controller/ble_ll_scan.h
index 388a599..82133b7 100644
--- a/nimble/controller/include/controller/ble_ll_scan.h
+++ b/nimble/controller/include/controller/ble_ll_scan.h
@@ -98,6 +98,7 @@ struct ble_ll_scan_params
#define BLE_LL_AUX_HAS_ADI 0x80
#define BLE_LL_SET_AUX_FLAG(aux_data, flag) ((aux_data)->flags |= flag)
+#define BLE_LL_CLEAR_AUX_FLAG(aux_data, flag) ((aux_data)->flags &= ~flag)
#define BLE_LL_CHECK_AUX_FLAG(aux_data, flag) (!!((aux_data)->flags & flag))
struct ble_ll_aux_data {
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 95977dc..a0b151a 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -1855,6 +1855,18 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
return -1;
}
+ if (ext_hdr_len == 0) {
+ if (current_aux) {
+ /* This is last element in the chain.
+ * Clear incomplete flag
+ */
+ BLE_LL_CLEAR_AUX_FLAG(current_aux, BLE_LL_AUX_INCOMPLETE_BIT);
+ return 1;
+ }
+
+ return -1;
+ }
+
ext_hdr_flags = rxbuf[3];
ext_hdr = &rxbuf[4];
@@ -2025,55 +2037,56 @@ ble_ll_scan_parse_ext_hdr(struct os_mbuf *om,
ext_hdr_flags = rxbuf[3];
ext_hdr = &rxbuf[4];
- i = 0;
- if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_ADVA_BIT)) {
- i += BLE_LL_EXT_ADV_ADVA_SIZE;
- }
+ if (ext_hdr_len) {
+ i = 0;
+ if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_ADVA_BIT)) {
+ i += BLE_LL_EXT_ADV_ADVA_SIZE;
+ }
- if (adva) {
- memcpy(out_evt->addr, adva, 6);
- out_evt->addr_type = adva_type;
- }
+ if (adva) {
+ memcpy(out_evt->addr, adva, 6);
+ out_evt->addr_type = adva_type;
+ }
- if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_TARGETA_BIT)) {
- i += BLE_LL_EXT_ADV_TARGETA_SIZE;
- }
+ if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_TARGETA_BIT)) {
+ i += BLE_LL_EXT_ADV_TARGETA_SIZE;
+ }
- if (inita) {
- memcpy(out_evt->dir_addr, inita, 6);
- out_evt->dir_addr_type = inita_type;
- out_evt->evt_type |= BLE_HCI_ADV_DIRECT_MASK;
- }
+ if (inita) {
+ memcpy(out_evt->dir_addr, inita, 6);
+ out_evt->dir_addr_type = inita_type;
+ out_evt->evt_type |= BLE_HCI_ADV_DIRECT_MASK;
+ }
- if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_RFU_BIT)) {
- /* Just skip it for now*/
- i += 1;
- }
+ if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_RFU_BIT)) {
+ /* Just skip it for now*/
+ i += 1;
+ }
- if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_DATA_INFO_BIT)) {
- ble_ll_ext_scan_parse_adv_info(scansm, out_evt, (ext_hdr + i));
- i += BLE_LL_EXT_ADV_DATA_INFO_SIZE;
- } else if (out_evt->evt_type & BLE_HCI_ADV_SCAN_RSP_MASK) {
- out_evt->sid = (aux_data->adi >> 12);
- }
+ if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_DATA_INFO_BIT)) {
+ ble_ll_ext_scan_parse_adv_info(scansm, out_evt, (ext_hdr + i));
+ i += BLE_LL_EXT_ADV_DATA_INFO_SIZE;
+ } else if (out_evt->evt_type & BLE_HCI_ADV_SCAN_RSP_MASK) {
+ out_evt->sid = (aux_data->adi >> 12);
+ }
- /* In this point of time we don't want to care about aux ptr */
- if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_AUX_PTR_BIT)) {
- i += BLE_LL_EXT_ADV_AUX_PTR_SIZE;
- }
+ /* In this point of time we don't want to care about aux ptr */
+ if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_AUX_PTR_BIT)) {
+ i += BLE_LL_EXT_ADV_AUX_PTR_SIZE;
+ }
- if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_SYNC_INFO_BIT)) {
- /* TODO Handle periodic adv */
- i += BLE_LL_EXT_ADV_SYNC_INFO_SIZE;
- }
+ if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_SYNC_INFO_BIT)) {
+ /* TODO Handle periodic adv */
+ i += BLE_LL_EXT_ADV_SYNC_INFO_SIZE;
+ }
- if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_TX_POWER_BIT)) {
- out_evt->tx_power = *(ext_hdr + i);
- i += BLE_LL_EXT_ADV_TX_POWER_SIZE;
- }
+ if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_TX_POWER_BIT)) {
+ out_evt->tx_power = *(ext_hdr + i);
+ i += BLE_LL_EXT_ADV_TX_POWER_SIZE;
+ }
- /* Skip ADAC if it is there */
- i = ext_hdr_len;
+ /* TODO Handle ACAD if needed */
+ }
/* In the event we need information on primary and secondary PHY used during
* advertising.
@@ -2086,8 +2099,10 @@ ble_ll_scan_parse_ext_hdr(struct os_mbuf *om,
out_evt->sec_phy = aux_data->aux_phy;
out_evt->prim_phy = aux_data->aux_primary_phy;
- /* Adjust mbuf to contain advertising data only */
- os_mbuf_adj(om, i);
+ if (ext_hdr_len) {
+ /* Adjust mbuf to contain advertising data only */
+ os_mbuf_adj(om, ext_hdr_len);
+ }
/* Let us first keep update event type in aux data.
* Note that in aux chain and aux scan response packets
@@ -2097,7 +2112,7 @@ ble_ll_scan_parse_ext_hdr(struct os_mbuf *om,
out_evt->evt_type = aux_data->evt_type;
done:
- return pdu_len - i - 1;
+ return pdu_len - ext_hdr_len - 1;
}
static int
[mynewt-nimble] 02/07: nimble/ll: Remove some trash comment
Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 8469d0bf1e29ac0627f729a77cdb3b55da20c766
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jan 10 13:12:44 2019 +0100
nimble/ll: Remove some trash comment
---
nimble/controller/src/ble_ll_scan.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 7c08227..3056f5a 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -1859,7 +1859,6 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
ext_hdr = &rxbuf[4];
i = 0;
- /* Just all until AUX PTR it for now*/
if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_ADVA_BIT)) {
memcpy(tmp_aux_data.addr, ext_hdr + i, 6);
tmp_aux_data.addr_type =
[mynewt-nimble] 03/07: nimble/ll: Minor fix
Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit eb19fd1bc45062543a1114dc445b8440716fa661
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jan 10 13:15:01 2019 +0100
nimble/ll: Minor fix
Use current_aux instead of ble_hdr->rxinfo.user_data for better readability
---
nimble/controller/src/ble_ll_scan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 3056f5a..95977dc 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -1851,7 +1851,7 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
tmp_aux_data.mode = rxbuf[2] >> 6;
ext_hdr_len = rxbuf[2] & 0x3F;
- if (ext_hdr_len < BLE_LL_EXT_ADV_AUX_PTR_SIZE && !ble_hdr->rxinfo.user_data) {
+ if (ext_hdr_len < BLE_LL_EXT_ADV_AUX_PTR_SIZE && !current_aux) {
return -1;
}