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/07/12 13:46:37 UTC
[mynewt-nimble] branch master updated (83dff41 -> 181ed07)
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 83dff41 apps: Stop using ble_npl api
new caaceb1 nimble/ll: Add ble_ll_scan_interrupt function
new 5ccaec1 nimble/ll: With new ref_cnt in truncated case aux_data->evt must be there
new 0e9b96d nimble/ll: Add assert to detect not completed chained advertising report
new 7fb407e nimble/ll: Minor coding style issues
new 41a33b9 nimble/ll: Send truncated when error on parsing ext header
new 03a6288 nimble/ll: Add missing aux_data check
new d1bcaa1 nimble/ll: Fix error handling when sending chained adv report
new cb1137d nimble/ll: Fix start time calculations
new 7858eb5 nimble/ll: Minor rename parameter for consistency
new 7a9e314 nimble/ll: Check if truncated on CRC error
new 001516f nimble/ll: Minor comment fix
new 181ed07 nimble/ll: Fix return value
The 12 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_conn.c | 5 +-
nimble/controller/src/ble_ll_scan.c | 123 ++++++++++++++-------
nimble/controller/src/ble_ll_sched.c | 8 +-
4 files changed, 92 insertions(+), 49 deletions(-)
[mynewt-nimble] 09/12: nimble/ll: Minor rename parameter for
consistency
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 7858eb588507dbc53651170a9548926ec7ff53f8
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Wed Jul 10 14:32:16 2019 +0200
nimble/ll: Minor rename parameter for consistency
---
nimble/controller/src/ble_ll_scan.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index aa87e8a..021cd07 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -1116,14 +1116,14 @@ ble_ll_scan_window_chk(struct ble_ll_scan_sm *scansm, uint32_t cputime)
}
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
static void
-ble_ll_scan_aux_data_free(struct ble_ll_aux_data *aux_scan)
+ble_ll_scan_aux_data_free(struct ble_ll_aux_data *aux_data)
{
- if (aux_scan) {
- if (aux_scan->evt) {
- ble_hci_trans_buf_free((uint8_t *)aux_scan->evt);
- aux_scan->evt = NULL;
+ if (aux_data) {
+ if (aux_data->evt) {
+ ble_hci_trans_buf_free((uint8_t *)aux_data->evt);
+ aux_data->evt = NULL;
}
- os_memblock_put(&ext_adv_pool, aux_scan);
+ os_memblock_put(&ext_adv_pool, aux_data);
STATS_INC(ble_ll_stats, aux_freed);
}
}
[mynewt-nimble] 08/12: nimble/ll: Fix start time calculations
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 cb1137d295780b525e6787237de73614ca2db9a8
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Wed Jul 10 13:49:17 2019 +0200
nimble/ll: Fix start time calculations
---
nimble/controller/src/ble_ll_sched.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/nimble/controller/src/ble_ll_sched.c b/nimble/controller/src/ble_ll_sched.c
index e69affd..4dd187a 100644
--- a/nimble/controller/src/ble_ll_sched.c
+++ b/nimble/controller/src/ble_ll_sched.c
@@ -1705,9 +1705,9 @@ ble_ll_sched_aux_scan(struct ble_mbuf_hdr *ble_hdr,
start_time = ble_hdr->beg_cputime + off_ticks;
start_time_rem_usecs = ble_hdr->rem_usecs + off_rem_usecs;
- if (start_time_rem_usecs > 30) {
+ if (start_time_rem_usecs >= 31) {
start_time++;
- start_time_rem_usecs -= 30;
+ start_time_rem_usecs -= 31;
}
start_time -= g_ble_ll_sched_offset_ticks;
[mynewt-nimble] 05/12: nimble/ll: Send truncated when error on
parsing ext header
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 41a33b9a314a2de7d05e1793f091f1e86cc71f9e
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jul 11 10:02:32 2019 +0200
nimble/ll: Send truncated when error on parsing ext header
---
nimble/controller/src/ble_ll_scan.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 2ec8dc8..7e19143 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -2575,9 +2575,19 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
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? */
- ble_hci_trans_buf_free((uint8_t *)evt);
rc = -1;
+ /* If we were in the middle of advertising report, let us send truncated report. */
+ if (aux_data &&
+ BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_SENT_EVENT_TO_HOST) &&
+ BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_CHAIN_BIT)) {
+ evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_TRUNCATED);
+ BLE_LL_AUX_SET_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
+
+ ble_ll_hci_event_send((uint8_t *)evt);
+ goto done;
+ }
+
+ ble_hci_trans_buf_free((uint8_t *)evt);
goto done;
}
[mynewt-nimble] 04/12: nimble/ll: Minor coding style issues
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 7fb407e682855e29841fad232b46435699656eea
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Wed Jul 10 13:26:53 2019 +0200
nimble/ll: Minor coding style issues
---
nimble/controller/src/ble_ll_scan.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index e26370e..2ec8dc8 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -1824,8 +1824,8 @@ ble_ll_scan_get_aux_data(struct ble_mbuf_hdr *ble_hdr, uint8_t *rxbuf)
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 */
- return -1;
+ /* Out of memory */
+ return -1;
}
}
@@ -2633,7 +2633,7 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
}
}
- } else if (aux_data ) {
+ } else if (aux_data) {
if (BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_ERR_BIT)) {
evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_TRUNCATED);
BLE_LL_AUX_SET_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
@@ -2668,7 +2668,7 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
BLE_LL_ASSERT(offset <= datalen);
- if (aux_data){
+ if (aux_data) {
/* Store any event left for later use */
aux_data->evt = evt;
} else {
[mynewt-nimble] 11/12: nimble/ll: Minor comment 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 001516faa0c9588b138bd5d4e4e7ef2ceb51e03d
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Wed Jul 10 16:36:35 2019 +0200
nimble/ll: Minor comment 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 51fb50d..06d33ae 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -2988,7 +2988,6 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
/* Set scan response check flag */
scan_rsp_chk = BLE_MBUF_HDR_SCAN_RSP_RCV(hdr);
- /* We dont care about scan requests or connect requests */
if (!BLE_MBUF_HDR_CRC_OK(hdr)) {
goto scan_continue;
}
@@ -3010,6 +3009,7 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
}
#endif
+ /* We dont care about scan requests or connect requests */
if ((ptype == BLE_ADV_PDU_TYPE_SCAN_REQ) || (ptype == BLE_ADV_PDU_TYPE_CONNECT_IND)) {
goto scan_continue;
}
[mynewt-nimble] 02/12: nimble/ll: With new ref_cnt in truncated
case aux_data->evt must be there
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 5ccaec1a0be66b8d4047662bf5db0e4834d173dd
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Wed Jul 10 12:17:24 2019 +0200
nimble/ll: With new ref_cnt in truncated case aux_data->evt must be there
---
nimble/controller/src/ble_ll_scan.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 8579ef2..8221292 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -454,15 +454,9 @@ ble_ll_scan_send_truncated_if_chained(struct ble_ll_aux_data *aux_data)
return;
}
- if (aux_data->evt) {
- evt = aux_data->evt;
- aux_data->evt = NULL;
- } else {
- evt = ble_ll_scan_init_ext_adv_report(NULL);
- if (!evt) {
- return;
- }
- }
+ BLE_LL_ASSERT(aux_data->evt);
+ evt = aux_data->evt;
+ aux_data->evt = NULL;
evt->event_len = sizeof(*evt) - BLE_HCI_EVENT_HDR_LEN;
evt->evt_type = aux_data->evt_type;
[mynewt-nimble] 12/12: nimble/ll: Fix return value
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 181ed07b08838dc539ba6256c87bf8791e5f44ca
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jul 11 11:23:48 2019 +0200
nimble/ll: Fix return value
---
nimble/controller/src/ble_ll_sched.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/nimble/controller/src/ble_ll_sched.c b/nimble/controller/src/ble_ll_sched.c
index 4dd187a..3679c6f 100644
--- a/nimble/controller/src/ble_ll_sched.c
+++ b/nimble/controller/src/ble_ll_sched.c
@@ -1685,7 +1685,7 @@ ble_ll_sched_aux_scan(struct ble_mbuf_hdr *ble_hdr,
struct ble_ll_scan_sm *scansm,
struct ble_ll_aux_data *aux_scan)
{
- int rc;
+ int rc = 1;
os_sr_t sr;
uint32_t off_ticks;
uint32_t off_rem_usecs;
@@ -1749,7 +1749,6 @@ ble_ll_sched_aux_scan(struct ble_mbuf_hdr *ble_hdr,
* anything. We can make it smarter later on
*/
if (ble_ll_sched_is_overlap(sch, entry)) {
- rc = -1;
break;
}
}
[mynewt-nimble] 01/12: nimble/ll: Add ble_ll_scan_interrupt function
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 caaceb1946286fc8f22bd90e75a05d264cea9837
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jun 20 00:10:21 2019 +0200
nimble/ll: Add ble_ll_scan_interrupt function
This is common fuction to be called whenever scanning has been
interrupted. This function sends event to LL task.
Also with this patch, scheduled AUX entry gets pointer to aux_data when
it is scheduled and not when aux_data is created. This is because
aux_data->ref_cnt is increased when scheduled.
---
nimble/controller/include/controller/ble_ll_scan.h | 5 ++-
nimble/controller/src/ble_ll_conn.c | 5 +--
nimble/controller/src/ble_ll_scan.c | 45 +++++++++++++++-------
nimble/controller/src/ble_ll_sched.c | 1 +
4 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/nimble/controller/include/controller/ble_ll_scan.h b/nimble/controller/include/controller/ble_ll_scan.h
index 3fe4985..e1f8197 100644
--- a/nimble/controller/include/controller/ble_ll_scan.h
+++ b/nimble/controller/include/controller/ble_ll_scan.h
@@ -153,7 +153,7 @@ struct ble_ll_scan_sm
uint32_t scan_win_start_time;
struct ble_npl_event scan_sched_ev;
struct hal_timer scan_timer;
- struct ble_npl_event scan_wfr_ev;
+ struct ble_npl_event scan_interrupted_ev;
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
struct hal_timer duration_timer;
@@ -238,6 +238,9 @@ void ble_ll_scan_chk_resume(void);
/* Called when wait for response timer expires in scanning mode */
void ble_ll_scan_wfr_timer_exp(void);
+/* Called when scan could be interrupted */
+void ble_ll_scan_interrupted(struct ble_ll_scan_sm *scansm);
+
int ble_ll_scan_adv_decode_addr(uint8_t pdu_type, uint8_t *rxbuf,
struct ble_mbuf_hdr *ble_hdr,
uint8_t **addr, uint8_t *addr_type,
diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c
index c7ea56e..17dc3b7 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -546,7 +546,6 @@ ble_ll_conn_init_wfr_timer_exp(void)
{
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
struct ble_ll_conn_sm *connsm;
- struct ble_ll_scan_sm *scansm;
connsm = g_ble_ll_conn_create_sm;
if (!connsm) {
@@ -556,8 +555,8 @@ ble_ll_conn_init_wfr_timer_exp(void)
ble_ll_conn_reset_pending_aux_conn_rsp();
connsm->inita_identity_used = 0;
- scansm = connsm->scansm;
- ble_ll_event_send(&scansm->scan_wfr_ev);
+ ble_ll_scan_interrupted(connsm->scansm);
+
#endif
}
/**
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index db55972..8579ef2 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -226,7 +226,7 @@ ble_ll_aux_scan_cb(struct ble_ll_sched_item *sch)
scansm->cur_aux_data->scanning = 1;
if (ble_ll_scan_start(scansm, sch)) {
- ble_ll_event_send(&scansm->scan_wfr_ev);
+ ble_ll_scan_interrupted(scansm);
goto done;
}
@@ -252,7 +252,6 @@ ble_ll_scan_ext_adv_init(struct ble_ll_aux_data **aux_data)
memset(e, 0, sizeof(*e));
e->sch.sched_cb = ble_ll_aux_scan_cb;
- e->sch.cb_arg = e;
e->sch.sched_type = BLE_LL_SCHED_TYPE_AUX_SCAN;
e->ref_cnt = 1;
ble_ll_trace_u32x2(BLE_LL_TRACE_ID_AUX_REF, (uint32_t)e, e->ref_cnt);
@@ -1347,30 +1346,39 @@ ble_ll_scan_start_next_phy(struct ble_ll_scan_sm *scansm,
}
static void
-ble_ll_aux_scan_rsp_failed(void)
+ble_ll_aux_scan_rsp_failed(struct ble_ll_scan_sm *scansm)
{
+ if (!scansm->cur_aux_data) {
+ return;
+ }
+
STATS_INC(ble_ll_stats, aux_scan_rsp_err);
- ble_ll_scan_clean_cur_aux_data();
+ ble_ll_scan_interrupted(scansm);
}
#endif
static void
-ble_ll_scan_wfr_event_cb(struct ble_npl_event *ev)
+ble_ll_scan_interrupted_event_cb(struct ble_npl_event *ev)
{
struct ble_ll_scan_sm *scansm = &g_ble_ll_scan_sm;
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
+ struct ble_ll_aux_data *aux_data;
+#endif
if (!scansm->scan_enabled) {
return;
}
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
- if (scansm && scansm->cur_aux_data) {
+ aux_data = ble_npl_event_get_arg(ev);
+
+ if (aux_data) {
if (scansm->scan_rsp_pending) {
STATS_INC(ble_ll_stats, aux_scan_rsp_err);
}
- ble_ll_scan_end_adv_evt(scansm->cur_aux_data);
- ble_ll_scan_aux_data_unref(scansm->cur_aux_data);
- scansm->cur_aux_data = NULL;
+ ble_ll_scan_end_adv_evt(aux_data);
+ ble_ll_scan_aux_data_unref(aux_data);
+ ble_npl_event_set_arg(ev, NULL);
STATS_INC(ble_ll_stats, aux_missed_adv);
}
#endif
@@ -1627,7 +1635,7 @@ ble_ll_scan_rx_isr_start(uint8_t pdu_type, uint16_t *rxflags)
} else {
ble_ll_scan_req_backoff(scansm, 0);
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
- ble_ll_aux_scan_rsp_failed();
+ ble_ll_aux_scan_rsp_failed(scansm);
#endif
}
}
@@ -2200,7 +2208,7 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
* return 0 in this case because we dont want the phy disabled.
*/
if (rxpdu == NULL) {
- ble_ll_event_send(&scansm->scan_wfr_ev);
+ ble_ll_scan_interrupted(scansm);
return 0;
}
@@ -2484,6 +2492,17 @@ ble_ll_scan_timer_cb(void *arg)
ble_ll_event_send(&scansm->scan_sched_ev);
}
+void
+ble_ll_scan_interrupted(struct ble_ll_scan_sm *scansm)
+{
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
+ ble_npl_event_set_arg(&scansm->scan_interrupted_ev, scansm->cur_aux_data);
+ scansm->cur_aux_data = NULL;
+#endif
+
+ ble_ll_event_send(&scansm->scan_interrupted_ev);
+}
+
/**
* Called when the wait for response timer expires while in the scanning
* state.
@@ -2496,7 +2515,7 @@ ble_ll_scan_wfr_timer_exp(void)
struct ble_ll_scan_sm *scansm;
scansm = &g_ble_ll_scan_sm;
- ble_ll_event_send(&scansm->scan_wfr_ev);
+ ble_ll_scan_interrupted(scansm);
}
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
@@ -3824,7 +3843,7 @@ ble_ll_scan_common_init(void)
scansm);
#endif
- ble_npl_event_init(&scansm->scan_wfr_ev, ble_ll_scan_wfr_event_cb, scansm);
+ ble_npl_event_init(&scansm->scan_interrupted_ev, ble_ll_scan_interrupted_event_cb, NULL);
}
/**
diff --git a/nimble/controller/src/ble_ll_sched.c b/nimble/controller/src/ble_ll_sched.c
index caf477b..e69affd 100644
--- a/nimble/controller/src/ble_ll_sched.c
+++ b/nimble/controller/src/ble_ll_sched.c
@@ -1698,6 +1698,7 @@ ble_ll_sched_aux_scan(struct ble_mbuf_hdr *ble_hdr,
int phy_mode;
sch = &aux_scan->sch;
+ BLE_LL_ASSERT(sch->cb_arg == NULL);
off_ticks = os_cputime_usecs_to_ticks(aux_scan->offset);
off_rem_usecs = aux_scan->offset - os_cputime_ticks_to_usecs(off_ticks);
[mynewt-nimble] 06/12: nimble/ll: Add missing aux_data check
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 03a628808378900e188d5aee06bf17af6eb175c5
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jul 11 10:03:43 2019 +0200
nimble/ll: Add missing aux_data check
---
nimble/controller/src/ble_ll_scan.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 7e19143..9e755cc 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -2635,11 +2635,13 @@ 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_AUX_SET_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
rc = -1;
- if (!BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_SENT_EVENT_TO_HOST)) {
- ble_hci_trans_buf_free((uint8_t *)evt);
- goto done;
+ if (aux_data) {
+ BLE_LL_AUX_SET_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
+ if (!BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_SENT_EVENT_TO_HOST)) {
+ ble_hci_trans_buf_free((uint8_t *)evt);
+ goto done;
+ }
}
}
[mynewt-nimble] 03/12: nimble/ll: Add assert to detect not
completed chained 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 0e9b96d21763c0d9e874a20f90815b19595e96c1
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Wed Jul 10 13:23:35 2019 +0200
nimble/ll: Add assert to detect not completed chained advertising report
---
nimble/controller/src/ble_ll_scan.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 8221292..e26370e 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -1156,6 +1156,11 @@ ble_ll_scan_aux_data_unref(struct ble_ll_aux_data *aux_data)
ble_ll_trace_u32x2(BLE_LL_TRACE_ID_AUX_UNREF, (uint32_t) aux_data, aux_data->ref_cnt);
if (aux_data->ref_cnt == 0) {
+ /* Below assert is to detect missing complete or truncated event in case of chaining */
+ BLE_LL_ASSERT(!((BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_CHAIN_BIT) &&
+ BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_SENT_EVENT_TO_HOST)) &&
+ !(BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT) ||
+ !BLE_LL_AUX_CHECK_FLAG(aux_data, BLE_LL_AUX_INCOMPLETE_BIT))));
ble_ll_scan_aux_data_free(aux_data);
}
@@ -2646,6 +2651,16 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
if (aux_data) {
BLE_LL_AUX_SET_FLAG(aux_data, BLE_LL_SENT_EVENT_TO_HOST);
+ /* In case it is scannable AUX and we are waiting for scan response,
+ * let us clear BLE_LL_SENT_EVENT_TO_HOST flag as we consider scan response
+ * as separate report even aux_data is reused.
+ * This is needed to proper detect of not completed advertising
+ * reports.
+ */
+ if ((aux_data->evt_type & BLE_HCI_ADV_SCAN_MASK) &&
+ !(aux_data->evt_type & BLE_HCI_ADV_SCAN_RSP_MASK)) {
+ BLE_LL_AUX_CLEAR_FLAG(aux_data, BLE_LL_SENT_EVENT_TO_HOST);
+ }
}
evt = next_evt;
[mynewt-nimble] 10/12: nimble/ll: Check if truncated on CRC error
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 7a9e3147aa4edf0231478539f0546d414735d4e5
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Wed Jul 10 16:36:16 2019 +0200
nimble/ll: Check if truncated on CRC error
---
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 021cd07..51fb50d 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -3199,7 +3199,7 @@ scan_continue:
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
if (aux_data) {
- if (evt_possibly_truncated) {
+ if (evt_possibly_truncated || !BLE_MBUF_HDR_CRC_OK(hdr)) {
ble_ll_scan_end_adv_evt(aux_data);
}
[mynewt-nimble] 07/12: nimble/ll: Fix error handling when sending
chained adv 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 d1bcaa11a860710def805b4f4bf1da17e3ae1e47
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Wed Jul 10 13:41:40 2019 +0200
nimble/ll: Fix error handling when sending chained adv report
In case there NimBLE has scheduled for next aux chain which is already
fired, but there was an issue with previous report sending over the HCI,
removing scheduled item from the scheduler will not succeed.
This patch makes sure truncated event will be delivered to the
host in such a case.
---
nimble/controller/src/ble_ll_scan.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 9e755cc..aa87e8a 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -3155,8 +3155,9 @@ 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->sch.cb_arg);
aux_data->sch.cb_arg = NULL;
- evt_possibly_truncated = 1;
+
}
+ evt_possibly_truncated = 1;
}
} else if (!rc && scansm->scan_filt_dups) {
ble_ll_scan_dup_update_ext(ident_addr_type, ident_addr, aux_data);