From 1737a129186e440e3f6a14642d122a3d2f2330f4 Mon Sep 17 00:00:00 2001 From: Guogang Li Date: Thu, 15 Aug 2024 13:06:43 -0700 Subject: [PATCH] Fixed bug to handle fast advertisement in BLE scan PiperOrigin-RevId: 663420728 --- connections/implementation/p2p_cluster_pcp_handler.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/connections/implementation/p2p_cluster_pcp_handler.cc b/connections/implementation/p2p_cluster_pcp_handler.cc index 882bee49..a8d84040 100644 --- a/connections/implementation/p2p_cluster_pcp_handler.cc +++ b/connections/implementation/p2p_cluster_pcp_handler.cc @@ -720,6 +720,14 @@ void P2pClusterPcpHandler::BleV2PeripheralDiscoveredHandler( return; } + if (client->GetDiscoveryOptions() + .fast_advertisement_service_uuid.empty() && + fast_advertisement) { + NEARBY_LOGS(INFO) << "Ignore the fast advertisement due to cient " + "doesn't receive it."; + return; + } + auto ble_status_or = BleAdvertisement::CreateBleAdvertisement( fast_advertisement, advertisement_bytes); if (!ble_status_or.ok()) { @@ -781,6 +789,7 @@ void P2pClusterPcpHandler::BleV2PeripheralDiscoveredHandler( found_endpoints_in_ble_discover_cb_[peripheral_id] = ble_endpoint_state; StopEndpointLostByMediumAlarm(advertisement.GetEndpointId(), Medium::BLUETOOTH); + OnEndpointFound(client, std::make_shared(BluetoothEndpoint{ {