legacy support

pull/8738/head
paul-szczepanek-arm 2018-11-07 16:51:48 +00:00 committed by Vincent Coubard
parent 7de5d8c763
commit 56146a44fb
2 changed files with 35 additions and 3 deletions

View File

@ -465,6 +465,10 @@ private:
uint8_t _active_sets[(MAX_ADVERTISING_SETS / 8) + 1];
private:
bool is_extended_advertising_enabled() {
return _pal_gap.is_feature_supported(pal::Gap::ControllerSupportedFeatures_t::LE_EXTENDED_ADVERTISING);
}
static bool get_adv_set_bit(const uint8_t *bytes, uint8_t bit_number) {
if (bit_number > MAX_ADVERTISING_SETS) {
return false;

View File

@ -1614,9 +1614,9 @@ ble_error_t GenericGap::setAdvertisingParams(AdvHandle_t handle, const GapAdvert
return BLE_ERROR_INVALID_PARAM;
}
if (_pal_gap.is_feature_supported(pal::Gap::ControllerSupportedFeatures_t::LE_EXTENDED_ADVERTISING)) {
// do legacy stuff
return BLE_ERROR_OPERATION_NOT_PERMITTED;
if (!is_extended_advertising_enabled()) {
memcpy(&getLegacyAdvertisingParams(), params, sizeof(GapAdvertisingParams));
return BLE_ERROR_NONE;
}
pal::advertising_event_properties_t event_properties;//TODO
@ -1686,6 +1686,13 @@ ble_error_t GenericGap::setAdvertisingPayload(AdvHandle_t handle, const GapAdver
return BLE_ERROR_INVALID_PARAM;
}
if (!is_extended_advertising_enabled()) {
if (handle == Gap::LEGACY_ADVERTISING_HANDLE) {
memcpy(&getLegacyAdvertisingPayload(), payload, sizeof(GapAdvertisingData));
}
return BLE_ERROR_NOT_IMPLEMENTED;
}
return _pal_gap.set_extended_advertising_data(
handle,
/*TODO fragment*/ pal::advertising_fragment_description_t::FIRST_FRAGMENT,
@ -1700,6 +1707,13 @@ ble_error_t GenericGap::setAdvertisingScanResponse(AdvHandle_t handle, const Gap
return BLE_ERROR_INVALID_PARAM;
}
if (!is_extended_advertising_enabled()) {
if (handle == Gap::LEGACY_ADVERTISING_HANDLE) {
memcpy(&getLegacyAdvertisingScanResponse(), response, sizeof(GapAdvertisingData));
}
return BLE_ERROR_NOT_IMPLEMENTED;
}
return _pal_gap.set_extended_scan_response_data(
handle,
/*TODO fragment*/ pal::advertising_fragment_description_t::FIRST_FRAGMENT,
@ -1718,6 +1732,13 @@ ble_error_t GenericGap::startAdvertising(
return BLE_ERROR_INVALID_PARAM;
}
if (!is_extended_advertising_enabled()) {
if (handle == Gap::LEGACY_ADVERTISING_HANDLE) {
return startAdvertising(getLegacyAdvertisingParams());
}
return BLE_ERROR_NOT_IMPLEMENTED;
}
/* round up */
uint16_t duration_10ms = maxDuration ? (maxDuration - 1) / 10 + 1 : 0 ;
@ -1741,6 +1762,13 @@ ble_error_t GenericGap::stopAdvertising(AdvHandle_t handle) {
return BLE_ERROR_INVALID_PARAM;
}
if (!is_extended_advertising_enabled()) {
if (handle == Gap::LEGACY_ADVERTISING_HANDLE) {
return stopAdvertising();
}
return BLE_ERROR_NOT_IMPLEMENTED;
}
return _pal_gap.extended_advertising_enable(
true,
1,