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 // Waits for an ACL LE connection update and returns the new values of the 63 // connection parameters. Subsequent calls will wait for new connection 64 // updates before returning. Servers should cache connection updates so that 65 // none are lost before and in between calls. 66 rpc WaitConnectionUpdate(WaitConnectionUpdateRequest) returns (WaitConnectionUpdateResponse); 67 // Returns the current ACL LE connection parameters. 68 rpc GetConnectionParameters(GetConnectionParametersRequest) returns (GetConnectionParametersResponse); 69 // Disconnect an ACL connection. 70 // The related Connection must not be reused afterwards. 71 rpc Disconnect(DisconnectRequest) returns (google.protobuf.Empty); 72 // Wait for the disconnection of an ACL connection. 73 rpc WaitDisconnection(WaitDisconnectionRequest) returns (google.protobuf.Empty); 74 // Start an advertising set using legacy or extended advertising, 75 // except periodic advertising. 76 // If it is set as connectable, the advertisement may lead to a connection, 77 // the server shall restart advertising again after any incoming connection has 78 // been established. 79 // Canceling the `Advertise` call shall stop advertising. 80 rpc Advertise(AdvertiseRequest) returns (stream AdvertiseResponse); 81 // Run LE scanning and return each device found. 82 // Canceling the `Scan` call shall stop scanning. 83 rpc Scan(ScanRequest) returns (stream ScanningResponse); 84 // Start BR/EDR inquiry and returns each device found. 85 // Canceling the `Inquiry` call shall stop inquiry. 86 rpc Inquiry(google.protobuf.Empty) returns (stream InquiryResponse); 87 // Set BR/EDR discoverability mode. 88 rpc SetDiscoverabilityMode(SetDiscoverabilityModeRequest) returns (google.protobuf.Empty); 89 // Set BR/EDR connectability mode. 90 rpc SetConnectabilityMode(SetConnectabilityModeRequest) returns (google.protobuf.Empty); 91} 92 93// Bluetooth device own address type. 94enum OwnAddressType { 95 PUBLIC = 0x0; 96 RANDOM = 0x1; 97 RESOLVABLE_OR_PUBLIC = 0x2; 98 RESOLVABLE_OR_RANDOM = 0x3; 99} 100 101// Advertisement primary PHY types. 102enum PrimaryPhy { 103 PRIMARY_1M = 0; 104 PRIMARY_CODED = 2; 105} 106 107// Advertisement secondary PHY types. 108enum SecondaryPhy { 109 SECONDARY_NONE = 0; 110 SECONDARY_1M = 1; 111 SECONDARY_2M = 2; 112 SECONDARY_CODED = 3; 113} 114 115// Discoverability modes. 116enum DiscoverabilityMode { 117 NOT_DISCOVERABLE = 0; 118 DISCOVERABLE_LIMITED = 1; 119 DISCOVERABLE_GENERAL = 2; 120} 121 122// Connectability modes (BR/EDR only). 123enum ConnectabilityMode { 124 NOT_CONNECTABLE = 0; 125 CONNECTABLE = 1; 126} 127 128// A Token representing an ACL connection. 129// It's acquired via a `Connect` or `ConnectLE`. 130message Connection { 131 // Opaque value filled by the gRPC server, must not be modified nor crafted. 132 google.protobuf.Any cookie = 1; 133} 134 135// Data types notably used for Extended Inquiry Response and Advertising Data. 136// The Flags data type is mandatory must be automatically set by the IUT and is 137// not exposed here. 138// include_<data type> are used in advertising requests for data types 139// which may not be exposed to the user and that must be set by the IUT 140// when specified. 141// See Core Supplement, Part A, Data Types for details. 142message DataTypes { 143 repeated string incomplete_service_class_uuids16 = 1; // Incomplete List of 16bit Service Class UUIDs 144 repeated string complete_service_class_uuids16 = 2; // Complete List of 16bit Service Class UUIDs 145 repeated string incomplete_service_class_uuids32 = 3; // Incomplete List of 32bit Service Class UUIDs 146 repeated string complete_service_class_uuids32 = 4; // Complete List of 32bit Service Class UUIDs 147 repeated string incomplete_service_class_uuids128 = 5; // Incomplete List of 128bit Service Class UUIDs 148 repeated string complete_service_class_uuids128 = 6; // Complete List of 128bit Service Class UUIDs 149 // Shortened Local Name 150 oneof shortened_local_name_oneof { 151 string shortened_local_name = 7; 152 bool include_shortened_local_name = 8; 153 } 154 // Complete Local Name 155 oneof complete_local_name_oneof { 156 string complete_local_name = 9; 157 bool include_complete_local_name = 10; 158 } 159 // Tx Power Level 160 oneof tx_power_level_oneof { 161 uint32 tx_power_level = 11; 162 bool include_tx_power_level = 12; 163 } 164 // Class of Device 165 oneof class_of_device_oneof { 166 uint32 class_of_device = 13; 167 bool include_class_of_device = 14; 168 } 169 uint32 peripheral_connection_interval_min = 15; // Peripheral Connection Interval Range minimum value, 16 bits 170 uint32 peripheral_connection_interval_max = 16; // Peripheral Connection Interval Range maximum value, 16 bits 171 repeated string service_solicitation_uuids16 = 17; // List of 16bit Service Solicitation UUIDs 172 repeated string service_solicitation_uuids128 = 18; // List of 128bit Service Solicitation UUIDs 173 map<string, bytes> service_data_uuid16 = 19; // Service Data 16bit UUID 174 repeated bytes public_target_addresses = 20; // Public Target Addresses 175 repeated bytes random_target_addresses = 21; // Random Target Addresses 176 uint32 appearance = 22; // Appearance (16bits) 177 // Advertising Interval 178 oneof advertising_interval_oneof { 179 uint32 advertising_interval = 23; // 16 bits 180 bool include_advertising_interval = 24; 181 } 182 repeated string service_solicitation_uuids32 = 25; // List of 32bit Service Solicitation UUIDs 183 map<string, bytes> service_data_uuid32 = 26; // Service Data 32bit UUID 184 map<string, bytes> service_data_uuid128 = 27; // Service Data 128bit UUID 185 string uri = 28; // URI 186 bytes le_supported_features = 29; // LE Supported Features 187 bytes manufacturer_specific_data = 30; // Manufacturer Specific Data 188 DiscoverabilityMode le_discoverability_mode = 31; // Flags LE Discoverability Mode 189 DataTypes encrypted_data = 32; 190} 191 192// Response of the `ReadLocalAddress` method. 193message ReadLocalAddressResponse { 194 // Local Bluetooth device address as array of 6 bytes. 195 bytes address = 1; 196} 197 198// Request of the `Connect` method. 199message ConnectRequest { 200 // Peer Bluetooth device address as array of 6 bytes. 201 bytes address = 1; 202} 203 204// Response of the `Connect` method. 205message ConnectResponse { 206 // Response result. 207 oneof result { 208 // Connection on `Connect` success 209 Connection connection = 1; 210 // Peer not found error. 211 google.protobuf.Empty peer_not_found = 2; 212 // A connection with peer already exists. 213 google.protobuf.Empty connection_already_exists = 3; 214 // Pairing failure error. 215 google.protobuf.Empty pairing_failure = 4; 216 // Authentication failure error. 217 google.protobuf.Empty authentication_failure = 5; 218 // Encryption failure error. 219 google.protobuf.Empty encryption_failure = 6; 220 } 221} 222 223// Request of the `WaitConnection` method. 224message WaitConnectionRequest { 225 // Peer Bluetooth device address as array of 6 bytes. 226 bytes address = 1; 227} 228 229// Response of the `WaitConnection` method. 230message WaitConnectionResponse { 231 // Response result. 232 oneof result { 233 // Connection on `WaitConnection` success 234 Connection connection = 1; 235 } 236} 237 238// Request of the `ConnectLE` method. 239message ConnectLERequest { 240 // Own address type. 241 OwnAddressType own_address_type = 1; 242 // Peer Bluetooth device address as array of 6 bytes. 243 oneof address { 244 // Public device address. 245 bytes public = 2; 246 // Random device address. 247 bytes random = 3; 248 // Public identity device address. 249 bytes public_identity = 4; 250 // Random (static) identity device address. 251 bytes random_static_identity = 5; 252 } 253} 254 255// Response of the `ConnectLE` method. 256message ConnectLEResponse { 257 // Response result. 258 oneof result { 259 // Connection on `ConnectLE` success 260 Connection connection = 1; 261 // Peer not found error. 262 google.protobuf.Empty peer_not_found = 2; 263 // A connection with peer already exists. 264 google.protobuf.Empty connection_already_exists = 3; 265 } 266} 267 268// Request of the `WaitConnectionUpdate` method. 269message WaitConnectionUpdateRequest { 270 // Connection on which to wait for connection updates. 271 Connection connection = 1; 272} 273 274// Response of the `WaitConnectionUpdate` method. 275message WaitConnectionUpdateResponse { 276 // Response result. 277 oneof result { 278 // The new connection parameters on success. 279 ConnectionParameters connection_parameters = 1; 280 // No LE connection matching the Connection in the request was found. 281 google.protobuf.Empty connection_not_found = 2; 282 } 283} 284 285// Request of the `GetConnectionParameters` method. 286message GetConnectionParametersRequest { 287 // Connection whose parameters will be returned. 288 Connection connection = 1; 289} 290 291// Response of the `GetConnectionParameters` method. 292message GetConnectionParametersResponse { 293 // Response result. 294 oneof result { 295 // The current connection parameters on success. 296 ConnectionParameters connection_parameters = 1; 297 // No LE connection matching the Connection in the request was found. 298 google.protobuf.Empty connection_not_found = 2; 299 } 300} 301 302// Response of the `WaitConnectionUpdate` method. 303message ConnectionParameters { 304 // Connection interval used on this connection. 305 // Range: 0x0006 to 0x0C80 306 // Time = N × 1.25 ms 307 // Time Range: 7.5 ms to 4000 ms. 308 uint32 connection_interval = 1; 309 // Peripheral latency for the connection in number of subrated connection 310 // events. 311 // Range: 0x0000 to 0x01F3 312 uint32 peripheral_latency = 2; 313 // Supervision timeout for this connection. 314 // Range: 0x000A to 0x0C80 315 // Time = N × 10 ms 316 // Time Range: 100 ms to 32000 ms 317 uint32 supervision_timeout = 3; 318} 319 320// Request of the `Disconnect` method. 321message DisconnectRequest { 322 // Connection that should be disconnected. 323 Connection connection = 1; 324} 325 326// Request of the `WaitDisconnection` method. 327message WaitDisconnectionRequest { 328 // Connection to wait disconnection from. 329 Connection connection = 1; 330} 331 332// Request of the `Advertise` method. 333message AdvertiseRequest { 334 // `true` to use legacy advertising. 335 // The implementation shall fail when set to `false` and 336 // extended advertising is not supported. 337 bool legacy = 1; 338 // Advertisement data. 339 DataTypes data = 2; 340 // If none, the device is not scannable. 341 DataTypes scan_response_data = 3; 342 // Target Bluetooth device address as array of 6 bytes. 343 // If none, advertisement is undirected. 344 oneof target { 345 // Public device address or public identity address. 346 bytes public = 4; 347 // Random device address or random (static) identity address. 348 bytes random = 5; 349 } 350 // Own address type to advertise. 351 OwnAddressType own_address_type = 6; 352 // `true` if the device is connectable. 353 bool connectable = 7; 354 // Interval & range of the advertisement. 355 float interval = 8; 356 // If not specified, the IUT is free to select any interval min and max 357 // which comprises the specified interval. 358 float interval_range = 9; 359 // Extended only: primary PHYs. 360 PrimaryPhy primary_phy = 10; 361 // Extended only: secondary PHYs. 362 SecondaryPhy secondary_phy = 11; 363} 364 365// Response of the `Advertise` method. 366message AdvertiseResponse { 367 // Connection of a connectable `Advertise`. 368 Connection connection = 1; 369} 370 371// Request of the `Scan` method. 372message ScanRequest { 373 // `true` the use legacy scanning. 374 // The implementation shall fail when set to `false` and 375 // extended scanning is not supported. 376 bool legacy = 1; 377 // Scan in passive mode (versus active one). 378 bool passive = 2; 379 // Own address type. 380 OwnAddressType own_address_type = 3; 381 // Interval & window of the scan. 382 float interval = 4; 383 float window = 5; 384 // Scanning PHYs. 385 repeated PrimaryPhy phys = 6; 386} 387 388// Response of the `Scan` method. 389message ScanningResponse { 390 // `true` if the response is legacy. 391 bool legacy = 1; 392 // Peer Bluetooth device address as array of 6 bytes. 393 oneof address { 394 // Public device address. 395 bytes public = 2; 396 // Random device address. 397 bytes random = 3; 398 // Public identity device address (corresponds to resolved private address). 399 bytes public_identity = 4; 400 // Random (static) identity device address (corresponds to resolved private address). 401 bytes random_static_identity = 5; 402 } 403 // Direct Bluetooth device address as array of 6 bytes. 404 oneof direct_address { 405 // Public device address. 406 bytes direct_public = 6; 407 // Non-resolvable private address or static device address. 408 bytes direct_non_resolvable_random = 7; 409 // Resolvable private address (resolved by controller). 410 bytes direct_resolved_public = 8; 411 // Resolvable private address (resolved by controller). 412 bytes direct_resolved_random = 9; 413 // Resolvable private address (controller unable to resolve). 414 bytes direct_unresolved_random = 10; 415 } 416 // `true` if the peer is connectable. 417 bool connectable = 11; 418 // `true` if the peer is scannable. 419 bool scannable = 12; 420 // `true` if the `undirected.data` is truncated. 421 // This indicates that the advertisement data are truncated. 422 bool truncated = 13; 423 // Advertising SID from 0x00 to 0x0F. 424 uint32 sid = 14; 425 // On extended only: primary PHYs. 426 PrimaryPhy primary_phy = 15; 427 // On extended only: secondary PHYs. 428 SecondaryPhy secondary_phy = 16; 429 // TX power in dBm, range: -127 to +20. 430 int32 tx_power = 17; 431 // Received Signal Strength Indication in dBm, range: -127 to +20. 432 int32 rssi = 18; 433 // Interval of the periodic advertising, 0 if not periodic 434 // or within 7.5 ms to 81,918.75 ms range. 435 float periodic_advertising_interval = 19; 436 // Scan response data. 437 DataTypes data = 20; 438} 439 440// Response of the `Inquiry` method. 441message InquiryResponse { 442 bytes address = 1; 443 uint32 page_scan_repetition_mode = 2; 444 uint32 class_of_device = 3; 445 uint32 clock_offset = 4; 446 int32 rssi = 5; 447 DataTypes data = 6; 448} 449 450// Request of the `SetDiscoverabilityMode` method. 451message SetDiscoverabilityModeRequest { 452 DiscoverabilityMode mode = 1; 453} 454 455// Request of the `SetConnectabilityMode` method. 456message SetConnectabilityModeRequest { 457 ConnectabilityMode mode = 1; 458} 459