OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "device/bluetooth/bluetooth_export.h" |
| 13 #include "device/bluetooth/bluetooth_gatt_characteristic.h" |
| 14 #include "device/bluetooth/bluetooth_local_gatt_service.h" |
| 15 #include "device/bluetooth/bluetooth_uuid.h" |
| 16 |
| 17 namespace device { |
| 18 |
| 19 // BluetoothLocalGattCharacteristic represents a local GATT characteristic. This |
| 20 // class is used to represent GATT characteristics that belong to a locally |
| 21 // hosted service. To achieve this, users need to specify the instance of the |
| 22 // GATT service that contains this characteristic during construction. |
| 23 // |
| 24 // Note: We use virtual inheritance on the GATT characteristic since it will be |
| 25 // inherited by platform specific versions of the GATT characteristic classes |
| 26 // also. The platform specific remote GATT characteristic classes will inherit |
| 27 // both this class and their GATT characteristic class, hence causing an |
| 28 // inheritance diamond. |
| 29 class DEVICE_BLUETOOTH_EXPORT BluetoothLocalGattCharacteristic |
| 30 : public virtual BluetoothGattCharacteristic { |
| 31 public: |
| 32 // Constructs a BluetoothLocalGattCharacteristic associated with a local GATT |
| 33 // service when the adapter is in the peripheral role. |
| 34 // |
| 35 // This method constructs a characteristic with UUID |uuid|, initial cached |
| 36 // value |value|, properties |properties|, and permissions |permissions|. |
| 37 // |value| will be cached and returned for read requests and automatically set |
| 38 // for write requests by default, unless an instance of |
| 39 // BluetoothRemoteGattService::Delegate has been provided to the associated |
| 40 // BluetoothRemoteGattService instance, in which case the delegate will handle |
| 41 // read |
| 42 // and write requests. The service instance will contain this characteristic. |
| 43 // TODO(rkc): Investigate how to handle |PROPERTY_EXTENDED_PROPERTIES| |
| 44 // correctly. |
| 45 static BluetoothLocalGattCharacteristic* Create( |
| 46 const BluetoothUUID& uuid, |
| 47 const std::vector<uint8_t>& value, |
| 48 Properties properties, |
| 49 Permissions permissions, |
| 50 BluetoothLocalGattService* service); |
| 51 |
| 52 protected: |
| 53 BluetoothLocalGattCharacteristic(); |
| 54 ~BluetoothLocalGattCharacteristic() override; |
| 55 |
| 56 private: |
| 57 DISALLOW_COPY_AND_ASSIGN(BluetoothLocalGattCharacteristic); |
| 58 }; |
| 59 |
| 60 } // namespace device |
| 61 |
| 62 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_H_ |
OLD | NEW |