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