1syntax = "proto3"; 2 3option java_outer_classname = "GattProto"; 4 5package pandora; 6 7import "pandora_experimental/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 42enum AttStatusCode { 43 SUCCESS = 0x00; 44 UNKNOWN_ERROR = 0x101; 45 INVALID_HANDLE = 0x01; 46 READ_NOT_PERMITTED = 0x02; 47 WRITE_NOT_PERMITTED = 0x03; 48 INSUFFICIENT_AUTHENTICATION = 0x05; 49 INVALID_OFFSET = 0x07; 50 ATTRIBUTE_NOT_FOUND = 0x0A; 51 INVALID_ATTRIBUTE_LENGTH = 0x0D; 52 APPLICATION_ERROR = 0x80; 53} 54 55enum AttProperties { 56 PROPERTY_NONE = 0x00; 57 PROPERTY_READ = 0x02; 58 PROPERTY_WRITE = 0x08; 59} 60 61enum AttPermissions { 62 PERMISSION_NONE = 0x00; 63 PERMISSION_READ = 0x01; 64 PERMISSION_WRITE = 0x10; 65 PERMISSION_READ_ENCRYPTED = 0x02; 66} 67 68// A message representing a GATT service. 69message GattService { 70 uint32 handle = 1; 71 uint32 type = 2; 72 string uuid = 3; 73 repeated GattService included_services = 4; 74 repeated GattCharacteristic characteristics = 5; 75} 76 77// A message representing a GATT characteristic. 78message GattCharacteristic { 79 uint32 properties = 1; 80 uint32 permissions = 2; 81 string uuid = 3; 82 uint32 handle = 4; 83 repeated GattCharacteristicDescriptor descriptors = 5; 84} 85 86// A message representing a GATT descriptors. 87message GattCharacteristicDescriptor { 88 uint32 handle = 1; 89 uint32 permissions = 2; 90 string uuid = 3; 91} 92 93message AttValue { 94 // Descriptor handle or Characteristic handle (not Characteristic Value handle). 95 uint32 handle = 1; 96 bytes value = 2; 97} 98 99// Request for the `ExchangeMTU` rpc. 100message ExchangeMTURequest { 101 Connection connection = 1; 102 int32 mtu = 2; 103} 104 105// Response for the `ExchangeMTU` rpc. 106message ExchangeMTUResponse {} 107 108// Request for the `WriteAttFromHandle` rpc. 109message WriteRequest { 110 Connection connection = 1; 111 uint32 handle = 2; 112 bytes value = 3; 113} 114 115// Request for the `WriteAttFromHandle` rpc. 116message WriteResponse { 117 uint32 handle = 1; 118 AttStatusCode status = 2; 119} 120 121// Request for the `DiscoverServiceByUuid` rpc. 122message DiscoverServiceByUuidRequest { 123 Connection connection = 1; 124 string uuid = 2; 125} 126 127// Request for the `DiscoverServices` rpc. 128message DiscoverServicesRequest { 129 Connection connection = 1; 130} 131 132// Response for the `DiscoverServices` rpc. 133message DiscoverServicesResponse { 134 repeated GattService services = 1; 135} 136 137// Request for the `DiscoverServicesSdp` rpc. 138message DiscoverServicesSdpRequest { 139 bytes address = 1; 140} 141 142// Response for the `DiscoverServicesSdp` rpc. 143message DiscoverServicesSdpResponse { 144 repeated string service_uuids = 1; 145} 146 147// Request for the `ClearCache` rpc. 148message ClearCacheRequest { 149 Connection connection = 1; 150} 151 152// Response for the `ClearCache` rpc. 153message ClearCacheResponse {} 154 155// Request for the `ReadCharacteristicFromHandle` rpc. 156message ReadCharacteristicRequest { 157 Connection connection = 1; 158 uint32 handle = 2; 159} 160 161// Request for the `ReadCharacteristicsFromUuid` rpc. 162message ReadCharacteristicsFromUuidRequest { 163 Connection connection = 1; 164 string uuid = 2; 165 uint32 start_handle = 3; 166 uint32 end_handle = 4; 167} 168 169// Response for the `ReadCharacteristicFromHandle` rpc. 170message ReadCharacteristicResponse { 171 AttValue value = 1; 172 AttStatusCode status = 2; 173} 174 175// Response for the `ReadCharacteristicsFromUuid` rpc. 176message ReadCharacteristicsFromUuidResponse { 177 repeated ReadCharacteristicResponse characteristics_read = 1; 178} 179 180// Request for the `ReadCharacteristicDescriptorFromHandle` rpc. 181message ReadCharacteristicDescriptorRequest { 182 Connection connection = 1; 183 uint32 handle = 2; 184} 185 186// Response for the `ReadCharacteristicDescriptorFromHandle` rpc. 187message ReadCharacteristicDescriptorResponse { 188 AttValue value = 1; 189 AttStatusCode status = 2; 190} 191 192message GattServiceParams { 193 string uuid = 1; 194 repeated GattCharacteristicParams characteristics = 2; 195} 196 197message GattCharacteristicParams { 198 uint32 properties = 1; 199 uint32 permissions = 2; 200 string uuid = 3; 201} 202 203message RegisterServiceRequest { 204 GattServiceParams service = 1; 205} 206 207message RegisterServiceResponse { 208 GattService service = 1; 209} 210