ZCL_PutNextElement Function
C
ZCL_Status_t ZCL_PutNextElement(ZCL_NextElement_t *element);
Description
Adds an element to the outgoing command payload
This function is used to simplify forming a correst payload for general commands (read/write attributes etc.). A single command may involve actions on several attributes, and so the overall payload should contain pieces corresponding to each attribute.
The general idea is to provide a buffer for the payload and some content. The function writes the content in a correct way to the buffer and calculate the overall payload length. The buffer and the payload length are then passed as parameters to the ZCL_AttributeReq() function.
See the following example:
ZCL_NextElement_t element; ZCL_ReadAttributeReq_t readAttrReqElement; ZCL_Request_t readAttrReq; uint8_t buffer[BUFFER_SIZE]; element.payloadLength = 0; element.payload = buffer; element.id = ZCL_READ_ATTRIBUTES_COMMAND_ID; element.content = &readAttrReqElement; readAttrReqElement = ATTRIBUTE_ID1; //Set to the ID of the first attribute ZCL_PutNextElement(&element); readAttrReqElement = ATTRIBUTE_ID2; //Set to the ID of the second attribute ZCL_PutNextElement(&element); readAttrReq.requestLength = element.payloadLength; readAttrReq.requestPayload = buffer; ...
Note, however, that the usage may differ depending on a command's type.
Parameters
Param | Description |
---|---|
element | information about payload and element status of the operation: |
::ZCL_SUCCESS_STATUS (0x00) | an element has been written to the payload successfully, more elements can be added \n |
::ZCL_END_PAYLOAD_REACHED_STATUS (0xFD) | an element has been written successfully, and |
the payload is full | no more elements can be added \n |
::ZCL_INVALID_PARAMETER_STATUS (0xFF) | the argument is NULL |
Returns
None