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

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: 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 5dd4ec1203bfba8fbd43f4a622f4f0d2bd22f35c..b2bc68cab3a7f0ece81865a4676e44aa26361b81 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
@@ -316,6 +316,28 @@ bool BluetoothLowEnergyEventRouter::GetCharacteristic(
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