diff --git a/cpp/core/internal/client_proxy.cc b/cpp/core/internal/client_proxy.cc index aac4e09c..409414f3 100644 --- a/cpp/core/internal/client_proxy.cc +++ b/cpp/core/internal/client_proxy.cc @@ -153,15 +153,21 @@ void ClientProxy::OnEndpointFound(const std::string& service_id, endpoint_id.c_str(), service_id.c_str(), absl::BytesToHexString(endpoint_info.data()).c_str()); if (!IsDiscoveringServiceId(service_id)) { - NEARBY_LOG(INFO, "ClientProxy [Endpoint Found]: [no discovery] id=%s", + NEARBY_LOG(INFO, + "ClientProxy [Endpoint Found]: Ignoring event for id=%s because " + "this client is not discovering", endpoint_id.c_str()); return; } + if (discovered_endpoint_ids_.count(endpoint_id)) { - NEARBY_LOG(INFO, "ClientProxy [Endpoint Found]: [duplicate] id=%s", + NEARBY_LOG(WARNING, + "ClientProxy [Endpoint Found]: Ignoring event for id=%s because " + "this client already reported this endpoint as found", endpoint_id.c_str()); return; } + discovered_endpoint_ids_.insert(endpoint_id); discovery_info_.listener.endpoint_found_cb(endpoint_id, endpoint_info, service_id); @@ -171,9 +177,25 @@ void ClientProxy::OnEndpointLost(const std::string& service_id, const std::string& endpoint_id) { MutexLock lock(&mutex_); - if (!IsDiscoveringServiceId(service_id)) return; + NEARBY_LOG(INFO, "ClientProxy [Endpoint Lost]: [enter] id=%s; service=%s", + endpoint_id.c_str(), service_id.c_str()); + if (!IsDiscoveringServiceId(service_id)) { + NEARBY_LOG(INFO, + "ClientProxy [Endpoint Lost]: Ignoring event for id=%s because " + "this client is not discovering", + endpoint_id.c_str()); + return; + } + const auto it = discovered_endpoint_ids_.find(endpoint_id); - if (it == discovered_endpoint_ids_.end()) return; + if (it == discovered_endpoint_ids_.end()) { + NEARBY_LOG(WARNING, + "ClientProxy [Endpoint Lost]: Ignoring event for id=%s because " + "this client has not yet reported this endpoint as found", + endpoint_id.c_str()); + return; + } + discovered_endpoint_ids_.erase(it); discovery_info_.listener.endpoint_lost_cb(endpoint_id); } diff --git a/cpp/core/internal/mediums/ble.cc b/cpp/core/internal/mediums/ble.cc index 91191bc7..bda74756 100644 --- a/cpp/core/internal/mediums/ble.cc +++ b/cpp/core/internal/mediums/ble.cc @@ -186,6 +186,12 @@ bool Ble::StartScanning(const std::string& service_id, const std::string& service_id, const ByteArray& medium_advertisement_bytes, bool fast_advertisement) { + // Don't bother trying to parse zero byte advertisements. + if (medium_advertisement_bytes.size() == 0) { + NEARBY_LOGS(INFO) << "Skipping zero byte advertisement " + << "with service_id: " << service_id; + return; + } // Unwrap connection BleAdvertisement from medium // BleAdvertisement. auto connection_advertisement_bytes = diff --git a/proto/bootstrap_enums.proto b/proto/bootstrap_enums.proto index c23cc314..6d1ade6d 100644 --- a/proto/bootstrap_enums.proto +++ b/proto/bootstrap_enums.proto @@ -17,6 +17,8 @@ syntax = "proto2"; package location.nearby.proto; option optimize_for = LITE_RUNTIME; +option (logs_proto.file_not_used_for_logging_except_enums) = true; +option java_api_version = 2; option java_package = "com.google.location.nearby.proto"; option java_outer_classname = "BootstrapEnums"; diff --git a/proto/magic_pair_enums.proto b/proto/magic_pair_enums.proto index c6fb65b5..0f508861 100644 --- a/proto/magic_pair_enums.proto +++ b/proto/magic_pair_enums.proto @@ -17,6 +17,8 @@ syntax = "proto2"; package location.nearby.proto; option optimize_for = LITE_RUNTIME; +option (logs_proto.file_not_used_for_logging_except_enums) = true; +option java_api_version = 2; option java_package = "com.google.location.nearby.proto"; option java_outer_classname = "MagicPairEnums"; option objc_class_prefix = "GNCP"; diff --git a/proto/nearby_client_enums.proto b/proto/nearby_client_enums.proto index 7f33bebe..b932c14e 100644 --- a/proto/nearby_client_enums.proto +++ b/proto/nearby_client_enums.proto @@ -17,6 +17,8 @@ syntax = "proto2"; package location.nearby.proto; option optimize_for = LITE_RUNTIME; +option (logs_proto.file_not_used_for_logging_except_enums) = true; +option java_api_version = 2; option java_package = "com.google.location.nearby.proto"; option java_outer_classname = "NearbyClientEnums"; option objc_class_prefix = "GNCP";