mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Added flag to enable GATT on non-extended device
PiperOrigin-RevId: 538851144
This commit is contained in:
committed by
Copybara-Service
parent
742f57423c
commit
ae900f0baf
@@ -114,8 +114,20 @@ bool BleGattClient::DiscoverServiceAndCharacteristics(
|
||||
if (!NearbyFlags::GetInstance().GetBoolFlag(
|
||||
platform::config_package_nearby::nearby_platform_feature::
|
||||
kEnableBleV2Gatt)) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": GATT is disabled.";
|
||||
return false;
|
||||
auto windows_bluetooth_adapter_ = ::winrt::Windows::Devices::Bluetooth::
|
||||
BluetoothAdapter::GetDefaultAsync()
|
||||
.get();
|
||||
if (windows_bluetooth_adapter_.IsExtendedAdvertisingSupported()) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": GATT is disabled.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!NearbyFlags::GetInstance().GetBoolFlag(
|
||||
platform::config_package_nearby::nearby_platform_feature::
|
||||
kEnableBleV2GattOnNonExtendedDevice)) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": GATT is disabled.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::string flat_characteristics =
|
||||
|
||||
@@ -374,10 +374,18 @@ std::unique_ptr<api::ble_v2::GattServer> BleV2Medium::StartGattServer(
|
||||
if (!NearbyFlags::GetInstance().GetBoolFlag(
|
||||
platform::config_package_nearby::nearby_platform_feature::
|
||||
kEnableBleV2Gatt)) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": GATT is disabled.";
|
||||
return nullptr;
|
||||
}
|
||||
if (adapter_->IsExtendedAdvertisingSupported()) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": GATT is disabled.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!NearbyFlags::GetInstance().GetBoolFlag(
|
||||
platform::config_package_nearby::nearby_platform_feature::
|
||||
kEnableBleV2GattOnNonExtendedDevice)) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": GATT is disabled.";
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
auto gatt_server =
|
||||
std::make_unique<BleGattServer>(adapter_, std::move(callback));
|
||||
|
||||
@@ -396,8 +404,17 @@ std::unique_ptr<api::ble_v2::GattClient> BleV2Medium::ConnectToGattServer(
|
||||
if (!NearbyFlags::GetInstance().GetBoolFlag(
|
||||
platform::config_package_nearby::nearby_platform_feature::
|
||||
kEnableBleV2Gatt)) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": GATT is disabled.";
|
||||
return nullptr;
|
||||
if (adapter_->IsExtendedAdvertisingSupported()) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": GATT is disabled.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!NearbyFlags::GetInstance().GetBoolFlag(
|
||||
platform::config_package_nearby::nearby_platform_feature::
|
||||
kEnableBleV2GattOnNonExtendedDevice)) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": GATT is disabled.";
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user