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

Unified Diff: device/bluetooth/bluetooth_task_manager_win.cc

Issue 1739383002: Implement read & write remote GATT characteristic value for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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: device/bluetooth/bluetooth_task_manager_win.cc
diff --git a/device/bluetooth/bluetooth_task_manager_win.cc b/device/bluetooth/bluetooth_task_manager_win.cc
index c45f022a9ec91761c2d394adc2ba1ba7f7568067..c201a623e3200430918e72845adbc7472d86a0e7 100644
--- a/device/bluetooth/bluetooth_task_manager_win.cc
+++ b/device/bluetooth/bluetooth_task_manager_win.cc
@@ -809,6 +809,44 @@ void BluetoothTaskManagerWin::GetGattIncludedDescriptors(
number_of_descriptors, hr));
}
+void BluetoothTaskManagerWin::ReadCharacteristicValue(
+ base::FilePath service_path,
+ BTH_LE_GATT_CHARACTERISTIC characteristic,
+ const ReadGattCharacteristicValueCallback& callback) {
+ scoped_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE> win_characteristic_value;
+ HRESULT hr =
+ win::BluetoothLowEnergyWrapper::GetInstance()
+ ->ReadTheValueOfACharacteristic(
+ service_path, (PBTH_LE_GATT_CHARACTERISTIC)(&characteristic),
+ &win_characteristic_value);
+
+ ui_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(callback, base::Passed(&win_characteristic_value), hr));
+}
+
+void BluetoothTaskManagerWin::WriteCharacteristicValue(
+ base::FilePath service_path,
+ BTH_LE_GATT_CHARACTERISTIC characteristic,
+ std::vector<uint8_t> new_value,
+ const HResultCallback& callback) {
+ ULONG length = sizeof(ULONG) + new_value.size();
+ PBTH_LE_GATT_CHARACTERISTIC_VALUE win_new_value =
+ (BTH_LE_GATT_CHARACTERISTIC_VALUE*)malloc(length);
+ win_new_value->DataSize = new_value.size();
+ for (ULONG i = 0; i < new_value.size(); i++)
+ win_new_value->Data[i] = new_value[i];
+
+ HRESULT hr =
+ win::BluetoothLowEnergyWrapper::GetInstance()
+ ->WriteTheValueOfACharacteristic(
+ service_path, (PBTH_LE_GATT_CHARACTERISTIC)(&characteristic),
+ win_new_value);
+ free(win_new_value);
+
+ ui_task_runner_->PostTask(FROM_HERE, base::Bind(callback, hr));
+}
+
void BluetoothTaskManagerWin::PostGetGattIncludedCharacteristics(
const base::FilePath& service_path,
const BluetoothUUID& uuid,
@@ -832,4 +870,30 @@ void BluetoothTaskManagerWin::PostGetGattIncludedDescriptors(
service_path, *characteristic, callback));
}
+void BluetoothTaskManagerWin::PostReadCharacteristicValue(
+ const base::FilePath& service_path,
+ const PBTH_LE_GATT_CHARACTERISTIC characteristic,
+ const ReadGattCharacteristicValueCallback& callback) {
+ DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
+ bluetooth_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&BluetoothTaskManagerWin::ReadCharacteristicValue,
+ this, service_path, *characteristic, callback));
+ FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_,
+ OnBluetoothAttemptReadGattCharacteristic());
+}
+
+void BluetoothTaskManagerWin::PostWriteCharacteristicValue(
+ const base::FilePath& service_path,
+ const PBTH_LE_GATT_CHARACTERISTIC characteristic,
+ const std::vector<uint8_t>& new_value,
+ const HResultCallback& callback) {
+ DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
+ bluetooth_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&BluetoothTaskManagerWin::WriteCharacteristicValue, this,
+ service_path, *characteristic, new_value, callback));
+ FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_,
+ OnBluetoothAttemptWriteGattCharacteristic());
+}
+
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698