BLE: Address special case when advertising payload size is 0.

pull/8738/head
Vincent Coubard 2018-11-13 23:40:16 +00:00
parent ff9b380c44
commit 09d22a329c
1 changed files with 8 additions and 3 deletions

View File

@ -1872,8 +1872,10 @@ ble_error_t GenericGap::setAdvertisingData(
&pal::Gap::set_extended_scan_response_data : &pal::Gap::set_extended_scan_response_data :
&pal::Gap::set_extended_advertising_data; &pal::Gap::set_extended_advertising_data;
// FIXME: Handle the case where the payload size is 0 for (size_t i = 0, end = payload.size();
for (size_t i = 0, end = payload.size(); i < end; i += MAX_HCI_DATA_LENGTH) { (i < end) || (i == 0 && end == 0);
i += MAX_HCI_DATA_LENGTH)
{
// select the operation based on the index // select the operation based on the index
op_t op(op_t::INTERMEDIATE_FRAGMENT); op_t op(op_t::INTERMEDIATE_FRAGMENT);
if (end < MAX_HCI_DATA_LENGTH) { if (end < MAX_HCI_DATA_LENGTH) {
@ -2065,7 +2067,10 @@ ble_error_t GenericGap::setPeriodicAdvertisingPayload(
typedef pal::advertising_fragment_description_t op_t; typedef pal::advertising_fragment_description_t op_t;
for (size_t i = 0, end = payload.size(); i < end; i += MAX_HCI_DATA_LENGTH) { for (size_t i = 0, end = payload.size();
(i < end) || (i == 0 && end == 0);
i += MAX_HCI_DATA_LENGTH
) {
// select the operation based on the index // select the operation based on the index
op_t op(op_t::INTERMEDIATE_FRAGMENT); op_t op(op_t::INTERMEDIATE_FRAGMENT);
if (end < MAX_HCI_DATA_LENGTH) { if (end < MAX_HCI_DATA_LENGTH) {