<?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>How to receive acknowledgment at switch - Zigbee light control example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/62551/how-to-receive-acknowledgment-at-switch---zigbee-light-control-example</link><description>Hi, I am looking where can I get the ACK from the light bulb, in Zigbee light control example. I am using the latest sdk nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8. 
 what I am actually trying to achieve is to measure the network latency. I have already</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Jun 2020 11:58:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/62551/how-to-receive-acknowledgment-at-switch---zigbee-light-control-example" /><item><title>RE: How to receive acknowledgment at switch - Zigbee light control example</title><link>https://devzone.nordicsemi.com/thread/256425?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 11:58:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8cb0410-fa07-4b7e-aac6-b3e8a68eb995</guid><dc:creator>Awais</dc:creator><description>&lt;p&gt;Hi Marjeris,&lt;br /&gt;&lt;br /&gt;I am&amp;nbsp;&lt;span&gt;measuring latency exactly like you told, thanks anyways.&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;Awais&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to receive acknowledgment at switch - Zigbee light control example</title><link>https://devzone.nordicsemi.com/thread/256357?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 09:31:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31e59837-d383-43cc-b821-6807b105e713</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi Awais,&lt;/p&gt;
&lt;p&gt;Unfortunately we don&amp;#39;t have any specific example to do a benchmark in BLE Mesh, but it&amp;#39;s possible to use any of the BT Mesh examples to measure latency.&lt;/p&gt;
&lt;p&gt;To measure latency you can make a client node to send acknowledged SET message to a specific server node in the network and ait for Status response. The difference between the timestamps of outgoing message (capture using TX_COMPLETE event) and incoming message (access metadata parameter of the status callback timestamp when the message PDU was received) will give you a round trip latency.&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: How to receive acknowledgment at switch - Zigbee light control example</title><link>https://devzone.nordicsemi.com/thread/255726?ContentTypeID=1</link><pubDate>Thu, 18 Jun 2020 10:13:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bba299f1-7251-4273-a539-9e21436d38e0</guid><dc:creator>Awais</dc:creator><description>&lt;p&gt;Thanks a lot for pointing me towards the right direction (benchmark example), I will implement it and will get back to you for further queries if any&lt;br /&gt;&lt;br /&gt;p.s. do we also have a benchmark application example for BT mesh, I have seen it for BLE but not for mesh, I do have an implementation already but I could then compare it with something. Thanks again&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;Awais&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to receive acknowledgment at switch - Zigbee light control example</title><link>https://devzone.nordicsemi.com/thread/255603?ContentTypeID=1</link><pubDate>Wed, 17 Jun 2020 15:47:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fc98572-82dd-4e31-9a44-bb00ae6ba481</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am assuming you are talking about the APS ACKs. When you send a command where APS ACK is enabled in the data request packet, you will get an APS ACK (end-to-end acknowledge), as you can see in the following sniffer trace:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x400/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-2d7441f86f124145a209719152d0d54a/pastedimage1592407930839v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;Each frame is also acknowledge by the 802.15.4 (MAC) layer between frames.&lt;/p&gt;
&lt;p&gt;You can parse the APS ACK if you register a callback when calling ZB_ZCL_ON_OFF_SEND_REQ(). The callback can look something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static zb_void_t on_off_cmd_cb(zb_bufid_t param)
{
    // Parse APS ACK.
    zb_bufid_t                     p_asdu = param;
    zb_zcl_command_send_status_t * p_cmd_ping_status = ZB_BUF_GET_PARAM(p_asdu, zb_zcl_command_send_status_t);
    zb_uint16_t                    short_addr;
    zb_ret_t                       zb_err_code;


    if (param == 0)
    {
        return;
    }


    // Resolve received address to the short address.
    if (p_cmd_ping_status-&amp;gt;dst_addr.addr_type == ZB_ZCL_ADDR_TYPE_SHORT)
    {
        short_addr = p_cmd_ping_status-&amp;gt;dst_addr.u.short_addr;
    }
    else if (p_cmd_ping_status-&amp;gt;dst_addr.addr_type == ZB_ZCL_ADDR_TYPE_IEEE)
    {
        short_addr = zb_address_short_by_ieee(p_cmd_ping_status-&amp;gt;dst_addr.u.ieee_addr);
    }
    else
    {
        //Just checking we have a valid address type
        NRF_LOG_ERROR(&amp;quot;on_off cmd acknowledged with an unknown destination address type: %d&amp;quot;, p_cmd_ping_status-&amp;gt;dst_addr.addr_type);
        zb_buf_free(param);
        return;
    }


    NRF_LOG_INFO(&amp;quot;on_off cmd acknowledge by destination address: %x, endpoint %d and status %d &amp;quot;, short_addr, p_cmd_ping_status-&amp;gt;dst_endpoint, p_cmd_ping_status-&amp;gt;status);
    zb_buf_free(param);
    return;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Just remember to free the buffer used when sending the command in this callback when you are finish parsing the APS ACK, if no callback is set (cb=NUL) the stack will free the buffer upon receibing the APS ACK automatically.&lt;/p&gt;
&lt;p&gt;And you can register the callback by passing it as the last parameter in ZB_ZCL_ON_OFF_SEND_REQ():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    ZB_ZCL_ON_OFF_SEND_REQ(bufid,
                           m_device_ctx.bulb_params.short_addr,
                           ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                           m_device_ctx.bulb_params.endpoint,
                           LIGHT_SWITCH_ENDPOINT,
                           ZB_AF_HA_PROFILE_ID,
                           ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
                           cmd_id,
                           on_off_cmd_cb);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The log output of the switch device will now look like this after sending an ON/OFF command:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app: Send ON/OFF command: 1
&amp;lt;info&amp;gt; app: on_off cmd acknowledge by destination address: E00B, endpoint 10 and status 0 found.
&amp;lt;info&amp;gt; app: Send ON/OFF command: 0
&amp;lt;info&amp;gt; app: on_off cmd acknowledge by destination address: E00B, endpoint 10 and status 0 found.
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can use a similar approach for getting the timing between the command and the APS ACK and thus the latency in your application.&lt;/p&gt;
&lt;p&gt;The good news is that we already have a benchmark example which does everything for you and you can use it to measure latency in a network (echo mode): &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_tz_v4.1.0/benchmark.html"&gt;https://infocenter.nordicsemi.com/topic/sdk_tz_v4.1.0/benchmark.html&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;In the benchmark example we used zb_zcl_finish_and_send_packet() to send a control command packet and zigbee_benchmark_frame_error_handler is registered as a callback for handling incoming benchmark command APS ACKs. &lt;br /&gt;&lt;br /&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>