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

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

Issue 395633003: Enumerate Bluetooth LE services and expose them to chrome.bluetooth API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix x64 build. Created 6 years, 5 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_
7 7
8 #include <windows.h>
9 #include <setupapi.h>
10 // #include <bthledef.h>
11 // TODO(rpaquay):
12 // bthledef.h from Win8 SDK has a couple of issues when used in a Win32 app:
13 // * line 420: usage of "pragma pop" instead of "pragma warning(pop)"
14 // * line 349: no CALLBACK modifier in the definition of
15 // PFNBLUETOOTH_GATT_EVENT_CALLBACK.
16 //
17 // So, we duplicate the definitions we need and prevent the build from including
18 // the content of bthledef.h.
19 #ifndef __BTHLEDEF_H__
20 #define __BTHLEDEF_H__
21
22 //
23 // Bluetooth LE device interface GUID
24 //
25 // {781aee18-7733-4ce4-adb0-91f41c67b592}
26 DEFINE_GUID(GUID_BLUETOOTHLE_DEVICE_INTERFACE,
27 0x781aee18,
28 0x7733,
29 0x4ce4,
30 0xad,
31 0xd0,
32 0x91,
33 0xf4,
34 0x1c,
35 0x67,
36 0xb5,
37 0x92);
38
39 #endif // __BTHLEDEF_H__
40 #include <bluetoothapis.h>
41
42 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
43 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
44 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
45 #include "base/win/scoped_handle.h" 11 #include "base/win/scoped_handle.h"
12 #include "device/bluetooth/bluetooth_low_energy_defs_win.h"
46 13
47 namespace device { 14 namespace device {
48 namespace win { 15 namespace win {
49 16
50 // Represents a device registry property value 17 // Represents a device registry property value
51 class DeviceRegistryPropertyValue { 18 class DeviceRegistryPropertyValue {
52 public: 19 public:
53 // Creates a property value instance, where |property_type| is one of REG_xxx 20 // Creates a property value instance, where |property_type| is one of REG_xxx
54 // registry value type (e.g. REG_SZ, REG_DWORD), |value| is a byte array 21 // registry value type (e.g. REG_SZ, REG_DWORD), |value| is a byte array
55 // containing the propery value and |value_size| is the number of bytes in 22 // containing the propery value and |value_size| is the number of bytes in
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 DEVPROPTYPE property_type_; 65 DEVPROPTYPE property_type_;
99 scoped_ptr<uint8_t[]> value_; 66 scoped_ptr<uint8_t[]> value_;
100 size_t value_size_; 67 size_t value_size_;
101 68
102 DISALLOW_COPY_AND_ASSIGN(DevicePropertyValue); 69 DISALLOW_COPY_AND_ASSIGN(DevicePropertyValue);
103 }; 70 };
104 71
105 // Returns true only on Windows platforms supporting Bluetooth Low Energy. 72 // Returns true only on Windows platforms supporting Bluetooth Low Energy.
106 bool IsBluetoothLowEnergySupported(); 73 bool IsBluetoothLowEnergySupported();
107 74
75 struct BluetoothLowEnergyServiceInfo {
76 BluetoothLowEnergyServiceInfo();
77 ~BluetoothLowEnergyServiceInfo();
78
79 BTH_LE_UUID uuid;
80 };
81
108 struct BluetoothLowEnergyDeviceInfo { 82 struct BluetoothLowEnergyDeviceInfo {
109 BluetoothLowEnergyDeviceInfo(); 83 BluetoothLowEnergyDeviceInfo();
110 ~BluetoothLowEnergyDeviceInfo(); 84 ~BluetoothLowEnergyDeviceInfo();
111 85
112 base::FilePath path; 86 base::FilePath path;
113 std::string id; 87 std::string id;
114 std::string friendly_name; 88 std::string friendly_name;
115 BLUETOOTH_ADDRESS address; 89 BLUETOOTH_ADDRESS address;
116 bool visible; 90 bool visible;
117 bool authenticated; 91 bool authenticated;
118 bool connected; 92 bool connected;
119 }; 93 };
120 94
121 // Enumerates the list of known (i.e. already paired) Bluetooth LE devices on 95 // Enumerates the list of known (i.e. already paired) Bluetooth LE devices on
122 // this machine. In case of error, returns false and sets |error| with an error 96 // this machine. In case of error, returns false and sets |error| with an error
123 // message describing the problem. 97 // message describing the problem.
124 // Note: This function returns an error if Bluetooth Low Energy is not supported 98 // Note: This function returns an error if Bluetooth Low Energy is not supported
125 // on this Windows platform. 99 // on this Windows platform.
126 bool EnumerateKnownBluetoothLowEnergyDevices( 100 bool EnumerateKnownBluetoothLowEnergyDevices(
127 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, 101 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
128 std::string* error); 102 std::string* error);
129 103
104 // Enumerates the list of known (i.e. cached) GATT services for a given
105 // Bluetooth LE device |device_info| into |services|. In case of error, returns
106 // false and sets |error| with an error message describing the problem. Note:
107 // This function returns an error if Bluetooth Low Energy is not supported on
108 // this Windows platform.
109 bool EnumerateKnownBluetoothLowEnergyServices(
110 BluetoothLowEnergyDeviceInfo* device_info,
111 ScopedVector<BluetoothLowEnergyServiceInfo>* services,
112 std::string* error);
113
130 bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting( 114 bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting(
131 const std::string& instance_id, 115 const std::string& instance_id,
132 BLUETOOTH_ADDRESS* btha, 116 BLUETOOTH_ADDRESS* btha,
133 std::string* error); 117 std::string* error);
134 118
135 } // namespace win 119 } // namespace win
136 } // namespace device 120 } // namespace device
137 121
138 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ 122 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_defs_win.cc ('k') | device/bluetooth/bluetooth_low_energy_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698