ZCL_AttributeReq Function

C

void ZCL_AttributeReq(ZCL_Request_t *req);

Description

Sends a general ZCL command related to attributes to a remote device

The function is used to read/write attributes from a remote device, to report local attributes, and to discover attributes supported by a particular cluster on a remote device.

Command's parameters include addressing information, calback functions, command's ID, and the payload. The payload may be formed via the ZCL_PutNextElement() function and an instance of ZCL_NextElement_t type. The command may be used to perform actions on multiple attributes at a time; for example, to read several attributes from a remote device.

Attribute related commands are usually send to specific short or extended addresses. Sending such commands to bound devices (employing -APS_NO_ADDRESS mode) may not be as efficient, because in case of responses from more than one device the ZCL component will process only the first one.

The callback function specified in the \c req->ZCL_Notify field is called twice for most of the commands (excluding reporting): the first time to confirm that the command has been sent, and the second time upon receiving the response command. To differentiate these the callback's argument includes the ZCL_Notify_t-id field, which equals -ZCL_APS_CONFIRM_ID in the first case and -ZCL_ZCL_RESPONSE_ID in the second.

Common uses of the function include sending the following commands (the command's ID listed below should be assigned to the \c req->id field):

  • -ZCL_READ_ATTRIBUTES_COMMAND_ID - reading remote attributes (obtaining values)

  • -ZCL_WRITE_ATTRIBUTES_COMMAND_ID - writing remote attributes (assigning new values)

  • -ZCL_REPORT_ATTRIBUTES_COMMAND_ID - reporting local attributes to remote devices

(sending current attributes' values)

  • -ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID - discovering attributes of a remote device (obtaining

data types and IDs of attributes supported by a particular cluster)

  • -ZCL_DISCOVER_COMMANDS_RECEIVED_COMMAND_ID - discovering the commands received (obtaining

the list of commands those can be received and processed

  • -ZCL_DISCOVER_COMMANDS_GENEARATED_COMMAND_ID - discovering the commands generated (obtaining

the list of commands those can be generated and processed

  • -ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID - discovering attributes of a remote device (obtaining

data types,access control and IDs of attributes supported by a particular cluster)

Response statuses: Accessed via the ZCL_Notify_t-status field of the callback function specified in the \c req->ZCL_Notify field

All commands

-ZCL_SUCCESS_STATUS (0x00) - the request has been executed successfully

(all attributes are written, read, or reported, etc.)

-ZCL_INSUFFICIENT_SPACE_STATUS (0x89) - the ZCL buffer is not big enough

to hold the request's payload

-ZCL_UNSUPPORTED_ATTRIBUTE_STATUS (0x86) - an attribute specified in the request is

not supported by the destination node

-ZCL_INVALID_FIELD_STATUS (0x85) - a command's field contains an incorrect value \n -ZCL_INVALID_DATA_TYPE_STATUS (0x8D) - wrong attribute type has been specified \n -ZCL_TIMEOUT_STATUS (0x94) - the response command is expected, but has not

been received in time: the timeout based on network parameters (such as max network depth) has occured.

Write attributes command

-ZCL_WRITE_ATTRIBUTES_FAILURE_STATUS (0x0F) - not all attributes have been written;

see individual statuses of attribute records to check each attribute

Report attributes command

-ZCL_UNREPORTABLE_ATTRIBUTE_STATUS (0x8C) - the requested attribute is not

reportable

Parameters

ParamDescription
reqcommand parameters

Returns

None