Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1225)

Unified Diff: device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc

Issue 1974633002: Implement DBus changes needed for notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc
diff --git a/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc
index 4402b9fd08c3f434ff039b4d9373c53abb89767d..7b80de0a0bf875bf364bfbe1e0dbfebe5075adfd 100644
--- a/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc
+++ b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc
@@ -54,6 +54,16 @@ bool CanRead(const std::vector<std::string>& flags) {
return false;
}
+bool CanNotify(const std::vector<std::string>& flags) {
+ if (find(flags.begin(), flags.end(),
+ bluetooth_gatt_characteristic::kFlagNotify) != flags.end())
+ return true;
+ if (find(flags.begin(), flags.end(),
+ bluetooth_gatt_characteristic::kFlagIndicate) != flags.end())
+ return true;
+ return false;
+}
+
} // namespace
FakeBluetoothGattCharacteristicServiceProvider::
@@ -99,6 +109,7 @@ void FakeBluetoothGattCharacteristicServiceProvider::SendValueChanged(
const std::vector<uint8_t>& value) {
VLOG(1) << "Sent characteristic value changed: " << object_path_.value()
<< " UUID: " << uuid_;
+ sent_value_ = value;
}
void FakeBluetoothGattCharacteristicServiceProvider::GetValue(
@@ -156,6 +167,31 @@ void FakeBluetoothGattCharacteristicServiceProvider::SetValue(
delegate_->SetValue(value, callback, error_callback);
}
+bool FakeBluetoothGattCharacteristicServiceProvider::NotificationsChange(
+ bool start) {
+ VLOG(1) << "GATT characteristic value notification request: "
+ << object_path_.value() << " UUID: " << uuid_ << " start=" << start;
+ // Check if this characteristic is registered.
+ FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
+ static_cast<FakeBluetoothGattManagerClient*>(
+ bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
+ if (!fake_bluetooth_gatt_manager_client->IsServiceRegistered(service_path_)) {
+ VLOG(1) << "GATT characteristic not registered.";
+ return false;
+ }
+
+ if (!CanNotify(flags_)) {
+ VLOG(1) << "GATT characteristic not notifiable.";
+ return false;
+ }
+
+ // Pass on to the delegate.
+ DCHECK(delegate_);
+ start ? delegate_->StartNotifications() : delegate_->StopNotifications();
+
+ return true;
+}
+
const dbus::ObjectPath&
FakeBluetoothGattCharacteristicServiceProvider::object_path() const {
return object_path_;
« no previous file with comments | « device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698