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

[nRF52840 with zigbee] How to append user data append to HA profile ?

Hi,

I am developing a system similar to door lock system.

In our system, user data should transmit from ZED(or ZR) to ZC.

So i modified the ZB_ZCL_ON_OFF_SEND_REQ macro to add user data.

With wireshark, packet size is ok (includes the user data bytes).

But i cannot extract appended user data at ZC side.(Light On/Off command can be parsed successfully).

I am using HA profile.

Give some clues.

Thanks.

#define my_ZB_ZCL_ON_OFF_SEND_REQ(                                                         \
    buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, command_id, 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);           \
  ZB_ZCL_PACKET_PUT_DATA8(ptr, 0xab);  \
  ZB_ZCL_PACKET_PUT_DATA8(ptr, 0xcd);  \
  ZB_ZCL_PACKET_PUT_DATA8(ptr, 0xef);  \
  ZB_ZCL_PACKET_PUT_DATA8(ptr, 0x01);  \
  ZB_ZCL_PACKET_PUT_DATA8(ptr, 0xaa);  \
  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);  \
}

Parents
  • Hi,

    Could you explain a bit more about why you are not able to extract the appended user data? How are you implementing this right now?

    Since the payload is not what is expected for an on/off cluster you need to register an endpoint handler to intercept every frame coming to the endpoint and parse the data yourself.

    You can take a look at how it's handled in the zigbee_cli_cmd_attr.c file in the CLI example, as we handle reading attributes the same way.

    Best regards,

    Marjeris

  • Hi,

    EP handler is called successfully.

    Instead of using "NRF_ZIGBEE_EP_HANDLER_REGISTER(attr, cli_agent_ep_handler_attr)",

    call "ZB_AF_SET_ENDPOINT_HANDLER(10,cli_agent_ep_handler_attr)".

    and cli_agent_ep_handler_attr is called normally.

    But get_attr_table_row_by_sn return "-1".

    What is the problem ?

    Thanks.

    -------------------------------------------------------------------------------------------------------------------------------------

    static zb_uint8_t cli_agent_ep_handler_attr(zb_uint8_t param)
    {
    zb_buf_t * p_zcl_cmd_buf = (zb_buf_t *)ZB_BUF_FROM_REF(param);
    zb_zcl_parsed_hdr_t * p_cmd_info = ZB_GET_BUF_PARAM(p_zcl_cmd_buf, zb_zcl_parsed_hdr_t);
    zb_int8_t row;

    /* Get the row in the requests table according by the sequence number */
    row = get_attr_table_row_by_sn(p_cmd_info->seq_number);

Reply
  • Hi,

    EP handler is called successfully.

    Instead of using "NRF_ZIGBEE_EP_HANDLER_REGISTER(attr, cli_agent_ep_handler_attr)",

    call "ZB_AF_SET_ENDPOINT_HANDLER(10,cli_agent_ep_handler_attr)".

    and cli_agent_ep_handler_attr is called normally.

    But get_attr_table_row_by_sn return "-1".

    What is the problem ?

    Thanks.

    -------------------------------------------------------------------------------------------------------------------------------------

    static zb_uint8_t cli_agent_ep_handler_attr(zb_uint8_t param)
    {
    zb_buf_t * p_zcl_cmd_buf = (zb_buf_t *)ZB_BUF_FROM_REF(param);
    zb_zcl_parsed_hdr_t * p_cmd_info = ZB_GET_BUF_PARAM(p_zcl_cmd_buf, zb_zcl_parsed_hdr_t);
    zb_int8_t row;

    /* Get the row in the requests table according by the sequence number */
    row = get_attr_table_row_by_sn(p_cmd_info->seq_number);

Children
Related