<?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 get commands generated from client cluster in coordinator</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111607/how-to-get-commands-generated-from-client-cluster-in-coordinator</link><description>Hello, I have a question about how to get commands generated from a client cluster in a coordinator. I am currently developing a hub to control and retrieve data from home appliances that support the Zigbee protocol. This hub is equipped with nRF5340</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 31 May 2024 13:02:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111607/how-to-get-commands-generated-from-client-cluster-in-coordinator" /><item><title>RE: How to get commands generated from client cluster in coordinator</title><link>https://devzone.nordicsemi.com/thread/486917?ContentTypeID=1</link><pubDate>Fri, 31 May 2024 13:02:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a764239-77cb-4c28-a40d-e2a4954138c7</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Here is an example of a handpoint handler that prints the IEEE address, cluster ID, command ID, and payload. You can modify it to fit your requirements.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define IEEE_ADDR_BUF_SIZE 17

zb_uint8_t zb_nwk_coordinator_ep_handler(zb_bufid_t bufid)
{
	zb_zcl_parsed_hdr_t *cmd_info = ZB_BUF_GET_PARAM(bufid, zb_zcl_parsed_hdr_t);
	size_t payload_length = zb_buf_len(bufid);
	const zb_uint8_t *payload = zb_buf_begin(bufid);

	zb_uint16_t short_addr;
	zb_ieee_addr_t ieee_addr;
	
	switch (ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).source.addr_type) {
	case ZB_ZCL_ADDR_TYPE_SHORT:
		short_addr = ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).source.u.short_addr;
		zb_address_ieee_by_short(short_addr, ieee_addr);
		break;
	case ZB_ZCL_ADDR_TYPE_IEEE:
		ZB_IEEE_ADDR_COPY(ieee_addr, ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).source.u.ieee_addr);
		short_addr = zb_address_short_by_ieee(ieee_addr);
		break;
	}

	char ieee_addr_str[IEEE_ADDR_BUF_SIZE] = { 0 };
	char payload_str[255];
	ieee_addr_to_str(ieee_addr_str, IEEE_ADDR_BUF_SIZE, ieee_addr);
	to_hex_str(payload_str, sizeof(payload_str), payload, payload_length, false);

	LOG_INF(&amp;quot;Received ZCL cmd: IEEE_src_addr=%s, cluster_id=0x%04x, cmd_id=0x%02x, payload=[%s]&amp;quot;, 
						ieee_addr_str, 
						cmd_info-&amp;gt;cluster_id,
						cmd_info-&amp;gt;cmd_id,
						payload_str);

	return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I have tested this in the network coordinator sample. Make sure to register the endpoint handler &lt;span style="text-decoration:underline;"&gt;after&lt;/span&gt; registering the device context like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ZB_AF_REGISTER_DEVICE_CTX(&amp;amp;nwk_coordinator);
ZB_AF_SET_ENDPOINT_HANDLER(ZIGBEE_COORDINATOR_ENDPOINT, zb_nwk_coordinator_ep_handler);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get commands generated from client cluster in coordinator</title><link>https://devzone.nordicsemi.com/thread/486770?ContentTypeID=1</link><pubDate>Fri, 31 May 2024 05:34:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fbde195f-760f-4d0e-86eb-6a57a0d98c2a</guid><dc:creator>masayuki_i</dc:creator><description>&lt;p&gt;Thanks for the helpful info.&lt;/p&gt;
[quote userid="92402" url="~/f/nordic-q-a/111607/how-to-get-commands-generated-from-client-cluster-in-coordinator/486569"]Can you clarify your goal? Do you want the nRF5340 to retrieve information about ZCL commands that are sent specifically to the nRF5340, or commands that are sent on the network in general? What kind of information do you want to retrieve?[/quote]
&lt;p&gt;The goal is to be able to receive commands in general. I would like to get the eui64, cluster ID, command ID, and payload information for the device sending the command. For example, I would like to achieve the following. &lt;br /&gt;I have multiple Dimmer switches in my house and I want to know at the hub which switch sent which command and with what payload.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get commands generated from client cluster in coordinator</title><link>https://devzone.nordicsemi.com/thread/486569?ContentTypeID=1</link><pubDate>Thu, 30 May 2024 07:43:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98673a50-4f65-463a-b308-74144791d2ba</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Just to add to my colleague&amp;#39;s response.&lt;/p&gt;
[quote user=""]1. Is this log defined in a callback function that is called when the hub gets a command? Where is that callback function defined?[/quote]
&lt;p&gt;The logs you refer to come from &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/eef645c4a31201df353fdff5447262d7675fa1c1/subsys/zigbee/lib/zigbee_logger_ep/zigbee_logger_eprxzcl.c#L133"&gt;zigbee_logger_eprxzcl_ep_handler()&lt;/a&gt;. This is the endpoint logger, which parses and logs incoming ZCL frames. You can read more about this in &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.6.1/nrf/protocols/zigbee/configuring_libraries.html#configuring-zigbee-endpoint-logger"&gt;Configuring Zigbee endpoint logger&lt;/a&gt;. As described there, you can set endpoint handlers with &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/zboss/3.11.3.0/group__af__management__service.html#ga549b0a17bcf5d9788c23882d68298142"&gt;ZB_AF_SET_ENDPOINT_HANDLER()&lt;/a&gt;.&lt;/p&gt;
[quote user=""]2. Is there a correct way to use &amp;quot;zdo bind on&amp;quot; to retrieve information about a command? I would like to know if there is an easier way to get information about the command.[/quote]
&lt;p&gt;Can you clarify your goal? Do you want the nRF5340 to retrieve information about ZCL commands that are sent specifically to the nRF5340, or commands that are sent on the network in general? What kind of information do you want to retrieve?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get commands generated from client cluster in coordinator</title><link>https://devzone.nordicsemi.com/thread/486485?ContentTypeID=1</link><pubDate>Wed, 29 May 2024 13:52:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e76382e5-9c15-4052-a346-f272e3394f51</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;You can use the tools here :&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/zigbee/shell.html#zigbee-shell-command-list"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/zigbee/shell.html#zigbee-shell-command-list&lt;/a&gt;&amp;nbsp;and follow the method mentioned here:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_tz_v4.2.0/zigbee_multi_sensor_example.html?cp=9_3_3_8_5_3_1#zigbee_multi_sensor_example_test"&gt;https://infocenter.nordicsemi.com/topic/sdk_tz_v4.2.0/zigbee_multi_sensor_example.html?cp=9_3_3_8_5_3_1#zigbee_multi_sensor_example_test&lt;/a&gt;&amp;nbsp;witch is close to the old nRF5SDK that does not support nRF5340. info on that can be found here:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v4.2.0%2Fzigbee_example_cli_reference.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v4.2.0%2Fzigbee_example_cli_reference.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>