1 // Copyright 2015 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_DISCOVERY_FILTER_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DISCOVERY_FILTER_H_
10 #include "base/memory/scoped_vector.h"
11 #include "device/bluetooth/bluetooth_export.h"
12 #include "device/bluetooth/bluetooth_uuid.h"
16 // Used to keep a discovery filter that can be used to limit reported devices.
17 class DEVICE_BLUETOOTH_EXPORT BluetoothDiscoveryFilter
{
19 // Possible transports to use for scan filter.
21 TRANSPORT_CLASSIC
= 0x01,
23 TRANSPORT_DUAL
= (TRANSPORT_CLASSIC
| TRANSPORT_LE
)
25 using TransportMask
= uint8_t;
27 BluetoothDiscoveryFilter(TransportMask transport
);
28 ~BluetoothDiscoveryFilter();
30 // These getters return true when given field is set in filter, and copy this
31 // value to |out_*| parameter. If value is not set, returns false.
32 // Thes setters assign given value to proper filter field.
33 bool GetRSSI(int16_t* out_rssi
) const;
34 void SetRSSI(int16_t rssi
);
35 bool GetPathloss(uint16_t* out_pathloss
) const;
36 void SetPathloss(uint16_t pathloss
);
38 // Return and set transport field of this filter.
39 TransportMask
GetTransport() const;
40 void SetTransport(TransportMask transport
);
42 // Make |out_uuids| represent all uuids assigned to this filter.
43 void GetUUIDs(std::set
<device::BluetoothUUID
>& out_uuids
) const;
45 // Add UUID to internal UUIDs filter. If UUIDs filter doesn't exist, it will
47 void AddUUID(const device::BluetoothUUID
& uuid
);
49 // Copy content of |filter| and assigns it to this filter.
50 void CopyFrom(const BluetoothDiscoveryFilter
& filter
);
52 // Check if two filters are equal.
53 bool Equals(const BluetoothDiscoveryFilter
& filter
) const;
55 // Returns true if all fields in filter are empty
56 bool IsDefault() const;
58 // Returns result of merging two filters together. If at least one of the
59 // filters is NULL this will return an empty filter
60 static scoped_ptr
<device::BluetoothDiscoveryFilter
> Merge(
61 const device::BluetoothDiscoveryFilter
* filter_a
,
62 const device::BluetoothDiscoveryFilter
* filter_b
);
65 scoped_ptr
<int16_t> rssi_
;
66 scoped_ptr
<uint16_t> pathloss_
;
67 TransportMask transport_
;
68 ScopedVector
<device::BluetoothUUID
> uuids_
;
70 DISALLOW_COPY_AND_ASSIGN(BluetoothDiscoveryFilter
);
75 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DISCOVERY_FILTER_H_