14.2.3.5.1 Sending a General cluster command.

General cluster commands are sent via the ZCL_AttributeReq() function that has the pointer to an instance of the ZCL_Request_t type as an argument. The structure behind the pointer includes complete destination specification (device address, destination endpoint, cluster ID etc.), command ID, source endpoint ID, payload length, and payload itself.

The argument also includes the defaultResponse field for configuring default response bit. If it is set to ZCL_FRAME_CONTROL_ENABLE_DEFAULT_RESPONSE then ZCL default response command will be sent from the destination but not for the commands that already require command-specific ZCL response (e.g. read attribute command). Reception of unsolicited default responses is indicated by a special callback function

Consider the example:

ZCL_Request_t zclReq; //In the global scope
...
zclReq.id = …; // specify command ID, e.g. ZCL_READ_ATTRIBUTES_COMMAND_ID
zclReq.endpointId = APP_ENDPOINT_LIGHT; //Source application endpoint
zclReq.ZCL_Notify = ZCL_AttributeResp; //The callback function
 
//Setting destination address
zclReq.dstAddressing.addrMode = APS_NO_ADDRESS; //Use binding
zclReq.dstAddressing.profileId = PROFILE_ID;
zclReq.dstAddressing.clusterId = ONOFF_CLUSTER_ID;
zclReq.dstAddressing.clusterSide = ZCL_CLUSTER_SIDE_SERVER;
 
//Disable default response (won’t be sent for commands with specific ZCL response)
//but can be enabled for requests w/o response (e.g. attribute reports)
zclReq.defaultResponse = ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE;
 
zclReq.requestLength = …; // specify payload length
zclReq.requestPayload = …; // point to payload memory
 
//execute the request 
ZCL_AttributeReq(&zclReq);

Note: How to fill the req.requestLength and req.requestPayload fields is not shown in this example. The ZCL component provides ZCL_PutNextElement() function that can be used to simplify filling and parsing the payload and calculating its length correctly