| 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
|
|
|