| 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 bluetooth.mojom; | 5 module bluetooth.mojom; |
| 6 | 6 |
| 7 import "device/bluetooth/public/interfaces/device.mojom"; | 7 import "device/bluetooth/public/interfaces/device.mojom"; |
| 8 | 8 |
| 9 // Possible errors sent as a response by Adapter.ConnectToDevice on a Device |
| 10 // connection request. |
| 11 enum ConnectResult { |
| 12 SUCCESS, |
| 13 ATTRIBUTE_LENGTH_INVALID, |
| 14 AUTH_CANCELED, |
| 15 AUTH_FAILED, |
| 16 AUTH_REJECTED, |
| 17 AUTH_TIMEOUT, |
| 18 CONNECTION_CONGESTED, |
| 19 FAILED, |
| 20 INPROGRESS, |
| 21 INSUFFICIENT_ENCRYPTION, |
| 22 OFFSET_INVALID, |
| 23 READ_NOT_PERMITTED, |
| 24 REQUEST_NOT_SUPPORTED, |
| 25 UNKNOWN, |
| 26 UNSUPPORTED_DEVICE, |
| 27 WRITE_NOT_PERMITTED, |
| 28 DEVICE_NO_LONGER_IN_RANGE, |
| 29 UNTRANSLATED_CONNECT_ERROR_CODE |
| 30 }; |
| 31 |
| 9 struct AdapterInfo { | 32 struct AdapterInfo { |
| 10 string address; | 33 string address; |
| 11 string name; | 34 string name; |
| 12 bool initialized; | 35 bool initialized; |
| 13 bool present; | 36 bool present; |
| 14 bool powered; | 37 bool powered; |
| 15 bool discoverable; | 38 bool discoverable; |
| 16 bool discovering; | 39 bool discovering; |
| 17 }; | 40 }; |
| 18 | 41 |
| 19 interface Adapter { | 42 interface Adapter { |
| 20 // Gets basic information about the adapter. | 43 // Gets basic information about the adapter. |
| 21 GetInfo() => (AdapterInfo info); | 44 GetInfo() => (AdapterInfo info); |
| 22 | 45 |
| 23 // Gets the Device service for the device at the given address. | 46 // Creates a GATT connection to the device with |address| and returns a |
| 24 GetDevice(string address) => (Device? device); | 47 // Device if the connection was succesful. The GATT connection is tied to the |
| 48 // the lifetime of the Device message pipe. |
| 49 ConnectToDevice(string address) => (ConnectResult error, Device? device); |
| 25 | 50 |
| 26 // Retrieves the list of the devices known by the adapter including Connected | 51 // Retrieves the list of the devices known by the adapter including Connected |
| 27 // Devices, GATT Connected Devices, Paired Devices and Devices discovered | 52 // Devices, GATT Connected Devices, Paired Devices and Devices discovered |
| 28 // during a classic or low-energy scan. | 53 // during a classic or low-energy scan. |
| 29 GetDevices() => (array<DeviceInfo> devices); | 54 GetDevices() => (array<DeviceInfo> devices); |
| 30 | 55 |
| 31 // Sets the client that listens for the adapter's events. | 56 // Sets the client that listens for the adapter's events. |
| 32 SetClient(AdapterClient client); | 57 SetClient(AdapterClient client); |
| 33 }; | 58 }; |
| 34 | 59 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 46 // Generally called for each advertisement packet recevied, but this is not | 71 // Generally called for each advertisement packet recevied, but this is not |
| 47 // guaranteed on ChromeOS or Linux. Because the RSSI is always changing, | 72 // guaranteed on ChromeOS or Linux. Because the RSSI is always changing, |
| 48 // it's very likely this will be called for each advertising packet. | 73 // it's very likely this will be called for each advertising packet. |
| 49 DeviceChanged(DeviceInfo device); | 74 DeviceChanged(DeviceInfo device); |
| 50 }; | 75 }; |
| 51 | 76 |
| 52 interface AdapterFactory { | 77 interface AdapterFactory { |
| 53 // Gets an Adapter interface. Returns null if Bluetooth is not supported. | 78 // Gets an Adapter interface. Returns null if Bluetooth is not supported. |
| 54 GetAdapter() => (Adapter? adapter); | 79 GetAdapter() => (Adapter? adapter); |
| 55 }; | 80 }; |
| OLD | NEW |