This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to send buffer from light switch to light bulb?

Hello,

I am using nRF52833, nRF Connect SDK  v1.5.0.

I followed this link Zigbee: Light switch — nRF Connect SDK 1.5.0 documentation (nordicsemi.com) and successfully tested the Zigbee light switch example.

Now I want to send the buffer from the light switch to the light bulb.

Also, referred this API "ZB_ZCL_ON_OFF_SEND_REQ"

But I didn't find any provision to send buffer. 

Can you please help me to resolve this issue?

Thank you,

Pranav.

Parents
  • Hi,

    Which buffer do you want to send? Is there a specific cluster command you want to send? The command you send must be something that corresponds with the Zigbee specification, such as a cluster command. What is it you want to achieve by sending this buffer?

    Best regards,

    Marte

  • Hi Marte,

    I wanted to send a custom message i.e buffer (for ex. array) from light switch to light bulb.

    What is it you want to achieve by sending this buffer?

    By sending this custom message I wanted to perform some action i.e bulb on/off, set threshold, log that message etc.

    Do I need to create custom clusters for that?

    Thank you,

    Pranav.

  • Hi,

    If you want to turn the bulb on/off you should use the on/off cluster as is done in the example. This is done in the function button_handler() in main.c of the light switch sample, where it sends an on/off cluster command to the light bulb if either the on button or the off button are pressed. It allocates the output buffer and send on/off command with the following:

    zb_err_code = zb_buf_get_out_delayed_ext(light_switch_send_on_offcmd_id0);

    This will not send the command directly, but schedules a callback for execution if the buffer is available, where the callback in this case is the callback function light_switch_send_on_off(), which actually is responsible for sending the on/off command with ZB_ZCL_ON_OFF_SEND_REQ().

    If you want to send commands in Zigbee, you have to use cluster commands, and not just send a message. If there are clusters that already do what you want to do, I would recommend using them instead of creating your own cluster first. You can check out the ZBOSS documentation for a list of clusters in the ZBOSS stack, which is the stack used in NCS, and you can also check out the Zigbee Cluster Library Specification. They will give you information about which commands exist in the different clusters and how to use them. The clusters that are already implemented in the light switch and light bulb samples are Basic, Identify, Scenes, Groups, On/Off, and Level Control.

    Best regards,

    Marte

  • Hello Marte,

    Thank you for your reply.

    While referring to this link 

    ZIGBEE SDK ZB_GET_OUT_BUF_DELAYED2 call failed - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com) 

    I write same function like "light_switch_send_on_off" for sending my payload i.e array

     

    static void User_light_switch_send_on_off(zb_bufid_t bufid,zb_uint16_t cmd_id)
    {
            int size;
            zb_uint8_t buf[] = {0,1,2,3,4,5,6,7};
            size = sizeof(buf);
    
            
    	    ZB_ZCL_ON_OFF_SEND_USER_REQ(bufid,
    			       bulb_ctx.short_addr,
    			       ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
    			       bulb_ctx.endpoint,
    			       LIGHT_SWITCH_ENDPOINT,
    			       ZB_AF_HA_PROFILE_ID,
    			       ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
                       cmd_id,
    			       buf,
                       size,
    			       NULL);
    
    }

    #define ZB_ZCL_ON_OFF_SEND_USER_REQ(                                               \
      buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp,command_id, zcl_codec_ptr,size,cb)\
    {                                                                                               \
      zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer)                                             \
      ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, dis_default_resp)                    \
      ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), command_id); \
      for (zb_uint8_t i = 0; i < size; i++)                                        \
      {                                                                             \
      ZB_ZCL_PACKET_PUT_DATA8(ptr, (zcl_codec_ptr[i]));                              \
      }                                                                               \
      ZB_ZCL_FINISH_PACKET(buffer, ptr)                                               \
      ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_ON_OFF, cb); \
    }

    But while receiving on light_bulb side on "zcl_device_cb" function I am not able to extract my payload i.e array. 

    Am I doing something wrong? 

    Can you please help me to resolve this issue?

    Thank you, 

    Pranav

  • Hi Pranav,

    I apologize for the delayed response.

    Please be aware that the ON/OFF command is a command without a payload. I am not sure how using this to create your own command with a buffer payload works.

    You will have to parse the command in some way. You can try using Default response command sending and parsing. Incoming default response can be parsed using the following:

    zb_zcl_default_resp_payload_t* payload = ZB_ZCL_READ_DEFAULT_RESP(zcl_cmd_buf);

    You can also look in the ZCL API for other ways to parse commands, as how to parse them depend on the type of command, i.e. report attribute command parsing is its own thing.

    Best regards,

    Marte

Reply
  • Hi Pranav,

    I apologize for the delayed response.

    Please be aware that the ON/OFF command is a command without a payload. I am not sure how using this to create your own command with a buffer payload works.

    You will have to parse the command in some way. You can try using Default response command sending and parsing. Incoming default response can be parsed using the following:

    zb_zcl_default_resp_payload_t* payload = ZB_ZCL_READ_DEFAULT_RESP(zcl_cmd_buf);

    You can also look in the ZCL API for other ways to parse commands, as how to parse them depend on the type of command, i.e. report attribute command parsing is its own thing.

    Best regards,

    Marte

Children
No Data
Related