From 7fa8a3da920364640b644bfdb226efbcd7fac595 Mon Sep 17 00:00:00 2001 From: Sandeep Mistry Date: Fri, 12 May 2017 09:22:16 -0400 Subject: [PATCH] Correct EIR length calculations --- libraries/CurieBLE/src/internal/BLEDeviceManager.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libraries/CurieBLE/src/internal/BLEDeviceManager.cpp b/libraries/CurieBLE/src/internal/BLEDeviceManager.cpp index ed00e863..9d141478 100644 --- a/libraries/CurieBLE/src/internal/BLEDeviceManager.cpp +++ b/libraries/CurieBLE/src/internal/BLEDeviceManager.cpp @@ -369,17 +369,16 @@ BLEDeviceManager::setAdvertiseData(uint8_t type, const uint8_t* data, uint8_t le for (uint8_t i = 0; i < _scan_rsp_data_idx; i++) { - lengthOfAdv += _scan_rsp_data[i].data_len + 2; - } - + lengthOfScanRsp += _scan_rsp_data[i].data_len + 2; + } - if (((length + lengthOfAdv) < BLE_MAX_ADV_SIZE) && + if (((length + 2 + lengthOfAdv) <= BLE_MAX_ADV_SIZE) && (_adv_data_idx < ARRAY_SIZE(_adv_data))) { fill_area = &_adv_data[_adv_data_idx]; _adv_data_idx++; } - else if ((length + lengthOfScanRsp) < BLE_MAX_ADV_SIZE && + else if ((length + 2 + lengthOfScanRsp) <= BLE_MAX_ADV_SIZE && (_scan_rsp_data_idx < ARRAY_SIZE(_scan_rsp_data))) { fill_area = &_scan_rsp_data[_scan_rsp_data_idx];