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

Side by Side Diff: device/bluetooth/bluetooth_low_energy_win.cc

Issue 1749403002: Implement BluetoothRemoteGattCharacteristicWin::StartNotifySession and related unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use static_cast Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/bluetooth/bluetooth_low_energy_win.h" 5 #include "device/bluetooth/bluetooth_low_energy_win.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 result->path = 462 result->path =
463 base::FilePath(std::wstring(device_interface_detail_data->DevicePath)); 463 base::FilePath(std::wstring(device_interface_detail_data->DevicePath));
464 if (!CollectBluetoothLowEnergyDeviceInstanceId( 464 if (!CollectBluetoothLowEnergyDeviceInstanceId(
465 device_info_handle, &device_info_data, result, error)) { 465 device_info_handle, &device_info_data, result, error)) {
466 return false; 466 return false;
467 } 467 }
468 if (!CollectBluetoothLowEnergyDeviceFriendlyName( 468 if (!CollectBluetoothLowEnergyDeviceFriendlyName(
469 device_info_handle, &device_info_data, result, error)) { 469 device_info_handle, &device_info_data, result, error)) {
470 // Only fail if not the GATT service device interface, which doesn't have a 470 // Only fail if not the GATT service device interface, which doesn't have a
471 // friendly name. 471 // friendly name.
472 if (device_info_data.ClassGuid != 472 if (device_interface_data->InterfaceClassGuid !=
scheib 2016/04/05 22:44:02 Double check that you intend this change -- I don'
gogerald1 2016/04/06 22:54:48 Done. Split out
473 GUID_BLUETOOTH_GATT_SERVICE_DEVICE_INTERFACE) 473 GUID_BLUETOOTH_GATT_SERVICE_DEVICE_INTERFACE)
474 return false; 474 return false;
475 } 475 }
476 if (!CollectBluetoothLowEnergyDeviceAddress( 476 if (!CollectBluetoothLowEnergyDeviceAddress(
477 device_info_handle, &device_info_data, result, error)) { 477 device_info_handle, &device_info_data, result, error)) {
478 return false; 478 return false;
479 } 479 }
480 if (!CollectBluetoothLowEnergyDeviceStatus( 480 if (!CollectBluetoothLowEnergyDeviceStatus(
481 device_info_handle, &device_info_data, result, error)) { 481 device_info_handle, &device_info_data, result, error)) {
482 return false; 482 return false;
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 base::File file(service_path, base::File::FLAG_OPEN | base::File::FLAG_READ | 830 base::File file(service_path, base::File::FLAG_OPEN | base::File::FLAG_READ |
831 base::File::FLAG_WRITE); 831 base::File::FLAG_WRITE);
832 if (!file.IsValid()) 832 if (!file.IsValid())
833 return HRESULT_FROM_WIN32(ERROR_OPEN_FAILED); 833 return HRESULT_FROM_WIN32(ERROR_OPEN_FAILED);
834 834
835 return BluetoothGATTSetCharacteristicValue(file.GetPlatformFile(), 835 return BluetoothGATTSetCharacteristicValue(file.GetPlatformFile(),
836 characteristic, new_value, NULL, 836 characteristic, new_value, NULL,
837 BLUETOOTH_GATT_FLAG_NONE); 837 BLUETOOTH_GATT_FLAG_NONE);
838 } 838 }
839 839
840 HRESULT BluetoothLowEnergyWrapper::RegisterGattEvents(
841 base::FilePath& service_path,
842 BTH_LE_GATT_EVENT_TYPE event_type,
843 PVOID event_parameter,
844 PFNBLUETOOTH_GATT_EVENT_CALLBACK callback,
845 PVOID context,
846 BLUETOOTH_GATT_EVENT_HANDLE* out_handle) {
847 base::File file(service_path, base::File::FLAG_OPEN | base::File::FLAG_READ);
848 if (!file.IsValid())
849 return HRESULT_FROM_WIN32(ERROR_OPEN_FAILED);
850 return BluetoothGATTRegisterEvent(file.GetPlatformFile(), event_type,
851 event_parameter, callback, context,
852 out_handle, BLUETOOTH_GATT_FLAG_NONE);
853 }
854
855 HRESULT BluetoothLowEnergyWrapper::UnregisterGattEvent(
856 BLUETOOTH_GATT_EVENT_HANDLE event_handle) {
857 return BluetoothGATTUnregisterEvent(event_handle, BLUETOOTH_GATT_FLAG_NONE);
858 }
859
860 HRESULT BluetoothLowEnergyWrapper::WriteDescriptorValue(
861 base::FilePath& service_path,
862 const PBTH_LE_GATT_DESCRIPTOR descriptor,
863 PBTH_LE_GATT_DESCRIPTOR_VALUE new_value) {
864 base::File file(service_path, base::File::FLAG_OPEN | base::File::FLAG_READ |
865 base::File::FLAG_WRITE);
866 if (!file.IsValid())
867 return HRESULT_FROM_WIN32(ERROR_OPEN_FAILED);
868 return BluetoothGATTSetDescriptorValue(file.GetPlatformFile(), descriptor,
869 new_value, BLUETOOTH_GATT_FLAG_NONE);
870 }
871
840 } // namespace win 872 } // namespace win
841 } // namespace device 873 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698