mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
[NearbyConnections] Update ios BLE discovery related logs
PiperOrigin-RevId: 730693835
This commit is contained in:
@@ -14,8 +14,11 @@
|
||||
|
||||
#ifndef CORE_INTERNAL_BLE_ADVERTISEMENT_H_
|
||||
#define CORE_INTERNAL_BLE_ADVERTISEMENT_H_
|
||||
#include <string>
|
||||
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "connections/implementation/base_pcp_handler.h"
|
||||
#include "connections/implementation/pcp.h"
|
||||
#include "internal/platform/bluetooth_utils.h"
|
||||
@@ -98,6 +101,14 @@ class BleAdvertisement {
|
||||
std::string GetBluetoothMacAddress() const { return bluetooth_mac_address_; }
|
||||
ByteArray GetUwbAddress() const { return uwb_address_; }
|
||||
WebRtcState GetWebRtcState() const { return web_rtc_state_; }
|
||||
std::string ToReadableString() const {
|
||||
return absl::StrFormat(
|
||||
"BleAdvertisement { version=%d, pcp=%d, fast_advertisement=%v, "
|
||||
"service_id_hash=%s, endpoint_id=%s, endpoint_info_=%s}",
|
||||
static_cast<int>(version_), static_cast<int>(pcp_), fast_advertisement_,
|
||||
absl::BytesToHexString(service_id_hash_.AsStringView()), endpoint_id_,
|
||||
absl::BytesToHexString(endpoint_info_.AsStringView()));
|
||||
}
|
||||
|
||||
private:
|
||||
void DoInitialize(bool fast_advertisement, Version version, Pcp pcp,
|
||||
|
||||
@@ -15,9 +15,12 @@
|
||||
#ifndef CORE_INTERNAL_MEDIUMS_BLE_V2_BLE_ADVERTISEMENT_H_
|
||||
#define CORE_INTERNAL_MEDIUMS_BLE_V2_BLE_ADVERTISEMENT_H_
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "connections/implementation/mediums/ble_v2/ble_advertisement_header.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
|
||||
@@ -101,6 +104,17 @@ class BleAdvertisement {
|
||||
ByteArray GetDeviceToken() const { return device_token_; }
|
||||
int GetPsm() const { return psm_; }
|
||||
void SetPsm(int psm) { psm_ = psm; }
|
||||
std::string ToReadableString() const {
|
||||
return absl::StrFormat(
|
||||
"BleAdvertisement { version=%d, socket_version=%d, "
|
||||
"fast_advertisement=%v, service_id_hash=%s, data=%s, device_token=%s, "
|
||||
"psm=%d }",
|
||||
static_cast<int>(version_), static_cast<int>(socket_version_),
|
||||
fast_advertisement_,
|
||||
absl::BytesToHexString(service_id_hash_.AsStringView()),
|
||||
absl::BytesToHexString(data_.AsStringView()),
|
||||
absl::BytesToHexString(device_token_.AsStringView()), psm_);
|
||||
}
|
||||
|
||||
private:
|
||||
// Represents the extra fields of the `BleAdvertisement` used in Advertising +
|
||||
|
||||
@@ -167,9 +167,6 @@ bool DiscoveredPeripheralTracker::HandleOnLostAdvertisementLocked(
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG(INFO) << __func__ << ": Found OnLost advertisement for hash:"
|
||||
<< absl::BytesToHexString(on_lost_advertisement->ToBytes());
|
||||
|
||||
for (const auto& hash : on_lost_advertisement->hashes()) {
|
||||
for (const auto& it : gatt_advertisement_infos_) {
|
||||
if (it.second.advertisement_header.GetAdvertisementHash().string_data() ==
|
||||
@@ -449,13 +446,8 @@ BleAdvertisementHeader DiscoveredPeripheralTracker::HandleRawGattAdvertisements(
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG(INFO)
|
||||
<< "Report new peripheral for the advertisement header with hash "
|
||||
<< absl::BytesToHexString(
|
||||
new_advertisement_header.GetAdvertisementHash()
|
||||
.AsStringView())
|
||||
<< ", IsFastAdvertisement "
|
||||
<< gatt_advertisement.IsFastAdvertisement();
|
||||
LOG(INFO) << "Found new GATT advertisement : "
|
||||
<< gatt_advertisement.ToReadableString();
|
||||
sii_it->second.discovered_peripheral_callback.peripheral_discovered_cb(
|
||||
std::move(discovered_peripheral), service_id,
|
||||
gatt_advertisement.GetData(),
|
||||
|
||||
@@ -787,13 +787,7 @@ void P2pClusterPcpHandler::BleV2PeripheralDiscoveredHandler(
|
||||
|
||||
ble_endpoint_state.ble = true;
|
||||
found_endpoints_in_ble_discover_cb_[peripheral_id] = ble_endpoint_state;
|
||||
LOG(INFO) << "Found BleAdvertisement "
|
||||
<< absl::BytesToHexString(advertisement_bytes.data())
|
||||
<< " (with endpoint_id=" << advertisement.GetEndpointId()
|
||||
<< ", and endpoint_info="
|
||||
<< absl::BytesToHexString(
|
||||
advertisement.GetEndpointInfo().data())
|
||||
<< ").";
|
||||
LOG(INFO) << "Found " << advertisement.ToReadableString();
|
||||
StopEndpointLostByMediumAlarm(advertisement.GetEndpointId(), BLE);
|
||||
OnEndpointFound(
|
||||
client,
|
||||
@@ -2620,12 +2614,11 @@ ErrorOr<Medium> P2pClusterPcpHandler::StartBleV2Scanning(
|
||||
|
||||
BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::BleV2ConnectImpl(
|
||||
ClientProxy* client, BleV2Endpoint* endpoint) {
|
||||
VLOG(1) << "Client " << client->GetClientId()
|
||||
<< " is attempting to connect to endpoint(id="
|
||||
<< endpoint->endpoint_id << ") over BLE.";
|
||||
|
||||
BleV2Peripheral& peripheral = endpoint->ble_peripheral;
|
||||
|
||||
VLOG(1) << "Client " << client->GetClientId()
|
||||
<< " is attempting to connect to (" << peripheral.ToReadableString()
|
||||
<< ") over BLE.";
|
||||
ErrorOr<BleV2Socket> ble_socket_result = ble_v2_medium_.Connect(
|
||||
endpoint->service_id, peripheral,
|
||||
client->GetCancellationFlag(endpoint->endpoint_id));
|
||||
|
||||
@@ -339,6 +339,7 @@ cc_library(
|
||||
"@com_google_absl//absl/functional:any_invocable",
|
||||
"@com_google_absl//absl/status",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/strings:str_format",
|
||||
"@com_google_absl//absl/types:optional",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -75,9 +75,6 @@ bool BleV2Medium::StartScanning(const Uuid& service_uuid,
|
||||
}
|
||||
|
||||
BleV2Peripheral proxy(*this, peripheral);
|
||||
NEARBY_LOGS(INFO)
|
||||
<< "New peripheral imp=" << &peripheral
|
||||
<< ", callback the proxy peripheral=" << &proxy;
|
||||
if (!scanning_enabled_) return;
|
||||
scan_callback_.advertisement_found_cb(std::move(proxy),
|
||||
advertisement_data);
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "internal/platform/bluetooth_adapter.h"
|
||||
@@ -63,6 +65,14 @@ class BleV2Peripheral final {
|
||||
explicit operator bool() const { return IsValid(); }
|
||||
|
||||
bool GetImpl(ImplCallback callback) const;
|
||||
std::string ToReadableString() const {
|
||||
if (!IsValid()) {
|
||||
return "BleV2Peripheral { invalid }";
|
||||
}
|
||||
return absl::StrFormat("BleV2Peripheral { id=%s, psm=%d}",
|
||||
absl::BytesToHexString(GetId().AsStringView()),
|
||||
GetPsm());
|
||||
}
|
||||
|
||||
private:
|
||||
BleV2Medium* medium_ = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user