diff --git a/android/pandora/server/proto/pandora/host.proto b/android/pandora/server/proto/pandora/host.proto index 517f740ea9159cce30ea576b91b9d5fd7a1c07b4..d51417140c3660c3f74a5c1309b2d71fe391e139 100644 --- a/android/pandora/server/proto/pandora/host.proto +++ b/android/pandora/server/proto/pandora/host.proto @@ -18,8 +18,9 @@ service Host { // The GRPC server might take some time to be available after // this command. rpc Reset(google.protobuf.Empty) returns (google.protobuf.Empty); - // Remove pairing - rpc DeletePairing(DeletePairingRequest) returns (DeletePairingResponse); + // Read the local Bluetooth device address. + // This should return the same value as a Read BD_ADDR HCI command. + rpc ReadLocalAddress(google.protobuf.Empty) returns (ReadLocalAddressResponse); // Create an ACL BR/EDR connection to a peer. // This should send a CreateConnection on the HCI level. // If the two devices have not established a previous bond, @@ -31,13 +32,25 @@ service Host { rpc WaitConnection(WaitConnectionRequest) returns (WaitConnectionResponse); // Disconnect an ACL BR/EDR connection. The Connection must not be reused afterwards. rpc Disconnect(DisconnectRequest) returns (DisconnectResponse); - // Read the local Bluetooth device address. - // This should return the same value as a Read BD_ADDR HCI command. - rpc ReadLocalAddress(google.protobuf.Empty) returns (ReadLocalAddressResponse); - // Create a LE connection + // Create a LE connection. rpc ConnectLE(ConnectLERequest) returns (ConnectLEResponse); - // Disconnect ongoing LE connection + // Disconnect ongoing LE connection. rpc DisconnectLE(DisconnectLERequest) returns (google.protobuf.Empty); + // Listen to pairing events. + // This is handled independently from connections for several reasons: + // - Pairing can be triggered at any time and multiple times during the + // lifetime of a connection (this also explains why this is a stream). + // - In BR/EDR, the specification allows for a device to authenticate before + // connecting when in security mode 3 (link level enforced security). + rpc OnPairing(stream PairingEventAnswer) returns (stream PairingEvent); + // Remove pairing. + rpc DeletePairing(DeletePairingRequest) returns (DeletePairingResponse); +} + +// Response of the `ReadLocalAddress` method. +message ReadLocalAddressResponse { + // Local Bluetooth Device Address as array of 6 bytes. + bytes address = 1; } // A Token representing an ACL connection. @@ -93,15 +106,6 @@ message WaitConnectionResponse { } } -// Request of the `DeletePairing` method. -message DeletePairingRequest { - // Local Bluetooth Device Address as array of 6 bytes. - bytes address = 1; -} - -// Response of the `DeletePairing` method. -message DeletePairingResponse {} - // Request of the `Disconnect` method. message DisconnectRequest { // Connection that should be disconnected. @@ -111,12 +115,6 @@ message DisconnectRequest { // Response of the `Disconnect` method. message DisconnectResponse {} -// Response of the `ReadLocalAddress` method. -message ReadLocalAddressResponse { - // Local Bluetooth Device Address as array of 6 bytes. - bytes address = 1; -} - // Request of the `ConnectLE` method message ConnectLERequest { bytes address = 1; @@ -133,3 +131,53 @@ message ConnectLEResponse { message DisconnectLERequest { Connection connection = 1; } + +message PairingEvent { + // Peer Bluetooth Device Address as array of 6 bytes. + bytes address = 1; + // Authentication method used for this pairing event + oneof method { + // "Just Works" Secure Simple Pairing association + // model. Confirmation is automatic. + google.protobuf.Empty just_works = 2; + // Numeric Comparison Secure Simple Pairing association + // model. Confirmation is required. + uint32 numeric_comparison = 3; + // Passkey Entry Secure Simple Pairing association model. + // Passkey is shown to the user. + // The peer device receives a Passkey Entry request. + bytes passkey_entry_notification = 4; + // Passkey Entry Secure Simple Pairing association model. + // Passkey is typed by the user. + google.protobuf.Empty passkey_entry_request = 5; + // Legacy PIN Pairing. + // A PIN Code is typed by the user. + google.protobuf.Empty pin_code = 6; + } +} + +message PairingEventAnswer { + // Received pairing event. + PairingEvent event = 1; + // Answer when needed to the pairing event method. + oneof answer { + // Numeric Comparison confirmation. + // Used when pairing event method is `numeric_comparison`. + bool confirm = 2; + // Passkey typed by the user. + // Used when pairing event method is `passkey_entry_request`. + bytes passkey = 3; + // Pin typed by the user. + // Used when pairing event method is `pin_code`. + uint32 pin = 4; + }; +} + +// Request of the `DeletePairing` method. +message DeletePairingRequest { + // Local Bluetooth Device Address as array of 6 bytes. + bytes address = 1; +} + +// Response of the `DeletePairing` method. +message DeletePairingResponse {}