Hello, I' trying to use the macro here below, but there are no sample in SDK.
Have you any example for using it?
Many thanks
Abele
Hello, I' trying to use the macro here below, but there are no sample in SDK.
Have you any example for using it?
Many thanks
Abele
Hi Marjeris,
I apologize for the delay, but I was busy with other works. Now I'm on this project, and I tried to add the functions you suggest, but I have some errors and I'm not be able to find the right definitions, for example, for the light_switch_entry_t typedef and LIGHT_COORDINATOR_EP macro.
Where I can find these? What the sample code you refer to?
Many thanks for your help!
Abele
Hi Abele,
The code snippet I shared was just so you could see an example on how the ZB_ZCL_GENERAL_SEND_READ_ATTR_REQ macro is implemented and how to implement an endpoint handler to intercept the response, I don't recommend copying it directly, as some functions and structs in that snippet are defined by myself, sorry for the confusion about that. For example light_switch_entry_t is just a selfmade structure I defined to help me store the on/off state of the devices in the network.
And for example should change the "LIGHT_COORDINATOR_EP" for the name you have defined for your sending endpoint (from which endpoint are you sending the send read attribute request?).
I think it would be easier for me to help you if you could share your code (main.c) here.
BR,
Marjeris
Hi Marjeris,
many thanks for your help, now I'm be able to intercept the ZCL attr request response.
In my code I forgot the ZB_AF_REGISTER_DEVICE_CTX() initialization, then my macro call ZB_AF_SET_ENDPOINT_HANDLER(ZIGBEE_ZC_MAIN_ENDPOINT, callback_ep_handler) had no effects.
Now, when i send a read_attr request, the callback_ep_handler() function is invoked.
Two further questions:
- the callback_ep_handler() return the "zb_uint8_t param" value set to 0x04, it's right? What's the meaning of this parameter?
- I need using Groupcast command: for example, I have set cluster 4 inside two light bulb with the command "add group" (both with same group code, of course). How can I send the "groupcast" on/off command? There is an example how to make this?
Kind regards
Abele
Hi Abele,
Sorry for the late reply. Can you share the code of callback_ep_handler()? The packet ZCL packet handler (in this case callback_ep_handler()) should either return ZB_FALSE, if the packet is not processed by the application and the default ZCL handling is applied, or ZB_TRUE if the aplication does handle the packet and no default processing is needed. See "Implementing algorithm for overriding the handling of ZCL commands".
For sending and a group command you need to use the group ID as the destination address. Take a look at the light_switch_groups examples under example/zigbee/experimental
static zb_void_t light_switch_send_on_off(zb_uint8_t param, zb_uint16_t on_off) { zb_uint8_t cmd_id; zb_uint16_t group_id = DEFAULT_GROUP_ID; zb_buf_t * p_buf = ZB_BUF_FROM_REF(param); if (on_off) { cmd_id = ZB_ZCL_CMD_ON_OFF_ON_ID; } else { cmd_id = ZB_ZCL_CMD_ON_OFF_OFF_ID; } NRF_LOG_INFO("Send ON/OFF command: %d", on_off); ZB_ZCL_ON_OFF_SEND_REQ(p_buf, group_id, ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT, 0, LIGHT_SWITCH_ENDPOINT, ZB_AF_HA_PROFILE_ID, ZB_ZCL_DISABLE_DEFAULT_RESPONSE, cmd_id, NULL); }
Best regards,
Marjeris