summaryrefslogtreecommitdiffstats
path: root/device/bluetooth/bluetooth_gatt_notify_session.h
blob: cbedb623d47207eb085356e3ee06f31d56260df3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_H_

#include <string>

#include "base/callback.h"
#include "base/macros.h"
#include "device/bluetooth/bluetooth_export.h"

namespace device {

// A BluetoothGattNotifySession represents an active session for listening
// to value updates from GATT characteristics that support notifications and/or
// indications. Instances are obtained by calling
// BluetoothGattCharacteristic::StartNotifySession.
class DEVICE_BLUETOOTH_EXPORT BluetoothGattNotifySession {
 public:
  // Destructor automatically stops this session.
  virtual ~BluetoothGattNotifySession();

  // Returns the identifier of the associated characteristic.
  virtual std::string GetCharacteristicIdentifier() const = 0;

  // Returns true if this session is active.
  virtual bool IsActive() = 0;

  // Stops this session and calls |callback| upon completion. This won't
  // necessarily stop value updates from the characteristic -- since updates
  // are shared among BluetoothGattNotifySession instances -- but it will
  // terminate this session.
  virtual void Stop(const base::Closure& callback) = 0;

 protected:
  BluetoothGattNotifySession();

 private:
  DISALLOW_COPY_AND_ASSIGN(BluetoothGattNotifySession);
};

}  // namespace device

#endif  // DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_H_