@@ -880,6 +880,12 @@ ble_error_t Gap::setWhitelist(const whitelist_t &whitelist)
880880
881881ble_error_t Gap::enablePrivacy (bool enable)
882882{
883+ #if (BLE_GAP_HOST_BASED_PRIVACY == 0)
884+ /* we need either privacy on host or controller to enable it */
885+ if (enable && !_address_registry.is_controller_privacy_supported ()) {
886+ return BLE_ERROR_NOT_IMPLEMENTED;
887+ }
888+ #endif
883889 if (enable == _privacy_enabled) {
884890 // No change
885891 return BLE_ERROR_NONE;
@@ -1444,8 +1450,11 @@ ble_error_t Gap::update_ll_address_resolution_setting()
14441450 }
14451451#endif // BLE_ROLE_OBSERVER
14461452 }
1447-
1453+ #if BLE_GAP_HOST_BASED_PRIVACY
1454+ return BLE_ERROR_NONE;
1455+ #else
14481456 return _address_registry.enable_controller_address_resolution (enable);
1457+ #endif // BLE_GAP_HOST_BASED_PRIVACY
14491458}
14501459
14511460uint8_t Gap::getMaxAdvertisingSetNumber ()
@@ -2213,7 +2222,7 @@ void Gap::signal_connection_complete(
22132222 ConnectionCompleteEvent& event
22142223)
22152224{
2216- #if BLE_FEATURE_PRIVACY
2225+ #if BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVACY
22172226 bool address_resolved = false ;
22182227
22192228 /* if address resolution is not needed or already handled then the address is already resolved */
@@ -2246,7 +2255,7 @@ void Gap::signal_connection_complete(
22462255
22472256 /* first try to resolve synchronously in cache */
22482257 if (!address_resolved) {
2249- address_resolved = _address_registry.resolve_address_in_cache (
2258+ address_resolved = _address_registry.resolve_address_in_host_cache (
22502259 event.getPeerAddress (),
22512260 &peer_address_type,
22522261 &peer_address
@@ -2268,7 +2277,7 @@ void Gap::signal_connection_complete(
22682277 _event_handler->onConnectionComplete (event);
22692278 } else {
22702279 bool resolution_pending = false ;
2271- ble_error_t ret = _address_registry.queue_resolve_address (event.getPeerAddress ());
2280+ ble_error_t ret = _address_registry.queue_resolve_address_on_host (event.getPeerAddress ());
22722281
22732282 if (ret == BLE_ERROR_NONE) {
22742283 ConnectionCompleteEvent* event_copy = new (std::nothrow) ConnectionCompleteEvent (event);
@@ -2293,10 +2302,10 @@ void Gap::signal_connection_complete(
22932302#else
22942303 report_internal_connection_complete (event);
22952304 _event_handler->onConnectionComplete (event);
2296- #endif // BLE_FEATURE_PRIVACY
2305+ #endif // BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVACY
22972306}
22982307
2299- #if BLE_FEATURE_PRIVACY
2308+ #if BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVACY
23002309void Gap::conclude_signal_connection_complete_after_address_resolution (
23012310 ConnectionCompleteEvent &event,
23022311 target_peer_address_type_t identity_address_type,
@@ -2354,21 +2363,20 @@ void Gap::conclude_signal_connection_complete_after_address_resolution(
23542363#endif // BLE_FEATURE_SECURITY
23552364#endif // BLE_ROLE_PERIPHERAL
23562365}
2357- #endif // BLE_FEATURE_PRIVACY
2366+ #endif // BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVACY
23582367#endif // BLE_FEATURE_CONNECTABLE
23592368
23602369#if BLE_ROLE_OBSERVER
23612370void Gap::signal_advertising_report (
23622371 AdvertisingReportEvent& event
23632372)
23642373{
2365- #if BLE_FEATURE_PRIVACY
2374+ #if BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVACY
23662375 bool address_resolved = false ;
23672376
23682377 /* if address resolution is not needed or already handled then the address is already resolved */
23692378 if (!_privacy_enabled ||
23702379 _central_privacy_configuration.resolution_strategy == central_privacy_configuration_t ::DO_NOT_RESOLVE ||
2371- _address_registry.is_controller_privacy_supported () ||
23722380 event.getPeerAddressType () == peer_address_type_t ::PUBLIC ||
23732381 !is_random_private_resolvable_address (event.getPeerAddress ())) {
23742382 address_resolved = true ;
@@ -2379,7 +2387,7 @@ void Gap::signal_advertising_report(
23792387 const address_t *peer_address = nullptr ;
23802388 target_peer_address_type_t peer_address_type (target_peer_address_type_t ::RANDOM);
23812389
2382- address_resolved = _address_registry.resolve_address_in_cache (
2390+ address_resolved = _address_registry.resolve_address_in_host_cache (
23832391 event.getPeerAddress (),
23842392 &peer_address_type,
23852393 &peer_address
@@ -2412,7 +2420,7 @@ void Gap::signal_advertising_report(
24122420
24132421 /* if there is already an item with the same address pending don't kick off resolution*/
24142422 if (!duplicate_pending_event) {
2415- ret = _address_registry.queue_resolve_address (event.getPeerAddress ());
2423+ ret = _address_registry.queue_resolve_address_on_host (event.getPeerAddress ());
24162424 }
24172425
24182426 if (ret == BLE_ERROR_NONE) {
@@ -2429,11 +2437,11 @@ void Gap::signal_advertising_report(
24292437 _event_handler->onAdvertisingReport (
24302438 event
24312439 );
2432- #endif // BLE_FEATURE_PRIVACY
2440+ #endif // BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVACY
24332441}
24342442#endif // BLE_ROLE_OBSERVER
24352443
2436- #if BLE_FEATURE_PRIVACY
2444+ #if BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVACY
24372445#if BLE_ROLE_OBSERVER
24382446void Gap::conclude_signal_advertising_report_after_address_resolution (
24392447 AdvertisingReportEvent &event,
@@ -2457,7 +2465,7 @@ void Gap::conclude_signal_advertising_report_after_address_resolution(
24572465 _event_handler->onAdvertisingReport (event);
24582466}
24592467#endif // BLE_ROLE_OBSERVER
2460- #endif // BLE_FEATURE_PRIVACY
2468+ #endif // BLE_FEATURE_PRIVACY && BLE_GAP_HOST_BASED_PRIVACY
24612469
24622470void Gap::on_periodic_advertising_sync_established (
24632471 hci_error_code_t error,
@@ -3135,7 +3143,7 @@ const address_t *Gap::get_random_address(controller_operation_t operation, size_
31353143#if BLE_FEATURE_EXTENDED_ADVERTISING
31363144 if (is_extended_advertising_available ()) {
31373145 if (operation == controller_operation_t ::advertising) {
3138- if (_set_is_connectable.get (set_id) == false && peripheral_non_resolvable) {
3146+ if (! _set_is_connectable.get (set_id) && peripheral_non_resolvable) {
31393147 return &non_resolvable_address;
31403148 } else {
31413149 return &resolvable_address;
0 commit comments