mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Internal logging update
PiperOrigin-RevId: 669420403
This commit is contained in:
committed by
Copybara-Service
parent
e65a8a568c
commit
d5b5d92f87
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/log/check.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/cancellation_flag.h"
|
||||
@@ -142,10 +143,11 @@ bool BleMedium::StartAdvertising(
|
||||
const std::string& service_id, const ByteArray& advertisement_bytes,
|
||||
const std::string& fast_advertisement_service_uuid) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StartAdvertising: service_id=" << service_id
|
||||
<< ", advertisement bytes=" << advertisement_bytes.data()
|
||||
<< ", advertisement bytes="
|
||||
<< absl::BytesToHexString(std::string(advertisement_bytes))
|
||||
<< "(" << advertisement_bytes.size() << "),"
|
||||
<< " fast advertisement service uuid="
|
||||
<< fast_advertisement_service_uuid;
|
||||
<< ", fast advertisement service uuid="
|
||||
<< absl::BytesToHexString(fast_advertisement_service_uuid);
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
auto& peripheral = adapter_->GetPeripheral();
|
||||
peripheral.SetAdvertisementBytes(service_id, advertisement_bytes);
|
||||
@@ -261,11 +263,10 @@ bool BleMedium::StopAcceptingConnections(const std::string& service_id) {
|
||||
std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
api::BlePeripheral& remote_peripheral, const std::string& service_id,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
NEARBY_LOG_OBSOLETE(
|
||||
INFO,
|
||||
"G3 Ble Connect [self]: medium=%p, adapter=%p, peripheral=%p, "
|
||||
"service_id=%s",
|
||||
this, &GetAdapter(), &GetAdapter().GetPeripheral(), service_id.c_str());
|
||||
NEARBY_LOGS(INFO) << "G3 Ble Connect [self]: medium=" << this
|
||||
<< ", adapter=" << &GetAdapter()
|
||||
<< ", peripheral=" << &GetAdapter().GetPeripheral()
|
||||
<< ", service_id=" << service_id;
|
||||
// First, find an instance of remote medium, that exposed this peripheral.
|
||||
auto& adapter = static_cast<BlePeripheral&>(remote_peripheral).GetAdapter();
|
||||
auto* medium = static_cast<BleMedium*>(adapter.GetBleMedium());
|
||||
@@ -273,11 +274,10 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
if (!medium) return {}; // Can't find medium. Bail out.
|
||||
|
||||
BleServerSocket* remote_server_socket = nullptr;
|
||||
NEARBY_LOG_OBSOLETE(
|
||||
INFO,
|
||||
"G3 Ble Connect [peer]: medium=%p, adapter=%p, peripheral=%p, "
|
||||
"service_id=%s",
|
||||
medium, &adapter, &remote_peripheral, service_id.c_str());
|
||||
NEARBY_LOGS(INFO) << "G3 Ble Connect [peer]: medium=" << medium
|
||||
<< ", adapter=" << &adapter
|
||||
<< ", peripheral=" << &remote_peripheral
|
||||
<< ", service_id=" << service_id;
|
||||
// Then, find our server socket context in this medium.
|
||||
{
|
||||
absl::MutexLock medium_lock(&medium->mutex_);
|
||||
@@ -312,8 +312,7 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
return {};
|
||||
}
|
||||
|
||||
NEARBY_LOG_OBSOLETE(INFO, "G3 Ble Connect: connected: socket=%p",
|
||||
socket.get());
|
||||
NEARBY_LOGS(INFO) << "G3 Ble Connect: connected: socket=" << socket.get();
|
||||
return socket;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,9 +148,9 @@ bool BleGattClient::DiscoverServiceAndCharacteristics(
|
||||
absl::StrAppend(out, std::string(uuid));
|
||||
});
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Discover service_uuid="
|
||||
<< std::string(service_uuid)
|
||||
<< " with characteristic_uuids=" << flat_characteristics;
|
||||
NEARBY_VLOG(1) << __func__
|
||||
<< ": Discover service_uuid=" << std::string(service_uuid)
|
||||
<< " with characteristic_uuids=" << flat_characteristics;
|
||||
|
||||
try {
|
||||
if (ble_device_ == nullptr) {
|
||||
@@ -208,8 +208,7 @@ bool BleGattClient::DiscoverServiceAndCharacteristics(
|
||||
winrt::guid uuid = service.Uuid();
|
||||
std::string uuid_string = winrt::to_string(winrt::to_hstring(uuid));
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": Found service UUID=" << uuid_string;
|
||||
NEARBY_VLOG(1) << __func__ << ": Found service UUID=" << uuid_string;
|
||||
if (!is_nearby_uuid_equal_to_winrt_guid(service_uuid, uuid)) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
<< __func__
|
||||
@@ -239,8 +238,8 @@ bool BleGattClient::DiscoverServiceAndCharacteristics(
|
||||
gatt_characteristic.Uuid())));
|
||||
});
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Found GATT characteristics="
|
||||
<< flat_characteristics;
|
||||
NEARBY_VLOG(1) << __func__
|
||||
<< ": Found GATT characteristics=" << flat_characteristics;
|
||||
|
||||
bool found_all = true;
|
||||
|
||||
@@ -270,7 +269,7 @@ bool BleGattClient::DiscoverServiceAndCharacteristics(
|
||||
}
|
||||
|
||||
// found all characteristics.
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Found all characteristics.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Found all characteristics.";
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -294,9 +293,9 @@ absl::optional<api::ble_v2::GattCharacteristic>
|
||||
BleGattClient::GetCharacteristic(const Uuid& service_uuid,
|
||||
const Uuid& characteristic_uuid) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Stared to get characteristic UUID="
|
||||
<< std::string(characteristic_uuid)
|
||||
<< " in service UUID=" << std::string(service_uuid);
|
||||
NEARBY_VLOG(1) << __func__ << ": Stared to get characteristic UUID="
|
||||
<< std::string(characteristic_uuid)
|
||||
<< " in service UUID=" << std::string(service_uuid);
|
||||
try {
|
||||
std::optional<GattCharacteristic> gatt_characteristic =
|
||||
GetNativeCharacteristic(service_uuid, characteristic_uuid);
|
||||
@@ -341,8 +340,8 @@ BleGattClient::GetCharacteristic(const Uuid& service_uuid,
|
||||
native_characteristic_map_[result].native_characteristic =
|
||||
gatt_characteristic;
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Return Characteristic. uuid="
|
||||
<< std::string(characteristic_uuid);
|
||||
NEARBY_VLOG(1) << __func__ << ": Return Characteristic. uuid="
|
||||
<< std::string(characteristic_uuid);
|
||||
|
||||
return result;
|
||||
} catch (std::exception exception) {
|
||||
@@ -361,8 +360,8 @@ BleGattClient::GetCharacteristic(const Uuid& service_uuid,
|
||||
absl::optional<std::string> BleGattClient::ReadCharacteristic(
|
||||
const api::ble_v2::GattCharacteristic& characteristic) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Read characteristic="
|
||||
<< std::string(characteristic.uuid);
|
||||
NEARBY_VLOG(1) << __func__ << ": Read characteristic="
|
||||
<< std::string(characteristic.uuid);
|
||||
try {
|
||||
std::optional<GattCharacteristic> gatt_characteristic =
|
||||
GetNativeCharacteristic(characteristic.service_uuid,
|
||||
@@ -397,8 +396,8 @@ absl::optional<std::string> BleGattClient::ReadCharacteristic(
|
||||
data.push_back(static_cast<char>(data_reader.ReadByte()));
|
||||
}
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": Got characteristic value length=" << data.size();
|
||||
NEARBY_VLOG(1) << __func__
|
||||
<< ": Got characteristic value length=" << data.size();
|
||||
|
||||
return data;
|
||||
} catch (std::exception exception) {
|
||||
@@ -418,8 +417,8 @@ bool BleGattClient::WriteCharacteristic(
|
||||
const api::ble_v2::GattCharacteristic& characteristic,
|
||||
absl::string_view value, api::ble_v2::GattClient::WriteType write_type) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": write characteristic: "
|
||||
<< std::string(characteristic.uuid);
|
||||
NEARBY_VLOG(1) << __func__ << ": write characteristic: "
|
||||
<< std::string(characteristic.uuid);
|
||||
try {
|
||||
std::optional<GattCharacteristic> gatt_characteristic =
|
||||
native_characteristic_map_[characteristic].native_characteristic;
|
||||
@@ -449,10 +448,9 @@ bool BleGattClient::WriteCharacteristic(
|
||||
<< GattCommunicationStatusToString(status);
|
||||
return false;
|
||||
} else {
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": Write data to GATT characteristic: "
|
||||
<< std::string(characteristic.uuid)
|
||||
<< ", bytes count: " << value.size();
|
||||
NEARBY_VLOG(1) << __func__ << ": Write data to GATT characteristic: "
|
||||
<< std::string(characteristic.uuid)
|
||||
<< ", bytes count: " << value.size();
|
||||
return true;
|
||||
}
|
||||
} catch (std::exception exception) {
|
||||
@@ -473,8 +471,7 @@ bool BleGattClient::SetCharacteristicSubscription(
|
||||
absl::AnyInvocable<void(absl::string_view value)>
|
||||
on_characteristic_changed_cb) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": Started to set Characteristic Subscription.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Started to set Characteristic Subscription.";
|
||||
GattClientCharacteristicConfigurationDescriptorValue gcccd_value =
|
||||
GattClientCharacteristicConfigurationDescriptorValue::None;
|
||||
if ((characteristic.property & Property::kNotify) != Property::kNone) {
|
||||
@@ -552,7 +549,7 @@ bool BleGattClient::SetCharacteristicSubscription(
|
||||
void BleGattClient::Disconnect() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
try {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Disconnect is called.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Disconnect is called.";
|
||||
if (ble_device_ != nullptr) {
|
||||
ble_device_.Close();
|
||||
ble_device_ = nullptr;
|
||||
@@ -571,10 +568,9 @@ void BleGattClient::Disconnect() {
|
||||
|
||||
std::optional<GattCharacteristic> BleGattClient::GetNativeCharacteristic(
|
||||
const Uuid& service_uuid, const Uuid& characteristic_uuid) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": Stared to get native characteristic UUID="
|
||||
<< std::string(characteristic_uuid)
|
||||
<< " in service UUID=" << std::string(service_uuid);
|
||||
NEARBY_VLOG(1) << __func__ << ": Stared to get native characteristic UUID="
|
||||
<< std::string(characteristic_uuid)
|
||||
<< " in service UUID=" << std::string(service_uuid);
|
||||
|
||||
try {
|
||||
if (ble_device_ == nullptr) {
|
||||
@@ -604,9 +600,9 @@ std::optional<GattCharacteristic> BleGattClient::GetNativeCharacteristic(
|
||||
gatt_characteristics_result.Characteristics()) {
|
||||
if (is_nearby_uuid_equal_to_winrt_guid(characteristic_uuid,
|
||||
characteristic.Uuid())) {
|
||||
NEARBY_LOGS(VERBOSE)
|
||||
<< __func__ << ": Return native Characteristic. uuid="
|
||||
<< std::string(characteristic_uuid);
|
||||
NEARBY_VLOG(1) << __func__
|
||||
<< ": Return native Characteristic. uuid="
|
||||
<< std::string(characteristic_uuid);
|
||||
|
||||
return characteristic;
|
||||
}
|
||||
@@ -632,9 +628,8 @@ std::optional<GattCharacteristic> BleGattClient::GetNativeCharacteristic(
|
||||
bool BleGattClient::WriteCharacteristicConfigurationDescriptor(
|
||||
GattCharacteristic& characteristic,
|
||||
GattClientCharacteristicConfigurationDescriptorValue value) {
|
||||
NEARBY_LOGS(VERBOSE)
|
||||
<< __func__
|
||||
<< ": Stared to write characteristic configuration descriptor";
|
||||
NEARBY_VLOG(1) << __func__
|
||||
<< ": Stared to write characteristic configuration descriptor";
|
||||
|
||||
try {
|
||||
GattCommunicationStatus status =
|
||||
@@ -642,9 +637,9 @@ bool BleGattClient::WriteCharacteristicConfigurationDescriptor(
|
||||
.WriteClientCharacteristicConfigurationDescriptorAsync(value)
|
||||
.get();
|
||||
if (status == GattCommunicationStatus::Success) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": Successfully write client characteristic "
|
||||
"configuration descriptor";
|
||||
NEARBY_VLOG(1) << __func__
|
||||
<< ": Successfully write client characteristic "
|
||||
"configuration descriptor";
|
||||
return true;
|
||||
}
|
||||
NEARBY_LOGS(ERROR) << __func__
|
||||
@@ -670,7 +665,7 @@ bool BleGattClient::WriteCharacteristicConfigurationDescriptor(
|
||||
void BleGattClient::OnCharacteristicValueChanged(
|
||||
const api::ble_v2::GattCharacteristic& characteristic,
|
||||
GattValueChangedEventArgs args) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Gatt Characteristic value changed.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Gatt Characteristic value changed.";
|
||||
IBuffer buffer = args.CharacteristicValue();
|
||||
int size = buffer.Length();
|
||||
DataReader data_reader = DataReader::FromBuffer(buffer);
|
||||
@@ -679,8 +674,8 @@ void BleGattClient::OnCharacteristicValueChanged(
|
||||
for (int i = 0; i < size; ++i) {
|
||||
data.push_back(static_cast<char>(data_reader.ReadByte()));
|
||||
}
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": Got characteristic value length= " << data.size();
|
||||
NEARBY_VLOG(1) << __func__
|
||||
<< ": Got characteristic value length= " << data.size();
|
||||
|
||||
absl::AnyInvocable<void(absl::string_view value)>
|
||||
on_characteristic_changed_cb;
|
||||
|
||||
@@ -167,8 +167,7 @@ bool BleGattServer::UpdateCharacteristic(
|
||||
|
||||
for (auto& it : gatt_characteristic_datas_) {
|
||||
if (it.gatt_characteristic.uuid == characteristic.uuid) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": Found the characteristic to update.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Found the characteristic to update.";
|
||||
it.data = value;
|
||||
|
||||
// If it is in running, notify the value changed.
|
||||
@@ -201,8 +200,8 @@ absl::Status BleGattServer::NotifyCharacteristicChanged(
|
||||
const ByteArray& new_value) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
// Currently, the method is not hooked up at platform layer.
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Notify characteristic="
|
||||
<< std::string(characteristic.uuid) << " changed.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Notify characteristic="
|
||||
<< std::string(characteristic.uuid) << " changed.";
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
@@ -210,7 +209,7 @@ void BleGattServer::Stop() {
|
||||
absl::AnyInvocable<void()> close_notifier = nullptr;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Start to stop GATT server.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Start to stop GATT server.";
|
||||
if (gatt_service_provider_ != nullptr) {
|
||||
try {
|
||||
if (is_advertising_) {
|
||||
@@ -242,8 +241,8 @@ void BleGattServer::Stop() {
|
||||
bool BleGattServer::InitializeGattServer() {
|
||||
try {
|
||||
// Create and advertise GATT service.
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Create GATT service service_uuid="
|
||||
<< std::string(service_uuid_);
|
||||
NEARBY_VLOG(1) << __func__ << ": Create GATT service service_uuid="
|
||||
<< std::string(service_uuid_);
|
||||
|
||||
if (adapter_ == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Bluetooth adapter is absent.";
|
||||
@@ -320,12 +319,10 @@ bool BleGattServer::InitializeGattServer() {
|
||||
is_notify_supported = true;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": GATT characteristic properties: read="
|
||||
<< is_read_supported
|
||||
<< ",write=" << is_write_supported
|
||||
<< ",indicate=" << is_indicate_supported
|
||||
<< ",notify=" << is_notify_supported;
|
||||
NEARBY_VLOG(1) << __func__ << ": GATT characteristic properties: read="
|
||||
<< is_read_supported << ",write=" << is_write_supported
|
||||
<< ",indicate=" << is_indicate_supported
|
||||
<< ",notify=" << is_notify_supported;
|
||||
|
||||
gatt_characteristic_parameters.CharacteristicProperties(properties);
|
||||
gatt_characteristic_parameters.WriteProtectionLevel(
|
||||
@@ -334,10 +331,10 @@ bool BleGattServer::InitializeGattServer() {
|
||||
winrt::guid characteristic_uuid = nearby_uuid_to_winrt_guid(
|
||||
characteristic_data.gatt_characteristic.uuid);
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": Create characteristic characteristic_uuid="
|
||||
<< winrt::to_string(
|
||||
winrt::to_hstring(characteristic_uuid));
|
||||
NEARBY_VLOG(1) << __func__
|
||||
<< ": Create characteristic characteristic_uuid="
|
||||
<< winrt::to_string(
|
||||
winrt::to_hstring(characteristic_uuid));
|
||||
|
||||
GattLocalCharacteristicResult result =
|
||||
gatt_service_provider_.Service()
|
||||
@@ -356,9 +353,9 @@ bool BleGattServer::InitializeGattServer() {
|
||||
|
||||
::winrt::guid local_characteristic_guid =
|
||||
characteristic_data.local_characteristic.Uuid();
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Local GATT characteristic. uuid: "
|
||||
<< winrt::to_string(
|
||||
winrt::to_hstring(local_characteristic_guid));
|
||||
NEARBY_VLOG(1) << __func__ << ": Local GATT characteristic. uuid: "
|
||||
<< winrt::to_string(
|
||||
winrt::to_hstring(local_characteristic_guid));
|
||||
|
||||
// Setup gatt local characteristic events.
|
||||
if (is_read_supported) {
|
||||
@@ -408,9 +405,9 @@ bool BleGattServer::StartAdvertisement(const ByteArray& service_data,
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
try {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": service_data="
|
||||
<< absl::BytesToHexString(service_data.AsStringView())
|
||||
<< ", is_connectable=" << is_connectable;
|
||||
NEARBY_VLOG(1) << __func__ << ": service_data="
|
||||
<< absl::BytesToHexString(service_data.AsStringView())
|
||||
<< ", is_connectable=" << is_connectable;
|
||||
|
||||
if (is_advertising_) {
|
||||
NEARBY_LOGS(ERROR) << ": GATT server is already in advertising.";
|
||||
@@ -567,7 +564,7 @@ void BleGattServer::SetCloseNotifier(absl::AnyInvocable<void()> notifier) {
|
||||
request.RespondWithValue(buffer);
|
||||
deferral.Complete();
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Sent data to remote device.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Sent data to remote device.";
|
||||
return {};
|
||||
} catch (std::exception exception) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Exception: " << exception.what();
|
||||
|
||||
@@ -600,11 +600,11 @@ void BleMedium::AdvertisementReceivedHandler(
|
||||
|
||||
ByteArray advertisement_data(data);
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << "Nearby BLE Medium Advertisement discovered. "
|
||||
"0x16 Service data: advertisement bytes= 0x"
|
||||
<< absl::BytesToHexString(
|
||||
advertisement_data.AsStringView())
|
||||
<< "(" << advertisement_data.size() << ")";
|
||||
NEARBY_VLOG(1) << "Nearby BLE Medium Advertisement discovered. "
|
||||
"0x16 Service data: advertisement bytes= 0x"
|
||||
<< absl::BytesToHexString(
|
||||
advertisement_data.AsStringView())
|
||||
<< "(" << advertisement_data.size() << ")";
|
||||
|
||||
std::string peripheral_name =
|
||||
uint64_to_mac_address_string(args.BluetoothAddress());
|
||||
|
||||
@@ -1085,13 +1085,12 @@ void BleV2Medium::AdvertisementReceivedHandler(
|
||||
|
||||
ByteArray advertisement_data(data);
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << "Nearby BLE Medium "
|
||||
<< service_uuid_.Get16BitAsString()
|
||||
<< " Advertisement discovered. "
|
||||
"0x16 Service data: advertisement bytes= 0x"
|
||||
<< absl::BytesToHexString(
|
||||
advertisement_data.AsStringView())
|
||||
<< "(" << advertisement_data.size() << ")";
|
||||
NEARBY_VLOG(1) << "Nearby BLE Medium " << service_uuid_.Get16BitAsString()
|
||||
<< " Advertisement discovered. "
|
||||
"0x16 Service data: advertisement bytes= 0x"
|
||||
<< absl::BytesToHexString(
|
||||
advertisement_data.AsStringView())
|
||||
<< "(" << advertisement_data.size() << ")";
|
||||
|
||||
std::string bluetooth_address =
|
||||
uint64_to_mac_address_string(args.BluetoothAddress());
|
||||
|
||||
@@ -40,26 +40,26 @@ api::ble_v2::BlePeripheral* BleV2Socket::GetRemotePeripheral() {
|
||||
|
||||
bool BleV2Socket::Connect(api::ble_v2::BlePeripheral* ble_peripheral) {
|
||||
// TODO(b/271031645): implement BLE socket using weave
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Connect to BLE peripheral="
|
||||
<< ble_peripheral->GetAddress();
|
||||
NEARBY_VLOG(1) << __func__ << ": Connect to BLE peripheral="
|
||||
<< ble_peripheral->GetAddress();
|
||||
return false;
|
||||
}
|
||||
|
||||
ExceptionOr<ByteArray> BleV2Socket::BleInputStream::Read(std::int64_t size) {
|
||||
// TODO(b/271031645): implement BLE socket using weave
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Read data size=" << size;
|
||||
NEARBY_VLOG(1) << __func__ << ": Read data size=" << size;
|
||||
return ExceptionOr<ByteArray>(Exception::kIo);
|
||||
}
|
||||
|
||||
Exception BleV2Socket::BleInputStream::Close() {
|
||||
// TODO(b/271031645): implement BLE socket using weave
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Close BLE input stream.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Close BLE input stream.";
|
||||
return {Exception::kSuccess};
|
||||
}
|
||||
|
||||
Exception BleV2Socket::BleOutputStream::Write(const ByteArray& data) {
|
||||
// TODO(b/271031645): implement BLE socket using weave
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Write data size=" << data.size();
|
||||
NEARBY_VLOG(1) << __func__ << ": Write data size=" << data.size();
|
||||
return {Exception::kIo};
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "third_party/json/src/json.hpp"
|
||||
#include "internal/platform/feature_flags.h"
|
||||
#include "internal/platform/implementation/platform.h"
|
||||
#include "internal/platform/implementation/windows/generated/winrt/Windows.Foundation.h"
|
||||
#include "internal/platform/implementation/windows/utils.h"
|
||||
#include "internal/platform/logging.h"
|
||||
@@ -347,8 +348,8 @@ void BluetoothAdapter::RestoreRadioNameIfNecessary() {
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": loaded settings: " << local_settings.dump();
|
||||
NEARBY_VLOG(1) << __func__
|
||||
<< ": loaded settings: " << local_settings.dump();
|
||||
|
||||
LocalSettings settings = local_settings.get<LocalSettings>();
|
||||
|
||||
@@ -391,8 +392,8 @@ void BluetoothAdapter::StoreRadioNames(absl::string_view original_radio_name,
|
||||
|
||||
json encoded_local_settings;
|
||||
to_json(encoded_local_settings, local_settings);
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": saved settings: "
|
||||
<< encoded_local_settings.dump();
|
||||
NEARBY_VLOG(1) << __func__
|
||||
<< ": saved settings: " << encoded_local_settings.dump();
|
||||
|
||||
ByteArray data(encoded_local_settings.dump());
|
||||
|
||||
|
||||
@@ -345,8 +345,8 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
|
||||
std::unique_ptr<api::BluetoothPairing> BluetoothClassicMedium::CreatePairing(
|
||||
api::BluetoothDevice& remote_device) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Start to createPairing with device: "
|
||||
<< remote_device.GetMacAddress();
|
||||
NEARBY_VLOG(1) << __func__ << ": Start to createPairing with device: "
|
||||
<< remote_device.GetMacAddress();
|
||||
try {
|
||||
winrt::Windows::Devices::Bluetooth::BluetoothDevice bluetooth_device =
|
||||
winrt::Windows::Devices::Bluetooth::BluetoothDevice::
|
||||
@@ -360,8 +360,8 @@ std::unique_ptr<api::BluetoothPairing> BluetoothClassicMedium::CreatePairing(
|
||||
return std::make_unique<BluetoothPairing>(bluetooth_device,
|
||||
custom_pairing);
|
||||
}
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": Failed to get DeviceInformationCustomPairing.";
|
||||
NEARBY_VLOG(1) << __func__
|
||||
<< ": Failed to get DeviceInformationCustomPairing.";
|
||||
} catch (std::exception exception) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << " : Failed to create pairing. exception: "
|
||||
<< exception.what();
|
||||
|
||||
@@ -54,8 +54,7 @@ BluetoothPairing::BluetoothPairing(
|
||||
BluetoothDevice bluetooth_device,
|
||||
DeviceInformationCustomPairing custom_pairing)
|
||||
: bluetooth_device_(bluetooth_device), custom_pairing_(custom_pairing) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": BluetoothPairing is created for device.";
|
||||
NEARBY_VLOG(1) << __func__ << ": BluetoothPairing is created for device.";
|
||||
}
|
||||
|
||||
BluetoothPairing::~BluetoothPairing() {
|
||||
@@ -64,19 +63,17 @@ BluetoothPairing::~BluetoothPairing() {
|
||||
std::exchange(pairing_requested_token_, {}));
|
||||
}
|
||||
CancelPairing();
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": BluetoothPairing is destroyed for device.";
|
||||
NEARBY_VLOG(1) << __func__ << ": BluetoothPairing is destroyed for device.";
|
||||
}
|
||||
|
||||
bool BluetoothPairing::InitiatePairing(
|
||||
api::BluetoothPairingCallback pairing_cb) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Start to initiate pairing process.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Start to initiate pairing process.";
|
||||
try {
|
||||
pairing_requested_token_ = custom_pairing_.PairingRequested(
|
||||
{this, &BluetoothPairing::OnPairingRequested});
|
||||
if (!pairing_requested_token_) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< " Failed to registered pairing callback.";
|
||||
NEARBY_VLOG(1) << __func__ << " Failed to registered pairing callback.";
|
||||
return false;
|
||||
}
|
||||
pairing_callback_ = std::move(pairing_cb);
|
||||
@@ -107,14 +104,14 @@ bool BluetoothPairing::InitiatePairing(
|
||||
|
||||
bool BluetoothPairing::FinishPairing(
|
||||
std::optional<absl::string_view> pin_code) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << "Start to finish pairing.";
|
||||
NEARBY_VLOG(1) << __func__ << "Start to finish pairing.";
|
||||
try {
|
||||
if (!pairing_requested_) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << "No pairing requested.";
|
||||
NEARBY_VLOG(1) << __func__ << "No pairing requested.";
|
||||
return false;
|
||||
}
|
||||
if (!pairing_deferral_) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << "No ongoing pairing process.";
|
||||
NEARBY_VLOG(1) << __func__ << "No ongoing pairing process.";
|
||||
return false;
|
||||
}
|
||||
if (expecting_pin_code_) {
|
||||
@@ -129,7 +126,7 @@ bool BluetoothPairing::FinishPairing(
|
||||
pairing_requested_.Accept();
|
||||
}
|
||||
pairing_deferral_.Complete();
|
||||
NEARBY_LOGS(VERBOSE) << "Successfully finished pairing.";
|
||||
NEARBY_VLOG(1) << "Successfully finished pairing.";
|
||||
return true;
|
||||
} catch (std::exception exception) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Failed to finish pairing. exception: "
|
||||
@@ -146,11 +143,10 @@ bool BluetoothPairing::FinishPairing(
|
||||
}
|
||||
|
||||
bool BluetoothPairing::CancelPairing() {
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< " Start to cancel ongoing pairing process.";
|
||||
NEARBY_VLOG(1) << __func__ << " Start to cancel ongoing pairing process.";
|
||||
try {
|
||||
if (!pairing_deferral_) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << "No ongoing pairing process.";
|
||||
NEARBY_VLOG(1) << __func__ << "No ongoing pairing process.";
|
||||
return true;
|
||||
}
|
||||
// There is no way to explicitly cancel an in-progress pairing on Windows as
|
||||
@@ -161,7 +157,7 @@ bool BluetoothPairing::CancelPairing() {
|
||||
// deferral is completed, will know that cancellation was the actual result.
|
||||
was_cancelled_ = true;
|
||||
pairing_deferral_.Close();
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << "Canceled ongoing pairing process.";
|
||||
NEARBY_VLOG(1) << __func__ << "Canceled ongoing pairing process.";
|
||||
return true;
|
||||
} catch (std::exception exception) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Failed to cancel ongoing pairing "
|
||||
@@ -178,20 +174,19 @@ bool BluetoothPairing::CancelPairing() {
|
||||
}
|
||||
|
||||
bool BluetoothPairing::Unpair() {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Start to unpair with remote device.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Start to unpair with remote device.";
|
||||
try {
|
||||
if (!IsPaired()) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << " : Remote device Was not paired.";
|
||||
NEARBY_VLOG(1) << __func__ << " : Remote device Was not paired.";
|
||||
return true;
|
||||
}
|
||||
DeviceUnpairingResult unpairing_result =
|
||||
bluetooth_device_.DeviceInformation().Pairing().UnpairAsync().get();
|
||||
if (unpairing_result.Status() == DeviceUnpairingResultStatus::Unpaired) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Unpaired with remote device.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Unpaired with remote device.";
|
||||
return true;
|
||||
}
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": Failed to unpaired with remote device.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Failed to unpaired with remote device.";
|
||||
} catch (std::exception exception) {
|
||||
NEARBY_LOGS(ERROR) << __func__
|
||||
<< ": Failed to unpaired with device. exception: "
|
||||
@@ -229,7 +224,7 @@ bool BluetoothPairing::IsPaired() {
|
||||
void BluetoothPairing::OnPairingRequested(
|
||||
DeviceInformationCustomPairing custom_pairing,
|
||||
DevicePairingRequestedEventArgs pairing_requested) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << "Requested to pair.";
|
||||
NEARBY_VLOG(1) << __func__ << "Requested to pair.";
|
||||
try {
|
||||
DevicePairingKinds pairing_kind = pairing_requested.PairingKind();
|
||||
pairing_requested_ = pairing_requested;
|
||||
|
||||
@@ -32,8 +32,8 @@ Executor::Executor(int32_t max_concurrency)
|
||||
|
||||
void Executor::Execute(Runnable&& runnable) {
|
||||
if (shut_down_) {
|
||||
NEARBY_LOGS(VERBOSE) << "Warning: " << __func__
|
||||
<< ": Attempt to execute on a shut down pool.";
|
||||
NEARBY_VLOG(1) << "Warning: " << __func__
|
||||
<< ": Attempt to execute on a shut down pool.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
namespace nearby {
|
||||
namespace windows {
|
||||
|
||||
api::LogMessage::Severity min_log_severity_ = api::LogMessage::Severity::kInfo;
|
||||
api::LogMessage::Severity g_min_log_severity = api::LogMessage::Severity::kInfo;
|
||||
|
||||
inline absl::LogSeverity ConvertSeverity(api::LogMessage::Severity severity) {
|
||||
switch (severity) {
|
||||
@@ -65,11 +65,11 @@ std::ostream& LogMessage::Stream() { return log_streamer_.stream(); }
|
||||
namespace api {
|
||||
|
||||
void LogMessage::SetMinLogSeverity(Severity severity) {
|
||||
windows::min_log_severity_ = severity;
|
||||
windows::g_min_log_severity = severity;
|
||||
}
|
||||
|
||||
bool LogMessage::ShouldCreateLogMessage(Severity severity) {
|
||||
return severity >= windows::min_log_severity_;
|
||||
return severity >= windows::g_min_log_severity;
|
||||
}
|
||||
} // namespace api
|
||||
} // namespace nearby
|
||||
|
||||
@@ -36,7 +36,6 @@ class LogMessage : public api::LogMessage {
|
||||
|
||||
private:
|
||||
google::LogMessage log_streamer_;
|
||||
static api::LogMessage::Severity min_log_severity_;
|
||||
};
|
||||
|
||||
} // namespace windows
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "nlohmann/json_fwd.hpp"
|
||||
#include "internal/base/files.h"
|
||||
#include "internal/platform/implementation/platform.h"
|
||||
#include "internal/platform/implementation/windows/preferences_repository.h"
|
||||
#include "internal/platform/logging.h"
|
||||
|
||||
|
||||
@@ -83,13 +83,12 @@ ThreadPool::ThreadPool(PTP_POOL thread_pool,
|
||||
: thread_pool_(thread_pool),
|
||||
thread_pool_environ_(thread_pool_environ),
|
||||
max_pool_size_(max_pool_size) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Thread pool(" << this
|
||||
<< ") is created with size:" << max_pool_size_;
|
||||
NEARBY_VLOG(1) << __func__ << ": Thread pool(" << this
|
||||
<< ") is created with size:" << max_pool_size_;
|
||||
}
|
||||
|
||||
ThreadPool::~ThreadPool() {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Thread pool(" << this
|
||||
<< ") is released.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Thread pool(" << this << ") is released.";
|
||||
|
||||
if (thread_pool_ == nullptr) {
|
||||
return;
|
||||
@@ -112,8 +111,8 @@ bool ThreadPool::Run(Runnable task) {
|
||||
|
||||
PTP_WORK work;
|
||||
tasks_.push(std::move(task));
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Scheduled to run task("
|
||||
<< &tasks_.back() << ").";
|
||||
NEARBY_VLOG(1) << __func__ << ": Scheduled to run task(" << &tasks_.back()
|
||||
<< ").";
|
||||
|
||||
work = CreateThreadpoolWork(WorkCallback, this, &thread_pool_environ_);
|
||||
if (work == nullptr) {
|
||||
@@ -146,19 +145,19 @@ void ThreadPool::ShutDown() {
|
||||
if (running_tasks_count_ == 0) {
|
||||
CloseThreadpool(thread_pool_);
|
||||
thread_pool_ = nullptr;
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Thread pool(" << this
|
||||
<< ") is shut down.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Thread pool(" << this
|
||||
<< ") is shut down.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (shutdown_latch_ != nullptr) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Thread pool(" << this
|
||||
<< ") is already in shutting down.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Thread pool(" << this
|
||||
<< ") is already in shutting down.";
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Thread pool(" << this
|
||||
<< ") is shutting down.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Thread pool(" << this
|
||||
<< ") is shutting down.";
|
||||
|
||||
shutdown_latch_ = std::make_unique<CountDownLatch>(1);
|
||||
}
|
||||
@@ -170,8 +169,7 @@ void ThreadPool::ShutDown() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
CloseThreadpool(thread_pool_);
|
||||
thread_pool_ = nullptr;
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Thread pool(" << this
|
||||
<< ") is shut down.";
|
||||
NEARBY_VLOG(1) << __func__ << ": Thread pool(" << this << ") is shut down.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,8 +183,7 @@ void ThreadPool::RunNextTask() {
|
||||
return;
|
||||
}
|
||||
if (!tasks_.empty()) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__ << ": Run task(" << &tasks_.front()
|
||||
<< ").";
|
||||
NEARBY_VLOG(1) << __func__ << ": Run task(" << &tasks_.front() << ").";
|
||||
|
||||
task = std::move(tasks_.front());
|
||||
tasks_.pop();
|
||||
|
||||
@@ -15,18 +15,20 @@
|
||||
#include "internal/platform/implementation/windows/utils.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
// Standard C/C++ headers
|
||||
#include <codecvt>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <locale>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Third party headers
|
||||
#include "absl/strings/ascii.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
|
||||
// Nearby connections headers
|
||||
@@ -182,8 +184,8 @@ Uuid winrt_guid_to_nearby_uuid(const ::winrt::guid& guid) {
|
||||
int64_t data3 = guid.Data3;
|
||||
|
||||
int64_t msb = ((data1 >> 24) & 0xff) << 56 | ((data1 >> 16) & 0xff) << 48 |
|
||||
((data1 >> 8) & 0xff) << 40 | ((data1)&0xff) << 32 |
|
||||
((data2 >> 8) & 0xff) << 24 | ((data2)&0xff) << 16 |
|
||||
((data1 >> 8) & 0xff) << 40 | ((data1) & 0xff) << 32 |
|
||||
((data2 >> 8) & 0xff) << 24 | ((data2) & 0xff) << 16 |
|
||||
((data3 >> 8) & 0xff) << 8 | (data3 & 0xff);
|
||||
|
||||
int64_t lsb =
|
||||
@@ -215,7 +217,7 @@ winrt::guid nearby_uuid_to_winrt_guid(Uuid uuid) {
|
||||
}
|
||||
|
||||
bool is_nearby_uuid_equal_to_winrt_guid(const Uuid& uuid,
|
||||
const ::winrt::guid& guid) {
|
||||
const ::winrt::guid& guid) {
|
||||
return uuid == winrt_guid_to_nearby_uuid(guid);
|
||||
}
|
||||
|
||||
@@ -242,7 +244,7 @@ bool InspectableReader::ReadBoolean(IInspectable inspectable) {
|
||||
return property_value.GetBoolean();
|
||||
}
|
||||
|
||||
uint16 InspectableReader::ReadUint16(IInspectable inspectable) {
|
||||
uint16_t InspectableReader::ReadUint16(IInspectable inspectable) {
|
||||
if (inspectable == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
@@ -260,7 +262,7 @@ uint16 InspectableReader::ReadUint16(IInspectable inspectable) {
|
||||
return property_value.GetUInt16();
|
||||
}
|
||||
|
||||
uint32 InspectableReader::ReadUint32(IInspectable inspectable) {
|
||||
uint32_t InspectableReader::ReadUint32(IInspectable inspectable) {
|
||||
if (inspectable == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
@@ -316,7 +318,7 @@ std::vector<std::string> InspectableReader::ReadStringArray(
|
||||
winrt::com_array<winrt::hstring> strings;
|
||||
property_value.GetStringArray(strings);
|
||||
|
||||
for (winrt::hstring str : strings) {
|
||||
for (const winrt::hstring& str : strings) {
|
||||
result.push_back(winrt::to_string(str));
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -60,8 +60,7 @@ const std::string WebRtcMedium::GetDefaultCountryCode() {
|
||||
}
|
||||
std::wstring wideGeo(systemGeoName);
|
||||
std::string systemGeoNameString(wideGeo.begin(), wideGeo.end());
|
||||
NEARBY_LOGS(VERBOSE) << "GetUserDefaultGeoName() returns: "
|
||||
<< systemGeoNameString;
|
||||
NEARBY_VLOG(1) << "GetUserDefaultGeoName() returns: " << systemGeoNameString;
|
||||
return systemGeoNameString;
|
||||
}
|
||||
|
||||
|
||||
@@ -281,7 +281,6 @@ void WifiHotspotServerSocket::SocketErrorNotice(absl::string_view reason) {
|
||||
|
||||
bool WifiHotspotServerSocket::SetupServerSocketWinSock() {
|
||||
WSADATA wsa_data;
|
||||
WSAEVENT socket_event;
|
||||
int flag = 1;
|
||||
|
||||
int result = WSAStartup(MAKEWORD(2, 2), &wsa_data);
|
||||
@@ -347,7 +346,7 @@ bool WifiHotspotServerSocket::SetupServerSocketWinSock() {
|
||||
return false;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Hotspot Server Socket " << listen_socket_
|
||||
<< " started to listen with socket event: " << socket_event;
|
||||
<< " started to listen.";
|
||||
|
||||
submittable_executor_.Execute([this]() {
|
||||
DWORD index;
|
||||
|
||||
@@ -116,11 +116,11 @@ DEVINST SearchForDeviceInstance(wchar_t* pEntireDeviceList);
|
||||
void CloseRegKeyHandle(HKEY softwareKey); // NOLINT
|
||||
void OpenRegKeyHandle(DEVINST devInst, HKEY& softwareKey);
|
||||
DWORD GetRegKeyWCHARValue(DEVINST deviceInstance, LPCWSTR keyName, // NOLINT
|
||||
wchar_t* valOut, PDWORD pValLen, // NOLINT
|
||||
PDWORD pDataType); // NOLINT
|
||||
wchar_t* valOut, PDWORD pValLen, // NOLINT
|
||||
PDWORD pDataType); // NOLINT
|
||||
DWORD GetFullDllLoadPathFromPieRegistry(DEVINST pieDeviceInstance,
|
||||
PWCHAR* ppDllPathValue); // NOLINT
|
||||
HADAPTER WifiGetAdapterList(HINSTANCE murocApiDllHandle, // NOLINT
|
||||
HADAPTER WifiGetAdapterList(HINSTANCE murocApiDllHandle, // NOLINT
|
||||
PINTEL_ADAPTER_LIST_V120* ppAllAdapters);
|
||||
void RegisterIntelCallback(HINSTANCE murocApiDllHandle,
|
||||
MurocDefs::PINTEL_CALLBACK pIntelEventCbHandle);
|
||||
@@ -185,7 +185,7 @@ int WifiIntel::GetGOChannel() {
|
||||
nullptr;
|
||||
int channel = -1;
|
||||
|
||||
DWORD dwError = ERROR_SUCCESS; // NOLINT
|
||||
DWORD dwError = ERROR_SUCCESS; // NOLINT
|
||||
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE; // NOLINT
|
||||
INTEL_WIFI_HEADER intelWifiHeader;
|
||||
MurocDefs::INTEL_GO_OPERATION_CHANNEL_SETTING intelGOChan;
|
||||
@@ -194,8 +194,7 @@ int WifiIntel::GetGOChannel() {
|
||||
|
||||
WifiPanQueryPreferredChannelSettingFunc =
|
||||
(WIFIPANQUERYPREFERREDCHANNELSETTING)GetProcAddress( // NOLINT
|
||||
muroc_api_dll_handle_,
|
||||
"WifiPanQueryPreferredChannelSetting");
|
||||
muroc_api_dll_handle_, "WifiPanQueryPreferredChannelSetting");
|
||||
|
||||
if (WifiPanQueryPreferredChannelSettingFunc == nullptr) {
|
||||
dwError = GetLastError(); // NOLINT
|
||||
@@ -204,7 +203,7 @@ int WifiIntel::GetGOChannel() {
|
||||
<< dwError;
|
||||
return channel;
|
||||
}
|
||||
NEARBY_LOGS(VERBOSE)
|
||||
NEARBY_VLOG(1)
|
||||
<< "Load WifiPanQueryPreferredChannelSetting API completed successfully";
|
||||
|
||||
intelWifiHeader.dwSize =
|
||||
@@ -236,9 +235,8 @@ int WifiIntel::GetGOChannel() {
|
||||
|
||||
bool WifiIntel::SetScanFilter(int channel) {
|
||||
#ifndef NO_INTEL_PIE
|
||||
WIFILEGACYGOSETSCANFILTER WifiLegacyGoSetScanFilterFunc =
|
||||
nullptr;
|
||||
DWORD dwError = ERROR_SUCCESS; // NOLINT
|
||||
WIFILEGACYGOSETSCANFILTER WifiLegacyGoSetScanFilterFunc = nullptr;
|
||||
DWORD dwError = ERROR_SUCCESS; // NOLINT
|
||||
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE; // NOLINT
|
||||
INTEL_WIFI_HEADER intelWifiHeader;
|
||||
MurocDefs::WIFI_LEGACY_GO_SCAN_FILTER scanFilter;
|
||||
@@ -249,21 +247,18 @@ bool WifiIntel::SetScanFilter(int channel) {
|
||||
NEARBY_LOGS(INFO) << "Set scan channel:" << channel;
|
||||
WifiLegacyGoSetScanFilterFunc =
|
||||
(WIFILEGACYGOSETSCANFILTER)GetProcAddress( // NOLINT
|
||||
muroc_api_dll_handle_,
|
||||
"WifiLegacyGoSetScanFilter");
|
||||
muroc_api_dll_handle_, "WifiLegacyGoSetScanFilter");
|
||||
|
||||
if (WifiLegacyGoSetScanFilterFunc == nullptr) {
|
||||
dwError = GetLastError(); // NOLINT
|
||||
NEARBY_LOGS(INFO)
|
||||
<< "GetProcAddress WifiLegacyGoSetScanFilterFunc error: "
|
||||
<< dwError;
|
||||
NEARBY_LOGS(INFO) << "GetProcAddress WifiLegacyGoSetScanFilterFunc error: "
|
||||
<< dwError;
|
||||
return false;
|
||||
}
|
||||
NEARBY_LOGS(VERBOSE)
|
||||
NEARBY_VLOG(1)
|
||||
<< "Load WifiLegacyGoSetScanFilterFunc API completed successfully";
|
||||
|
||||
intelWifiHeader.dwSize =
|
||||
sizeof(MurocDefs::WIFI_LEGACY_GO_SCAN_FILTER);
|
||||
intelWifiHeader.dwSize = sizeof(MurocDefs::WIFI_LEGACY_GO_SCAN_FILTER);
|
||||
memset(&scanFilter, 0, sizeof(scanFilter));
|
||||
scanFilter.channel = (UINT8)channel;
|
||||
murocApiRetVal = WifiLegacyGoSetScanFilterFunc(
|
||||
@@ -288,9 +283,8 @@ bool WifiIntel::SetScanFilter(int channel) {
|
||||
|
||||
bool WifiIntel::ResetScanFilter() {
|
||||
#ifndef NO_INTEL_PIE
|
||||
WIFIPANRESETLEGACYGOSCANFILTER WifiPanReSetLegacyGoScanFilterFunc =
|
||||
nullptr;
|
||||
DWORD dwError = ERROR_SUCCESS; // NOLINT
|
||||
WIFIPANRESETLEGACYGOSCANFILTER WifiPanReSetLegacyGoScanFilterFunc = nullptr;
|
||||
DWORD dwError = ERROR_SUCCESS; // NOLINT
|
||||
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE; // NOLINT
|
||||
INTEL_WIFI_HEADER intelWifiHeader;
|
||||
|
||||
@@ -298,8 +292,7 @@ bool WifiIntel::ResetScanFilter() {
|
||||
|
||||
WifiPanReSetLegacyGoScanFilterFunc =
|
||||
(WIFIPANRESETLEGACYGOSCANFILTER)GetProcAddress( // NOLINT
|
||||
muroc_api_dll_handle_,
|
||||
"WifiPanReSetLegacyGoScanFilter");
|
||||
muroc_api_dll_handle_, "WifiPanReSetLegacyGoScanFilter");
|
||||
|
||||
if (WifiPanReSetLegacyGoScanFilterFunc == nullptr) {
|
||||
dwError = GetLastError(); // NOLINT
|
||||
@@ -308,11 +301,11 @@ bool WifiIntel::ResetScanFilter() {
|
||||
<< dwError;
|
||||
return false;
|
||||
}
|
||||
NEARBY_LOGS(VERBOSE)
|
||||
NEARBY_VLOG(1)
|
||||
<< "Load WifiPanReSetLegacyGoScanFilterFunc API completed successfully";
|
||||
intelWifiHeader.dwSize = 0;
|
||||
murocApiRetVal = WifiPanReSetLegacyGoScanFilterFunc(
|
||||
wifi_adapter_handle_, &intelWifiHeader);
|
||||
murocApiRetVal = WifiPanReSetLegacyGoScanFilterFunc(wifi_adapter_handle_,
|
||||
&intelWifiHeader);
|
||||
|
||||
if (murocApiRetVal == IWLAN_E_SUCCESS) { // NOLINT
|
||||
NEARBY_LOGS(INFO) << "Calling WifiPanReSetLegacyGoScanFilter API succeeded";
|
||||
@@ -385,8 +378,7 @@ bool IsHwIdMatching(DEVINST devInst, const wchar_t* expecedHwId) {
|
||||
// Compare to given HW ID
|
||||
wchar_t* pdest = wcsstr(currentDeviceHwId, expecedHwId); // NOLINT
|
||||
if (nullptr != pdest) {
|
||||
std::wcout << "wifi_intel.cc"
|
||||
<< ":" << __LINE__
|
||||
std::wcout << "wifi_intel.cc" << ":" << __LINE__
|
||||
<< "] Intel WIFI hwId is found: " << expecedHwId << std::endl;
|
||||
isHwIdFound = true;
|
||||
}
|
||||
@@ -442,10 +434,10 @@ void OpenRegKeyHandle(DEVINST devInst, HKEY& softwareKey) {
|
||||
if (devInst != NULL) {
|
||||
// opens a registry key for device-specific configuration information.
|
||||
configRet = CM_Open_DevNode_Key(devInst, KEY_READ, 0, // NOLINT
|
||||
RegDisposition_OpenExisting,
|
||||
&softwareKey, CM_REGISTRY_SOFTWARE);
|
||||
RegDisposition_OpenExisting, &softwareKey,
|
||||
CM_REGISTRY_SOFTWARE);
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << absl::StrFormat("softwareKey %p ", softwareKey);
|
||||
NEARBY_VLOG(1) << absl::StrFormat("softwareKey %p ", softwareKey);
|
||||
|
||||
if (configRet != CR_SUCCESS) {
|
||||
NEARBY_LOGS(INFO)
|
||||
@@ -493,11 +485,11 @@ DWORD GetFullDllLoadPathFromPieRegistry(DEVINST pieDeviceInstance,
|
||||
<< "Unexpected error! GetRegKeyWCHARValue return Value of " << status;
|
||||
return status;
|
||||
} else {
|
||||
NEARBY_LOGS(VERBOSE) << "Queried key length successfully!";
|
||||
NEARBY_VLOG(1) << "Queried key length successfully!";
|
||||
}
|
||||
|
||||
dllFullPathLen = (dllPathBufferLen + sizeof(PIE_API_DLL));
|
||||
NEARBY_LOGS(VERBOSE) << "dll Full Path Length = " << dllFullPathLen;
|
||||
NEARBY_VLOG(1) << "dll Full Path Length = " << dllFullPathLen;
|
||||
|
||||
pLoadPathString = new wchar_t[dllFullPathLen];
|
||||
SecureZeroMemory(pLoadPathString, dllFullPathLen); // NOLINT
|
||||
@@ -513,15 +505,14 @@ DWORD GetFullDllLoadPathFromPieRegistry(DEVINST pieDeviceInstance,
|
||||
return status;
|
||||
} else {
|
||||
pathString = pLoadPathString;
|
||||
NEARBY_LOGS(VERBOSE) << "Queried key successfully!";
|
||||
NEARBY_VLOG(1) << "Queried key successfully!";
|
||||
}
|
||||
|
||||
std::wstring fullString = pathString + PIE_API_DLL;
|
||||
|
||||
wcscpy_s(pLoadPathString, dllFullPathLen, fullString.c_str()); // NOLINT
|
||||
|
||||
std::wcout << "wifi_intel.cc"
|
||||
<< ":" << __LINE__
|
||||
std::wcout << "wifi_intel.cc" << ":" << __LINE__
|
||||
<< "] PIE Dll Path and Name = " << pLoadPathString << std::endl;
|
||||
|
||||
if (ppDllPathValue != nullptr) {
|
||||
@@ -551,8 +542,8 @@ HINSTANCE WifiIntel::PIEDllLoader() {
|
||||
// load the library and get the handle
|
||||
murocApiDllHandle = LoadLibraryW(pDllPathValue); // NOLINT
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << absl::StrFormat("Muroc Api Dll Handle is 0x%p ",
|
||||
murocApiDllHandle);
|
||||
NEARBY_VLOG(1) << absl::StrFormat("Muroc Api Dll Handle is 0x%p ",
|
||||
murocApiDllHandle);
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "GetFullDllLoadPathFromPieRegistry fails eith error: "
|
||||
<< ret;
|
||||
@@ -581,8 +572,8 @@ HADAPTER WifiGetAdapterList(HINSTANCE murocApiDllHandle,
|
||||
return INVALID_HADAPTER;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << "GetProcAddress for WifiGetAdapterListFunction API "
|
||||
"completed successfully";
|
||||
NEARBY_VLOG(1) << "GetProcAddress for WifiGetAdapterListFunction API "
|
||||
"completed successfully";
|
||||
INTEL_WIFI_HEADER intelHeader = {INTEL_STRUCT_VERSION_V156, // NOLINT
|
||||
sizeof(MurocDefs::INTEL_ADAPTER_LIST_V120)};
|
||||
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE;
|
||||
@@ -619,7 +610,7 @@ void RegisterIntelCallback(
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(VERBOSE) << "Load RegisterIntelCallback API successfully";
|
||||
NEARBY_VLOG(1) << "Load RegisterIntelCallback API successfully";
|
||||
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE;
|
||||
|
||||
murocApiRetVal = registerIntelCBFunc(pIntelEventCbHandle);
|
||||
@@ -649,13 +640,13 @@ void DeregisterIntelCallback(HINSTANCE murocApiDllHandle,
|
||||
}
|
||||
|
||||
{
|
||||
NEARBY_LOGS(VERBOSE) << "Load DeregisterIntelCallback API successfully";
|
||||
NEARBY_VLOG(1) << "Load DeregisterIntelCallback API successfully";
|
||||
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE;
|
||||
|
||||
murocApiRetVal = deregisterIntelCBFunc(fnCallback);
|
||||
|
||||
if (murocApiRetVal == IWLAN_E_SUCCESS) {
|
||||
NEARBY_LOGS(VERBOSE) << "Calling DeregisterIntelCallback API succeeded.";
|
||||
NEARBY_VLOG(1) << "Calling DeregisterIntelCallback API succeeded.";
|
||||
} else {
|
||||
NEARBY_LOGS(INFO)
|
||||
<< "Calling DeregisterIntelCallback API fails with error:"
|
||||
@@ -683,13 +674,13 @@ void FreeMemoryList(HINSTANCE murocApiDllHandle, void* ptr) {
|
||||
}
|
||||
|
||||
if ((freeMemoryListFunction != nullptr)) {
|
||||
NEARBY_LOGS(VERBOSE) << "Load FreeListMemory API successfully";
|
||||
NEARBY_VLOG(1) << "Load FreeListMemory API successfully";
|
||||
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE;
|
||||
|
||||
murocApiRetVal = freeMemoryListFunction(ptr);
|
||||
|
||||
if (murocApiRetVal == IWLAN_E_SUCCESS) {
|
||||
NEARBY_LOGS(VERBOSE) << "Calling FreeListMemory API succeeded.";
|
||||
NEARBY_VLOG(1) << "Calling FreeListMemory API succeeded.";
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "Calling FreeListMemory API failed with error: "
|
||||
<< murocApiRetVal;
|
||||
|
||||
Reference in New Issue
Block a user