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