1.2.2.1.2.4.12 GATTC_Write

C

uint16_t GATTC_Write(uint16_t connHandle, GATTC_WriteParams_T *p_writeParams);

Description

GATT Client initiates a write operation to GATT Server. This API should be used to write a Characteristic Value or Characteristic descriptor.

Refer ATT opcodes (ATT_WRITE_REQ/ATT_WRITE_CMD/ATT_PREPARE_WRITE_REQ/ATT_EXECUTE_WRITE_REQ) for write types.

Note

Write long attribute:

  • If the attribute is not long attribute, valueOffset should be set to 0 and writeType should be set to Write Request/Write Command as required.

  • If the attribute is a long attribute then first (ATT_MTU-3) bytes should be written with valueOffset set to 0 and writeType set to ATT_PREPARE_WRITE_REQ (See GATTC_WriteParams_T) in the API. The subsequent prepare write request should be called with appropriate value Offset and next set of data when event GATTC_EVT_WRITE_RESP is received. This should be repeated until expected number of bytes is queued up in the server. When event GATTC_EVT_WRITE_RESP is received for last prepare write request, this API should be called with writeType set to ATT_EXECUTE_WRITE_REQ and flags set to Execute write flag (See GATTC_WriteParams_T)

Parameters

ParameterDescription
[in] connHandleHandle of the connection to send write operation.
[in] p_writeParamsPointer to the Write Request parameters. Refer GATTC_WriteParams_T.

Return values

Return valueDescription
MBA_RES_SUCCESSSuccessfully starts the write operation.
MBA_RES_FAILOperation is not permitted.
MBA_RES_OOMInternal memory allocation failure.
MBA_RES_INVALID_PARAInvalid parameters. One of the following reasons: - Connection handle is not valid - Invalid write parameters. See GATTC_WriteParams_T for valid values.
MBA_RES_NO_RESOURCENo available resource to send write operation.
MBA_RES_BUSYGATT Client is busy. Another request is ongoing.