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

Unified Diff: device/bluetooth/bluetooth_low_energy_win.cc

Issue 1728163006: Implement BluetoothRemoteGattCharacteristicWin::GetDescriptors (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_low_energy_win.cc
diff --git a/device/bluetooth/bluetooth_low_energy_win.cc b/device/bluetooth/bluetooth_low_energy_win.cc
index 1e985b54f1b00b2b771c61374519a5c76a19490b..3e2c7c2a900a0c387bcb73b261545dc5d2ba8037 100644
--- a/device/bluetooth/bluetooth_low_energy_win.cc
+++ b/device/bluetooth/bluetooth_low_energy_win.cc
@@ -757,5 +757,42 @@ HRESULT BluetoothLowEnergyWrapper::ReadCharacteristicsOfAService(
return hr;
}
+HRESULT BluetoothLowEnergyWrapper::ReadDescriptorsOfACharacteristic(
+ base::FilePath& service_path,
+ const PBTH_LE_GATT_CHARACTERISTIC characteristic,
+ scoped_ptr<BTH_LE_GATT_DESCRIPTOR>* out_included_descriptors,
+ USHORT* out_counts) {
+ base::File file(service_path, base::File::FLAG_OPEN | base::File::FLAG_READ);
+ if (!file.IsValid())
+ return HRESULT_FROM_WIN32(ERROR_OPEN_FAILED);
+
+ USHORT required_length = 0;
+ HRESULT hr = BluetoothGATTGetDescriptors(
+ file.GetPlatformFile(), characteristic, 0, NULL, &required_length,
+ BLUETOOTH_GATT_FLAG_NONE);
+ if (hr != HRESULT_FROM_WIN32(ERROR_MORE_DATA))
+ return hr;
+
+ out_included_descriptors->reset(new BTH_LE_GATT_DESCRIPTOR[required_length]);
+ USHORT actual_length = required_length;
scheib 2016/03/01 00:06:22 I overlooked that you did not address this in prev
gogerald1 2016/03/01 17:00:13 Done.
+ hr = BluetoothGATTGetDescriptors(file.GetPlatformFile(), characteristic,
+ actual_length,
+ out_included_descriptors->get(),
+ &required_length, BLUETOOTH_GATT_FLAG_NONE);
+ if (SUCCEEDED(hr) && required_length != actual_length) {
+ LOG(ERROR) << "Retrieved # of descriptors is not equal to expected"
+ << " actual_length " << actual_length << " required_length "
+ << required_length;
+ hr = HRESULT_FROM_WIN32(ERROR_INVALID_USER_BUFFER);
+ }
+ *out_counts = actual_length;
+
+ if (FAILED(hr)) {
+ out_included_descriptors->reset(nullptr);
+ *out_counts = 0;
+ }
+ return hr;
+}
+
} // namespace win
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698