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.
Events generated
GATTC_EVT_ERROR_RESP Generated when fail to read.
GATTC_EVT_READ_RESP Generated when read successfully.
ATT_EVT_TIMEOUT Generated when server does not respond the request.
Parameters
Parameter | Description |
---|---|
[in] connHandle | Handle of the connection. |
[in] charHandle | Handle of the characteristic value or descriptor to be read. |
[in] valueOffset | Non-zero offset value to initiate a read blob request. |
Return values
Return value | Description |
---|---|
MBA_RES_SUCCESS | Successfully starts the read operation. |
MBA_RES_OOM | Internal memory allocation failure. |
MBA_RES_INVALID_PARA | Invalid parameters. Connection handle is not valid. |
MBA_RES_BUSY | GATT Client is busy. Another request is ongoing. |