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. Returns false if this session is inactive. | |
53 Stop() => (bool success); | |
scheib
2017/01/05 01:02:20
Copy more of the comment from bluetooth_discovery_
mbrunson
2017/01/05 01:19:14
Ok. I've copied the original comment from bluetoot
| |
54 }; | |
55 | |
42 interface Adapter { | 56 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 | 57 // 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 | 58 // Device if the connection was succesful. The GATT connection is tied to the |
48 // the lifetime of the Device message pipe. | 59 // the lifetime of the Device message pipe. |
49 ConnectToDevice(string address) => (ConnectResult result, Device? device); | 60 ConnectToDevice(string address) => (ConnectResult result, Device? device); |
50 | 61 |
51 // Retrieves the list of the devices known by the adapter including Connected | 62 // Retrieves the list of the devices known by the adapter including Connected |
52 // Devices, GATT Connected Devices, Paired Devices and Devices discovered | 63 // Devices, GATT Connected Devices, Paired Devices and Devices discovered |
53 // during a classic or low-energy scan. | 64 // during a classic or low-energy scan. |
54 GetDevices() => (array<DeviceInfo> devices); | 65 GetDevices() => (array<DeviceInfo> devices); |
55 | 66 |
67 // Gets basic information about the adapter. | |
68 GetInfo() => (AdapterInfo info); | |
69 | |
56 // Sets the client that listens for the adapter's events. | 70 // Sets the client that listens for the adapter's events. |
57 SetClient(AdapterClient client); | 71 SetClient(AdapterClient client); |
72 | |
73 // Requests the adapter to start a new discovery session. Returns null if | |
74 // session not created successfully. | |
75 StartDiscoverySession() => (DiscoverySession? session); | |
58 }; | 76 }; |
59 | 77 |
60 interface AdapterClient { | 78 interface AdapterClient { |
79 // Called when the discovering state of the adapter changes. | |
80 DiscoveringChanged(bool discovering); | |
81 | |
61 // Called the first time a device is discovered. | 82 // Called the first time a device is discovered. |
62 DeviceAdded(DeviceInfo device); | 83 DeviceAdded(DeviceInfo device); |
63 | 84 |
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: | 85 // Called when one of the following properties of a device changes: |
68 // Address, appearance, Bluetooth class, Inquiry RSSI, Inquiry TX Power, | 86 // Address, appearance, Bluetooth class, Inquiry RSSI, Inquiry TX Power, |
69 // Service UUIDs, Connectionable state, Connection state, Pairing state, | 87 // Service UUIDs, Connectionable state, Connection state, Pairing state, |
70 // Trustable state. | 88 // Trustable state. |
71 // Generally called for each advertisement packet recevied, but this is not | 89 // Generally called for each advertisement packet recevied, but this is not |
72 // guaranteed on ChromeOS or Linux. Because the RSSI is always changing, | 90 // guaranteed on ChromeOS or Linux. Because the RSSI is always changing, |
73 // it's very likely this will be called for each advertising packet. | 91 // it's very likely this will be called for each advertising packet. |
74 DeviceChanged(DeviceInfo device); | 92 DeviceChanged(DeviceInfo device); |
93 | |
94 // Called after the device hasn't been seen for 3 minutes. | |
95 DeviceRemoved(DeviceInfo device); | |
96 | |
75 }; | 97 }; |
76 | 98 |
77 interface AdapterFactory { | 99 interface AdapterFactory { |
78 // Gets an Adapter interface. Returns null if Bluetooth is not supported. | 100 // Gets an Adapter interface. Returns null if Bluetooth is not supported. |
79 GetAdapter() => (Adapter? adapter); | 101 GetAdapter() => (Adapter? adapter); |
80 }; | 102 }; |
OLD | NEW |