| OLD | NEW |
| 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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |