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

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

Issue 1915803002: Bluetooth class changes for implementing local GATT attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
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_SERVICE_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_SERVICE_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_SERVICE_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_SERVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 26 matching lines...) Expand all
37 // their gatt service class, hence causing an inheritance diamond. 37 // their gatt service class, hence causing an inheritance diamond.
38 class DEVICE_BLUETOOTH_EXPORT BluetoothLocalGattService 38 class DEVICE_BLUETOOTH_EXPORT BluetoothLocalGattService
39 : public virtual BluetoothGattService { 39 : public virtual BluetoothGattService {
40 public: 40 public:
41 // The Delegate class is used to send certain events that need to be handled 41 // The Delegate class is used to send certain events that need to be handled
42 // when the device is in peripheral mode. The delegate handles read and write 42 // when the device is in peripheral mode. The delegate handles read and write
43 // requests that are issued from remote clients. 43 // requests that are issued from remote clients.
44 class Delegate { 44 class Delegate {
45 public: 45 public:
46 // Callbacks used for communicating GATT request responses. 46 // Callbacks used for communicating GATT request responses.
47 typedef base::Callback<void(const std::vector<uint8_t>)> ValueCallback; 47 typedef base::Callback<void(const std::vector<uint8_t>&)> ValueCallback;
48 typedef base::Closure ErrorCallback; 48 typedef base::Closure ErrorCallback;
49 49
50 // Called when a remote device in the central role requests to read the 50 // Called when a remote device in the central role requests to read the
51 // value of the characteristic |characteristic| starting at offset |offset|. 51 // value of the characteristic |characteristic| starting at offset |offset|.
52 // This method is only called if the characteristic was specified as 52 // This method is only called if the characteristic was specified as
53 // readable and any authentication and authorization challenges were 53 // readable and any authentication and authorization challenges were
54 // satisfied by the remote device. 54 // satisfied by the remote device.
55 // 55 //
56 // To respond to the request with success and return the requested value, 56 // To respond to the request with success and return the requested value,
57 // the delegate must invoke |callback| with the value. Doing so will 57 // the delegate must invoke |callback| with the value. Doing so will
58 // automatically update the value property of |characteristic|. To respond 58 // automatically update the value property of |characteristic|. To respond
59 // to the request with failure (e.g. if an invalid offset was given), 59 // to the request with failure (e.g. if an invalid offset was given),
60 // delegates must invoke |error_callback|. If neither callback parameter is 60 // delegates must invoke |error_callback|. If neither callback parameter is
61 // invoked, the request will time out and result in an error. Therefore, 61 // invoked, the request will time out and result in an error. Therefore,
62 // delegates MUST invoke either |callback| or |error_callback|. 62 // delegates MUST invoke either |callback| or |error_callback|.
63 virtual void OnCharacteristicReadRequest( 63 virtual void OnCharacteristicReadRequest(
64 const BluetoothLocalGattService* service, 64 const BluetoothLocalGattService* service,
65 const BluetoothLocalGattCharacteristic* characteristic, 65 const BluetoothLocalGattCharacteristic* characteristic,
66 int offset, 66 int offset,
67 const ValueCallback& callback, 67 const ValueCallback& callback,
68 const ErrorCallback& error_callback) = 0; 68 const ErrorCallback& error_callback) = 0;
69 69
70 // Called when a remote device in the central role requests to write the 70 // Called when a remote device in the central role requests to write the
71 // value of the characteristic |characteristic| starting at offset |offset|. 71 // value of the characteristic |characteristic| starting at offset |offset|.
72 // This method is only called if the characteristic was specified as 72 // This method is only called if the characteristic was specified as
73 // writable and any authentication and authorization challenges were 73 // writable and any authentication and authorization challenges were
74 // satisfied by the remote device. 74 // satisfied by the remote device.
75 // 75 //
76 // To respond to the request with success the delegate must invoke 76 // To respond to the request with success the delegate must invoke
77 // |callback| with the new value of the characteristic. Doing so will 77 // |callback|. To respond to the request with failure delegates must invoke
78 // automatically update the value property of |characteristic|. To respond 78 // |error_callback|. If neither callback parameter is invoked, the request
79 // to the request with failure (e.g. if an invalid offset was given), 79 // will time out and result in an error. Therefore, delegates MUST invoke
80 // delegates must invoke |error_callback|. If neither callback parameter is 80 // either |callback| or |error_callback|.
81 // invoked, the request will time out and result in an error. Therefore,
82 // delegates MUST invoke either |callback| or |error_callback|.
83 virtual void OnCharacteristicWriteRequest( 81 virtual void OnCharacteristicWriteRequest(
84 const BluetoothLocalGattService* service, 82 const BluetoothLocalGattService* service,
85 const BluetoothLocalGattCharacteristic* characteristic, 83 const BluetoothLocalGattCharacteristic* characteristic,
86 const std::vector<uint8_t>& value, 84 const std::vector<uint8_t>& value,
87 int offset, 85 int offset,
88 const ValueCallback& callback, 86 const base::Closure& callback,
89 const ErrorCallback& error_callback) = 0; 87 const ErrorCallback& error_callback) = 0;
90 88
91 // Called when a remote device in the central role requests to read the 89 // Called when a remote device in the central role requests to read the
92 // value of the descriptor |descriptor| starting at offset |offset|. 90 // value of the descriptor |descriptor| starting at offset |offset|.
93 // This method is only called if the characteristic was specified as 91 // This method is only called if the characteristic was specified as
94 // readable and any authentication and authorization challenges were 92 // readable and any authentication and authorization challenges were
95 // satisfied by the remote device. 93 // satisfied by the remote device.
96 // 94 //
97 // To respond to the request with success and return the requested value, 95 // To respond to the request with success and return the requested value,
98 // the delegate must invoke |callback| with the value. Doing so will 96 // the delegate must invoke |callback| with the value. Doing so will
99 // automatically update the value property of |descriptor|. To respond 97 // automatically update the value property of |descriptor|. To respond
100 // to the request with failure (e.g. if an invalid offset was given), 98 // to the request with failure (e.g. if an invalid offset was given),
101 // delegates must invoke |error_callback|. If neither callback parameter is 99 // delegates must invoke |error_callback|. If neither callback parameter is
102 // invoked, the request will time out and result in an error. Therefore, 100 // invoked, the request will time out and result in an error. Therefore,
103 // delegates MUST invoke either |callback| or |error_callback|. 101 // delegates MUST invoke either |callback| or |error_callback|.
104 virtual void OnDescriptorReadRequest( 102 virtual void OnDescriptorReadRequest(
105 const BluetoothLocalGattService* service, 103 const BluetoothLocalGattService* service,
106 const BluetoothLocalGattDescriptor* descriptor, 104 const BluetoothLocalGattDescriptor* descriptor,
107 int offset, 105 int offset,
108 const ValueCallback& callback, 106 const ValueCallback& callback,
109 const ErrorCallback& error_callback) = 0; 107 const ErrorCallback& error_callback) = 0;
110 108
111 // Called when a remote device in the central role requests to write the 109 // Called when a remote device in the central role requests to write the
112 // value of the descriptor |descriptor| starting at offset |offset|. 110 // value of the descriptor |descriptor| starting at offset |offset|.
113 // This method is only called if the characteristic was specified as 111 // This method is only called if the characteristic was specified as
114 // writable and any authentication and authorization challenges were 112 // writable and any authentication and authorization challenges were
115 // satisfied by the remote device. 113 // satisfied by the remote device.
116 // 114 //
117 // To respond to the request with success the delegate must invoke 115 // To respond to the request with success the delegate must invoke
118 // |callback| with the new value of the descriptor. Doing so will 116 // |callback|. To respond to the request with failure delegates must invoke
119 // automatically update the value property of |descriptor|. To respond 117 // |error_callback|. If neither callback parameter is invoked, the request
120 // to the request with failure (e.g. if an invalid offset was given), 118 // will time out and result in an error. Therefore, delegates MUST invoke
121 // delegates must invoke |error_callback|. If neither callback parameter is 119 // either |callback| or |error_callback|.
122 // invoked, the request will time out and result in an error. Therefore,
123 // delegates MUST invoke either |callback| or |error_callback|.
124 virtual void OnDescriptorWriteRequest( 120 virtual void OnDescriptorWriteRequest(
125 const BluetoothLocalGattService* service, 121 const BluetoothLocalGattService* service,
126 const BluetoothLocalGattDescriptor* descriptor, 122 const BluetoothLocalGattDescriptor* descriptor,
127 const std::vector<uint8_t>& value, 123 const std::vector<uint8_t>& value,
128 int offset, 124 int offset,
129 const ValueCallback& callback, 125 const base::Closure& callback,
130 const ErrorCallback& error_callback) = 0; 126 const ErrorCallback& error_callback) = 0;
131 }; 127 };
132 128
133 // Creates a local GATT service to be used with |adapter| (which will own 129 // Creates a local GATT service to be used with |adapter| (which will own
134 // the created service object). A service can register or unregister itself 130 // the created service object). A service can register or unregister itself
135 // at any time by calling its Register/Unregister methods. |delegate| 131 // at any time by calling its Register/Unregister methods. |delegate|
136 // receives read/write requests for characteristic/descriptor values. It 132 // receives read/write requests for characteristic/descriptor values. It
137 // needs to outlive this object. 133 // needs to outlive this object.
138 // TODO(rkc): Implement included services. 134 // TODO(rkc): Implement included services.
139 static base::WeakPtr<BluetoothLocalGattService> Create( 135 static base::WeakPtr<BluetoothLocalGattService> Create(
(...skipping 18 matching lines...) Expand all
158 BluetoothLocalGattService(); 154 BluetoothLocalGattService();
159 ~BluetoothLocalGattService() override; 155 ~BluetoothLocalGattService() override;
160 156
161 private: 157 private:
162 DISALLOW_COPY_AND_ASSIGN(BluetoothLocalGattService); 158 DISALLOW_COPY_AND_ASSIGN(BluetoothLocalGattService);
163 }; 159 };
164 160
165 } // namespace device 161 } // namespace device
166 162
167 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_SERVICE_H_ 163 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_SERVICE_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_local_gatt_descriptor.cc ('k') | device/bluetooth/bluetooth_local_gatt_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698