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