@@ -900,9 +900,11 @@ ble_error_t Gap::enablePrivacy(bool enable)
900900 _address_registry.stop_private_address_generation ();
901901 }
902902
903+ #if !BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
903904 if (_address_registry.is_controller_privacy_supported ()) {
904905 update_ll_address_resolution_setting ();
905906 }
907+ #endif // !BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
906908
907909 return BLE_ERROR_NONE;
908910}
@@ -914,9 +916,11 @@ ble_error_t Gap::setPeripheralPrivacyConfiguration(
914916{
915917 _peripheral_privacy_configuration = *configuration;
916918
919+ #if !BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
917920 if (_address_registry.is_controller_privacy_supported ()) {
918921 update_ll_address_resolution_setting ();
919922 }
923+ #endif // !BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
920924
921925 return BLE_ERROR_NONE;
922926}
@@ -938,9 +942,11 @@ ble_error_t Gap::setCentralPrivacyConfiguration(
938942{
939943 _central_privacy_configuration = *configuration;
940944
945+ #if !BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
941946 if (_address_registry.is_controller_privacy_supported ()) {
942947 update_ll_address_resolution_setting ();
943948 }
949+ #endif // !BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
944950
945951 return BLE_ERROR_NONE;
946952}
@@ -1428,7 +1434,7 @@ bool Gap::initialize_whitelist() const
14281434 return true ;
14291435}
14301436
1431-
1437+ # if BLE_FEATURE_PRIVACY && !BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
14321438ble_error_t Gap::update_ll_address_resolution_setting ()
14331439{
14341440 // enable if privacy is enabled and resolution is requested in either central or peripheral mode
@@ -1450,6 +1456,7 @@ ble_error_t Gap::update_ll_address_resolution_setting()
14501456
14511457 return _address_registry.enable_controller_address_resolution (enable);
14521458}
1459+ #endif // BLE_FEATURE_PRIVACY && !BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
14531460
14541461uint8_t Gap::getMaxAdvertisingSetNumber ()
14551462{
@@ -2219,12 +2226,11 @@ void Gap::signal_connection_complete(
22192226 ConnectionCompleteEvent& event
22202227)
22212228{
2222- #if BLE_FEATURE_PRIVACY
2229+ #if BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
22232230 bool address_resolved = false ;
22242231
22252232 /* if address resolution is not needed or already handled then the address is already resolved */
22262233 if (!_privacy_enabled ||
2227- _address_registry.is_controller_privacy_supported () ||
22282234 event.getPeerAddressType () == peer_address_type_t ::PUBLIC ||
22292235 !is_random_private_resolvable_address (event.getPeerAddress ())) {
22302236 address_resolved = true ;
@@ -2235,7 +2241,7 @@ void Gap::signal_connection_complete(
22352241 address_resolved = true ;
22362242 }
22372243 }
2238- #endif
2244+ #endif // BLE_ROLE_CENTRAL
22392245
22402246#if BLE_ROLE_PERIPHERAL
22412247 if (event.getOwnRole () == connection_role_t ::PERIPHERAL) {
@@ -2252,7 +2258,7 @@ void Gap::signal_connection_complete(
22522258
22532259 /* first try to resolve synchronously in cache */
22542260 if (!address_resolved) {
2255- address_resolved = _address_registry.resolve_address_in_cache (
2261+ address_resolved = _address_registry.resolve_address_in_host_cache (
22562262 event.getPeerAddress (),
22572263 &peer_address_type,
22582264 &peer_address
@@ -2277,7 +2283,7 @@ void Gap::signal_connection_complete(
22772283 _event_handler->onConnectionComplete (event);
22782284 } else {
22792285 bool resolution_pending = false ;
2280- ble_error_t ret = _address_registry.queue_resolve_address (event.getPeerAddress ());
2286+ ble_error_t ret = _address_registry.queue_resolve_address_on_host (event.getPeerAddress ());
22812287
22822288 if (ret == BLE_ERROR_NONE) {
22832289 ConnectionCompleteEvent* event_copy = new (std::nothrow) ConnectionCompleteEvent (event);
@@ -2300,13 +2306,17 @@ void Gap::signal_connection_complete(
23002306 }
23012307 }
23022308#else
2309+ #if BLE_FEATURE_PRIVACY
2310+ if (!apply_peripheral_privacy_connection_policy (event)) {
2311+ return ;
2312+ }
2313+ #endif // BLE_FEATURE_PRIVACY
23032314 report_internal_connection_complete (event);
23042315 _event_handler->onConnectionComplete (event);
2305- #endif // BLE_FEATURE_PRIVACY
2316+ #endif // BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
23062317}
23072318
23082319#if BLE_FEATURE_PRIVACY
2309-
23102320bool Gap::apply_peripheral_privacy_connection_policy (
23112321 const ConnectionCompleteEvent &event
23122322)
@@ -2328,6 +2338,10 @@ bool Gap::apply_peripheral_privacy_connection_policy(
23282338
23292339 switch (_peripheral_privacy_configuration.resolution_strategy ) {
23302340 case peripheral_privacy_configuration_t ::REJECT_NON_RESOLVED_ADDRESS:
2341+ /* if there is no bond then allow unresolved addresses */
2342+ if (_address_registry.read_resolving_list_size () == 0 ) {
2343+ return true ;
2344+ }
23312345 _pal_gap.disconnect (
23322346 connection_handle,
23332347 local_disconnection_reason_t ::AUTHENTICATION_FAILURE
@@ -2356,8 +2370,9 @@ bool Gap::apply_peripheral_privacy_connection_policy(
23562370 return true ;
23572371#endif
23582372}
2373+ #endif // BLE_FEATURE_PRIVACY
23592374
2360-
2375+ # if BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
23612376void Gap::conclude_signal_connection_complete_after_address_resolution (
23622377 ConnectionCompleteEvent &event,
23632378 target_peer_address_type_t identity_address_type,
@@ -2383,21 +2398,20 @@ void Gap::conclude_signal_connection_complete_after_address_resolution(
23832398 report_internal_connection_complete (event);
23842399 _event_handler->onConnectionComplete (event);
23852400}
2386- #endif // BLE_FEATURE_PRIVACY
2401+ #endif // BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
23872402#endif // BLE_FEATURE_CONNECTABLE
23882403
23892404#if BLE_ROLE_OBSERVER
23902405void Gap::signal_advertising_report (
23912406 AdvertisingReportEvent& event
23922407)
23932408{
2394- #if BLE_FEATURE_PRIVACY
2409+ #if BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
23952410 bool address_resolved = false ;
23962411
23972412 /* if address resolution is not needed or already handled then the address is already resolved */
23982413 if (!_privacy_enabled ||
23992414 _central_privacy_configuration.resolution_strategy == central_privacy_configuration_t ::DO_NOT_RESOLVE ||
2400- _address_registry.is_controller_privacy_supported () ||
24012415 event.getPeerAddressType () == peer_address_type_t ::PUBLIC ||
24022416 !is_random_private_resolvable_address (event.getPeerAddress ())) {
24032417 address_resolved = true ;
@@ -2408,7 +2422,7 @@ void Gap::signal_advertising_report(
24082422 const address_t *peer_address = nullptr ;
24092423 target_peer_address_type_t peer_address_type (target_peer_address_type_t ::RANDOM);
24102424
2411- address_resolved = _address_registry.resolve_address_in_cache (
2425+ address_resolved = _address_registry.resolve_address_in_host_cache (
24122426 event.getPeerAddress (),
24132427 &peer_address_type,
24142428 &peer_address
@@ -2441,7 +2455,7 @@ void Gap::signal_advertising_report(
24412455
24422456 /* if there is already an item with the same address pending don't kick off resolution*/
24432457 if (!duplicate_pending_event) {
2444- ret = _address_registry.queue_resolve_address (event.getPeerAddress ());
2458+ ret = _address_registry.queue_resolve_address_on_host (event.getPeerAddress ());
24452459 }
24462460
24472461 if (ret == BLE_ERROR_NONE) {
@@ -2455,14 +2469,21 @@ void Gap::signal_advertising_report(
24552469 }
24562470 }
24572471#else
2472+ /* filter out unresolved address if at least one bond exists */
2473+ if (_address_registry.read_resolving_list_size () > 0 &&
2474+ _central_privacy_configuration.resolution_strategy == central_privacy_configuration_t ::RESOLVE_AND_FILTER &&
2475+ event.getPeerAddressType () != peer_address_type_t ::PUBLIC &&
2476+ is_random_private_resolvable_address (event.getPeerAddress ())) {
2477+ return ;
2478+ }
24582479 _event_handler->onAdvertisingReport (
24592480 event
24602481 );
2461- #endif // BLE_FEATURE_PRIVACY
2482+ #endif // BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
24622483}
24632484#endif // BLE_ROLE_OBSERVER
24642485
2465- #if BLE_FEATURE_PRIVACY
2486+ #if BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
24662487#if BLE_ROLE_OBSERVER
24672488void Gap::conclude_signal_advertising_report_after_address_resolution (
24682489 AdvertisingReportEvent &event,
@@ -2472,21 +2493,21 @@ void Gap::conclude_signal_advertising_report_after_address_resolution(
24722493{
24732494 /* fix the report with the new address if there's an identity found */
24742495 if (identity_address) {
2475- /* filter out resolved address based on policy */
2476- if (_central_privacy_configuration.resolution_strategy ==
2477- central_privacy_configuration_t ::RESOLVE_AND_FILTER) {
2478- return ;
2479- }
24802496 event.setPeerAddress (*identity_address);
24812497 event.setPeerAddressType (identity_address_type == target_peer_address_type_t ::RANDOM ?
24822498 peer_address_type_t ::RANDOM_STATIC_IDENTITY
24832499 : peer_address_type_t ::PUBLIC_IDENTITY);
2500+ } else if (_central_privacy_configuration.resolution_strategy ==
2501+ central_privacy_configuration_t ::RESOLVE_AND_FILTER &&
2502+ _address_registry.read_resolving_list_size () > 0 ) {
2503+ /* filter out unresolved address if at least one bond exists */
2504+ return ;
24842505 }
24852506
24862507 _event_handler->onAdvertisingReport (event);
24872508}
24882509#endif // BLE_ROLE_OBSERVER
2489- #endif // BLE_FEATURE_PRIVACY
2510+ #endif // BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
24902511
24912512void Gap::on_periodic_advertising_sync_established (
24922513 hci_error_code_t error,
@@ -3047,15 +3068,15 @@ void Gap::on_private_address_generated(bool connectable)
30473068 }
30483069}
30493070
3050-
3071+ #if BLE_FEATURE_PRIVACY
3072+ #if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
30513073void Gap::on_address_resolution_completed (
30523074 const address_t &peer_resolvable_address,
30533075 bool resolved,
30543076 target_peer_address_type_t identity_address_type,
30553077 const address_t &identity_address
30563078)
30573079{
3058- #if BLE_FEATURE_PRIVACY
30593080 if (!_event_handler || !_privacy_enabled) {
30603081 return ;
30613082 }
@@ -3105,9 +3126,9 @@ void Gap::on_address_resolution_completed(
31053126 delete event;
31063127 }
31073128#endif // BLE_ROLE_OBSERVER
3108- #endif // BLE_FEATURE_PRIVACY
31093129}
3110-
3130+ #endif // BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
3131+ #endif // BLE_FEATURE_PRIVACY
31113132
31123133bool Gap::is_advertising () const
31133134{
@@ -3165,7 +3186,7 @@ const address_t *Gap::get_random_address(controller_operation_t operation, size_
31653186#if BLE_FEATURE_EXTENDED_ADVERTISING
31663187 if (is_extended_advertising_available ()) {
31673188 if (operation == controller_operation_t ::advertising) {
3168- if (_set_is_connectable.get (set_id) == false && peripheral_non_resolvable) {
3189+ if (! _set_is_connectable.get (set_id) && peripheral_non_resolvable) {
31693190 return &non_resolvable_address;
31703191 } else {
31713192 return &resolvable_address;
0 commit comments