Q1, Would it send out APS ACK request? so the call back is dealing the APS ACK confirmation, right?
Q2, If we set the call back as NULL, how the buffer got released?
Q3, If multiple ZB_ZCL_SEND_COMMAND_SHORT are sent, would the zboss call the right call back?
It doesn't get released.
I'll have to get back to you on this tomorrow.
Here is an update.
Q2: Generally, if no callback is set, the stack will free it upon receiving APS ACK. The only broken scenario is when the stack cannot send the command - in such a situation the app should handle the return code to free it, which is impossible with the macro-version.
So you should either use zb_zcl_finish_and_send_packet() (which is described in zb_zcl_common.h in SDK_for_Thread_and_Zigbee_4.0.0) or provide a callback function.
Q3: They are called with the order of receiving APS ACKs. So, if one is lost, the order may differ from the sending queue.
How about ZB_ZCL_GROUPS_SEND_ADD_GROUP_REQ (..., cb), it uses ZB_ZCL_SEND_COMMAND_SHORT to send the packet. There is no way to check if the stack send the command in this case. How we deal this situation?
Heidi is out on business travel so I have taken over this case. If you want to check if the stack have sent the add group command you will need to register an endpoint handler and parse the add group response manually, just like you would parse a read attribute response for example.
From the ZCL spec section 18.104.22.168.1 the payload of the add group response command is the following:
This command is generated in response to a received Add Group command. The Status field is set toSUCCESS, DUPLICATE_EXISTS, or INSUFFICIENT_SPACE as appropriate. The Group ID field is set tothe Group ID field of the received Add Group command.
Correct me if I am wrong.
The following is how I understand
ZB_ZCL_GROUPS_SEND_ADD_GROUP_REQ (..., Default Response, cb, ...)
if Default Response is enabled, the client needs to register an endpoint handler to take care of it. The cb is assigned to handle the APS ACK. It the cb is NULL, the stack will free it upon receiving APS ACK.
When the server receives the Add Group command, it will respond it. The registered end point handler inside the client will receive the server response, and use ZB_ZCL_GROUPS_GET_ADD_GROUP_RES to parse the returned response.
Q1. If Default Response is enabled, the server will respond the default response and Add Group Command?
Q2. In the zigbee/light_control/light_bulb does not see any ZB_ZCL_GROUPS_GET_ADD_GROUP_REQ
to respond the add group command?
Q3. In Add group command definitions, it mentioned "For more information see 5.5.3_groups sample". Where to find 5.5.3?
Thanks so much
Sorry for the late reply.
hlshen said: if Default Response is enabled, the client needs to register an endpoint handler to take care of it.
For question 1 (Q1) I am actually not sure if you will get both a Default response and a Add group response if Default response is enabled, I will need to verify this using a sniffer, but from the ZCL specification it sounds like you either get a Add group response or a Default response.
In ZCL spec section 2.3.2:
If required, the device SHALL then generate a response to the command. Responses are detailed in thespecification of each command. If there is no response specified for a particular set of circumstances, (e.g., ifthe command has been rejected or is not recognized, or the command has succeeded but there is no responsespecified to indicate success), the Default Response command SHALL be generated, taking into account theconditions in 22.214.171.124.
If the Disable Default Response bit of the frame control field is not set to 0 (ZB_ZCL_DISABLE_DEFAULT_RESPONSE), or the other criteria listed in section 126.96.36.199 is not met, the Default Response will not be generated.
The enable/disable the Default response frame shouldn't have anything to do with your decision to register or not an endpoint handler.
Both the Default response and the Add group response command is handled by the stack, so you don't need any additional logic in your application. That's why you don't see any ZB_ZCL_GROUPS_GET_ADD_GROUP_REQ in the light bulb groups example (Q2).The endpoint handler is only implemented as a mechanism to override the default ZCL command processing of the stack, for example if you want to parse the Add group response command you need to do this in the endpoint handler.
The callback is to handle the APS ACK send events. If no callback is set, the stack will free the buffer upon receiving APS ACK, if you assign a callback for e.g further configuration or for parsing the APS ACK you need to remember to free the buffer when finished.
Q3. I think this is a typo in the documentation. I will check.