Skip to content

Commit 5a58b32

Browse files
committed
Correct EIR length calculations
1 parent 74d496f commit 5a58b32

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Diff for: libraries/CurieBLE/src/internal/BLEDeviceManager.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -369,17 +369,16 @@ BLEDeviceManager::setAdvertiseData(uint8_t type, const uint8_t* data, uint8_t le
369369

370370
for (uint8_t i = 0; i < _scan_rsp_data_idx; i++)
371371
{
372-
lengthOfAdv += _scan_rsp_data[i].data_len + 2;
373-
}
374-
372+
lengthOfScanRsp += _scan_rsp_data[i].data_len + 2;
373+
}
375374

376-
if (((length + lengthOfAdv) < BLE_MAX_ADV_SIZE) &&
375+
if (((length + 2 + lengthOfAdv) < BLE_MAX_ADV_SIZE) &&
377376
(_adv_data_idx < ARRAY_SIZE(_adv_data)))
378377
{
379378
fill_area = &_adv_data[_adv_data_idx];
380379
_adv_data_idx++;
381380
}
382-
else if ((length + lengthOfScanRsp) < BLE_MAX_ADV_SIZE &&
381+
else if ((length + 2 + lengthOfScanRsp) < BLE_MAX_ADV_SIZE &&
383382
(_scan_rsp_data_idx < ARRAY_SIZE(_scan_rsp_data)))
384383
{
385384
fill_area = &_scan_rsp_data[_scan_rsp_data_idx];

0 commit comments

Comments
 (0)