Remove unused code.

PiperOrigin-RevId: 915643059
This commit is contained in:
Francis Tsui
2026-05-14 15:21:21 -07:00
committed by Copybara-Service
parent b66eebfef4
commit 7d84d08619
10 changed files with 0 additions and 239 deletions
@@ -431,80 +431,6 @@ bool BleGattClient::WriteCharacteristic(
return false;
}
bool BleGattClient::SetCharacteristicSubscription(
const api::ble::GattCharacteristic& characteristic, bool enable,
absl::AnyInvocable<void(absl::string_view value)>
on_characteristic_changed_cb) {
absl::MutexLock lock(mutex_);
VLOG(1) << __func__ << ": Started to set Characteristic Subscription.";
GattClientCharacteristicConfigurationDescriptorValue gcccd_value =
GattClientCharacteristicConfigurationDescriptorValue::None;
if ((characteristic.property & Property::kNotify) != Property::kNone) {
gcccd_value = GattClientCharacteristicConfigurationDescriptorValue::Notify;
} else if ((characteristic.property & Property::kIndicate) !=
Property::kNone) {
gcccd_value =
GattClientCharacteristicConfigurationDescriptorValue::Indicate;
} else {
LOG(WARNING) << "Characeristic: " << std::string(characteristic.uuid)
<< " supports neither notifications nor indications.";
return false;
}
std::optional<GattCharacteristic> gatt_characteristic;
gatt_characteristic =
native_characteristic_map_[characteristic].native_characteristic;
if (!gatt_characteristic.has_value()) {
LOG(ERROR) << __func__ << ": Failed to get native GATT characteristic.";
return false;
}
// Write characteristic configuration descriptor
if (!WriteCharacteristicConfigurationDescriptor(
gatt_characteristic.value(),
enable
? gcccd_value
: GattClientCharacteristicConfigurationDescriptorValue::None)) {
return false;
}
// Set value changed handler
try {
if (enable) {
native_characteristic_map_[characteristic].on_characteristic_changed_cb =
std::move(on_characteristic_changed_cb);
native_characteristic_map_[characteristic].notification_token =
gatt_characteristic->ValueChanged(
[&](GattCharacteristic const& native_characteristic,
GattValueChangedEventArgs args) {
BleGattClient::OnCharacteristicValueChanged(characteristic,
args);
});
if (!native_characteristic_map_[characteristic].notification_token) {
LOG(ERROR) << __func__ << ": Failed to add value change handler.";
return false;
}
} else if (native_characteristic_map_[characteristic].notification_token) {
gatt_characteristic->ValueChanged(std::exchange(
native_characteristic_map_[characteristic].notification_token, {}));
}
LOG(ERROR) << __func__ << ": Successfully set Characteristic Subscription.";
return true;
} catch (std::exception exception) {
LOG(ERROR) << __func__ << ": Failed to set Characteristic Subscription."
<< exception.what();
} catch (const winrt::hresult_error& error) {
LOG(ERROR) << __func__
<< ": Failed to set Characteristic Subscription."
" WinRT exception: "
<< error.code() << ": " << winrt::to_string(error.message());
}
return false;
}
void BleGattClient::Disconnect() {
absl::MutexLock lock(mutex_);
try {
@@ -63,11 +63,6 @@ class BleGattClient : public api::ble::GattClient {
api::ble::GattClient::WriteType write_type) override
ABSL_LOCKS_EXCLUDED(mutex_);
bool SetCharacteristicSubscription(
const api::ble::GattCharacteristic& characteristic, bool enable,
absl::AnyInvocable<void(absl::string_view value)>
on_characteristic_changed_cb) override ABSL_LOCKS_EXCLUDED(mutex_);
void Disconnect() override ABSL_LOCKS_EXCLUDED(mutex_);
private: