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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 }; | 141 }; |
142 | 142 |
143 struct WebBluetoothRemoteGATTDescriptor { | 143 struct WebBluetoothRemoteGATTDescriptor { |
144 string instance_id; // See Instance ID Note above. | 144 string instance_id; // See Instance ID Note above. |
145 bluetooth.mojom.UUID uuid; | 145 bluetooth.mojom.UUID uuid; |
146 }; | 146 }; |
147 | 147 |
148 // Web Bluetooth Interface that Blink can use to perform | 148 // Web Bluetooth Interface that Blink can use to perform |
149 // Bluetooth GATT Operations on Bluetooth Devices. | 149 // Bluetooth GATT Operations on Bluetooth Devices. |
150 interface WebBluetoothService { | 150 interface WebBluetoothService { |
151 // Sets the client for this WebBluetoothService. The service will notify the | |
152 // client of device events e.g. when a Characteristic's value changes or when | |
153 // a device disconnects. | |
154 SetClient(associated WebBluetoothServiceClient client); | |
155 | |
156 RequestDevice(WebBluetoothRequestDeviceOptions options) | 151 RequestDevice(WebBluetoothRequestDeviceOptions options) |
157 => (WebBluetoothResult result, WebBluetoothDevice? device); | 152 => (WebBluetoothResult result, WebBluetoothDevice? device); |
158 | 153 |
159 // Creates a GATT Connection to a Bluetooth Device identified by |device_id| | 154 // Creates a GATT Connection to a Bluetooth Device identified by |device_id| |
160 // if a connection to the device didn't exist already. If a GATT connection | 155 // if a connection to the device didn't exist already. If a GATT connection |
161 // existed already then this function increases the ref count to keep that | 156 // existed already then this function increases the ref count to keep that |
162 // connection alive. | 157 // connection alive. |
163 RemoteServerConnect(WebBluetoothDeviceId device_id) => (WebBluetoothResult res
ult); | 158 // Returns the result of the connection request. |
| 159 RemoteServerConnect( |
| 160 WebBluetoothDeviceId device_id, |
| 161 associated WebBluetoothServerClient client) => (WebBluetoothResult result); |
164 | 162 |
165 // If a GATT connection exists for Device identified by |device_id| then | 163 // If a GATT connection exists for Device identified by |device_id| then |
166 // decreases the ref count for that connection. | 164 // decreases the ref count for that connection. |
167 RemoteServerDisconnect(WebBluetoothDeviceId device_id); | 165 RemoteServerDisconnect(WebBluetoothDeviceId device_id); |
168 | 166 |
169 // Returns the Services of a GATT Device identified by |device_id|. | 167 // Returns the Services of a GATT Device identified by |device_id|. |
170 // If |services_uuid| is present, filters services by |services_uuid|. | 168 // If |services_uuid| is present, filters services by |services_uuid|. |
171 // Otherwise returns all non-blocklisted services. | 169 // Otherwise returns all non-blocklisted services. |
172 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, at most one | 170 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, at most one |
173 // service will be returned. | 171 // service will be returned. |
(...skipping 30 matching lines...) Expand all Loading... |
204 // Writes a value to the characteristic identified by | 202 // Writes a value to the characteristic identified by |
205 // |characteristic_instance_id|. The callback is run with | 203 // |characteristic_instance_id|. The callback is run with |
206 // WebBluetoothResult::SUCCESS if the value was successfully | 204 // WebBluetoothResult::SUCCESS if the value was successfully |
207 // written. | 205 // written. |
208 RemoteCharacteristicWriteValue( | 206 RemoteCharacteristicWriteValue( |
209 string characteristic_instance_id, | 207 string characteristic_instance_id, |
210 array<uint8> value) => (WebBluetoothResult result); | 208 array<uint8> value) => (WebBluetoothResult result); |
211 | 209 |
212 // Starts notifications for the characteristic identified by | 210 // Starts notifications for the characteristic identified by |
213 // |characteristic_instance_id|. | 211 // |characteristic_instance_id|. |
| 212 // Returns the result of the connection request. |
214 RemoteCharacteristicStartNotifications( | 213 RemoteCharacteristicStartNotifications( |
215 string characteristic_instance_id) => (WebBluetoothResult result); | 214 string characteristic_instance_id, |
| 215 associated WebBluetoothCharacteristicClient client) => ( |
| 216 WebBluetoothResult result); |
216 | 217 |
217 // Stops notifications for the characteristic identified by | 218 // Stops notifications for the characteristic identified by |
218 // |characteristic_instance_id|. | 219 // |characteristic_instance_id|. |
219 RemoteCharacteristicStopNotifications( | 220 RemoteCharacteristicStopNotifications( |
220 string characteristic_instance_id) => (); | 221 string characteristic_instance_id) => (); |
221 | 222 |
222 // Returns the Descriptors of a GATT Characteristic identified by | 223 // Returns the Descriptors of a GATT Characteristic identified by |
223 // |characteristics_instance_id|. | 224 // |characteristics_instance_id|. |
224 // If |descriptor_uuid| is present, filters descriptors by | 225 // If |descriptor_uuid| is present, filters descriptors by |
225 // |descriptor_uuid|. Otherwise returns all non-blocklisted descriptors. | 226 // |descriptor_uuid|. Otherwise returns all non-blocklisted descriptors. |
(...skipping 18 matching lines...) Expand all Loading... |
244 | 245 |
245 // Writes a value to the descriptor identified by | 246 // Writes a value to the descriptor identified by |
246 // |descriptor_instance_id|. The callback is run with | 247 // |descriptor_instance_id|. The callback is run with |
247 // WebBluetoothResult::SUCCESS if the value was successfully | 248 // WebBluetoothResult::SUCCESS if the value was successfully |
248 // written. | 249 // written. |
249 RemoteDescriptorWriteValue( | 250 RemoteDescriptorWriteValue( |
250 string descriptor_instance_id, | 251 string descriptor_instance_id, |
251 array<uint8> value) => (WebBluetoothResult result); | 252 array<uint8> value) => (WebBluetoothResult result); |
252 }; | 253 }; |
253 | 254 |
254 // Classes should implement this interface and pass an associated pointer | 255 // Classes that implement this interface will be notified of device events. |
255 // bound to them to the WebBluetoothService by using SetClient. Classes | 256 interface WebBluetoothServerClient { |
256 // that do this will be notified of device events e.g. device disconnection. | 257 // Called when a device disconnects. |
257 interface WebBluetoothServiceClient { | 258 GATTServerDisconnected(); |
258 // The characteristic identified by |characteristic_instance_id| has received | 259 }; |
259 // a notification of value change. | |
260 RemoteCharacteristicValueChanged(string characteristic_instance_id, | |
261 array<uint8> value); | |
262 | 260 |
263 // The device identified by |device_id| has been disconnected. | 261 // Classes that implement this interface will be notified of characteristic |
264 GattServerDisconnected(WebBluetoothDeviceId device_id); | 262 // events. |
| 263 interface WebBluetoothCharacteristicClient { |
| 264 // Called when we receive a notification for the characteristic. |
| 265 RemoteCharacteristicValueChanged(array<uint8> value); |
265 }; | 266 }; |
OLD | NEW |