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 // Result codes that can occur during Web Bluetooth execution, which are | 9 // Result codes that can occur during Web Bluetooth execution, which are |
10 // transformed 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 WebBluetoothResult { | 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 DESCRIPTOR_NO_LONGER_EXISTS, |
23 // NetworkError: | 24 // NetworkError: |
24 CONNECT_ALREADY_IN_PROGRESS, | 25 CONNECT_ALREADY_IN_PROGRESS, |
25 CONNECT_ATTRIBUTE_LENGTH_INVALID, | 26 CONNECT_ATTRIBUTE_LENGTH_INVALID, |
26 CONNECT_AUTH_CANCELED, | 27 CONNECT_AUTH_CANCELED, |
27 CONNECT_AUTH_FAILED, | 28 CONNECT_AUTH_FAILED, |
28 CONNECT_AUTH_REJECTED, | 29 CONNECT_AUTH_REJECTED, |
29 CONNECT_AUTH_TIMEOUT, | 30 CONNECT_AUTH_TIMEOUT, |
30 CONNECT_CONNECTION_CONGESTED, | 31 CONNECT_CONNECTION_CONGESTED, |
31 CONNECT_INSUFFICIENT_ENCRYPTION, | 32 CONNECT_INSUFFICIENT_ENCRYPTION, |
32 CONNECT_OFFSET_INVALID, | 33 CONNECT_OFFSET_INVALID, |
(...skipping 11 matching lines...) Expand all Loading... |
44 NO_BLUETOOTH_ADAPTER, | 45 NO_BLUETOOTH_ADAPTER, |
45 CHOSEN_DEVICE_VANISHED, | 46 CHOSEN_DEVICE_VANISHED, |
46 CHOOSER_CANCELLED, | 47 CHOOSER_CANCELLED, |
47 CHOOSER_NOT_SHOWN_API_GLOBALLY_DISABLED, | 48 CHOOSER_NOT_SHOWN_API_GLOBALLY_DISABLED, |
48 CHOOSER_NOT_SHOWN_API_LOCALLY_DISABLED, | 49 CHOOSER_NOT_SHOWN_API_LOCALLY_DISABLED, |
49 CHOOSER_NOT_SHOWN_USER_DENIED_PERMISSION_TO_SCAN, | 50 CHOOSER_NOT_SHOWN_USER_DENIED_PERMISSION_TO_SCAN, |
50 SERVICE_NOT_FOUND, | 51 SERVICE_NOT_FOUND, |
51 NO_SERVICES_FOUND, | 52 NO_SERVICES_FOUND, |
52 CHARACTERISTIC_NOT_FOUND, | 53 CHARACTERISTIC_NOT_FOUND, |
53 NO_CHARACTERISTICS_FOUND, | 54 NO_CHARACTERISTICS_FOUND, |
| 55 DESCRIPTOR_NOT_FOUND, |
| 56 NO_DESCRIPTORS_FOUND, |
54 WEB_BLUETOOTH_NOT_SUPPORTED, | 57 WEB_BLUETOOTH_NOT_SUPPORTED, |
55 BLUETOOTH_LOW_ENERGY_NOT_AVAILABLE, | 58 BLUETOOTH_LOW_ENERGY_NOT_AVAILABLE, |
56 // NotSupportedError: | 59 // NotSupportedError: |
57 GATT_UNKNOWN_ERROR, | 60 GATT_UNKNOWN_ERROR, |
58 GATT_UNKNOWN_FAILURE, | 61 GATT_UNKNOWN_FAILURE, |
59 GATT_NOT_PERMITTED, | 62 GATT_NOT_PERMITTED, |
60 GATT_NOT_SUPPORTED, | 63 GATT_NOT_SUPPORTED, |
61 GATT_UNTRANSLATED_ERROR_CODE, | 64 GATT_UNTRANSLATED_ERROR_CODE, |
62 // SecurityError: | 65 // SecurityError: |
63 GATT_NOT_AUTHORIZED, | 66 GATT_NOT_AUTHORIZED, |
| 67 BLACKLISTED_DESCRIPTOR_UUID, |
64 BLACKLISTED_CHARACTERISTIC_UUID, | 68 BLACKLISTED_CHARACTERISTIC_UUID, |
65 BLACKLISTED_READ, | 69 BLACKLISTED_READ, |
66 BLACKLISTED_WRITE, | 70 BLACKLISTED_WRITE, |
67 NOT_ALLOWED_TO_ACCESS_ANY_SERVICE, | 71 NOT_ALLOWED_TO_ACCESS_ANY_SERVICE, |
68 NOT_ALLOWED_TO_ACCESS_SERVICE, | 72 NOT_ALLOWED_TO_ACCESS_SERVICE, |
69 REQUEST_DEVICE_WITH_BLACKLISTED_UUID, | 73 REQUEST_DEVICE_WITH_BLACKLISTED_UUID, |
70 REQUEST_DEVICE_FROM_CROSS_ORIGIN_IFRAME, | 74 REQUEST_DEVICE_FROM_CROSS_ORIGIN_IFRAME, |
71 REQUEST_DEVICE_WITHOUT_FRAME, | 75 REQUEST_DEVICE_WITHOUT_FRAME, |
72 }; | 76 }; |
73 | 77 |
(...skipping 28 matching lines...) Expand all Loading... |
102 string instance_id; | 106 string instance_id; |
103 string uuid; | 107 string uuid; |
104 }; | 108 }; |
105 | 109 |
106 struct WebBluetoothRemoteGATTCharacteristic { | 110 struct WebBluetoothRemoteGATTCharacteristic { |
107 string instance_id; | 111 string instance_id; |
108 string uuid; | 112 string uuid; |
109 uint32 properties; | 113 uint32 properties; |
110 }; | 114 }; |
111 | 115 |
| 116 struct WebBluetoothRemoteGATTDescriptor { |
| 117 string instance_id; |
| 118 string uuid; |
| 119 }; |
| 120 |
112 // Web Bluetooth Interface that Blink can use to perform | 121 // Web Bluetooth Interface that Blink can use to perform |
113 // Bluetooth GATT Operations on Bluetooth Devices. | 122 // Bluetooth GATT Operations on Bluetooth Devices. |
114 interface WebBluetoothService { | 123 interface WebBluetoothService { |
115 // Sets the client for this WebBluetoothService. The service will notify the | 124 // Sets the client for this WebBluetoothService. The service will notify the |
116 // client of device events e.g. when a Characteristic's value changes or when | 125 // client of device events e.g. when a Characteristic's value changes or when |
117 // a device disconnects. | 126 // a device disconnects. |
118 SetClient(associated WebBluetoothServiceClient client); | 127 SetClient(associated WebBluetoothServiceClient client); |
119 | 128 |
120 RequestDevice(WebBluetoothRequestDeviceOptions options) | 129 RequestDevice(WebBluetoothRequestDeviceOptions options) |
121 => (WebBluetoothResult result, WebBluetoothDevice? device); | 130 => (WebBluetoothResult result, WebBluetoothDevice? device); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 180 |
172 // Starts notifications for the characteristic with | 181 // Starts notifications for the characteristic with |
173 // |characteristic_instance_id|. | 182 // |characteristic_instance_id|. |
174 RemoteCharacteristicStartNotifications( | 183 RemoteCharacteristicStartNotifications( |
175 string characteristic_instance_id) => (WebBluetoothResult result); | 184 string characteristic_instance_id) => (WebBluetoothResult result); |
176 | 185 |
177 // Stops notifications for the characteristic with | 186 // Stops notifications for the characteristic with |
178 // |characteristic_instance_id|. | 187 // |characteristic_instance_id|. |
179 RemoteCharacteristicStopNotifications( | 188 RemoteCharacteristicStopNotifications( |
180 string characteristic_instance_id) => (); | 189 string characteristic_instance_id) => (); |
| 190 |
| 191 // Returns the Descriptors of a GATT Characteristics with |service_instance_id
|. |
| 192 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, only one |
| 193 // descriptor will be returned. |
| 194 RemoteCharacteristicGetDescriptors( |
| 195 string characteristics_instance_id, |
| 196 WebBluetoothGATTQueryQuantity quantity, |
| 197 bluetooth.mojom.UUID? characteristics_uuid) => ( |
| 198 WebBluetoothResult result, |
| 199 array<WebBluetoothRemoteGATTDescriptor>? descriptors); |
| 200 |
| 201 // Reads the value for descriptor with |
| 202 // |descriptor_instance_id|. If the value is successfully read the |
| 203 // callback will be run with WebBluetoothResult::SUCCESS and the |
| 204 // descriptor's value. If the value is not successfully read the |
| 205 // callback with be run with the corresponding error and nullptr for value. |
| 206 RemoteDescriptorReadValue( |
| 207 string descriptor_instance_id) => ( |
| 208 WebBluetoothResult result, |
| 209 array<uint8>? value); |
| 210 |
| 211 // Writes a value to the descriptor with |
| 212 // |descriptor_instance_id|. The callback is run with |
| 213 // WebBluetoothResult::SUCCESS if the value was successfully |
| 214 // written. |
| 215 RemoteDescriptorWriteValue( |
| 216 string descriptor_instance_id, |
| 217 array<uint8> value) => (WebBluetoothResult result); |
181 }; | 218 }; |
182 | 219 |
183 // Classes should implement this interface and pass an associated pointer | 220 // Classes should implement this interface and pass an associated pointer |
184 // bound to them to the WebBluetoothService by using SetClient. Classes | 221 // bound to them to the WebBluetoothService by using SetClient. Classes |
185 // that do this will be notified of device events e.g. device disconnection. | 222 // that do this will be notified of device events e.g. device disconnection. |
186 interface WebBluetoothServiceClient { | 223 interface WebBluetoothServiceClient { |
187 RemoteCharacteristicValueChanged(string characteristic_instance_id, | 224 RemoteCharacteristicValueChanged(string characteristic_instance_id, |
188 array<uint8> value); | 225 array<uint8> value); |
189 GattServerDisconnected(WebBluetoothDeviceId device_id); | 226 GattServerDisconnected(WebBluetoothDeviceId device_id); |
190 }; | 227 }; |
OLD | NEW |