Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1399)

Side by Side Diff: device/bluetooth/bluetooth_gatt_service.h

Issue 228643004: device/bluetooth: Add chromeos::BluetoothRemoteGattCharacteristicChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed potentially flaky expectation from unit test. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 }; 125 };
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 properties of the remote GATT service |service| have changed. 133 // Called when properties of the remote GATT service |service| have changed.
134 // This will get called for properties such as UUID, as well as for changes 134 // This will get called for properties such as UUID, as well as for changes
135 // to the list of known characteristics. Observers should read all GATT 135 // to the list of known characteristics and included services. Observers
136 // characteristic and descriptors objects and do any necessary set up 136 // should read all GATT characteristic and descriptors objects and do any
137 // required for a changed service. 137 // necessary set up required for a changed service. This method may be
138 // called several times, especially when the service is discovered for the
139 // first time. It will be called for each characteristic that is discovered
140 // or removed. Hence this method should be used to check whether or not all
141 // characteristics of a service have been discovered that correspond to the
142 // profile implemented by the Observer.
138 virtual void GattServiceChanged(BluetoothGattService* service) {} 143 virtual void GattServiceChanged(BluetoothGattService* service) {}
139 144
140 // Called when the value of a characteristic has been retrieved or updated 145 // Called when the remote GATT characteristic |characteristic| belonging to
141 // via a notification or inidication. 146 // GATT service |service| has been discovered. Use this to issue any initial
142 virtual void CharacteristicValueChanged( 147 // read/write requests to the characteristic but don't cache the pointer as
148 // it may become invalid. Instead, use the specially assigned identifier
149 // to obtain a characteristic and cache that identifier as necessary, as it
150 // can be used to retrieve the characteristic from its GATT service. The
151 // number of characteristics with the same UUID belonging to a service
152 // depends on the particular profile the remote device implements, hence the
153 // client of a GATT based profile will usually operate on the whole set of
154 // characteristics and not just one.
155 //
156 // This method will always be followed by a call to GattServiceChanged,
157 // which can be used by observers to get all the characteristics of a
158 // service and perform the necessary updates. GattCharacteristicAdded exists
159 // mostly for convenience.
160 virtual void GattCharacteristicAdded(
161 BluetoothGattService* service,
162 BluetoothGattCharacteristic* characteristic) {}
163
164 // Called when a GATT characteristic |characteristic| belonging to GATT
165 // service |service| has been removed. This method is for convenience
166 // and will be followed by a call to GattServiceChanged (except when called
167 // after the service gets removed) which should be used for bootstrapping a
168 // GATT based profile. See the documentation of GattCharacteristicAdded and
169 // GattServiceChanged for more information. Try to obtain the service from
170 // its device to see whether or not the service has been removed.
171 virtual void GattCharacteristicRemoved(
172 BluetoothGattService* service,
173 BluetoothGattCharacteristic* characteristic) {}
174
175 // Called when the value of a characteristic has changed. This might be a
176 // result of a read/write request to, or a notification/indication from, a
177 // remote GATT characteristic.
178 virtual void GattCharacteristicValueChanged(
143 BluetoothGattService* service, 179 BluetoothGattService* service,
144 BluetoothGattCharacteristic* characteristic, 180 BluetoothGattCharacteristic* characteristic,
145 const std::vector<uint8>& value) {} 181 const std::vector<uint8>& value) {}
146 }; 182 };
147 183
148 // The ErrorCallback is used by methods to asynchronously report errors. 184 // The ErrorCallback is used by methods to asynchronously report errors.
149 typedef base::Closure ErrorCallback; 185 typedef base::Closure ErrorCallback;
150 186
151 virtual ~BluetoothGattService(); 187 virtual ~BluetoothGattService();
152 188
153 // Adds and removes observers for events on this GATT service. If monitoring 189 // Adds and removes observers for events on this GATT service. If monitoring
154 // multiple services, check the |service| parameter of observer methods to 190 // multiple services, check the |service| parameter of observer methods to
155 // determine which service is issuing the event. 191 // determine which service is issuing the event.
156 virtual void AddObserver(Observer* observer) = 0; 192 virtual void AddObserver(Observer* observer) = 0;
157 virtual void RemoveObserver(Observer* observer) = 0; 193 virtual void RemoveObserver(Observer* observer) = 0;
158 194
159 // Constructs a BluetoothGattService that can be locally hosted when the local 195 // Constructs a BluetoothGattService that can be locally hosted when the local
160 // adapter is in the peripheral role. The resulting object can then be made 196 // adapter is in the peripheral role. The resulting object can then be made
161 // available by calling the "Register" method. This method constructs a 197 // available by calling the "Register" method. This method constructs a
162 // service with UUID |uuid|. Whether the constructed service is primary or 198 // service with UUID |uuid|. Whether the constructed service is primary or
163 // secondary is determined by |is_primary|. |delegate| is used to send certain 199 // secondary is determined by |is_primary|. |delegate| is used to send certain
164 // peripheral role events. If |delegate| is NULL, then this service will 200 // peripheral role events. If |delegate| is NULL, then this service will
165 // employ a default behavior when responding to read and write requests based 201 // employ a default behavior when responding to read and write requests based
166 // on the cached value of its characteristics and descriptors at a given time. 202 // on the cached value of its characteristics and descriptors at a given time.
167 static BluetoothGattService* Create(const BluetoothUUID& uuid, 203 static BluetoothGattService* Create(const BluetoothUUID& uuid,
168 bool is_primary, 204 bool is_primary,
169 Delegate* delegate); 205 Delegate* delegate);
170 206
171 // Identifier used to uniquely identify a GATT service object. This different 207 // Identifier used to uniquely identify a GATT service object. This is
172 // from the service UUID: while multiple services with the same UUID can exist 208 // different from the service UUID: while multiple services with the same UUID
173 // on a Bluetooth device, the identifier returned from this method is unique 209 // can exist on a Bluetooth device, the identifier returned from this method
174 // among all services of a device. The contents of the identifier are platform 210 // is unique among all services of a device. The contents of the identifier
175 // specific. 211 // are platform specific.
176 virtual std::string GetIdentifier() const = 0; 212 virtual std::string GetIdentifier() const = 0;
177 213
178 // The Bluetooth-specific UUID of the service. 214 // The Bluetooth-specific UUID of the service.
179 virtual BluetoothUUID GetUUID() const = 0; 215 virtual BluetoothUUID GetUUID() const = 0;
180 216
181 // Returns true, if this service hosted locally. If false, then this service 217 // Returns true, if this service hosted locally. If false, then this service
182 // represents a remote GATT service. 218 // represents a remote GATT service.
183 virtual bool IsLocal() const = 0; 219 virtual bool IsLocal() const = 0;
184 220
185 // Indicates whether the type of this service is primary or secondary. A 221 // Indicates whether the type of this service is primary or secondary. A
186 // primary service describes the primary function of the peripheral that 222 // primary service describes the primary function of the peripheral that
187 // hosts it, while a secondary service only makes sense in the presence of a 223 // hosts it, while a secondary service only makes sense in the presence of a
188 // primary service. A primary service may include other primary or secondary 224 // primary service. A primary service may include other primary or secondary
189 // services. 225 // services.
190 virtual bool IsPrimary() const = 0; 226 virtual bool IsPrimary() const = 0;
191 227
192 // List of characteristics that belong to this service. 228 // List of characteristics that belong to this service.
193 virtual const std::vector<BluetoothGattCharacteristic*>& 229 virtual std::vector<BluetoothGattCharacteristic*>
194 GetCharacteristics() const = 0; 230 GetCharacteristics() const = 0;
195 231
196 // List of GATT services that are included by this service. 232 // List of GATT services that are included by this service.
197 virtual const std::vector<BluetoothGattService*>& 233 virtual std::vector<BluetoothGattService*>
198 GetIncludedServices() const = 0; 234 GetIncludedServices() const = 0;
199 235
236 // Returns the GATT characteristic with identifier |identifier| if it belongs
237 // to this GATT service.
238 virtual BluetoothGattCharacteristic* GetCharacteristic(
239 const std::string& identifier) = 0;
240
200 // Adds characteristics and included services to the local attribute hierarchy 241 // Adds characteristics and included services to the local attribute hierarchy
201 // represented by this service. These methods only make sense for local 242 // represented by this service. These methods only make sense for local
202 // services and won't have an effect if this instance represents a remote 243 // services and won't have an effect if this instance represents a remote
203 // GATT service and will return false. While ownership of added 244 // GATT service and will return false. While ownership of added
204 // characteristics are taken over by the service, ownership of an included 245 // characteristics are taken over by the service, ownership of an included
205 // service is not taken. 246 // service is not taken.
206 virtual bool AddCharacteristic( 247 virtual bool AddCharacteristic(
207 BluetoothGattCharacteristic* characteristic) = 0; 248 BluetoothGattCharacteristic* characteristic) = 0;
208 virtual bool AddIncludedService(BluetoothGattService* service) = 0; 249 virtual bool AddIncludedService(BluetoothGattService* service) = 0;
209 250
(...skipping 14 matching lines...) Expand all
224 protected: 265 protected:
225 BluetoothGattService(); 266 BluetoothGattService();
226 267
227 private: 268 private:
228 DISALLOW_COPY_AND_ASSIGN(BluetoothGattService); 269 DISALLOW_COPY_AND_ASSIGN(BluetoothGattService);
229 }; 270 };
230 271
231 } // namespace device 272 } // namespace device
232 273
233 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ 274 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_gatt_descriptor.h ('k') | device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698