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

Zigbee attribute read request

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

Parents
  • Hi,

    Take a look at the source code of the Zigbee CLI example and see inside zigbee_cli_cmd_attr.c function readattr_send().

    I can also share with you a code snippet from an on-going tutorial project I am working on where I want to read the on/off state from the on/off cluster from a device with index idx from a list of devices stored in a custom light switch entry structure:

    I hope this was of help, let me know if you had more questions.

    Best regards,

    Marjeris

Reply
  • Hi,

    Take a look at the source code of the Zigbee CLI example and see inside zigbee_cli_cmd_attr.c function readattr_send().

    I can also share with you a code snippet from an on-going tutorial project I am working on where I want to read the on/off state from the on/off cluster from a device with index idx from a list of devices stored in a custom light switch entry structure:

    I hope this was of help, let me know if you had more questions.

    Best regards,

    Marjeris

Children
  • Hi Marjeris,

    many thanks for your answer.
    Waiting for, I'm also seen CLI example. then I added this code to my application (function name is different but the code is like).
    Using PC10059 dongle and Wireshark as Zigbee communication sniffer, I see the EndNode answer that contains expected data, but I'm not be able to get the received data to store it in my custom database. (the callback as commented on your code is not the right way)
    Have you any suggest or any example how to get the received data??


  • Hi Abele,

    Yes, you need to register a endpoint handler with ZB_AF_SET_ENDPOINT_HANDLER() to intercept the ZCL packets, see more information in here.

    Inside the handler you should check the command direction, cluster ID and command ID, and call the dedicated API for getting the contents of the read attribute response frame ZB_ZCL_GENERAL_GET_NEXT_READ_ATTR_RES, then free the buffer and return ZB_TRUE, otherwise return ZB_FALSE to indicate to the stack to perform the default command processing. 

    See "Implementing algorithm for overriding the handling of ZCL commands" in the link I provided above. I attach an example code from the same project I mentioned above:

    In main function you will also need to register the device context and set the endpoint handler receive hook, for example after setting the device role:

    BR,

    Marjeris

  • Hi Marjeris
    I have seen the code you suggest; I think that it is intended for End-Node devices.
    I'm developing a Zigbee Coordinator + BLE and I need populate the GATT database with info fro all device commissioned and connected to network
    I use the readattr_send function I got from CLI example, that I have adapted to insert on my code and with radio sniffer I see the request from Coordinator to Endnode, the answer from Endnode to Coordinator and all related ACK. My purpose is to get data received from endnode.
    How can I reach my goal? How can I get the read_attr data on Coordinator side?

  • Hi Abele,

    The code is from a coordinator node. I have a table with entries for each light switch connected to the coordinator and I update this table with the current on/off state of the switch/lightbulb by reading their on/off state attribute. Have you tried to implement an endpoint handler to intercept the answer from the endnode to the coordinator?

  • 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