Skip to content

Commit 7cdc5b0

Browse files
author
Cruz Monrreal
authored
Merge pull request #9919 from pan-/workaround-extended-report
BLE - Report extended advertising in legacy handler
2 parents dbb33ef + 2543887 commit 7cdc5b0

File tree

1 file changed

+67
-18
lines changed

1 file changed

+67
-18
lines changed

features/FEATURE_BLE/source/generic/GenericGap.tpp

Lines changed: 67 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2926,28 +2926,77 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
29262926
const uint8_t *data
29272927
)
29282928
{
2929-
if (!_eventHandler) {
2929+
#if BLE_FEATURE_PRIVACY
2930+
// Check if the address hasn't been resolved
2931+
if (_privacy_enabled &&
2932+
_central_privacy_configuration.resolution_strategy == CentralPrivacyConfiguration_t::RESOLVE_AND_FILTER &&
2933+
address_type != NULL &&
2934+
*address_type == pal::connection_peer_address_type_t::RANDOM_ADDRESS &&
2935+
is_random_private_resolvable_address(address.data())
2936+
) {
29302937
return;
29312938
}
2939+
#endif // BLE_FEATURE_PRIVACY
29322940

2933-
_eventHandler->onAdvertisingReport(
2934-
AdvertisingReportEvent(
2935-
event_type,
2936-
address_type ?
2937-
(peer_address_type_t::type) address_type->value() :
2938-
peer_address_type_t::ANONYMOUS,
2939-
(BLEProtocol::AddressBytes_t &) address,
2940-
primary_phy,
2941-
secondary_phy ? *secondary_phy : phy_t::NONE,
2942-
advertising_sid,
2943-
tx_power,
2941+
if (_deprecated_scan_api_used == false) {
2942+
// report in new event handler
2943+
if (!_eventHandler) {
2944+
return;
2945+
}
2946+
_eventHandler->onAdvertisingReport(
2947+
AdvertisingReportEvent(
2948+
event_type,
2949+
address_type ?
2950+
(peer_address_type_t::type) address_type->value() :
2951+
peer_address_type_t::ANONYMOUS,
2952+
(BLEProtocol::AddressBytes_t &) address,
2953+
primary_phy,
2954+
secondary_phy ? *secondary_phy : phy_t::NONE,
2955+
advertising_sid,
2956+
tx_power,
2957+
rssi,
2958+
periodic_advertising_interval,
2959+
(ble::peer_address_type_t::type) direct_address_type.value(),
2960+
(BLEProtocol::AddressBytes_t &) direct_address,
2961+
mbed::make_Span(data, data_length)
2962+
)
2963+
);
2964+
} else {
2965+
if (event_type.legacy_advertising() == false) {
2966+
return;
2967+
}
2968+
2969+
GapAdvertisingParams::AdvertisingType_t advertising_type;
2970+
2971+
if (event_type.connectable() == false) {
2972+
if (event_type.scannable_advertising()) {
2973+
advertising_type = GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED;
2974+
} else {
2975+
advertising_type = GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED;
2976+
}
2977+
} else {
2978+
if (event_type.directed_advertising()) {
2979+
advertising_type = GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED;
2980+
} else {
2981+
advertising_type = GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED;
2982+
}
2983+
}
2984+
2985+
// This handler is not supposed to be called with V1 API as the extended
2986+
// scan is not called. However the Cordio LL stack doesn't act that way
2987+
// and use extended scan with V1 API.
2988+
BLE_DEPRECATED_API_USE_BEGIN()
2989+
LegacyGap::processAdvertisementReport(
2990+
address.data(),
29442991
rssi,
2945-
periodic_advertising_interval,
2946-
(ble::peer_address_type_t::type) direct_address_type.value(),
2947-
(BLEProtocol::AddressBytes_t &) direct_address,
2948-
mbed::make_Span(data, data_length)
2949-
)
2950-
);
2992+
event_type.scan_response(),
2993+
advertising_type,
2994+
data_length,
2995+
data,
2996+
(peer_address_type_t::type) address_type->value()
2997+
);
2998+
BLE_DEPRECATED_API_USE_END()
2999+
}
29513000
}
29523001

29533002
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>

0 commit comments

Comments
 (0)