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

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

Issue 263333003: chrome.bluetoothLowEnergy: Implement writeCharacteristicValue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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 eeccc823e9f38608a8493cc4810b19ce4e5fca99..301a72c5b158078d3c5eb8c5f120b5a796cb8a5a 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
@@ -343,6 +343,28 @@ bool BluetoothLowEnergyEventRouter::ReadCharacteristicValue(
return true;
}
+bool BluetoothLowEnergyEventRouter::WriteCharacteristicValue(
+ const std::string& instance_id,
+ const std::vector<uint8>& value,
+ const base::Closure& callback,
+ const base::Closure& error_callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (!adapter_) {
+ VLOG(1) << "BluetoothAdapter not ready.";
+ return false;
+ }
+
+ BluetoothGattCharacteristic* characteristic =
+ FindCharacteristicById(instance_id);
+ if (!characteristic) {
+ VLOG(1) << "Characteristic not found: " << instance_id;
+ return false;
+ }
+
+ characteristic->WriteRemoteCharacteristic(value, callback, error_callback);
+ return true;
+}
+
void BluetoothLowEnergyEventRouter::SetAdapterForTesting(
device::BluetoothAdapter* adapter) {
adapter_ = adapter;

Powered by Google App Engine
This is Rietveld 408576698