Roll WebRTC 8837:8852, Libjingle 8836:8851
[chromium-blink-merge.git] / device / bluetooth / bluetooth_low_energy_win.h
blobf9873225dca299dc072ac4a9c0dae1f40d1564ce
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
3 // found in the LICENSE file.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_
8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/win/scoped_handle.h"
12 #include "device/bluetooth/bluetooth_export.h"
13 #include "device/bluetooth/bluetooth_low_energy_defs_win.h"
15 namespace device {
16 namespace win {
18 // Represents a device registry property value
19 class DEVICE_BLUETOOTH_EXPORT DeviceRegistryPropertyValue {
20 public:
21 // Creates a property value instance, where |property_type| is one of REG_xxx
22 // registry value type (e.g. REG_SZ, REG_DWORD), |value| is a byte array
23 // containing the property value and |value_size| is the number of bytes in
24 // |value|. Note the returned instance takes ownership of the bytes in
25 // |value|.
26 static scoped_ptr<DeviceRegistryPropertyValue> Create(
27 DWORD property_type,
28 scoped_ptr<uint8_t[]> value,
29 size_t value_size);
30 ~DeviceRegistryPropertyValue();
32 // Returns the vaue type a REG_xxx value (e.g. REG_SZ, REG_DWORD, ...)
33 DWORD property_type() const { return property_type_; }
35 std::string AsString() const;
36 DWORD AsDWORD() const;
38 private:
39 DeviceRegistryPropertyValue(DWORD property_type,
40 scoped_ptr<uint8_t[]> value,
41 size_t value_size);
43 DWORD property_type_;
44 scoped_ptr<uint8_t[]> value_;
45 size_t value_size_;
47 DISALLOW_COPY_AND_ASSIGN(DeviceRegistryPropertyValue);
50 // Represents the value associated to a DEVPROPKEY.
51 class DEVICE_BLUETOOTH_EXPORT DevicePropertyValue {
52 public:
53 // Creates a property value instance, where |property_type| is one of
54 // DEVPROP_TYPE_xxx value type , |value| is a byte array containing the
55 // property value and |value_size| is the number of bytes in |value|. Note the
56 // returned instance takes ownership of the bytes in |value|.
57 DevicePropertyValue(DEVPROPTYPE property_type,
58 scoped_ptr<uint8_t[]> value,
59 size_t value_size);
61 DEVPROPTYPE property_type() const { return property_type_; }
63 uint32_t AsUint32() const;
65 private:
66 DEVPROPTYPE property_type_;
67 scoped_ptr<uint8_t[]> value_;
68 size_t value_size_;
70 DISALLOW_COPY_AND_ASSIGN(DevicePropertyValue);
73 // Returns true only on Windows platforms supporting Bluetooth Low Energy.
74 bool IsBluetoothLowEnergySupported();
76 struct BluetoothLowEnergyServiceInfo {
77 BluetoothLowEnergyServiceInfo();
78 ~BluetoothLowEnergyServiceInfo();
80 BTH_LE_UUID uuid;
83 struct BluetoothLowEnergyDeviceInfo {
84 BluetoothLowEnergyDeviceInfo();
85 ~BluetoothLowEnergyDeviceInfo();
87 base::FilePath path;
88 std::string id;
89 std::string friendly_name;
90 BLUETOOTH_ADDRESS address;
91 bool visible;
92 bool authenticated;
93 bool connected;
96 // Enumerates the list of known (i.e. already paired) Bluetooth LE devices on
97 // this machine. In case of error, returns false and sets |error| with an error
98 // message describing the problem.
99 // Note: This function returns an error if Bluetooth Low Energy is not supported
100 // on this Windows platform.
101 bool EnumerateKnownBluetoothLowEnergyDevices(
102 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
103 std::string* error);
105 // Enumerates the list of known (i.e. cached) GATT services for a given
106 // Bluetooth LE device |device_path| into |services|. In case of error, returns
107 // false and sets |error| with an error message describing the problem. Note:
108 // This function returns an error if Bluetooth Low Energy is not supported on
109 // this Windows platform.
110 bool EnumerateKnownBluetoothLowEnergyServices(
111 const base::FilePath& device_path,
112 ScopedVector<BluetoothLowEnergyServiceInfo>* services,
113 std::string* error);
115 bool DEVICE_BLUETOOTH_EXPORT
116 ExtractBluetoothAddressFromDeviceInstanceIdForTesting(
117 const std::string& instance_id,
118 BLUETOOTH_ADDRESS* btha,
119 std::string* error);
121 } // namespace win
122 } // namespace device
124 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_