1.1.2.1.2.4.9 GATTC_Read

C

uint16_t GATTC_Read(uint16_t connHandle, uint16_t charHandle, uint16_t valueOffset);

Description

GATT Client initiates a read operation to GATT Server when this API is called. This API should be used to read a Characteristic Value or Characteristic descriptor.

Note

Read long attributes:

  • If the attribute is not long attribute, valueOffset should be set to 0 and Read request is sent to GATT Server by this API.

  • If the attribute is a long attribute then first (ATT_MTU-1) bytes are read with valueOffset set to 0 (API uses Read Request) and rest of the bytes are read using appropriate Non-zero valueOffset (API uses Read Blob Request). The Read Blob Request should be initiated in the application by calling the API GATTC_Read with non-zero valueOffset when the event GATTC_EVT_READ_RESP is received. This should be repeated each time the event GATTC_EVT_READ_RESP is received until expected number of bytes of the long attribute are read.

Parameters

ParameterDescription
[in] connHandleHandle of the connection.
[in] charHandleHandle of the characteristic value or descriptor to be read.
[in] valueOffsetNon-zero offset value to initiate a read blob request.

Return values

Return valueDescription
MBA_RES_SUCCESSSuccessfully starts the read operation.
MBA_RES_OOMInternal memory allocation failure.
MBA_RES_INVALID_PARAInvalid parameters. Connection handle is not valid.
MBA_RES_BUSYGATT Client is busy. Another request is ongoing.