GATTC_Write
C
uint16_t GATTC_Write(uint16_t connHandle, GATTC_WriteParams_T *p_writeParams);
Description
Initiates a write operation from the GATT Client to the GATT Server.
Note
Use this API to write a Characteristic Value or a Characteristic Descriptor. See ATT opcodes for write types (ATT_WRITE_REQ, ATT_WRITE_CMD, ATT_PREPARE_WRITE_REQ, ATT_EXECUTE_WRITE_REQ). - For non-long attributes, set valueOffset to 0 and choose Write Request/Write Command. - For long attributes, write the first (ATT_MTU-3) bytes with valueOffset set to 0 and writeType as ATT_PREPARE_WRITE_REQ. Subsequent prepare write requests should be made with the correct valueOffset and data upon receiving GATTC_EVT_WRITE_RESP. Continue until all bytes are queued on the server. After the last prepare write response, call this API with writeType as ATT_EXECUTE_WRITE_REQ and flags as Execute write flags.
Events generated
GATTC_EVT_ERROR_RESP is generated on write failure.
GATTC_EVT_WRITE_RESP is generated on successful write.
ATT_EVT_TIMEOUT is generated if the server does not respond.
Parameters
Parameter | Description |
---|---|
[in] connHandle | Handle of the connection to send write operation. |
[in] p_writeParams | Pointer to the write parameters structure (see GATTC_WriteParams_T). |
Return values
Return value | Description |
---|---|
MBA_RES_SUCCESS | Successfully starts the write operation. |
MBA_RES_FAIL | Operation not permitted. |
MBA_RES_OOM | Memory allocation failure occurred internally. |
MBA_RES_INVALID_PARA | Invalid parameters (invalid connection handle or write parameters). |
MBA_RES_NO_RESOURCE | No resources available to perform the write. |
MBA_RES_BUSY | GATT Client is busy with another ongoing request. |