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_BLUETOOTH_GATT_SERVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ | 6 #define DEVICE_BLUETOOTH_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_uuid.h" | 12 #include "device/bluetooth/bluetooth_uuid.h" |
13 | 13 |
14 namespace device { | 14 namespace device { |
15 | 15 |
| 16 class BluetoothDevice; |
16 class BluetoothGattCharacteristic; | 17 class BluetoothGattCharacteristic; |
17 class BluetoothGattDescriptor; | 18 class BluetoothGattDescriptor; |
18 | 19 |
19 // BluetoothGattService represents a local or remote GATT service. A GATT | 20 // BluetoothGattService represents a local or remote GATT service. A GATT |
20 // service is hosted by a peripheral and represents a collection of data in | 21 // 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 | 22 // the form of GATT characteristics and a set of included GATT services if this |
22 // service is what is called "a primary service". | 23 // service is what is called "a primary service". |
23 // | 24 // |
24 // Instances of the BluetoothGattService class are used for two functions: | 25 // Instances of the BluetoothGattService class are used for two functions: |
25 // 1. To represent GATT attribute hierarchies that have been received from a | 26 // 1. To represent GATT attribute hierarchies that have been received from a |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // represents a remote GATT service. | 219 // represents a remote GATT service. |
219 virtual bool IsLocal() const = 0; | 220 virtual bool IsLocal() const = 0; |
220 | 221 |
221 // Indicates whether the type of this service is primary or secondary. A | 222 // Indicates whether the type of this service is primary or secondary. A |
222 // primary service describes the primary function of the peripheral that | 223 // primary service describes the primary function of the peripheral that |
223 // hosts it, while a secondary service only makes sense in the presence of a | 224 // hosts it, while a secondary service only makes sense in the presence of a |
224 // primary service. A primary service may include other primary or secondary | 225 // primary service. A primary service may include other primary or secondary |
225 // services. | 226 // services. |
226 virtual bool IsPrimary() const = 0; | 227 virtual bool IsPrimary() const = 0; |
227 | 228 |
| 229 // Returns the BluetoothDevice that this GATT service was received from, which |
| 230 // also owns this service. Local services always return NULL. |
| 231 virtual BluetoothDevice* GetDevice() const = 0; |
| 232 |
228 // List of characteristics that belong to this service. | 233 // List of characteristics that belong to this service. |
229 virtual std::vector<BluetoothGattCharacteristic*> | 234 virtual std::vector<BluetoothGattCharacteristic*> |
230 GetCharacteristics() const = 0; | 235 GetCharacteristics() const = 0; |
231 | 236 |
232 // List of GATT services that are included by this service. | 237 // List of GATT services that are included by this service. |
233 virtual std::vector<BluetoothGattService*> | 238 virtual std::vector<BluetoothGattService*> |
234 GetIncludedServices() const = 0; | 239 GetIncludedServices() const = 0; |
235 | 240 |
236 // Returns the GATT characteristic with identifier |identifier| if it belongs | 241 // Returns the GATT characteristic with identifier |identifier| if it belongs |
237 // to this GATT service. | 242 // to this GATT service. |
238 virtual BluetoothGattCharacteristic* GetCharacteristic( | 243 virtual BluetoothGattCharacteristic* GetCharacteristic( |
239 const std::string& identifier) = 0; | 244 const std::string& identifier) const = 0; |
240 | 245 |
241 // Adds characteristics and included services to the local attribute hierarchy | 246 // Adds characteristics and included services to the local attribute hierarchy |
242 // represented by this service. These methods only make sense for local | 247 // represented by this service. These methods only make sense for local |
243 // services and won't have an effect if this instance represents a remote | 248 // services and won't have an effect if this instance represents a remote |
244 // GATT service and will return false. While ownership of added | 249 // GATT service and will return false. While ownership of added |
245 // characteristics are taken over by the service, ownership of an included | 250 // characteristics are taken over by the service, ownership of an included |
246 // service is not taken. | 251 // service is not taken. |
247 virtual bool AddCharacteristic( | 252 virtual bool AddCharacteristic( |
248 BluetoothGattCharacteristic* characteristic) = 0; | 253 BluetoothGattCharacteristic* characteristic) = 0; |
249 virtual bool AddIncludedService(BluetoothGattService* service) = 0; | 254 virtual bool AddIncludedService(BluetoothGattService* service) = 0; |
(...skipping 15 matching lines...) Expand all Loading... |
265 protected: | 270 protected: |
266 BluetoothGattService(); | 271 BluetoothGattService(); |
267 | 272 |
268 private: | 273 private: |
269 DISALLOW_COPY_AND_ASSIGN(BluetoothGattService); | 274 DISALLOW_COPY_AND_ASSIGN(BluetoothGattService); |
270 }; | 275 }; |
271 | 276 |
272 } // namespace device | 277 } // namespace device |
273 | 278 |
274 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ | 279 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ |
OLD | NEW |