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);  \
}

  • 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

  • Examples are not many. So i just think that data will be followed to  data8.

    I just dumped after data8 and not found.

    Maybe my appended data is not copied to call back parameter field.

    As you suggested, i will reference zigbee_cli_cmd_attr.c

    Thanks.

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

    if (cluster_id == ZB_ZCL_CLUSTER_ID_ON_OFF)
    {
    uint8_t value = p_device_cb_param->cb_param.set_attr_value_param.values.data8;

    uint8_t *p = (uint8_t *)&p_device_cb_param->cb_param.set_attr_value_param.values.data8; // I access like this..but failed.

  • Hi,

    I added ep handler register sentence and related functions in main.c.

    but the handler is not called when packet is received.

    My code is coordinator side.

    Pls help me.

    Thanks.

    ===============================================================

    NRF_ZIGBEE_EP_HANDLER_REGISTER(attr, cli_agent_ep_handler_attr);

  • Hi,

    The generated ld file does not include section ".zb_ep_handlers" which contain new end point handler i registered.

    Adding codes in main.c, is there something to do for section management ?

    Thanks.

    PS>

    I added zb_ep_handers section information in xml file. and after that map file generated zb_ep_handlers normally.

    but registered handler is not called.

    -------- in map file --------

    .zb_ep_handlers
    0x0000000000037c34 0x4
    0x0000000000037c34 __zb_ep_handlers_start__ = .
    0x0000000000037c34 __start_zb_ep_handlers = __zb_ep_handlers_start__
    *(.zb_ep_handlers*)
    .zb_ep_handlers
    0x0000000000037c34 0x4 Output/zigbee_light_coordinator_pca10056 Release/Obj/main.o
    0x0000000000037c34 zb_ep_attr
    0x0000000000037c38 __zb_ep_handlers_end__ = (__zb_ep_handlers_start__ + SIZEOF (.zb_ep_handlers))
    0x0000000000000004 __zb_ep_handlers_size__ = SIZEOF (.zb_ep_handlers)

  • For registering an endpoint handler you should use

    ZB_AF_SET_ENDPOINT_HANDLER()

    In the CLI example the NRF_ZIGBEE_EP_HANDLER_REGISTER is just a macro for storing multiple endpoint handlers (NRF_SECTION_ITEM_REGISTER) and they are registered using ZB_AF_SET_ENDPOINT_HANDLER() in main.c.

    Try then to add a nrf log info message inside your handler function to test if the handler is being called or not.

    Best regards,

    Marjeris

Related