<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Zigbee attribute read request</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51964/zigbee-attribute-read-request</link><description>Hello, I&amp;#39; trying to use the macro here below, but there are no sample in SDK. Have you any example for using it? Many thanks 
 Abele</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 28 Oct 2019 12:28:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51964/zigbee-attribute-read-request" /><item><title>RE: Zigbee attribute read request</title><link>https://devzone.nordicsemi.com/thread/217064?ContentTypeID=1</link><pubDate>Mon, 28 Oct 2019 12:28:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff502b5e-c11f-405f-af67-3256e8b529a1</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;&amp;nbsp;Hi Abele,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply. Can you share the code of callback_ep_handler()? The packet ZCL packet handler (in this case callback_ep_handler()) should either return ZB_FALSE, if the packet is not processed by the application and the default ZCL handling is applied, or ZB_TRUE if the aplication does handle the packet and no default processing is needed. See &amp;quot;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v3.2.0%2Fusing_zigbee__z_c_l.html&amp;amp;cp=5_3_3_3_1_8_1&amp;amp;anchor=process_zcl_cmd_implementing"&gt;Implementing algorithm for overriding the handling of ZCL commands&lt;/a&gt;&amp;quot;.&lt;/p&gt;
&lt;p&gt;For sending and a group command you need to use the group ID as the destination address. Take a look at the light_switch_groups examples under example/zigbee/experimental&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static zb_void_t light_switch_send_on_off(zb_uint8_t param, zb_uint16_t on_off)
{
    zb_uint8_t           cmd_id;
    zb_uint16_t          group_id = DEFAULT_GROUP_ID;
    zb_buf_t           * p_buf = ZB_BUF_FROM_REF(param);

    if (on_off)
    {
        cmd_id = ZB_ZCL_CMD_ON_OFF_ON_ID;
    }
    else
    {
        cmd_id = ZB_ZCL_CMD_ON_OFF_OFF_ID;
    }

    NRF_LOG_INFO(&amp;quot;Send ON/OFF command: %d&amp;quot;, on_off);

    ZB_ZCL_ON_OFF_SEND_REQ(p_buf,
                           group_id,
                           ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT,
                           0,
                           LIGHT_SWITCH_ENDPOINT,
                           ZB_AF_HA_PROFILE_ID,
                           ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
                           cmd_id,
                           NULL);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee attribute read request</title><link>https://devzone.nordicsemi.com/thread/216303?ContentTypeID=1</link><pubDate>Wed, 23 Oct 2019 08:33:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:332d3138-5ca3-42c5-bbfd-06e88648a446</guid><dc:creator>abe</dc:creator><description>&lt;p&gt;Hi &lt;span&gt;Marjeris,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;many thanks for your help, now I&amp;#39;m be able to intercept the ZCL attr request response. &lt;br /&gt;In my code I forgot the ZB_AF_REGISTER_DEVICE_CTX() initialization, then my macro call ZB_AF_SET_ENDPOINT_HANDLER(ZIGBEE_ZC_MAIN_ENDPOINT, callback_ep_handler) had no effects. &lt;br /&gt;Now, when i send a read_attr request, the callback_ep_handler() function is invoked.&lt;br /&gt;Two further questions:&lt;br /&gt;- the callback_ep_handler() return the &amp;quot;zb_uint8_t param&amp;quot; value set to 0x04, it&amp;#39;s right? What&amp;#39;s the meaning of this parameter?&lt;br /&gt;- I need using Groupcast command: for example, I have set cluster 4 inside two light bulb with the command &amp;quot;add group&amp;quot; (both with same group code, of course). How can I send the &amp;quot;groupcast&amp;quot; on/off command? There is an example how to make this?&lt;br /&gt;Kind regards&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Abele&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee attribute read request</title><link>https://devzone.nordicsemi.com/thread/215854?ContentTypeID=1</link><pubDate>Mon, 21 Oct 2019 08:59:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d355d80f-3aad-4d5d-9eb2-bafd63bf2bea</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi Abele,&lt;/p&gt;
&lt;p&gt;The code snippet I shared was just so you could see an example on how the ZB_ZCL_GENERAL_SEND_READ_ATTR_REQ macro is implemented and how to implement an endpoint handler to intercept the response, I don&amp;#39;t recommend copying it directly, as some functions and structs in that snippet are defined by myself, sorry for the confusion about that. For example light_switch_entry_t is just a selfmade structure I defined to help me store the on/off state of the devices in the network.&lt;/p&gt;
&lt;p&gt;And for example should change the &amp;quot;LIGHT_COORDINATOR_EP&amp;quot; for the name you have defined for your sending endpoint (from which endpoint are you sending the send read attribute request?).&lt;/p&gt;
&lt;p&gt;I think it would be easier for me to help you if you could share your code (main.c) here.&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee attribute read request</title><link>https://devzone.nordicsemi.com/thread/214757?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2019 09:01:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7178be1b-ed94-42e9-a4ad-c866cbc5dc6c</guid><dc:creator>abe</dc:creator><description>&lt;p&gt;Hi Marjeris,&lt;br /&gt;I apologize for the delay, but I was busy with other works. Now I&amp;#39;m on this project, and I tried to add the functions you suggest, but I have some errors and I&amp;#39;m not be able to find the right definitions, for example, for the light_switch_entry_t typedef and LIGHT_COORDINATOR_EP macro.&lt;br /&gt;Where I can find these? What the sample code you refer to?&lt;br /&gt;Many thanks for your help!&lt;br /&gt;Abele&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee attribute read request</title><link>https://devzone.nordicsemi.com/thread/210347?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 10:22:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e72098a6-0431-4a19-bb97-da0eebf455a1</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi Abele,&lt;/p&gt;
&lt;p&gt;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?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee attribute read request</title><link>https://devzone.nordicsemi.com/thread/209685?ContentTypeID=1</link><pubDate>Fri, 13 Sep 2019 16:36:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b89d9e8-c3cb-4899-ac47-7e1e934a3488</guid><dc:creator>abe</dc:creator><description>&lt;p&gt;Hi Marjeris&lt;br /&gt;I have seen the code you suggest; I think that it is intended for End-Node devices.&lt;br /&gt;I&amp;#39;m developing a Zigbee Coordinator + BLE and I need populate the GATT database with info fro all device commissioned and connected to network&lt;br /&gt;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.&lt;br /&gt;How can I reach my goal? How can I get the read_attr data on Coordinator side?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee attribute read request</title><link>https://devzone.nordicsemi.com/thread/209677?ContentTypeID=1</link><pubDate>Fri, 13 Sep 2019 15:18:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03fd9e47-3369-4483-bad4-11fcb185af14</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi Abele,&lt;/p&gt;
&lt;p&gt;Yes, you need to register a endpoint handler with ZB_AF_SET_ENDPOINT_HANDLER() to intercept the ZCL packets, see more information in &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.thread_zigbee.v3.0.0%2Fusing_zigbee__z_c_l.html&amp;amp;anchor=process_zcl_cmd"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;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.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;See &amp;quot;Implementing algorithm for overriding the handling of ZCL commands&amp;quot; in the link I provided above. I attach an example code from the same project I mentioned above:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static zb_uint8_t print_read_attr_on_off(zb_buf_t * p_zcl_cmd_buf, light_switch_entry_t * p_entry)
{
    zb_zcl_read_attr_res_t * p_attr_resp;

    /* Get the contents of Read Attribute Response frame */
    ZB_ZCL_GENERAL_GET_NEXT_READ_ATTR_RES(p_zcl_cmd_buf, p_attr_resp);
    if((p_attr_resp-&amp;gt;status == ZB_ZCL_STATUS_SUCCESS) &amp;amp;&amp;amp; (p_attr_resp-&amp;gt;attr_id == ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID))
    {
        if(p_attr_resp-&amp;gt;attr_value[0] == 1)
        {
            p_entry-&amp;gt;on_off_state = true;
        }
        else
        {
            p_entry-&amp;gt;on_off_state = false;
        }

        NRF_LOG_INFO(&amp;quot;Received device on/off state, idx %d, on/off state: %d&amp;quot;, p_entry-&amp;gt;idx, p_entry-&amp;gt;on_off_state);
        zb_free_buf(p_zcl_cmd_buf);
        return ZB_TRUE;
    }

    return ZB_FALSE;
}

static zb_uint8_t on_off_switch_ep_handler(zb_uint8_t param)
{
    zb_buf_t             * zcl_cmd_buf          = (zb_buf_t *)ZB_BUF_FROM_REF(param);
    zb_zcl_parsed_hdr_t  * cmd_info             = ZB_GET_BUF_PARAM(zcl_cmd_buf, zb_zcl_parsed_hdr_t);
    zb_uint16_t            short_addr;
    light_switch_entry_t * p_entry;

    // Address resolution.
    if (cmd_info-&amp;gt;addr_data.common_data.source.addr_type == ZB_ZCL_ADDR_TYPE_SHORT)
    {
        short_addr = cmd_info-&amp;gt;addr_data.common_data.source.u.short_addr;
    }
    else if (cmd_info-&amp;gt;addr_data.common_data.source.addr_type== ZB_ZCL_ADDR_TYPE_IEEE) 
    {
        short_addr = zb_address_short_by_ieee(cmd_info-&amp;gt;addr_data.common_data.source.u.ieee_addr);
    }
    else
    {
        NRF_LOG_ERROR(&amp;quot;Endpoint handler: unknown destination address type: %d&amp;quot;, cmd_info-&amp;gt;addr_data.common_data.source.addr_type);
        return ZB_FALSE;
    }


    // On/Off cluster read attribute response.
    if ((cmd_info-&amp;gt;cmd_direction == ZB_ZCL_FRAME_DIRECTION_TO_CLI) &amp;amp;&amp;amp; \
             (cmd_info-&amp;gt;cmd_id == ZB_ZCL_CMD_READ_ATTRIB_RESP) &amp;amp;&amp;amp; \
             (cmd_info-&amp;gt;cluster_id == ZB_ZCL_CLUSTER_ID_ON_OFF))
    {
        //Process the incoming command response, in this case I store the on/off state of the switch in the correct light switch entry with the correct address and source endpoint of the response message  
        p_entry = get_by_short_address_endpoint(short_addr, cmd_info-&amp;gt;addr_data.common_data.src_endpoint);
        if (p_entry == NULL) 
        {
            NRF_LOG_INFO(&amp;quot;ON/OFF attr resp: entry not found endpoint %d, dst_addr %d&amp;quot;, cmd_info-&amp;gt;addr_data.common_data.src_endpoint, short_addr);
            return ZB_FALSE;
        }

        return print_read_attr_on_off(zcl_cmd_buf, p_entry);
    }
    return ZB_FALSE;
}

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    /* Set channels on which the coordinator will try to create a new network. */
    zb_set_network_coordinator_role(IEEE_CHANNEL_MASK);
    zb_set_max_children(MAX_CHILDREN);
    
    /* Register dimmer switch device context (endpoints). */
    ZB_AF_REGISTER_DEVICE_CTX(&amp;amp;on_off_switch_ctx);

    /* Set the endpoint receive hook */
    ZB_AF_SET_ENDPOINT_HANDLER(LIGHT_COORDINATOR_EP, on_off_switch_ep_handler);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee attribute read request</title><link>https://devzone.nordicsemi.com/thread/209462?ContentTypeID=1</link><pubDate>Thu, 12 Sep 2019 14:40:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab5844e9-c410-4efb-a95e-7955a46ee1ca</guid><dc:creator>abe</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Marjeris,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;many thanks for your answer.&lt;br /&gt;Waiting for, I&amp;#39;m also seen CLI example. then I added this code to my application (function name is different but the code is like).&lt;br /&gt;Using PC10059 dongle and Wireshark as Zigbee communication sniffer, I see the EndNode answer that contains expected data, but I&amp;#39;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)&lt;br /&gt;Have you any suggest or any example how to get the received data??&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;
/**@brief Actually construct the Read Attribute frame and send it.
 *
 * @param param ZBOSS buffer to fill.
 * @param cb_param Row of the read attribute table to refer to.
 */
static zb_void_t readattr_send(zb_uint8_t param, zb_uint16_t cb_param)
{
    zb_ret_t zb_err_code;
    zb_buf_t * p_buf = ZB_BUF_FROM_REF(param);
    zb_uint8_t row = cb_param;
    zb_uint8_t * p_cmd_buf;
    attr_query_t * p_row = &amp;amp;(m_attr_table[row]);

    p_row-&amp;gt;seq_num = ZCL_CTX().seq_number;
    ZB_ZCL_GENERAL_INIT_READ_ATTR_REQ_A(p_buf, p_cmd_buf, p_row-&amp;gt;direction, ZB_ZCL_ENABLE_DEFAULT_RESPONSE);
    ZB_ZCL_GENERAL_ADD_ID_READ_ATTR_REQ(p_cmd_buf, p_row-&amp;gt;attr_id);
    ZB_ZCL_GENERAL_SEND_READ_ATTR_REQ(p_buf, p_cmd_buf, 
                                      p_row-&amp;gt;remote_node,
                                      p_row-&amp;gt;remote_addr_mode, 
                                      p_row-&amp;gt;remote_ep,
                                      LIGHT_SWITCH_ENDPOINT, 
                                      p_row-&amp;gt;profile_id,
                                      p_row-&amp;gt;cluster_id, 
                                      frame_acked_cb);

    zb_err_code = ZB_SCHEDULE_ALARM(invalidate_row_cb, row,
                                    ATTRIBUTE_ROW_TIMEOUT_S * ZB_TIME_ONE_SECOND);
    ZB_ERROR_CHECK(zb_err_code);
}&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee attribute read request</title><link>https://devzone.nordicsemi.com/thread/209417?ContentTypeID=1</link><pubDate>Thu, 12 Sep 2019 12:09:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebb8cca9-3cde-4f2c-898f-f1e6257afb70</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Take a look at the source code of the Zigbee CLI example and see inside zigbee_cli_cmd_attr.c function readattr_send().&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*Read device On/Off state from the On/Off cluster. */
static void read_device_state(zb_uint8_t param, zb_uint16_t idx)
{
    zb_uint8_t           * p_cmd_buf;
    zb_buf_t             * p_buf   = ZB_BUF_FROM_REF(param);
    light_switch_entry_t * p_entry = get_by_idx(idx);

    if (p_entry == NULL)
    {
        NRF_LOG_WARNING(&amp;quot;Unable to read device state. Device with idx: %d not found.&amp;quot;, idx);
        ZB_FREE_BUF_BY_REF(param);

        return;
    }

    NRF_LOG_INFO(&amp;quot;Resolve device state for device with idx: %d&amp;quot;, idx);
    ZB_ZCL_GENERAL_INIT_READ_ATTR_REQ(p_buf, p_cmd_buf, ZB_ZCL_ENABLE_DEFAULT_RESPONSE);
    ZB_ZCL_GENERAL_ADD_ID_READ_ATTR_REQ(p_cmd_buf, ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID);
    ZB_ZCL_GENERAL_SEND_READ_ATTR_REQ(p_buf, 
        p_cmd_buf,
        p_entry-&amp;gt;short_address,
        ZB_APS_ADDR_MODE_16_ENDP_PRESENT, 
        p_entry-&amp;gt;endpoint,
        LIGHT_COORDINATOR_EP, //Sending endpoint 
        ZB_AF_HA_PROFILE_ID,
        ZB_ZCL_CLUSTER_ID_ON_OFF, 
        read_device_state_cb); // For this type of requests the response will not arrive inside the callback. Please take a look at the endpoint handler. You can use the callback for further configuration (call another function) but if not you can just use it to free the buffer, see frame_acked_cb in CLI example.   
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I hope this was of help, let me know if you had more questions.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>