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_GATT_CONNECTION_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_CONNECTION_H_
10 #include "base/callback.h"
11 #include "device/bluetooth/bluetooth_export.h"
15 // BluetoothGattConnection represents a GATT connection to a Bluetooth device
16 // that has GATT services. Instances are obtained from a BluetoothDevice,
17 // and the connection is kept alive as long as there is at least one
18 // active BluetoothGattConnection object. BluetoothGattConnection objects
19 // automatically update themselves, when the connection is terminated by the
20 // operating system (e.g. due to user action).
21 class DEVICE_BLUETOOTH_EXPORT BluetoothGattConnection
{
23 // Destructor automatically closes this GATT connection. If this is the last
24 // remaining GATT connection and this results in a call to the OS, that call
25 // may not always succeed. Users can make an explicit call to
26 // BluetoothGattConnection::Close to make sure that they are notified of
27 // a possible error via the callback.
28 virtual ~BluetoothGattConnection();
30 // Returns the Bluetooth address of the device that this connection is open
32 virtual std::string
GetDeviceAddress() const = 0;
34 // Returns true if this connection is open.
35 virtual bool IsConnected() = 0;
37 // Disconnects this GATT connection and calls |callback| upon completion.
38 // After a successful invocation, the device may still remain connected due to
39 // other GATT connections.
40 virtual void Disconnect(const base::Closure
& callback
) = 0;
43 BluetoothGattConnection();
46 DISALLOW_COPY_AND_ASSIGN(BluetoothGattConnection
);
51 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_CONNECTION_H_