1// Copyright 2009 Google Inc. All Rights Reserved.
2
3package polo.wire.protobuf;
4
5option java_outer_classname = "PoloProto";
6option java_package = "com.google.polo.wire.protobuf";
7option optimize_for = LITE_RUNTIME;
8
9// OuterMessage - base outer message type used in the protocol.
10
11message OuterMessage {
12
13  // MessageType indicates the type of the enclosed message (serialized in the
14  // `payload` field)
15  enum MessageType {
16    // Initialization phase
17    MESSAGE_TYPE_PAIRING_REQUEST = 10;
18    MESSAGE_TYPE_PAIRING_REQUEST_ACK = 11;
19
20    // Configuration phase
21    MESSAGE_TYPE_OPTIONS = 20;
22    MESSAGE_TYPE_CONFIGURATION = 30;
23    MESSAGE_TYPE_CONFIGURATION_ACK = 31;
24
25    // Pairing phase
26    MESSAGE_TYPE_SECRET = 40;
27    MESSAGE_TYPE_SECRET_ACK = 41;
28  }
29
30  // Protocol status states.
31  enum Status {
32    STATUS_OK = 200;
33    STATUS_ERROR = 400;
34    STATUS_BAD_CONFIGURATION = 401;
35    STATUS_BAD_SECRET = 402;
36  }
37
38  required uint32 protocol_version = 1 [default = 1];
39
40  // Protocol status. Any status other than STATUS_OK implies a fault.
41  required Status status = 2;
42
43  // Encapsulated message.  These fields are required if status is STATUS_OK.
44  optional MessageType type = 3;
45  optional bytes payload = 4;
46
47}
48
49
50//
51// Initialization messages
52//
53
54message PairingRequest {
55  // String name of the service to pair with.  The name used should be an
56  // established convention of the application protocol.
57  required string service_name = 1;
58
59  // Descriptive name of the client.
60  optional string client_name = 2;
61}
62
63message PairingRequestAck {
64  // Descriptive name of the server.
65  optional string server_name = 1;
66}
67
68
69//
70// Configuration messages
71//
72
73message Options {
74  message Encoding {
75    enum EncodingType {
76      ENCODING_TYPE_UNKNOWN = 0;
77      ENCODING_TYPE_ALPHANUMERIC = 1;
78      ENCODING_TYPE_NUMERIC = 2;
79      ENCODING_TYPE_HEXADECIMAL = 3;
80      ENCODING_TYPE_QRCODE = 4;
81    }
82
83    required EncodingType type = 1;
84    required uint32 symbol_length = 2;
85  }
86
87  enum RoleType {
88    ROLE_TYPE_UNKNOWN = 0;
89    ROLE_TYPE_INPUT = 1;
90    ROLE_TYPE_OUTPUT = 2;
91  }
92
93  // List of encodings this endpoint accepts when serving as an input device.
94  repeated Encoding input_encodings = 1;
95
96  // List of encodings this endpoint can generate as an output device.
97  repeated Encoding output_encodings = 2;
98
99  // Preferred role, if any.
100  optional RoleType preferred_role = 3;
101}
102
103message Configuration {
104  // The encoding to be used in this session.
105  required Options.Encoding encoding = 1;
106
107  // The role of the client (ie, the one initiating pairing). This implies the
108  // peer (server) acts as the complementary role.
109  required Options.RoleType client_role = 2;
110}
111
112message ConfigurationAck {
113}
114
115
116//
117// Pairing messages
118//
119
120message Secret {
121  required bytes secret = 1;
122}
123
124message SecretAck {
125  required bytes secret = 1;
126}
127
128