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 88enum ServiceType { 89 PRIMARY = 0x00; 90 SECONDARY = 0x01; 91} 92 93// A message representing a GATT service. 94message GattService { 95 uint32 handle = 1; 96 ServiceType service_type = 2; 97 string uuid = 3; 98 repeated GattService included_services = 4; 99 repeated GattCharacteristic characteristics = 5; 100} 101 102// A message representing a GATT characteristic. 103message GattCharacteristic { 104 uint32 properties = 1; 105 uint32 permissions = 2; 106 string uuid = 3; 107 uint32 handle = 4; 108 repeated GattCharacteristicDescriptor descriptors = 5; 109} 110 111// A message representing a GATT descriptors. 112message GattCharacteristicDescriptor { 113 uint32 handle = 1; 114 uint32 permissions = 2; 115 string uuid = 3; 116} 117 118message AttValue { 119 // Descriptor handle or Characteristic handle (not Characteristic Value handle). 120 uint32 handle = 1; 121 bytes value = 2; 122} 123 124// Request for the `ExchangeMTU` rpc. 125message ExchangeMTURequest { 126 Connection connection = 1; 127 int32 mtu = 2; 128} 129 130// Response for the `ExchangeMTU` rpc. 131message ExchangeMTUResponse {} 132 133// Request for the `WriteAttFromHandle` rpc. 134message WriteRequest { 135 Connection connection = 1; 136 uint32 handle = 2; 137 bytes value = 3; 138} 139 140// Request for the `WriteAttFromHandle` rpc. 141message WriteResponse { 142 uint32 handle = 1; 143 AttStatusCode status = 2; 144} 145 146// Request for the `SetCharacteristicNotificationFromHandle` rpc. 147message SetCharacteristicNotificationFromHandleRequest { 148 Connection connection = 1; 149 uint32 handle = 2; 150 EnableValue enable_value = 3; 151} 152 153// Response for the `SetCharacteristicNotificationFromHandle` rpc. 154message SetCharacteristicNotificationFromHandleResponse { 155 uint32 handle = 1; 156 AttStatusCode status = 2; 157} 158 159// Request for the `WaitCharacteristicNotification` rpc. 160message WaitCharacteristicNotificationRequest { 161 Connection connection = 1; 162 uint32 handle = 2; 163} 164 165// Response for the `WaitCharacteristicNotification` rpc. 166message WaitCharacteristicNotificationResponse { 167 bool characteristic_notification_received = 1; 168} 169 170// Request for the `DiscoverServiceByUuid` rpc. 171message DiscoverServiceByUuidRequest { 172 Connection connection = 1; 173 string uuid = 2; 174} 175 176// Request for the `DiscoverServices` rpc. 177message DiscoverServicesRequest { 178 Connection connection = 1; 179} 180 181// Response for the `DiscoverServices` rpc. 182message DiscoverServicesResponse { 183 repeated GattService services = 1; 184} 185 186// Request for the `DiscoverServicesSdp` rpc. 187message DiscoverServicesSdpRequest { 188 bytes address = 1; 189} 190 191// Response for the `DiscoverServicesSdp` rpc. 192message DiscoverServicesSdpResponse { 193 repeated string service_uuids = 1; 194} 195 196// Request for the `ClearCache` rpc. 197message ClearCacheRequest { 198 Connection connection = 1; 199} 200 201// Response for the `ClearCache` rpc. 202message ClearCacheResponse {} 203 204// Request for the `ReadCharacteristicFromHandle` rpc. 205message ReadCharacteristicRequest { 206 Connection connection = 1; 207 uint32 handle = 2; 208} 209 210// Request for the `ReadCharacteristicsFromUuid` rpc. 211message ReadCharacteristicsFromUuidRequest { 212 Connection connection = 1; 213 string uuid = 2; 214 uint32 start_handle = 3; 215 uint32 end_handle = 4; 216} 217 218// Response for the `ReadCharacteristicFromHandle` rpc. 219message ReadCharacteristicResponse { 220 AttValue value = 1; 221 AttStatusCode status = 2; 222} 223 224// Response for the `ReadCharacteristicsFromUuid` rpc. 225message ReadCharacteristicsFromUuidResponse { 226 repeated ReadCharacteristicResponse characteristics_read = 1; 227} 228 229// Request for the `ReadCharacteristicDescriptorFromHandle` rpc. 230message ReadCharacteristicDescriptorRequest { 231 Connection connection = 1; 232 uint32 handle = 2; 233} 234 235// Response for the `ReadCharacteristicDescriptorFromHandle` rpc. 236message ReadCharacteristicDescriptorResponse { 237 AttValue value = 1; 238 AttStatusCode status = 2; 239} 240 241message GattServiceParams { 242 string uuid = 1; 243 repeated GattCharacteristicParams characteristics = 2; 244} 245 246message GattCharacteristicParams { 247 uint32 properties = 1; 248 uint32 permissions = 2; 249 string uuid = 3; 250 repeated GattDescriptorParams descriptors = 4; 251} 252 253message GattDescriptorParams { 254 uint32 properties = 1; 255 uint32 permissions = 2; 256 string uuid = 3; 257} 258 259message RegisterServiceRequest { 260 GattServiceParams service = 1; 261} 262 263message RegisterServiceResponse { 264 GattService service = 1; 265} 266 267message NotifyOnCharacteristicRequest { 268 uint32 handle = 1; 269 bytes value = 2; 270} 271 272message NotifyOnCharacteristicResponse { 273 AttStatusCode status = 1; 274} 275 276message IndicateOnCharacteristicRequest { 277 uint32 handle = 1; 278 bytes value = 2; 279} 280 281message IndicateOnCharacteristicResponse { 282 AttStatusCode status = 1; 283} 284