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

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

Issue 297003004: chrome.bluetoothLowEnergy: Implement readDescriptorValue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git cl format Created 6 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 83d8a63fde33f7f821cdbbaa51b08c423c9fbece..385e0db36711deadcf1445e9199e8b04b3d75e3b 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
@@ -441,6 +441,30 @@ bool BluetoothLowEnergyEventRouter::WriteCharacteristicValue(
return true;
}
+bool BluetoothLowEnergyEventRouter::ReadDescriptorValue(
+ const std::string& instance_id,
+ const base::Closure& callback,
+ const base::Closure& error_callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (!adapter_) {
+ VLOG(1) << "BluetoothAdapter not ready.";
+ return false;
+ }
+
+ BluetoothGattDescriptor* descriptor = FindDescriptorById(instance_id);
+ if (!descriptor) {
+ VLOG(1) << "Descriptor not found: " << instance_id;
+ return false;
+ }
+
+ descriptor->ReadRemoteDescriptor(
+ base::Bind(&BluetoothLowEnergyEventRouter::ValueCallback,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback),
+ error_callback);
+ return true;
+}
+
void BluetoothLowEnergyEventRouter::SetAdapterForTesting(
device::BluetoothAdapter* adapter) {
adapter_ = adapter;
@@ -812,7 +836,7 @@ BluetoothGattDescriptor* BluetoothLowEnergyEventRouter::FindDescriptorById(
void BluetoothLowEnergyEventRouter::ValueCallback(
const base::Closure& callback,
const std::vector<uint8>& value) {
- VLOG(2) << "Remote characteristic value read successful.";
+ VLOG(2) << "Remote characteristic/descriptor value read successful.";
callback.Run();
}

Powered by Google App Engine
This is Rietveld 408576698