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 | 9 // Possible errors sent as a response by Adapter.ConnectToDevice on a Device |
10 // connection request. | 10 // connection request. |
(...skipping 21 matching lines...) Expand all Loading... |
32 struct AdapterInfo { | 32 struct AdapterInfo { |
33 string address; | 33 string address; |
34 string name; | 34 string name; |
35 bool initialized; | 35 bool initialized; |
36 bool present; | 36 bool present; |
37 bool powered; | 37 bool powered; |
38 bool discoverable; | 38 bool discoverable; |
39 bool discovering; | 39 bool discovering; |
40 }; | 40 }; |
41 | 41 |
| 42 interface DiscoverySession { |
| 43 // Returns true if the session is active, false otherwise. If false, the |
| 44 // adapter might still be discovering as there might still be other active |
| 45 // sessions; this just means that this instance no longer has a say in |
| 46 // whether or not discovery should continue. In this case, a new |
| 47 // DiscoverySession should be started to make sure that device discovery |
| 48 // continues. |
| 49 IsActive() => (bool active); |
| 50 |
| 51 // Requests this discovery session instance to stop. If this instance is |
| 52 // active, the session will stop. After a successful invocation, the |
| 53 // adapter may or may not stop device discovery, depending on whether or not |
| 54 // other active discovery sessions are present. Users are highly encouraged |
| 55 // to call this method to end a discovery session, instead of relying on |
| 56 // disconnecting the message pipe, so that they can respond to the result. |
| 57 // Returns true on success. Returns false if this session is inactive or an |
| 58 // error occurs while stopping the session. |
| 59 Stop() => (bool success); |
| 60 }; |
| 61 |
42 interface Adapter { | 62 interface Adapter { |
43 // Gets basic information about the adapter. | |
44 GetInfo() => (AdapterInfo info); | |
45 | |
46 // Creates a GATT connection to the device with |address| and returns a | 63 // Creates a GATT connection to the device with |address| and returns a |
47 // Device if the connection was succesful. The GATT connection is tied to the | 64 // Device if the connection was succesful. The GATT connection is tied to the |
48 // the lifetime of the Device message pipe. | 65 // the lifetime of the Device message pipe. |
49 ConnectToDevice(string address) => (ConnectResult result, Device? device); | 66 ConnectToDevice(string address) => (ConnectResult result, Device? device); |
50 | 67 |
51 // Retrieves the list of the devices known by the adapter including Connected | 68 // Retrieves the list of the devices known by the adapter including Connected |
52 // Devices, GATT Connected Devices, Paired Devices and Devices discovered | 69 // Devices, GATT Connected Devices, Paired Devices and Devices discovered |
53 // during a classic or low-energy scan. | 70 // during a classic or low-energy scan. |
54 GetDevices() => (array<DeviceInfo> devices); | 71 GetDevices() => (array<DeviceInfo> devices); |
55 | 72 |
| 73 // Gets basic information about the adapter. |
| 74 GetInfo() => (AdapterInfo info); |
| 75 |
56 // Sets the client that listens for the adapter's events. | 76 // Sets the client that listens for the adapter's events. |
57 SetClient(AdapterClient client); | 77 SetClient(AdapterClient client); |
| 78 |
| 79 // Requests the adapter to start a new discovery session. Returns null if |
| 80 // session not created successfully. |
| 81 StartDiscoverySession() => (DiscoverySession? session); |
58 }; | 82 }; |
59 | 83 |
60 interface AdapterClient { | 84 interface AdapterClient { |
| 85 // Called when the discovering state of the adapter changes. |
| 86 DiscoveringChanged(bool discovering); |
| 87 |
61 // Called the first time a device is discovered. | 88 // Called the first time a device is discovered. |
62 DeviceAdded(DeviceInfo device); | 89 DeviceAdded(DeviceInfo device); |
63 | 90 |
64 // Called after the device hasn't been seen for 3 minutes. | |
65 DeviceRemoved(DeviceInfo device); | |
66 | |
67 // Called when one of the following properties of a device changes: | 91 // Called when one of the following properties of a device changes: |
68 // Address, appearance, Bluetooth class, Inquiry RSSI, Inquiry TX Power, | 92 // Address, appearance, Bluetooth class, Inquiry RSSI, Inquiry TX Power, |
69 // Service UUIDs, Connectionable state, Connection state, Pairing state, | 93 // Service UUIDs, Connectionable state, Connection state, Pairing state, |
70 // Trustable state. | 94 // Trustable state. |
71 // Generally called for each advertisement packet recevied, but this is not | 95 // Generally called for each advertisement packet recevied, but this is not |
72 // guaranteed on ChromeOS or Linux. Because the RSSI is always changing, | 96 // guaranteed on ChromeOS or Linux. Because the RSSI is always changing, |
73 // it's very likely this will be called for each advertising packet. | 97 // it's very likely this will be called for each advertising packet. |
74 DeviceChanged(DeviceInfo device); | 98 DeviceChanged(DeviceInfo device); |
| 99 |
| 100 // Called after the device hasn't been seen for 3 minutes. |
| 101 DeviceRemoved(DeviceInfo device); |
75 }; | 102 }; |
76 | 103 |
77 interface AdapterFactory { | 104 interface AdapterFactory { |
78 // Gets an Adapter interface. Returns null if Bluetooth is not supported. | 105 // Gets an Adapter interface. Returns null if Bluetooth is not supported. |
79 GetAdapter() => (Adapter? adapter); | 106 GetAdapter() => (Adapter? adapter); |
80 }; | 107 }; |
OLD | NEW |