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 module blink.mojom; | 5 module blink.mojom; |
6 | 6 |
7 import "device/bluetooth/public/interfaces/uuid.mojom"; | 7 import "device/bluetooth/public/interfaces/uuid.mojom"; |
8 | 8 |
9 // Bluetooth Terminology: | 9 // Bluetooth Terminology: |
10 // | 10 // |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 }; | 153 }; |
154 | 154 |
155 struct WebBluetoothRemoteGATTDescriptor { | 155 struct WebBluetoothRemoteGATTDescriptor { |
156 string instance_id; // See Instance ID Note above. | 156 string instance_id; // See Instance ID Note above. |
157 bluetooth.mojom.UUID uuid; | 157 bluetooth.mojom.UUID uuid; |
158 }; | 158 }; |
159 | 159 |
160 // Web Bluetooth Interface that Blink can use to perform | 160 // Web Bluetooth Interface that Blink can use to perform |
161 // Bluetooth GATT Operations on Bluetooth Devices. | 161 // Bluetooth GATT Operations on Bluetooth Devices. |
162 interface WebBluetoothService { | 162 interface WebBluetoothService { |
163 // Sets the client for this WebBluetoothService. The service will notify the | |
164 // client of device events e.g. when a Characteristic's value changes or when | |
165 // a device disconnects. | |
166 SetClient(associated WebBluetoothServiceClient client); | |
167 | |
168 RequestDevice(WebBluetoothRequestDeviceOptions options) | 163 RequestDevice(WebBluetoothRequestDeviceOptions options) |
169 => (WebBluetoothResult result, WebBluetoothDevice? device); | 164 => (WebBluetoothResult result, WebBluetoothDevice? device); |
170 | 165 |
171 // Creates a GATT Connection to a Bluetooth Device identified by |device_id| | 166 // Creates a GATT Connection to a Bluetooth Device identified by |device_id| |
172 // if a connection to the device didn't exist already. If a GATT connection | 167 // if a connection to the device didn't exist already. If a GATT connection |
173 // existed already then this function increases the ref count to keep that | 168 // existed already then this function increases the ref count to keep that |
174 // connection alive. | 169 // connection alive. |
175 RemoteServerConnect(WebBluetoothDeviceId device_id) => (WebBluetoothResult res ult); | 170 RemoteServerConnect(WebBluetoothDeviceId device_id) => ( |
171 WebBluetoothResult result, | |
172 associated WebBluetoothServerClient&? client_request); | |
176 | 173 |
177 // If a GATT connection exists for Device identified by |device_id| then | 174 // If a GATT connection exists for Device identified by |device_id| then |
178 // decreases the ref count for that connection. | 175 // decreases the ref count for that connection. |
179 RemoteServerDisconnect(WebBluetoothDeviceId device_id); | 176 RemoteServerDisconnect(WebBluetoothDeviceId device_id); |
180 | 177 |
181 // Returns the Services of a GATT Device identified by |device_id|. | 178 // Returns the Services of a GATT Device identified by |device_id|. |
182 // If |services_uuid| is present, filters services by |services_uuid|. | 179 // If |services_uuid| is present, filters services by |services_uuid|. |
183 // Otherwise returns all non-blocklisted services. | 180 // Otherwise returns all non-blocklisted services. |
184 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, at most one | 181 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, at most one |
185 // service will be returned. | 182 // service will be returned. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 // |characteristic_instance_id|. The callback is run with | 214 // |characteristic_instance_id|. The callback is run with |
218 // WebBluetoothResult::SUCCESS if the value was successfully | 215 // WebBluetoothResult::SUCCESS if the value was successfully |
219 // written. | 216 // written. |
220 RemoteCharacteristicWriteValue( | 217 RemoteCharacteristicWriteValue( |
221 string characteristic_instance_id, | 218 string characteristic_instance_id, |
222 array<uint8> value) => (WebBluetoothResult result); | 219 array<uint8> value) => (WebBluetoothResult result); |
223 | 220 |
224 // Starts notifications for the characteristic identified by | 221 // Starts notifications for the characteristic identified by |
225 // |characteristic_instance_id|. | 222 // |characteristic_instance_id|. |
226 RemoteCharacteristicStartNotifications( | 223 RemoteCharacteristicStartNotifications( |
227 string characteristic_instance_id) => (WebBluetoothResult result); | 224 string characteristic_instance_id) => ( |
225 WebBluetoothResult result, | |
226 associated WebBluetoothCharacteristicClient&? client_request); | |
228 | 227 |
229 // Stops notifications for the characteristic identified by | 228 // Stops notifications for the characteristic identified by |
230 // |characteristic_instance_id|. | 229 // |characteristic_instance_id|. |
231 RemoteCharacteristicStopNotifications( | 230 RemoteCharacteristicStopNotifications( |
232 string characteristic_instance_id) => (); | 231 string characteristic_instance_id) => (); |
233 | 232 |
234 // Returns the Descriptors of a GATT Characteristic identified by | 233 // Returns the Descriptors of a GATT Characteristic identified by |
235 // |characteristics_instance_id|. | 234 // |characteristics_instance_id|. |
236 // If |descriptor_uuid| is present, filters descriptors by | 235 // If |descriptor_uuid| is present, filters descriptors by |
237 // |descriptor_uuid|. Otherwise returns all non-blocklisted descriptors. | 236 // |descriptor_uuid|. Otherwise returns all non-blocklisted descriptors. |
(...skipping 18 matching lines...) Expand all Loading... | |
256 | 255 |
257 // Writes a value to the descriptor identified by | 256 // Writes a value to the descriptor identified by |
258 // |descriptor_instance_id|. The callback is run with | 257 // |descriptor_instance_id|. The callback is run with |
259 // WebBluetoothResult::SUCCESS if the value was successfully | 258 // WebBluetoothResult::SUCCESS if the value was successfully |
260 // written. | 259 // written. |
261 RemoteDescriptorWriteValue( | 260 RemoteDescriptorWriteValue( |
262 string descriptor_instance_id, | 261 string descriptor_instance_id, |
263 array<uint8> value) => (WebBluetoothResult result); | 262 array<uint8> value) => (WebBluetoothResult result); |
264 }; | 263 }; |
265 | 264 |
266 // Classes should implement this interface and pass an associated pointer | 265 interface WebBluetoothCharacteristicClient { |
ortuno
2017/03/01 04:52:06
Please add comments to both functions.
juncai
2017/03/02 03:23:50
Done.
| |
267 // bound to them to the WebBluetoothService by using SetClient. Classes | 266 RemoteCharacteristicValueChanged(array<uint8> value); |
268 // that do this will be notified of device events e.g. device disconnection. | 267 }; |
269 interface WebBluetoothServiceClient { | |
270 // The characteristic identified by |characteristic_instance_id| has received | |
271 // a notification of value change. | |
272 RemoteCharacteristicValueChanged(string characteristic_instance_id, | |
273 array<uint8> value); | |
274 | 268 |
275 // The device identified by |device_id| has been disconnected. | 269 interface WebBluetoothServerClient { |
276 GattServerDisconnected(WebBluetoothDeviceId device_id); | 270 GattServerDisconnected(); |
ortuno
2017/03/01 04:52:06
nit: GATTServerDisconnected();
juncai
2017/03/02 03:23:49
Done.
| |
277 }; | 271 }; |
OLD | NEW |