OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Bluetooth API. | |
6 // TODO(bryeung): mark this API as ChromeOS only (see crbug.com/119398). | |
7 | |
8 [nodoc] namespace experimental.bluetooth { | |
9 dictionary Device { | |
10 DOMString address; | |
11 DOMString name; | |
12 }; | |
13 | |
14 dictionary Socket { | |
15 long id; | |
16 }; | |
17 | |
18 // TODO(bryeung): This is a temporary hack until Blobs are supported | |
19 dictionary Blob { | |
20 DOMString data; | |
21 }; | |
22 | |
23 dictionary OutOfBandPairingData { | |
24 // Simple Pairing Hash C | |
25 // Always 16 octets long. | |
26 // TODO(bryeung): this should really be an octet[] | |
27 DOMString hash; | |
28 | |
29 // Simple Pairing Randomizer R | |
30 // Always 16 octets long. | |
31 // TODO(bryeung): this should really be an octet[] | |
32 DOMString randomizer; | |
33 }; | |
34 | |
35 // Reports failures via chrome.extension.lastError. | |
36 callback ResultCallback = void (); | |
37 callback BooleanCallback = void (boolean result); | |
38 callback AddressCallback = void (DOMString result); | |
39 callback DevicesCallback = void (Device[] result); | |
40 callback SocketCallback = void (Socket result); | |
41 callback DataCallback = void (Blob result); | |
42 callback OutOfBandPairingDataCallback = void (OutOfBandPairingData data); | |
43 | |
44 interface Functions { | |
45 // Checks if the system has bluetooth support. | |
46 // |callback| : Called with the boolean result. | |
47 static void isAvailable(BooleanCallback callback); | |
48 | |
49 // Checks if the system's bluetooth module has power. | |
50 // |callback| : Called with the boolean result. | |
51 static void isPowered(BooleanCallback callback); | |
52 | |
53 // Get the bluetooth address of the system's bluetooth module. | |
54 // |callback| : Called with the address, or null if there was an error. | |
55 static void getAddress(AddressCallback callback); | |
56 | |
57 // Get a list of bluetooth devices that support a service. | |
58 // |service| : The UUID of the desired service. | |
59 // |callback| : Called with an array of Device objects, all of which | |
60 // provide a service with UUID equal to |uuid|. | |
61 static void getDevicesWithServiceUUID( | |
62 DOMString uuid, DevicesCallback callback); | |
63 | |
64 // Get a list of bluetooth devices that support a service. | |
65 // |service| : The name of the desired service. | |
66 // |callback| : Called with an array of Device objects, all of which | |
67 // provide a service with name equal to |name|. | |
68 static void getDevicesWithServiceName( | |
69 DOMString name, DevicesCallback callback); | |
70 | |
71 // Connect to a service on a device. | |
72 // |device| : The target device. | |
73 // |service| : The target service UUID. | |
74 // |callback| : Called when the connection is established with a Socket | |
75 // that can be used to communicate with |device|. | |
76 static void connect( | |
77 Device device, DOMString service, SocketCallback callback); | |
78 | |
79 // Close a bluetooth connection. | |
80 // |socket| : The socket to disconnect. | |
81 // |callback| : Called to indicate success or failure. | |
82 static void disconnect(Socket socket, optional ResultCallback callback); | |
83 | |
84 // Read data from a bluetooth connection. | |
85 // |socket| : The socket to read from. | |
86 // |callback| : Called with the data when it is available. | |
87 static void read(Socket socket, DataCallback callback); | |
88 | |
89 // Write data to a bluetooth connection. | |
90 // |socket| : The socket to write to. | |
91 // |data| : The data to write. | |
92 // |callback| : Called to indicate success or failure. | |
93 static void write( | |
94 Socket socket, Blob data, optional ResultCallback callback); | |
95 | |
96 // Get the local Out of Band Pairing data. | |
97 // |callback| : Called with the data. | |
98 static void getOutOfBandPairingData(OutOfBandPairingDataCallback callback); | |
99 | |
100 // Set the Out of Band Pairing data for the bluetooth device at |address|. | |
101 // |address| : The bluetooth address of the device sending the data. | |
102 // |data| : The data. | |
103 // |callback| : Called to indicate success or failure. | |
104 static void setOutOfBandPairingData( | |
105 DOMString address, | |
106 OutOfBandPairingData data, | |
107 optional ResultCallback callback); | |
108 }; | |
109 | |
110 interface Events { | |
111 // Fired when the availability of bluetooth on the system changes. | |
112 // |available| : True if bluetooth is available, false otherwise. | |
113 static void onAvailabilityChanged(boolean available); | |
114 | |
115 // Fired when the power state of bluetooth on the system changes. | |
116 // |powered| : True if bluetooth is powered, false otherwise. | |
117 static void onPowerChanged(boolean has_power); | |
118 }; | |
119 }; | |
OLD | NEW |