BLE - Report extended advertising in legacy handler if legacy API in use.

Workaround for the Cordio stack as extended advertising can be reported for a legacy advertising command.
pull/9919/head
Vincent Coubard 2019-03-03 19:30:42 +00:00
parent b5d713d6d7
commit 25438875c9
1 changed files with 67 additions and 18 deletions

View File

@ -2921,10 +2921,23 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
const uint8_t *data
)
{
#if BLE_FEATURE_PRIVACY
// Check if the address hasn't been resolved
if (_privacy_enabled &&
_central_privacy_configuration.resolution_strategy == CentralPrivacyConfiguration_t::RESOLVE_AND_FILTER &&
address_type != NULL &&
*address_type == pal::connection_peer_address_type_t::RANDOM_ADDRESS &&
is_random_private_resolvable_address(address.data())
) {
return;
}
#endif // BLE_FEATURE_PRIVACY
if (_deprecated_scan_api_used == false) {
// report in new event handler
if (!_eventHandler) {
return;
}
_eventHandler->onAdvertisingReport(
AdvertisingReportEvent(
event_type,
@ -2943,6 +2956,42 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
mbed::make_Span(data, data_length)
)
);
} else {
if (event_type.legacy_advertising() == false) {
return;
}
GapAdvertisingParams::AdvertisingType_t advertising_type;
if (event_type.connectable() == false) {
if (event_type.scannable_advertising()) {
advertising_type = GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED;
} else {
advertising_type = GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED;
}
} else {
if (event_type.directed_advertising()) {
advertising_type = GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED;
} else {
advertising_type = GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED;
}
}
// This handler is not supposed to be called with V1 API as the extended
// scan is not called. However the Cordio LL stack doesn't act that way
// and use extended scan with V1 API.
BLE_DEPRECATED_API_USE_BEGIN()
LegacyGap::processAdvertisementReport(
address.data(),
rssi,
event_type.scan_response(),
advertising_type,
data_length,
data,
(peer_address_type_t::type) address_type->value()
);
BLE_DEPRECATED_API_USE_END()
}
}
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>