• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
48enum AttStatusCode {
49  SUCCESS = 0x00;
50  UNKNOWN_ERROR = 0x101;
51  INVALID_HANDLE = 0x01;
52  READ_NOT_PERMITTED = 0x02;
53  WRITE_NOT_PERMITTED = 0x03;
54  INSUFFICIENT_AUTHENTICATION = 0x05;
55  INVALID_OFFSET = 0x07;
56  ATTRIBUTE_NOT_FOUND = 0x0A;
57  INVALID_ATTRIBUTE_LENGTH = 0x0D;
58  APPLICATION_ERROR = 0x80;
59}
60
61enum AttProperties {
62  PROPERTY_NONE = 0x00;
63  PROPERTY_READ = 0x02;
64  PROPERTY_WRITE = 0x08;
65}
66
67enum AttPermissions {
68  PERMISSION_NONE = 0x00;
69  PERMISSION_READ = 0x01;
70  PERMISSION_READ_ENCRYPTED = 0x02;
71  PERMISSION_READ_ENCRYPTED_MITM = 0x04;
72  PERMISSION_WRITE = 0x10;
73  PERMISSION_WRITE_ENCRYPTED = 0x20;
74  PERMISSION_WRITE_ENCRYPTED_MITM = 0x40;
75}
76
77enum EnableValue {
78  ENABLE_NOTIFICATION_VALUE = 0;
79  ENABLE_INDICATION_VALUE = 1;
80}
81
82// A message representing a GATT service.
83message GattService {
84  uint32 handle = 1;
85  uint32 type = 2;
86  string uuid = 3;
87  repeated GattService included_services = 4;
88  repeated GattCharacteristic characteristics = 5;
89}
90
91// A message representing a GATT characteristic.
92message GattCharacteristic {
93  uint32 properties = 1;
94  uint32 permissions = 2;
95  string uuid = 3;
96  uint32 handle = 4;
97  repeated GattCharacteristicDescriptor descriptors = 5;
98}
99
100// A message representing a GATT descriptors.
101message GattCharacteristicDescriptor {
102  uint32 handle = 1;
103  uint32 permissions = 2;
104  string uuid = 3;
105}
106
107message AttValue {
108  // Descriptor handle or Characteristic handle (not Characteristic Value handle).
109  uint32 handle = 1;
110  bytes value = 2;
111}
112
113// Request for the `ExchangeMTU` rpc.
114message ExchangeMTURequest {
115  Connection connection = 1;
116  int32 mtu = 2;
117}
118
119// Response for the `ExchangeMTU` rpc.
120message ExchangeMTUResponse {}
121
122// Request for the `WriteAttFromHandle` rpc.
123message WriteRequest {
124  Connection connection = 1;
125  uint32 handle = 2;
126  bytes value = 3;
127}
128
129// Request for the `WriteAttFromHandle` rpc.
130message WriteResponse {
131  uint32 handle = 1;
132  AttStatusCode status = 2;
133}
134
135// Request for the `SetCharacteristicNotificationFromHandle` rpc.
136message SetCharacteristicNotificationFromHandleRequest {
137  Connection connection = 1;
138  uint32 handle = 2;
139  EnableValue enable_value = 3;
140}
141
142// Response for the `SetCharacteristicNotificationFromHandle` rpc.
143message SetCharacteristicNotificationFromHandleResponse {
144  uint32 handle = 1;
145  AttStatusCode status = 2;
146}
147
148// Request for the `WaitCharacteristicNotification` rpc.
149message WaitCharacteristicNotificationRequest {
150  Connection connection = 1;
151  uint32 handle = 2;
152}
153
154// Response for the `WaitCharacteristicNotification` rpc.
155message WaitCharacteristicNotificationResponse {
156  bool characteristic_notification_received = 1;
157}
158
159// Request for the `DiscoverServiceByUuid` rpc.
160message DiscoverServiceByUuidRequest {
161  Connection connection = 1;
162  string uuid = 2;
163}
164
165// Request for the `DiscoverServices` rpc.
166message DiscoverServicesRequest {
167  Connection connection = 1;
168}
169
170// Response for the `DiscoverServices` rpc.
171message DiscoverServicesResponse {
172  repeated GattService services = 1;
173}
174
175// Request for the `DiscoverServicesSdp` rpc.
176message DiscoverServicesSdpRequest {
177  bytes address = 1;
178}
179
180// Response for the `DiscoverServicesSdp` rpc.
181message DiscoverServicesSdpResponse {
182  repeated string service_uuids = 1;
183}
184
185// Request for the `ClearCache` rpc.
186message ClearCacheRequest {
187  Connection connection = 1;
188}
189
190// Response for the `ClearCache` rpc.
191message ClearCacheResponse {}
192
193// Request for the `ReadCharacteristicFromHandle` rpc.
194message ReadCharacteristicRequest {
195  Connection connection = 1;
196  uint32 handle = 2;
197}
198
199// Request for the `ReadCharacteristicsFromUuid` rpc.
200message ReadCharacteristicsFromUuidRequest {
201  Connection connection = 1;
202  string uuid = 2;
203  uint32 start_handle = 3;
204  uint32 end_handle = 4;
205}
206
207// Response for the `ReadCharacteristicFromHandle` rpc.
208message ReadCharacteristicResponse {
209  AttValue value = 1;
210  AttStatusCode status = 2;
211}
212
213// Response for the `ReadCharacteristicsFromUuid` rpc.
214message ReadCharacteristicsFromUuidResponse {
215  repeated ReadCharacteristicResponse characteristics_read = 1;
216}
217
218// Request for the `ReadCharacteristicDescriptorFromHandle` rpc.
219message ReadCharacteristicDescriptorRequest {
220  Connection connection = 1;
221  uint32 handle = 2;
222}
223
224// Response for the `ReadCharacteristicDescriptorFromHandle` rpc.
225message ReadCharacteristicDescriptorResponse {
226  AttValue value = 1;
227  AttStatusCode status = 2;
228}
229
230message GattServiceParams {
231  string uuid = 1;
232  repeated GattCharacteristicParams characteristics = 2;
233}
234
235message GattCharacteristicParams {
236  uint32 properties = 1;
237  uint32 permissions = 2;
238  string uuid = 3;
239  repeated GattDescriptorParams descriptors = 4;
240}
241
242message GattDescriptorParams {
243  uint32 properties = 1;
244  uint32 permissions = 2;
245  string uuid = 3;
246}
247
248message RegisterServiceRequest {
249  GattServiceParams service = 1;
250}
251
252message RegisterServiceResponse {
253  GattService service = 1;
254}
255