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/08 13:11:26 UTC

[mynewt-nimble] 04/06: nimble/ll: Improve data packing in extended advertising report

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 b25cbd4c2eaea611dba715122ed526b7f5238f16
Author: Ɓukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jan 3 12:14:03 2019 +0100

    nimble/ll: Improve data packing in extended advertising report
    
    Without this patch, even having buffer of 257 octets for the HCI event, Nimble was
    sending 253 octets of data plus 2 octets of header.
    This patch fixes it.
---
 nimble/controller/src/ble_ll_scan.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 719ee11..3222531 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -2539,7 +2539,7 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
     int datalen;
     int rc;
     bool need_event;
-    uint8_t max_event_len;
+    uint16_t max_event_len;
 
     if (!ble_ll_hci_is_le_event_enabled(BLE_HCI_LE_SUBEV_EXT_ADV_RPT)) {
         rc = -1;
@@ -2570,8 +2570,11 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
         goto done;
     }
 
+    /* Max_event_len contains advertising data and BLE_HCI_EVENT_HDR_LEN as this is related
+     * to the buffer available for the event. The maximum is 255 + 2
+     */
     offset = 0;
-    max_event_len = min(UINT8_MAX, BLE_LL_MAX_EVT_LEN);
+    max_event_len = min(UINT8_MAX + BLE_HCI_EVENT_HDR_LEN, BLE_LL_MAX_EVT_LEN);
 
     do {
         need_event = false;