| 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 // Errors that can occur during Web Bluetooth execution, which are transformed | 9 // Result codes that can occur during Web Bluetooth execution, which are |
| 10 // to a DOMException in Source/modules/bluetooth/BluetoothError.cpp. | 10 // transformed to a DOMException in Source/modules/bluetooth/BluetoothError.cpp. |
| 11 // | 11 // |
| 12 // These errors all produce constant message strings. If a particular message | 12 // These errors all produce constant message strings. If a particular message |
| 13 // needs a dynamic component, we should add a separate enum so type-checking the | 13 // needs a dynamic component, we should add a separate enum so type-checking the |
| 14 // IPC ensures the dynamic component is passed. | 14 // IPC ensures the dynamic component is passed. |
| 15 enum WebBluetoothError { | 15 enum WebBluetoothResult { |
| 16 SUCCESS, | 16 SUCCESS, |
| 17 // AbortError: | 17 // AbortError: |
| 18 // InvalidModificationError: | 18 // InvalidModificationError: |
| 19 GATT_INVALID_ATTRIBUTE_LENGTH, | 19 GATT_INVALID_ATTRIBUTE_LENGTH, |
| 20 // InvalidStateError: | 20 // InvalidStateError: |
| 21 SERVICE_NO_LONGER_EXISTS, | 21 SERVICE_NO_LONGER_EXISTS, |
| 22 CHARACTERISTIC_NO_LONGER_EXISTS, | 22 CHARACTERISTIC_NO_LONGER_EXISTS, |
| 23 // NetworkError: | 23 // NetworkError: |
| 24 CONNECT_ALREADY_IN_PROGRESS, | 24 CONNECT_ALREADY_IN_PROGRESS, |
| 25 CONNECT_ATTRIBUTE_LENGTH_INVALID, | 25 CONNECT_ATTRIBUTE_LENGTH_INVALID, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 // Web Bluetooth Interface that Blink can use to perform | 111 // Web Bluetooth Interface that Blink can use to perform |
| 112 // Bluetooth GATT Operations on Bluetooth Devices. | 112 // Bluetooth GATT Operations on Bluetooth Devices. |
| 113 interface WebBluetoothService { | 113 interface WebBluetoothService { |
| 114 // Sets the client for this WebBluetoothService. The service will notify the | 114 // Sets the client for this WebBluetoothService. The service will notify the |
| 115 // client of device events e.g. when a Characteristic's value changes or when | 115 // client of device events e.g. when a Characteristic's value changes or when |
| 116 // a device disconnects. | 116 // a device disconnects. |
| 117 SetClient(associated WebBluetoothServiceClient client); | 117 SetClient(associated WebBluetoothServiceClient client); |
| 118 | 118 |
| 119 RequestDevice(WebBluetoothRequestDeviceOptions options) | 119 RequestDevice(WebBluetoothRequestDeviceOptions options) |
| 120 => (WebBluetoothError error, WebBluetoothDevice? device); | 120 => (WebBluetoothResult result, WebBluetoothDevice? device); |
| 121 | 121 |
| 122 // Creates a GATT Connection to a Bluetooth Device with |device_id| if a | 122 // Creates a GATT Connection to a Bluetooth Device with |device_id| if a |
| 123 // connection to the device didn't exist already. If a GATT connection existed | 123 // connection to the device didn't exist already. If a GATT connection existed |
| 124 // already then this function increases the ref count to keep that connection | 124 // already then this function increases the ref count to keep that connection |
| 125 // alive. | 125 // alive. |
| 126 RemoteServerConnect(WebBluetoothDeviceId device_id) => (WebBluetoothError erro
r); | 126 RemoteServerConnect(WebBluetoothDeviceId device_id) => (WebBluetoothResult res
ult); |
| 127 | 127 |
| 128 // If a GATT connection exists for Device with |device_id| then decreases | 128 // If a GATT connection exists for Device with |device_id| then decreases |
| 129 // the ref count for that connection. | 129 // the ref count for that connection. |
| 130 RemoteServerDisconnect(WebBluetoothDeviceId device_id); | 130 RemoteServerDisconnect(WebBluetoothDeviceId device_id); |
| 131 | 131 |
| 132 // If |services_uuid| is present, returns services with |services_uuid|. | 132 // If |services_uuid| is present, returns services with |services_uuid|. |
| 133 // Otherwise returns all non-blacklisted services. | 133 // Otherwise returns all non-blacklisted services. |
| 134 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, only one | 134 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, only one |
| 135 // service will be returned. | 135 // service will be returned. |
| 136 RemoteServerGetPrimaryServices( | 136 RemoteServerGetPrimaryServices( |
| 137 WebBluetoothDeviceId device_id, | 137 WebBluetoothDeviceId device_id, |
| 138 WebBluetoothGATTQueryQuantity quantity, | 138 WebBluetoothGATTQueryQuantity quantity, |
| 139 bluetooth.mojom.UUID? services_uuid) => ( | 139 bluetooth.mojom.UUID? services_uuid) => ( |
| 140 WebBluetoothError error, | 140 WebBluetoothResult result, |
| 141 array<WebBluetoothRemoteGATTService>? services); | 141 array<WebBluetoothRemoteGATTService>? services); |
| 142 | 142 |
| 143 // Returns the Characteristics of a GATT Service with |service_instance_id|. | 143 // Returns the Characteristics of a GATT Service with |service_instance_id|. |
| 144 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, only one | 144 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, only one |
| 145 // characteristic will be returned. | 145 // characteristic will be returned. |
| 146 RemoteServiceGetCharacteristics( | 146 RemoteServiceGetCharacteristics( |
| 147 string service_instance_id, | 147 string service_instance_id, |
| 148 WebBluetoothGATTQueryQuantity quantity, | 148 WebBluetoothGATTQueryQuantity quantity, |
| 149 bluetooth.mojom.UUID? characteristics_uuid) => ( | 149 bluetooth.mojom.UUID? characteristics_uuid) => ( |
| 150 WebBluetoothError error, | 150 WebBluetoothResult result, |
| 151 array<WebBluetoothRemoteGATTCharacteristic>? characteristics); | 151 array<WebBluetoothRemoteGATTCharacteristic>? characteristics); |
| 152 | 152 |
| 153 // Reads the value for characteristic with | 153 // Reads the value for characteristic with |
| 154 // |characteristic_instance_id|. If the value is successfully read the | 154 // |characteristic_instance_id|. If the value is successfully read the |
| 155 // callback will be run with WebBluetoothError::SUCCESS and the | 155 // callback will be run with WebBluetoothResult::SUCCESS and the |
| 156 // characteristic's value. If the value is not successfully read the | 156 // characteristic's value. If the value is not successfully read the |
| 157 // callback with be run with the corresponding error and nullptr for value. | 157 // callback with be run with the corresponding error and nullptr for value. |
| 158 RemoteCharacteristicReadValue( | 158 RemoteCharacteristicReadValue( |
| 159 string characteristic_instance_id) => ( | 159 string characteristic_instance_id) => ( |
| 160 WebBluetoothError error, | 160 WebBluetoothResult result, |
| 161 array<uint8>? value); | 161 array<uint8>? value); |
| 162 | 162 |
| 163 // Writes a value to the characteristic with | 163 // Writes a value to the characteristic with |
| 164 // |characteristic_instance_id|. The callback is run with | 164 // |characteristic_instance_id|. The callback is run with |
| 165 // WebBluetoothError::SUCCESS if the value was successfully | 165 // WebBluetoothResult::SUCCESS if the value was successfully |
| 166 // written. | 166 // written. |
| 167 RemoteCharacteristicWriteValue( | 167 RemoteCharacteristicWriteValue( |
| 168 string characteristic_instance_id, | 168 string characteristic_instance_id, |
| 169 array<uint8> value) => (WebBluetoothError error); | 169 array<uint8> value) => (WebBluetoothResult result); |
| 170 | 170 |
| 171 // Starts notifications for the characteristic with | 171 // Starts notifications for the characteristic with |
| 172 // |characteristic_instance_id|. | 172 // |characteristic_instance_id|. |
| 173 RemoteCharacteristicStartNotifications( | 173 RemoteCharacteristicStartNotifications( |
| 174 string characteristic_instance_id) => (WebBluetoothError error); | 174 string characteristic_instance_id) => (WebBluetoothResult result); |
| 175 | 175 |
| 176 // Stops notifications for the characteristic with | 176 // Stops notifications for the characteristic with |
| 177 // |characteristic_instance_id|. | 177 // |characteristic_instance_id|. |
| 178 RemoteCharacteristicStopNotifications( | 178 RemoteCharacteristicStopNotifications( |
| 179 string characteristic_instance_id) => (); | 179 string characteristic_instance_id) => (); |
| 180 }; | 180 }; |
| 181 | 181 |
| 182 // Classes should implement this interface and pass an associated pointer | 182 // Classes should implement this interface and pass an associated pointer |
| 183 // bound to them to the WebBluetoothService by using SetClient. Classes | 183 // bound to them to the WebBluetoothService by using SetClient. Classes |
| 184 // that do this will be notified of device events e.g. device disconnection. | 184 // that do this will be notified of device events e.g. device disconnection. |
| 185 interface WebBluetoothServiceClient { | 185 interface WebBluetoothServiceClient { |
| 186 RemoteCharacteristicValueChanged(string characteristic_instance_id, | 186 RemoteCharacteristicValueChanged(string characteristic_instance_id, |
| 187 array<uint8> value); | 187 array<uint8> value); |
| 188 GattServerDisconnected(WebBluetoothDeviceId device_id); | 188 GattServerDisconnected(WebBluetoothDeviceId device_id); |
| 189 }; | 189 }; |
| OLD | NEW |