fix packetisation in adv set data

pull/8738/head
paul-szczepanek-arm 2018-11-09 15:16:05 +00:00 committed by Vincent Coubard
parent 23dc808968
commit 2f6d861818
1 changed files with 11 additions and 10 deletions

View File

@ -1686,23 +1686,20 @@ ble_error_t GenericGap::setAdvertisingData(AdvHandle_t handle, const Advertising
uint16_t index = 0; uint16_t index = 0;
const uint16_t& length = payload->getPayloadLen(); const uint16_t& length = payload->getPayloadLen();
uint16_t packet_data_length = length; uint16_t packet_data_length = length;
pal::advertising_fragment_description_t operation(
pal::advertising_fragment_description_t::COMPLETE_FRAGMENT typedef pal::advertising_fragment_description_t op_t;
); op_t operation = (length > MAX_HCI_DATA_LENGTH) ? op_t::FIRST_FRAGMENT : op_t::COMPLETE_FRAGMENT;
operation = (length > MAX_HCI_DATA_LENGTH) ?
pal::advertising_fragment_description_t::COMPLETE_FRAGMENT
: operation = pal::advertising_fragment_description_t::FIRST_FRAGMENT;
while (index < length) { while (index < length) {
if ((length - index) > MAX_HCI_DATA_LENGTH) { if ((length - index) > MAX_HCI_DATA_LENGTH) {
packet_data_length = MAX_HCI_DATA_LENGTH; packet_data_length = MAX_HCI_DATA_LENGTH;
} else { } else {
packet_data_length = length - index; packet_data_length = length - index;
operation = pal::advertising_fragment_description_t::LAST_FRAGMENT; operation = op_t::LAST_FRAGMENT;
} }
if (scan_reponse) { if (scan_reponse) {
_pal_gap.set_extended_scan_response_data( status = _pal_gap.set_extended_scan_response_data(
handle, handle,
operation, operation,
minimiseFragmentation, minimiseFragmentation,
@ -1710,7 +1707,7 @@ ble_error_t GenericGap::setAdvertisingData(AdvHandle_t handle, const Advertising
payload->getPayload() + index payload->getPayload() + index
); );
} else { } else {
_pal_gap.set_extended_advertising_data( status = _pal_gap.set_extended_advertising_data(
handle, handle,
operation, operation,
minimiseFragmentation, minimiseFragmentation,
@ -1719,9 +1716,13 @@ ble_error_t GenericGap::setAdvertisingData(AdvHandle_t handle, const Advertising
); );
} }
if (status != BLE_ERROR_NONE) {
return status;
}
index += packet_data_length; index += packet_data_length;
operation = pal::advertising_fragment_description_t::INTERMEDIATE_FRAGMENT; operation = op_t::INTERMEDIATE_FRAGMENT;
} }
return status; return status;