1syntax = "proto3";
2
3option java_outer_classname = "GattProto";
4
5package pandora;
6
7import "pandora/host.proto";
8import "google/protobuf/empty.proto";
9
10service GATT {
11  // Request an MTU size.
12  rpc ExchangeMTU(ExchangeMTURequest) returns (ExchangeMTUResponse);
13
14  // Writes on the given characteristic or descriptor with given handle.
15  rpc WriteAttFromHandle(WriteRequest) returns (WriteResponse);
16
17  // Starts service discovery for given uuid.
18  rpc DiscoverServiceByUuid(DiscoverServiceByUuidRequest) returns (DiscoverServicesResponse);
19
20  // Starts services discovery.
21  rpc DiscoverServices(DiscoverServicesRequest) returns (DiscoverServicesResponse);
22
23  // Starts services discovery using SDP.
24  rpc DiscoverServicesSdp(DiscoverServicesSdpRequest) returns (DiscoverServicesSdpResponse);
25
26  // Clears DUT GATT cache.
27  rpc ClearCache(ClearCacheRequest) returns (ClearCacheResponse);
28
29  // Reads characteristic with given handle.
30  rpc ReadCharacteristicFromHandle(ReadCharacteristicRequest) returns (ReadCharacteristicResponse);
31
32  // Reads characteristic with given uuid, start and end handles.
33  rpc ReadCharacteristicsFromUuid(ReadCharacteristicsFromUuidRequest) returns (ReadCharacteristicsFromUuidResponse);
34
35  // Reads characteristic with given descriptor handle.
36  rpc ReadCharacteristicDescriptorFromHandle(ReadCharacteristicDescriptorRequest) returns (ReadCharacteristicDescriptorResponse);
37
38  // Register a GATT service
39  rpc RegisterService(RegisterServiceRequest) returns (RegisterServiceResponse);
40
41  // Set characteristic notification/indication with given client characteristic configuration descriptor handle
42  rpc SetCharacteristicNotificationFromHandle(SetCharacteristicNotificationFromHandleRequest) returns  (SetCharacteristicNotificationFromHandleResponse);
43
44  // Wait for characteristic notification/indication
45  rpc WaitCharacteristicNotification(WaitCharacteristicNotificationRequest) returns (WaitCharacteristicNotificationResponse);
46
47  // Notify on characteristic
48  rpc NotifyOnCharacteristic(NotifyOnCharacteristicRequest) returns (NotifyOnCharacteristicResponse);
49
50  // Indicate on characteristic
51  rpc IndicateOnCharacteristic(IndicateOnCharacteristicRequest) returns (IndicateOnCharacteristicResponse);
52}
53
54enum AttStatusCode {
55  SUCCESS = 0x00;
56  UNKNOWN_ERROR = 0x101;
57  INVALID_HANDLE = 0x01;
58  READ_NOT_PERMITTED = 0x02;
59  WRITE_NOT_PERMITTED = 0x03;
60  INSUFFICIENT_AUTHENTICATION = 0x05;
61  INVALID_OFFSET = 0x07;
62  ATTRIBUTE_NOT_FOUND = 0x0A;
63  INVALID_ATTRIBUTE_LENGTH = 0x0D;
64  APPLICATION_ERROR = 0x80;
65}
66
67enum AttProperties {
68  PROPERTY_NONE = 0x00;
69  PROPERTY_READ = 0x02;
70  PROPERTY_WRITE = 0x08;
71}
72
73enum AttPermissions {
74  PERMISSION_NONE = 0x00;
75  PERMISSION_READ = 0x01;
76  PERMISSION_READ_ENCRYPTED = 0x02;
77  PERMISSION_READ_ENCRYPTED_MITM = 0x04;
78  PERMISSION_WRITE = 0x10;
79  PERMISSION_WRITE_ENCRYPTED = 0x20;
80  PERMISSION_WRITE_ENCRYPTED_MITM = 0x40;
81}
82
83enum EnableValue {
84  ENABLE_NOTIFICATION_VALUE = 0;
85  ENABLE_INDICATION_VALUE = 1;
86}
87
88// A message representing a GATT service.
89message GattService {
90  uint32 handle = 1;
91  uint32 type = 2;
92  string uuid = 3;
93  repeated GattService included_services = 4;
94  repeated GattCharacteristic characteristics = 5;
95}
96
97// A message representing a GATT characteristic.
98message GattCharacteristic {
99  uint32 properties = 1;
100  uint32 permissions = 2;
101  string uuid = 3;
102  uint32 handle = 4;
103  repeated GattCharacteristicDescriptor descriptors = 5;
104}
105
106// A message representing a GATT descriptors.
107message GattCharacteristicDescriptor {
108  uint32 handle = 1;
109  uint32 permissions = 2;
110  string uuid = 3;
111}
112
113message AttValue {
114  // Descriptor handle or Characteristic handle (not Characteristic Value handle).
115  uint32 handle = 1;
116  bytes value = 2;
117}
118
119// Request for the `ExchangeMTU` rpc.
120message ExchangeMTURequest {
121  Connection connection = 1;
122  int32 mtu = 2;
123}
124
125// Response for the `ExchangeMTU` rpc.
126message ExchangeMTUResponse {}
127
128// Request for the `WriteAttFromHandle` rpc.
129message WriteRequest {
130  Connection connection = 1;
131  uint32 handle = 2;
132  bytes value = 3;
133}
134
135// Request for the `WriteAttFromHandle` rpc.
136message WriteResponse {
137  uint32 handle = 1;
138  AttStatusCode status = 2;
139}
140
141// Request for the `SetCharacteristicNotificationFromHandle` rpc.
142message SetCharacteristicNotificationFromHandleRequest {
143  Connection connection = 1;
144  uint32 handle = 2;
145  EnableValue enable_value = 3;
146}
147
148// Response for the `SetCharacteristicNotificationFromHandle` rpc.
149message SetCharacteristicNotificationFromHandleResponse {
150  uint32 handle = 1;
151  AttStatusCode status = 2;
152}
153
154// Request for the `WaitCharacteristicNotification` rpc.
155message WaitCharacteristicNotificationRequest {
156  Connection connection = 1;
157  uint32 handle = 2;
158}
159
160// Response for the `WaitCharacteristicNotification` rpc.
161message WaitCharacteristicNotificationResponse {
162  bool characteristic_notification_received = 1;
163}
164
165// Request for the `DiscoverServiceByUuid` rpc.
166message DiscoverServiceByUuidRequest {
167  Connection connection = 1;
168  string uuid = 2;
169}
170
171// Request for the `DiscoverServices` rpc.
172message DiscoverServicesRequest {
173  Connection connection = 1;
174}
175
176// Response for the `DiscoverServices` rpc.
177message DiscoverServicesResponse {
178  repeated GattService services = 1;
179}
180
181// Request for the `DiscoverServicesSdp` rpc.
182message DiscoverServicesSdpRequest {
183  bytes address = 1;
184}
185
186// Response for the `DiscoverServicesSdp` rpc.
187message DiscoverServicesSdpResponse {
188  repeated string service_uuids = 1;
189}
190
191// Request for the `ClearCache` rpc.
192message ClearCacheRequest {
193  Connection connection = 1;
194}
195
196// Response for the `ClearCache` rpc.
197message ClearCacheResponse {}
198
199// Request for the `ReadCharacteristicFromHandle` rpc.
200message ReadCharacteristicRequest {
201  Connection connection = 1;
202  uint32 handle = 2;
203}
204
205// Request for the `ReadCharacteristicsFromUuid` rpc.
206message ReadCharacteristicsFromUuidRequest {
207  Connection connection = 1;
208  string uuid = 2;
209  uint32 start_handle = 3;
210  uint32 end_handle = 4;
211}
212
213// Response for the `ReadCharacteristicFromHandle` rpc.
214message ReadCharacteristicResponse {
215  AttValue value = 1;
216  AttStatusCode status = 2;
217}
218
219// Response for the `ReadCharacteristicsFromUuid` rpc.
220message ReadCharacteristicsFromUuidResponse {
221  repeated ReadCharacteristicResponse characteristics_read = 1;
222}
223
224// Request for the `ReadCharacteristicDescriptorFromHandle` rpc.
225message ReadCharacteristicDescriptorRequest {
226  Connection connection = 1;
227  uint32 handle = 2;
228}
229
230// Response for the `ReadCharacteristicDescriptorFromHandle` rpc.
231message ReadCharacteristicDescriptorResponse {
232  AttValue value = 1;
233  AttStatusCode status = 2;
234}
235
236message GattServiceParams {
237  string uuid = 1;
238  repeated GattCharacteristicParams characteristics = 2;
239}
240
241message GattCharacteristicParams {
242  uint32 properties = 1;
243  uint32 permissions = 2;
244  string uuid = 3;
245  repeated GattDescriptorParams descriptors = 4;
246}
247
248message GattDescriptorParams {
249  uint32 properties = 1;
250  uint32 permissions = 2;
251  string uuid = 3;
252}
253
254message RegisterServiceRequest {
255  GattServiceParams service = 1;
256}
257
258message RegisterServiceResponse {
259  GattService service = 1;
260}
261
262message NotifyOnCharacteristicRequest {
263  uint32 handle = 1;
264  bytes value = 2;
265}
266
267message NotifyOnCharacteristicResponse {
268  AttStatusCode status = 1;
269}
270
271message IndicateOnCharacteristicRequest {
272  uint32 handle = 1;
273  bytes value = 2;
274}
275
276message IndicateOnCharacteristicResponse {
277  AttStatusCode status = 1;
278}
279