summaryrefslogtreecommitdiff
path: root/proto/polo.proto
blob: 04914390e9cb951e42d923ca656c7af2b5037f40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Copyright 2009 Google Inc. All Rights Reserved.

package polo.wire.protobuf;

option javanano_use_deprecated_package = true;
option java_outer_classname = "PoloProto";
option java_package = "com.google.polo.wire.protobuf";
option optimize_for = LITE_RUNTIME;

// OuterMessage - base outer message type used in the protocol.

message OuterMessage {

  // MessageType indicates the type of the enclosed message (serialized in the
  // `payload` field)
  enum MessageType {
    // Initialization phase
    MESSAGE_TYPE_PAIRING_REQUEST = 10;
    MESSAGE_TYPE_PAIRING_REQUEST_ACK = 11;

    // Configuration phase
    MESSAGE_TYPE_OPTIONS = 20;
    MESSAGE_TYPE_CONFIGURATION = 30;
    MESSAGE_TYPE_CONFIGURATION_ACK = 31;

    // Pairing phase
    MESSAGE_TYPE_SECRET = 40;
    MESSAGE_TYPE_SECRET_ACK = 41;
  }

  // Protocol status states.
  enum Status {
    STATUS_OK = 200;
    STATUS_ERROR = 400;
    STATUS_BAD_CONFIGURATION = 401;
    STATUS_BAD_SECRET = 402;
  }

  required uint32 protocol_version = 1 [default = 1];

  // Protocol status. Any status other than STATUS_OK implies a fault.
  required Status status = 2;

  // Encapsulated message.  These fields are required if status is STATUS_OK.
  optional MessageType type = 3;
  optional bytes payload = 4;

}


//
// Initialization messages
//

message PairingRequest {
  // String name of the service to pair with.  The name used should be an
  // established convention of the application protocol.
  required string service_name = 1;

  // Descriptive name of the client.
  optional string client_name = 2;
}

message PairingRequestAck {
  // Descriptive name of the server.
  optional string server_name = 1;
}


//
// Configuration messages
//

message Options {
  message Encoding {
    enum EncodingType {
      ENCODING_TYPE_UNKNOWN = 0;
      ENCODING_TYPE_ALPHANUMERIC = 1;
      ENCODING_TYPE_NUMERIC = 2;
      ENCODING_TYPE_HEXADECIMAL = 3;
      ENCODING_TYPE_QRCODE = 4;
    }

    required EncodingType type = 1;
    required uint32 symbol_length = 2;
  }

  enum RoleType {
    ROLE_TYPE_UNKNOWN = 0;
    ROLE_TYPE_INPUT = 1;
    ROLE_TYPE_OUTPUT = 2;
  }

  // List of encodings this endpoint accepts when serving as an input device.
  repeated Encoding input_encodings = 1;

  // List of encodings this endpoint can generate as an output device.
  repeated Encoding output_encodings = 2;

  // Preferred role, if any.
  optional RoleType preferred_role = 3;
}

message Configuration {
  // The encoding to be used in this session.
  required Options.Encoding encoding = 1;

  // The role of the client (ie, the one initiating pairing). This implies the
  // peer (server) acts as the complementary role.
  required Options.RoleType client_role = 2;
}

message ConfigurationAck {
}


//
// Pairing messages
//

message Secret {
  required bytes secret = 1;
}

message SecretAck {
  required bytes secret = 1;
}