| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // GATT service that contains this characteristic during construction. | 22 // GATT service that contains this characteristic during construction. |
| 23 // | 23 // |
| 24 // Note: We use virtual inheritance on the GATT characteristic since it will be | 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 | 25 // inherited by platform specific versions of the GATT characteristic classes |
| 26 // also. The platform specific remote GATT characteristic classes will inherit | 26 // also. The platform specific remote GATT characteristic classes will inherit |
| 27 // both this class and their GATT characteristic class, hence causing an | 27 // both this class and their GATT characteristic class, hence causing an |
| 28 // inheritance diamond. | 28 // inheritance diamond. |
| 29 class DEVICE_BLUETOOTH_EXPORT BluetoothLocalGattCharacteristic | 29 class DEVICE_BLUETOOTH_EXPORT BluetoothLocalGattCharacteristic |
| 30 : public virtual BluetoothGattCharacteristic { | 30 : public virtual BluetoothGattCharacteristic { |
| 31 public: | 31 public: |
| 32 enum NotificationStatus { |
| 33 NOTIFICATION_SUCCESS = 0, |
| 34 NOTIFY_PROPERTY_NOT_SET, |
| 35 INDICATE_PROPERTY_NOT_SET, |
| 36 SERVICE_NOT_REGISTERED, |
| 37 }; |
| 38 |
| 32 // Constructs a BluetoothLocalGattCharacteristic associated with a local GATT | 39 // Constructs a BluetoothLocalGattCharacteristic associated with a local GATT |
| 33 // service when the adapter is in the peripheral role. | 40 // service when the adapter is in the peripheral role. |
| 34 // | 41 // |
| 35 // This method constructs a characteristic with UUID |uuid|, initial cached | 42 // This method constructs a characteristic with UUID |uuid|, initial cached |
| 36 // value |value|, properties |properties|, and permissions |permissions|. | 43 // value |value|, properties |properties|, and permissions |permissions|. |
| 37 // |value| will be cached and returned for read requests and automatically set | 44 // |value| will be cached and returned for read requests and automatically set |
| 38 // for write requests by default, unless an instance of | 45 // for write requests by default, unless an instance of |
| 39 // BluetoothRemoteGattService::Delegate has been provided to the associated | 46 // BluetoothRemoteGattService::Delegate has been provided to the associated |
| 40 // BluetoothRemoteGattService instance, in which case the delegate will handle | 47 // BluetoothRemoteGattService instance, in which case the delegate will handle |
| 41 // read and write requests. The service instance will contain this | 48 // read and write requests. The service instance will contain this |
| 42 // characteristic. | 49 // characteristic. |
| 43 // TODO(rkc): Investigate how to handle |PROPERTY_EXTENDED_PROPERTIES| | 50 // TODO(rkc): Investigate how to handle |PROPERTY_EXTENDED_PROPERTIES| |
| 44 // correctly. | 51 // correctly. |
| 45 static base::WeakPtr<BluetoothLocalGattCharacteristic> Create( | 52 static base::WeakPtr<BluetoothLocalGattCharacteristic> Create( |
| 46 const BluetoothUUID& uuid, | 53 const BluetoothUUID& uuid, |
| 47 Properties properties, | 54 Properties properties, |
| 48 Permissions permissions, | 55 Permissions permissions, |
| 49 BluetoothLocalGattService* service); | 56 BluetoothLocalGattService* service); |
| 50 | 57 |
| 58 // Notify that the remote central that the value of this characteristic has |
| 59 // been changed and the new value is |new_value|. |indicate| should be set to |
| 60 // true if we want to use an indication instead of a notification. An |
| 61 // indication waits for a response from the remote, making it more reliable |
| 62 // but notifications may be faster. |
| 63 virtual NotificationStatus NotifyValueChanged( |
| 64 const std::vector<uint8_t>& new_value, |
| 65 bool indicate) = 0; |
| 66 |
| 51 protected: | 67 protected: |
| 52 BluetoothLocalGattCharacteristic(); | 68 BluetoothLocalGattCharacteristic(); |
| 53 ~BluetoothLocalGattCharacteristic() override; | 69 ~BluetoothLocalGattCharacteristic() override; |
| 54 | 70 |
| 55 private: | 71 private: |
| 56 DISALLOW_COPY_AND_ASSIGN(BluetoothLocalGattCharacteristic); | 72 DISALLOW_COPY_AND_ASSIGN(BluetoothLocalGattCharacteristic); |
| 57 }; | 73 }; |
| 58 | 74 |
| 59 } // namespace device | 75 } // namespace device |
| 60 | 76 |
| 61 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_H_ | 77 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_H_ |
| OLD | NEW |