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 | |
7 [nodoc] namespace experimental.bluetooth { | |
Mihai Parparita -not on Chrome
2012/03/21 21:48:52
Antony: Is there an IDL equivalent to the "platfor
bryeung
2012/03/22 00:37:04
I believe I've set this up to NIY for now. Are yo
| |
8 dictionary Device { | |
9 DOMString address; | |
10 DOMString name; | |
11 }; | |
12 | |
13 dictionary Socket { | |
14 long id; | |
15 }; | |
16 | |
17 // TODO(bryeung): This is a temporary hack until Blobs are supported | |
18 dictionary Blob { | |
19 DOMString data; | |
20 }; | |
21 | |
22 dictionary OutOfBandPairingData { | |
23 // Simple Pairing Hash C | |
24 // Always 16 octets long. | |
25 // TODO(bryeung): this should really be an octet[] | |
26 DOMString hash; | |
27 | |
28 // Simple Pairing Randomizer R | |
29 // Always 16 octets long. | |
30 // TODO(bryeung): this should really be an octet[] | |
31 DOMString randomizer; | |
32 }; | |
33 | |
34 callback ResultCallback = void (boolean success); | |
35 callback BooleanCallback = void (boolean result); | |
asargent_no_longer_on_chrome
2012/03/21 21:19:58
On an email thread I think Mihai had made the sugg
bryeung
2012/03/21 21:34:14
Oops! Thanks for the reminder: I had meant to do
| |
36 callback AddressCallback = void (DOMString result); | |
37 callback DevicesCallback = void (Device[] result); | |
38 callback SocketCallback = void (Socket result); | |
39 callback DataCallback = void (Blob result); | |
40 callback OutOfBandPairingDataCallback = void (OutOfBandPairingData data); | |
41 | |
42 interface Functions { | |
43 // Checks if the system has bluetooth support. | |
44 // |callback| : Called with the boolean result. | |
45 static void isAvailable(BooleanCallback callback); | |
46 | |
47 // Checks if the system's bluetooth module has power. | |
48 // |callback| : Called with the boolean result. | |
49 static void isPowered(BooleanCallback callback); | |
50 | |
51 // Get the bluetooth address of the system's bluetooth module. | |
52 // |callback| : Called with the address, or null if there was an error. | |
53 static void getAddress(AddressCallback callback); | |
54 | |
55 // Get a list of bluetooth devices that support a service. | |
56 // |service| : The UUID of the desired service. | |
57 // |callback| : Called with an array of Device objects, all of which | |
58 // provide |service|. | |
59 static void getDevicesWithService( | |
60 DOMString service, DevicesCallback callback); | |
61 | |
62 // Connect to a service on a device. | |
63 // |device| : The target device. | |
64 // |service| : The target service UUID. | |
65 // |callback| : Called when the connection is established with a Socket | |
66 // that can be used to communicate with |device|. | |
67 static void connect( | |
68 Device device, DOMString service, SocketCallback callback); | |
69 | |
70 // Close a bluetooth connection. | |
71 // |socket| : The socket to disconnect. | |
72 // |callback| : Called to indicate success or failure. | |
73 static void disconnect(Socket socket, ResultCallback callback); | |
asargent_no_longer_on_chrome
2012/03/21 21:19:58
Would it make sense for the callback to be optiona
bryeung
2012/03/21 21:34:14
I changed all ResultCallback callbacks to be optio
| |
74 | |
75 // Read data from a bluetooth connection. | |
76 // |socket| : The socket to read from. | |
77 // |callback| : Called with the data when it is available. | |
78 static void read(Socket socket, DataCallback callback); | |
79 | |
80 // Write data to a bluetooth connection. | |
81 // |socket| : The socket to write to. | |
82 // |data| : The data to write. | |
83 // |callback| : Called to indicate success or failure. | |
84 static void write(Socket socket, Blob data, ResultCallback callback); | |
85 | |
86 // Get the local Out of Band Pairing data. | |
87 // |callback| : Called with the data. | |
88 static void getOutOfBandPairingData(OutOfBandPairingDataCallback callback); | |
89 | |
90 // Set the Out of Band Pairing data for the bluetooth device at |address|. | |
91 // |address| : The bluetooth address of the device sending the data. | |
92 // |data| : The data. | |
93 // |callback| : Called to indicate success or failure. | |
94 static void setOutOfBandPairingData( | |
95 DOMString address, OutOfBandPairingData data, ResultCallback callback); | |
asargent_no_longer_on_chrome
2012/03/21 21:19:58
same question here - can callback be optional?
bryeung
2012/03/21 21:34:14
Done.
| |
96 }; | |
97 | |
98 interface Events { | |
99 // Fired when the availability of bluetooth on the system changes. | |
100 // |available| : True if bluetooth is available, false otherwise. | |
101 static void onAvailabilityChanged(boolean available); | |
102 | |
103 // Fired when the power state of bluetooth on the system changes. | |
104 // |powered| : True if bluetooth is powered, false otherwise. | |
105 static void onPowerChanged(boolean has_power); | |
106 }; | |
107 }; | |
OLD | NEW |