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