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

Unified Diff: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc

Issue 1920353002: Implement create attribute API functions for BTLE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@api_changes
Patch Set: owners 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
Index: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
diff --git a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
index 3f2d43608bea8f6b67660371b66212a66b977115..bf58f2d581a7e3ecd6f70878f03f7d67796c8822 100644
--- a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
+++ b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
@@ -24,6 +24,7 @@
#include "device/bluetooth/bluetooth_gatt_connection.h"
#include "device/bluetooth/bluetooth_gatt_notify_session.h"
#include "device/bluetooth/bluetooth_gatt_service.h"
+#include "device/bluetooth/bluetooth_local_gatt_characteristic.h"
#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
#include "device/bluetooth/bluetooth_remote_gatt_descriptor.h"
#include "device/bluetooth/bluetooth_uuid.h"
@@ -1057,6 +1058,33 @@ void BluetoothLowEnergyEventRouter::GattDescriptorValueChanged(
std::move(args));
}
+void BluetoothLowEnergyEventRouter::AddLocalCharacteristic(
+ const std::string& id,
+ const std::string& service_id) {
+ if (chrc_id_to_service_id_.find(id) != chrc_id_to_service_id_.end())
+ VLOG(1) << "Local characteristic with id " << id
+ << " already exists. Replacing.";
+ chrc_id_to_service_id_[id] = service_id;
+}
+
+device::BluetoothLocalGattCharacteristic*
+BluetoothLowEnergyEventRouter::GetLocalCharacteristic(
+ const std::string& id) const {
+ if (chrc_id_to_service_id_.find(id) == chrc_id_to_service_id_.end()) {
+ VLOG(1) << "Characteristic with id " << id << " not found.";
+ return nullptr;
+ }
+ device::BluetoothLocalGattService* service =
+ adapter_->GetGattService(chrc_id_to_service_id_.at(id));
+ if (!service) {
+ VLOG(1) << "Parent service of characteristic with id " << id
+ << " not found.";
+ return nullptr;
+ }
+
+ return service->GetCharacteristic(id);
+}
+
void BluetoothLowEnergyEventRouter::OnGetAdapter(
const base::Closure& callback,
scoped_refptr<device::BluetoothAdapter> adapter) {

Powered by Google App Engine
This is Rietveld 408576698