| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_GATT_SERVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_GATT_SERVICE_H_ |
| 6 #define DEVICE_BLUETOOTH_GATT_SERVICE_H_ | 6 #define DEVICE_BLUETOOTH_GATT_SERVICE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "device/bluetooth/bluetooth_utils.h" | 12 #include "device/bluetooth/bluetooth_uuid.h" |
| 13 | 13 |
| 14 namespace device { | 14 namespace device { |
| 15 | 15 |
| 16 class BluetoothGattCharacteristic; | 16 class BluetoothGattCharacteristic; |
| 17 class BluetoothGattDescriptor; | 17 class BluetoothGattDescriptor; |
| 18 | 18 |
| 19 // BluetoothGattService represents a local or remote GATT service. A GATT | 19 // BluetoothGattService represents a local or remote GATT service. A GATT |
| 20 // service is hosted by a peripheral and represents a collection of data in | 20 // service is hosted by a peripheral and represents a collection of data in |
| 21 // the form of GATT characteristics and a set of included GATT services if this | 21 // the form of GATT characteristics and a set of included GATT services if this |
| 22 // service is what is called "a primary service". | 22 // service is what is called "a primary service". |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 // Interface for observing changes from a BluetoothGattService. Properties | 127 // Interface for observing changes from a BluetoothGattService. Properties |
| 128 // of remote services are received asynchronously. The Observer interface can | 128 // of remote services are received asynchronously. The Observer interface can |
| 129 // be used to be notified when the initial values of a service are received | 129 // be used to be notified when the initial values of a service are received |
| 130 // as well as when successive changes occur during its life cycle. | 130 // as well as when successive changes occur during its life cycle. |
| 131 class Observer { | 131 class Observer { |
| 132 public: | 132 public: |
| 133 // Called when the UUID of |service| have changed. | 133 // Called when the UUID of |service| have changed. |
| 134 virtual void UuidChanged( | 134 virtual void UuidChanged( |
| 135 BluetoothGattService* service, | 135 BluetoothGattService* service, |
| 136 const bluetooth_utils::UUID& uuid) {} | 136 const BluetoothUUID& uuid) {} |
| 137 | 137 |
| 138 // Called when the services included by |service| have changed. | 138 // Called when the services included by |service| have changed. |
| 139 virtual void IncludedServicesChanged( | 139 virtual void IncludedServicesChanged( |
| 140 BluetoothGattService* service, | 140 BluetoothGattService* service, |
| 141 const std::vector<BluetoothGattService*>& included_services) {} | 141 const std::vector<BluetoothGattService*>& included_services) {} |
| 142 | 142 |
| 143 // Called when the characteristics that belong to |service| have changed. | 143 // Called when the characteristics that belong to |service| have changed. |
| 144 virtual void CharacteristicsChanged( | 144 virtual void CharacteristicsChanged( |
| 145 BluetoothGattService* service, | 145 BluetoothGattService* service, |
| 146 const std::vector<BluetoothGattCharacteristic*>& characteristics) {} | 146 const std::vector<BluetoothGattCharacteristic*>& characteristics) {} |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 // The ErrorCallback is used by methods to asynchronously report errors. | 149 // The ErrorCallback is used by methods to asynchronously report errors. |
| 150 typedef base::Callback<void(const std::string&)> ErrorCallback; | 150 typedef base::Callback<void(const std::string&)> ErrorCallback; |
| 151 | 151 |
| 152 // Constructs a BluetoothGattService that can be locally hosted when the local | 152 // Constructs a BluetoothGattService that can be locally hosted when the local |
| 153 // adapter is in the peripheral role. The resulting object can then be made | 153 // adapter is in the peripheral role. The resulting object can then be made |
| 154 // available by calling the "Register" method. This method constructs a | 154 // available by calling the "Register" method. This method constructs a |
| 155 // service with UUID |uuid|. Whether the constructed service is primary or | 155 // service with UUID |uuid|. Whether the constructed service is primary or |
| 156 // secondary is determined by |is_primary|. |delegate| is used to send certain | 156 // secondary is determined by |is_primary|. |delegate| is used to send certain |
| 157 // peripheral role events. If |delegate| is NULL, then this service will | 157 // peripheral role events. If |delegate| is NULL, then this service will |
| 158 // employ a default behavior when responding to read and write requests based | 158 // employ a default behavior when responding to read and write requests based |
| 159 // on the cached value of its characteristics and descriptors at a given time. | 159 // on the cached value of its characteristics and descriptors at a given time. |
| 160 static BluetoothGattService* Create(const bluetooth_utils::UUID& uuid, | 160 static BluetoothGattService* Create(const BluetoothUUID& uuid, |
| 161 bool is_primary, | 161 bool is_primary, |
| 162 Delegate* delegate); | 162 Delegate* delegate); |
| 163 | 163 |
| 164 // The Bluetooth-specific UUID of the service. | 164 // The Bluetooth-specific UUID of the service. |
| 165 virtual const bluetooth_utils::UUID& GetUuid() const = 0; | 165 virtual const BluetoothUUID& GetUuid() const = 0; |
| 166 | 166 |
| 167 // Returns true, if this service hosted locally. If false, then this service | 167 // Returns true, if this service hosted locally. If false, then this service |
| 168 // represents a remote GATT service. | 168 // represents a remote GATT service. |
| 169 virtual bool IsLocal() const = 0; | 169 virtual bool IsLocal() const = 0; |
| 170 | 170 |
| 171 // Indicates whether the type of this service is primary or secondary. A | 171 // Indicates whether the type of this service is primary or secondary. A |
| 172 // primary service describes the primary function of the peripheral that | 172 // primary service describes the primary function of the peripheral that |
| 173 // hosts it, while a secondary service only makes sense in the presence of a | 173 // hosts it, while a secondary service only makes sense in the presence of a |
| 174 // primary service. A primary service may include other primary or secondary | 174 // primary service. A primary service may include other primary or secondary |
| 175 // services. | 175 // services. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 BluetoothGattService(); | 217 BluetoothGattService(); |
| 218 virtual ~BluetoothGattService(); | 218 virtual ~BluetoothGattService(); |
| 219 | 219 |
| 220 private: | 220 private: |
| 221 DISALLOW_COPY_AND_ASSIGN(BluetoothGattService); | 221 DISALLOW_COPY_AND_ASSIGN(BluetoothGattService); |
| 222 }; | 222 }; |
| 223 | 223 |
| 224 } // namespace device | 224 } // namespace device |
| 225 | 225 |
| 226 #endif // DEVICE_BLUETOOTH_GATT_SERVICE_H_ | 226 #endif // DEVICE_BLUETOOTH_GATT_SERVICE_H_ |
| OLD | NEW |