File: bluetooth_local_gatt_characteristic.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (64 lines) | stat: -rw-r--r-- 2,541 bytes parent folder | download | duplicates (9)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_H_

#include <stdint.h>
#include <vector>

#include "device/bluetooth/bluetooth_export.h"
#include "device/bluetooth/bluetooth_gatt_characteristic.h"
#include "device/bluetooth/bluetooth_local_gatt_service.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"

namespace device {

// BluetoothLocalGattCharacteristic represents a local GATT characteristic. This
// class is used to represent GATT characteristics that belong to a locally
// hosted service. To achieve this, users need to specify the instance of the
// GATT service that contains this characteristic during construction.
//
// Note: We use virtual inheritance on the GATT characteristic since it will be
// inherited by platform specific versions of the GATT characteristic classes
// also. The platform specific remote GATT characteristic classes will inherit
// both this class and their GATT characteristic class, hence causing an
// inheritance diamond.
class DEVICE_BLUETOOTH_EXPORT BluetoothLocalGattCharacteristic
    : public virtual BluetoothGattCharacteristic {
 public:
  enum NotificationStatus {
    NOTIFICATION_SUCCESS = 0,
    NOTIFY_PROPERTY_NOT_SET,
    INDICATE_PROPERTY_NOT_SET,
    SERVICE_NOT_REGISTERED,
  };

  BluetoothLocalGattCharacteristic(const BluetoothLocalGattCharacteristic&) =
      delete;
  BluetoothLocalGattCharacteristic& operator=(
      const BluetoothLocalGattCharacteristic&) = delete;
  ~BluetoothLocalGattCharacteristic() override = default;

  // Notify the remote device |device| that the value of characteristic
  // |characteristic| has changed and the new value is |new_value|. |indicate|
  // should be set to true if we want to use an indication instead of a
  // notification. An indication waits for a response from the remote, making
  // it more reliable but notifications may be faster.
  virtual NotificationStatus NotifyValueChanged(
      const BluetoothDevice* device,
      const std::vector<uint8_t>& new_value,
      bool indicate) = 0;

  virtual BluetoothLocalGattService* GetService() const = 0;

  virtual std::vector<BluetoothLocalGattDescriptor*> GetDescriptors() const = 0;

 protected:
  BluetoothLocalGattCharacteristic() = default;
};

}  // namespace device

#endif  // DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_H_