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

Get received APS data from Zigbee stack

We have a Zigbee device that doesn't seem to use ZCL to transfer data and I have been trying to see if there is a way to get it working with an nrf52840 acting as a coordinator. The device successfully authenticates and starts sending data that I can see using Wireshark. Wireshark complains about the ZCL data and when I look at that part of the packet I can tell it is actually the specially encoded data coming from the device and doesn't look like it fits the ZCL specification at all. I think if I could just access the APS data directly that would be all I need since the device encoding is already something we handle with other coordinators. Is there a way to access the incoming APS data directly?

The following is an example packet capture from Wireshark showing the data in question:

0000 61 88 27 21 74 00 00 1c 4c 48 00 00 00 1c 4c 0a a.'!t...LH....L.
0010 15 00 01 01 00 01 00 01 1e 00 02 39 08 4e 56 00 ...........9.NV.
0020 41 41 41 41 41 30 90 2d 02 09 26 0c 0a 02 15 1c AAAAA0.-..&.....
0030 4c 24 23 23 01 00 00 00 04 21 74 1a 00 00 fc d1 L$##.....!t.....
0040 01 0c f3 0d 00 00 44 08 00 00 00 00 00 00 20 05 ......D....... .
0050 47 68 6f 73 74 Ghost

The device always uses endpoint 1, cluster 1, profile 1. What should be the ZCL frame is specially encoded data from the device.

Parents Reply Children
  • Out of those two links are there specific commands that I would use to receive the APS data? I thought there would be a simple callback that I could use to intercept the incoming data and then flag it as processed before any of the ZCL processing happens. Is there a way to go farther up in the stack potentially to get the data? Is there something that can be done with zb_af_set_data_indication? I tried using zb_af_set_data_indication but the callback never seems to be called.

    What part of the sniffer log would you need? I included an example packet for the specific incoming data that doesn't work. The device joins and immediately starts sending data. I can't include the entire log since it would have sensitive information in it. 

  • Hi,

    You can use zb_aps_get_aps_payload to get access to the APS payload, which returns a pointer to the payload. The functions in the links I added in my last reply are the only APS functions that are available to the user and the application. The rest is a part of the ZBOSS stack and therefore unavailable.

    As for the sniffer log it would help to get the pcap file, or a picture of the packet itself if the former isn't possible. The part you've already added here doesn't tell me much, and it would help to get something that gives more information about the packet, such as showing the application layer, and the cluster library frame if it's a Zigbee HA packet, like shown below.

    Best regards,

    Marte

  • Is there a way to know when to call zb_aps_get_aps_payload? The issue I have is that there seems to be no way to get triggered when the data I need comes in.

    Here is a screenshot of the data in question:

  • Hi,

    I'm sorry for the late reply. I've asked our Zigbee team internally about your issue, and I'll come back to you when I get a response from them.

    Best regards,

    Marte

  • Hi,

    I got the Zigbee team to look at the screenshot of the sniffer log. It is not ZCL that's the problem, but the profile ID (0x0001), which is not recognized by the stack. In such situations, the only solution is to use the zb_af_set_data_indication API.

    Please register the callback before zboss_start:

    ...
    zb_af_set_data_indication(data_indication);
    ...

    Example callback implementation:

    static zb_uint8_t data_indication(zb_uint8_t param)
    {
      zb_buf_t *buf = ZB_BUF_FROM_REF(param);
      zb_uint8_t aps_payload_size = 0;
      zb_uint8_t *aps_payload_ptr = zb_aps_get_aps_payload(param, &aps_payload_size);
      zb_apsde_data_indication_t *data_ind = ZB_GET_BUF_PARAM(buf, zb_apsde_data_indication_t);
      zb_bool_t processed = ZB_FALSE;
      if ((data_ind->profileid == 0x0001) &&
          (data_ind->clusterid == 0x0001))
      {
        NRF_LOG_DEBUG("zb_buf_len: %hd, aps_payload_size: %hd",
                      ZB_BUF_LEN(buf), aps_payload_size));
        for (zb_uint8_t i = 0; i < aps_payload_size; ++i)
        {
          NRF_LOG_DEBUG("aps_payload[%hd] == 0x%hx",
                        i, aps_payload_ptr[i]));
        }
        ZB_FREE_BUF(buf);
        processed = ZB_TRUE;
      }
      return processed;
    }

    Best regards,

    Marte

Related