• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2022 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17option java_outer_classname = "HostProto";
18
19package pandora;
20
21import "google/protobuf/empty.proto";
22import "google/protobuf/any.proto";
23
24// Service to trigger Bluetooth Host procedures
25//
26// At startup, the Host must be in BR/EDR connectable mode
27// (see GAP connectability modes).
28service Host {
29  // Factory reset the host.
30  // **After** responding to this command, the gRPC server should loose
31  // all its state.
32  // This is comparable to a process restart or an hardware reset.
33  // The gRPC server might take some time to be available after
34  // this command.
35  rpc FactoryReset(google.protobuf.Empty) returns (google.protobuf.Empty);
36  // Reset the host by performing an HCI reset. Previous bonds must
37  // not be removed and the gRPC server must not be restarted.
38  rpc Reset(google.protobuf.Empty) returns (google.protobuf.Empty);
39  // Read the local Bluetooth device address.
40  // This should return the same value as a Read BD_ADDR HCI command.
41  rpc ReadLocalAddress(google.protobuf.Empty) returns (ReadLocalAddressResponse);
42  // Create an ACL BR/EDR connection to a peer.
43  // If the two devices have not established a previous bond,
44  // the peer must be discoverable.
45  // Whether this also triggers pairing (i.e. authentication and/or encryption)
46  // is implementation defined:
47  // some Bluetooth Host stack trigger pairing when ACL connection is being
48  // established, others when a profile or service requiring a specific
49  // security level is being opened. If it does trigger pairing, pairing events
50  // shall be handled through `Security.OnPairing` if a corresponding stream
51  // has been opened prior to this call, otherwise, they shall be automatically
52  // confirmed by the host before this method returns.
53  rpc Connect(ConnectRequest) returns (ConnectResponse);
54  // Wait for an active ACL BR/EDR connection from a peer.
55  // If the peer has been connected prior to this call, the server will
56  // return it. This shall return the same connection only once.
57  rpc WaitConnection(WaitConnectionRequest) returns (WaitConnectionResponse);
58  // Create an ACL LE connection.
59  // Unlike BR/EDR `Connect`, this must not trigger or wait any
60  // pairing/encryption and return as soon as the connection is complete.
61  rpc ConnectLE(ConnectLERequest) returns (ConnectLEResponse);
62  // Disconnect an ACL connection.
63  // The related Connection must not be reused afterwards.
64  rpc Disconnect(DisconnectRequest) returns (google.protobuf.Empty);
65  // Wait for the disconnection of an ACL connection.
66  rpc WaitDisconnection(WaitDisconnectionRequest) returns (google.protobuf.Empty);
67  // Start an advertising set using legacy or extended advertising,
68  // except periodic advertising.
69  // If it is set as connectable, the advertisement may lead to a connection,
70  // the server shall restart advertising again after any incoming connection has
71  // been established.
72  // Canceling the `Advertise` call shall stop advertising.
73  rpc Advertise(AdvertiseRequest) returns (stream AdvertiseResponse);
74  // Run LE scanning and return each device found.
75  // Canceling the `Scan` call shall stop scanning.
76  rpc Scan(ScanRequest) returns (stream ScanningResponse);
77  // Start BR/EDR inquiry and returns each device found.
78  // Canceling the `Inquiry` call shall stop inquiry.
79  rpc Inquiry(google.protobuf.Empty) returns (stream InquiryResponse);
80  // Set BR/EDR discoverability mode.
81  rpc SetDiscoverabilityMode(SetDiscoverabilityModeRequest) returns (google.protobuf.Empty);
82  // Set BR/EDR connectability mode.
83  rpc SetConnectabilityMode(SetConnectabilityModeRequest) returns (google.protobuf.Empty);
84}
85
86// Bluetooth device own address type.
87enum OwnAddressType {
88  PUBLIC = 0x0;
89  RANDOM = 0x1;
90  RESOLVABLE_OR_PUBLIC = 0x2;
91  RESOLVABLE_OR_RANDOM = 0x3;
92}
93
94// Advertisement primary PHY types.
95enum PrimaryPhy {
96  PRIMARY_1M = 0;
97  PRIMARY_CODED = 2;
98}
99
100// Advertisement secondary PHY types.
101enum SecondaryPhy {
102  SECONDARY_NONE = 0;
103  SECONDARY_1M = 1;
104  SECONDARY_2M = 2;
105  SECONDARY_CODED = 3;
106}
107
108// Discoverability modes.
109enum DiscoverabilityMode {
110  NOT_DISCOVERABLE = 0;
111  DISCOVERABLE_LIMITED = 1;
112  DISCOVERABLE_GENERAL = 2;
113}
114
115// Connectability modes (BR/EDR only).
116enum ConnectabilityMode {
117  NOT_CONNECTABLE = 0;
118  CONNECTABLE = 1;
119}
120
121// A Token representing an ACL connection.
122// It's acquired via a `Connect` or `ConnectLE`.
123message Connection {
124  // Opaque value filled by the gRPC server, must not be modified nor crafted.
125  google.protobuf.Any cookie = 1;
126}
127
128// Data types notably used for Extended Inquiry Response and Advertising Data.
129// The Flags data type is mandatory must be automatically set by the IUT and is
130// not exposed here.
131// include_<data type> are used in advertising requests for data types
132// which may not be exposed to the user and that must be set by the IUT
133// when specified.
134// See Core Supplement, Part A, Data Types for details.
135message DataTypes {
136  repeated string incomplete_service_class_uuids16 = 1; // Incomplete List of 16bit Service Class UUIDs
137  repeated string complete_service_class_uuids16 = 2; // Complete List of 16bit Service Class UUIDs
138  repeated string incomplete_service_class_uuids32 = 3; // Incomplete List of 32bit Service Class UUIDs
139  repeated string complete_service_class_uuids32 = 4; // Complete List of 32bit Service Class UUIDs
140  repeated string incomplete_service_class_uuids128 = 5; // Incomplete List of 128bit Service Class UUIDs
141  repeated string complete_service_class_uuids128 = 6; // Complete List of 128bit Service Class UUIDs
142  // Shortened Local Name
143  oneof shortened_local_name_oneof {
144    string shortened_local_name = 7;
145    bool include_shortened_local_name = 8;
146  }
147  // Complete Local Name
148  oneof complete_local_name_oneof {
149    string complete_local_name = 9;
150    bool include_complete_local_name = 10;
151  }
152  // Tx Power Level
153  oneof tx_power_level_oneof {
154    uint32 tx_power_level = 11;
155    bool include_tx_power_level = 12;
156  }
157  //  Class of Device
158  oneof class_of_device_oneof {
159    uint32 class_of_device = 13;
160    bool include_class_of_device = 14;
161  }
162  uint32 peripheral_connection_interval_min = 15; // Peripheral Connection Interval Range minimum value, 16 bits
163  uint32 peripheral_connection_interval_max = 16; // Peripheral Connection Interval Range maximum value, 16 bits
164  repeated string service_solicitation_uuids16 = 17; // List of 16bit Service Solicitation UUIDs
165  repeated string service_solicitation_uuids128 = 18; // List of 128bit Service Solicitation UUIDs
166  map<string, bytes> service_data_uuid16 = 19; // Service Data 16bit UUID
167  repeated bytes public_target_addresses = 20; // Public Target Addresses
168  repeated bytes random_target_addresses = 21; // Random Target Addresses
169  uint32 appearance = 22; // Appearance (16bits)
170  // Advertising Interval
171  oneof advertising_interval_oneof {
172    uint32 advertising_interval = 23; // 16 bits
173    bool include_advertising_interval = 24;
174  }
175  repeated string service_solicitation_uuids32 = 25; // List of 32bit Service Solicitation UUIDs
176  map<string, bytes> service_data_uuid32 = 26; // Service Data 32bit UUID
177  map<string, bytes> service_data_uuid128 = 27; // Service Data 128bit UUID
178  string uri = 28; // URI
179  bytes le_supported_features = 29; // LE Supported Features
180  bytes manufacturer_specific_data = 30; // Manufacturer Specific Data
181  DiscoverabilityMode le_discoverability_mode = 31; // Flags LE Discoverability Mode
182}
183
184// Response of the `ReadLocalAddress` method.
185message ReadLocalAddressResponse {
186  // Local Bluetooth device address as array of 6 bytes.
187  bytes address = 1;
188}
189
190// Request of the `Connect` method.
191message ConnectRequest {
192  // Peer Bluetooth device address as array of 6 bytes.
193  bytes address = 1;
194}
195
196// Response of the `Connect` method.
197message ConnectResponse {
198  // Response result.
199  oneof result {
200    // Connection on `Connect` success
201    Connection connection = 1;
202    // Peer not found error.
203    google.protobuf.Empty peer_not_found = 2;
204    // A connection with peer already exists.
205    google.protobuf.Empty connection_already_exists = 3;
206    // Pairing failure error.
207    google.protobuf.Empty pairing_failure = 4;
208    // Authentication failure error.
209    google.protobuf.Empty authentication_failure = 5;
210    // Encryption failure error.
211    google.protobuf.Empty encryption_failure = 6;
212  }
213}
214
215// Request of the `WaitConnection` method.
216message WaitConnectionRequest {
217  // Peer Bluetooth device address as array of 6 bytes.
218  bytes address = 1;
219}
220
221// Response of the `WaitConnection` method.
222message WaitConnectionResponse {
223  // Response result.
224  oneof result {
225    // Connection on `WaitConnection` success
226    Connection connection = 1;
227  }
228}
229
230// Request of the `ConnectLE` method.
231message ConnectLERequest {
232  // Own address type.
233  OwnAddressType own_address_type = 1;
234  // Peer Bluetooth device address as array of 6 bytes.
235  oneof address {
236    // Public device address.
237    bytes public = 2;
238    // Random device address.
239    bytes random = 3;
240    // Public identity device address.
241    bytes public_identity = 4;
242    // Random (static) identity device address.
243    bytes random_static_identity = 5;
244  }
245}
246
247// Response of the `ConnectLE` method.
248message ConnectLEResponse {
249  // Response result.
250  oneof result {
251    // Connection on `ConnectLE` success
252    Connection connection = 1;
253    // Peer not found error.
254    google.protobuf.Empty peer_not_found = 2;
255    // A connection with peer already exists.
256    google.protobuf.Empty connection_already_exists = 3;
257  }
258}
259
260// Request of the `Disconnect` method.
261message DisconnectRequest {
262  // Connection that should be disconnected.
263  Connection connection = 1;
264}
265
266// Request of the `WaitDisconnection` method.
267message WaitDisconnectionRequest {
268  // Connection to wait disconnection from.
269  Connection connection = 1;
270}
271
272// Request of the `Advertise` method.
273message AdvertiseRequest {
274  // `true` to use legacy advertising.
275  // The implementation shall fail when set to `false` and
276  // extended advertising is not supported.
277  bool legacy = 1;
278  // Advertisement data.
279  DataTypes data = 2;
280  // If none, the device is not scannable.
281  DataTypes scan_response_data = 3;
282  // Target Bluetooth device address as array of 6 bytes.
283  // If none, advertisement is undirected.
284  oneof target {
285    // Public device address or public identity address.
286    bytes public = 4;
287    // Random device address or random (static) identity address.
288    bytes random = 5;
289  }
290  // Own address type to advertise.
291  OwnAddressType own_address_type = 6;
292  // `true` if the device is connectable.
293  bool connectable = 7;
294  // Interval & range of the advertisement.
295  float interval = 8;
296  // If not specified, the IUT is free to select any interval min and max
297  // which comprises the specified interval.
298  float interval_range = 9;
299  // Extended only: primary PHYs.
300  PrimaryPhy primary_phy = 10;
301  // Extended only: secondary PHYs.
302  SecondaryPhy secondary_phy = 11;
303}
304
305// Response of the `Advertise` method.
306message AdvertiseResponse {
307  // Connection of a connectable `Advertise`.
308  Connection connection = 1;
309}
310
311// Request of the `Scan` method.
312message ScanRequest {
313  // `true` the use legacy scanning.
314  // The implementation shall fail when set to `false` and
315  // extended scanning is not supported.
316  bool legacy = 1;
317  // Scan in passive mode (versus active one).
318  bool passive = 2;
319  // Own address type.
320  OwnAddressType own_address_type = 3;
321  // Interval & window of the scan.
322  float interval = 4;
323  float window = 5;
324  // Scanning PHYs.
325  repeated PrimaryPhy phys = 6;
326}
327
328// Response of the `Scan` method.
329message ScanningResponse {
330  // `true` if the response is legacy.
331  bool legacy = 1;
332  // Peer Bluetooth device address as array of 6 bytes.
333  oneof address {
334    // Public device address.
335    bytes public = 2;
336    // Random device address.
337    bytes random = 3;
338    // Public identity device address (corresponds to resolved private address).
339    bytes public_identity = 4;
340    // Random (static) identity device address (corresponds to resolved private address).
341    bytes random_static_identity = 5;
342  }
343  // Direct Bluetooth device address as array of 6 bytes.
344  oneof direct_address {
345    // Public device address.
346    bytes direct_public = 6;
347    // Non-resolvable private address or static device address.
348    bytes direct_non_resolvable_random = 7;
349    // Resolvable private address (resolved by controller).
350    bytes direct_resolved_public = 8;
351    // Resolvable private address (resolved by controller).
352    bytes direct_resolved_random = 9;
353    // Resolvable private address (controller unable to resolve).
354    bytes direct_unresolved_random = 10;
355  }
356  // `true` if the peer is connectable.
357  bool connectable = 11;
358  // `true` if the peer is scannable.
359  bool scannable = 12;
360  // `true` if the `undirected.data` is truncated.
361  // This indicates that the advertisement data are truncated.
362  bool truncated = 13;
363  // Advertising SID from 0x00 to 0x0F.
364  uint32 sid = 14;
365  // On extended only: primary PHYs.
366  PrimaryPhy primary_phy = 15;
367  // On extended only: secondary PHYs.
368  SecondaryPhy secondary_phy = 16;
369  // TX power in dBm, range: -127 to +20.
370  int32 tx_power = 17;
371  // Received Signal Strength Indication in dBm, range: -127 to +20.
372  int32 rssi = 18;
373  // Interval of the periodic advertising, 0 if not periodic
374  // or within 7.5 ms to 81,918.75 ms range.
375  float periodic_advertising_interval = 19;
376  // Scan response data.
377  DataTypes data = 20;
378}
379
380// Response of the `Inquiry` method.
381message InquiryResponse {
382  bytes address = 1;
383  uint32 page_scan_repetition_mode = 2;
384  uint32 class_of_device = 3;
385  uint32 clock_offset = 4;
386  int32 rssi = 5;
387  DataTypes data = 6;
388}
389
390// Request of the `SetDiscoverabilityMode` method.
391message SetDiscoverabilityModeRequest {
392  DiscoverabilityMode mode = 1;
393}
394
395// Request of the `SetConnectabilityMode` method.
396message SetConnectabilityModeRequest {
397  ConnectabilityMode mode = 1;
398}
399