<?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 CLI wrapper</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/76326/zigbee-cli-wrapper</link><description>Hello, 
 So I was exploring the nRF52840 DK as a Zigbee device when I found this page: Zigbee CLI wrapper . 
 This seems very promising, having a python CLI to interface with the nRF52840. However, I&amp;#39;m not finding too much information about it. I have</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 09 Jul 2021 12:07:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/76326/zigbee-cli-wrapper" /><item><title>RE: Zigbee CLI wrapper</title><link>https://devzone.nordicsemi.com/thread/319362?ContentTypeID=1</link><pubDate>Fri, 09 Jul 2021 12:07:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3fdc02d1-8e1a-42a9-be01-d31763f413c0</guid><dc:creator>Fernando Fontes</dc:creator><description>&lt;p&gt;Hello Marte,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you very much for the support.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee CLI wrapper</title><link>https://devzone.nordicsemi.com/thread/316060?ContentTypeID=1</link><pubDate>Fri, 18 Jun 2021 11:52:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffb7bc30-e308-4768-a16a-3515bb383549</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Fernando,&lt;/p&gt;
&lt;p&gt;Good to hear that you were able to create your own script!&lt;/p&gt;
&lt;p&gt;Q1&lt;/p&gt;
&lt;p&gt;A possible workaround for the connection error is to&amp;nbsp;use the function wait_until_connected to check if you are connected before calling bdb.channel, bdb.role and bdb.start. This function returns None if CLI is not connected, so you can use it as follows:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;cli_dev = ZbCliDevice(**param)
if cli_dev.wait_until_connected(timeout=1)==None:
    cli_dev.bdb.channel = config_dict[&amp;#39;CLIDevice&amp;#39;][&amp;#39;channels&amp;#39;]
    cli_dev.bdb.role = config_dict[&amp;#39;CLIDevice&amp;#39;][&amp;#39;role&amp;#39;]
    cli_dev.bdb.start()&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here I added a timeout to the function, as by default it&amp;nbsp;tries to connect 10 times before stopping, and I only want to check once to&amp;nbsp;make sure I am not connected already.&lt;/p&gt;
&lt;p&gt;Q2&lt;/p&gt;
&lt;p&gt;You are limited by the commands that exist in the CLI library,&amp;nbsp;all of which can be found&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_tz_v4.1.0/zigbee_example_cli_reference.html"&gt;here&lt;/a&gt;. Unfortunately, there is no command to broadcast just a general command to all devices&amp;nbsp;as the commands&amp;nbsp;always use something to identify the devices by, such as their addresses and endpoints for commands to a specific device, or their clusters for a more general command. However, almost all devices will have the Basic cluster. If they have an endpoint and have clusters implemented, they will also have the Basic cluster. The only example in our SDK that does not have this cluster is the light coordinator from the light control example, and this is because this example only has functionality for being a coordinator, so only the network steering commissioning mechanism, and nothing more. Therefore, you can send a match_desc command with the basic cluster (cluster ID 0). In terminal this will be:&lt;/p&gt;
&lt;pre&gt;zdo match_desc 0xffff 0xffff 0x0104 1 0 0&lt;/pre&gt;
&lt;p&gt;While in the wrapper it should be something like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;response = cli_dev.zdo.match_desc([constants.BASIC_CLUSTER],[])&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Q3:&lt;/p&gt;
&lt;p&gt;Yes, that should be possible. The available commands can be found in the different files in&amp;nbsp;&lt;span&gt;zb_cli_wrapper/src/utils/cmd_wrappers/zigbee/. Bind on is a zdo command, so that is found in zdo.py, and subscribe is found in zcl.py since it is a zcl command.&lt;/span&gt;&amp;nbsp; If you look in these files you will see &amp;quot;Avalable commands&amp;quot; close to the top of the files, which lists all commands you can use from that module. For more information about how to use each command, you can look in the&amp;nbsp;CommandWrapper class of the file, and look for the function corresponding to the command you want to use. There you will find some information as well as a line looking something like this:&lt;/p&gt;
&lt;p&gt;cmd = Commands.&amp;lt;command_name&amp;gt;.format(&amp;lt;parameters&amp;gt;)&lt;/p&gt;
&lt;p&gt;This line tells you what parameters the command takes, so this can be a good thing to use as a reference.&lt;/p&gt;
&lt;p&gt;For the specific case of sending zdo bind on and zcl subscribe, you can do something like the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cli_dev.zdo.bind(src_eui64, src_ep, dst_eui64, dst_ep, cluster_id, dst_short)
cli_dev.zcl.subscribe(eui64, ep, cluster_id, profile_id, attr_id, attr_type)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This only subscribes to the attribute reports, but it does not print (or log) them. To do so, you must enable logging:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;cli_dev.log.enable(log_module, log_level)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee CLI wrapper</title><link>https://devzone.nordicsemi.com/thread/315823?ContentTypeID=1</link><pubDate>Thu, 17 Jun 2021 10:30:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15f5dd41-402e-4ee1-8f97-a84421bd807f</guid><dc:creator>Fernando Fontes</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;Thank you for your support.&lt;/p&gt;
&lt;p&gt;So, after opening the README file and after investigating the MQTT_Zigbee_gateway.py file I was able to create my own script without any problem.&lt;/p&gt;
&lt;p&gt;However, I have a few questions about what is possible to do:&lt;/p&gt;
&lt;h4 id="mcetoc_1f8co7ouv0"&gt;&lt;strong&gt;1. To create a CLI device object I did the following:&lt;/strong&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="color:#000080;"&gt;&lt;code&gt;cli_dev = ZbCliDevice(**param)&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#000080;"&gt;&lt;code&gt; cli_dev.bdb.channel = config_dict['CLIDevice']['channels']&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#000080;"&gt;&lt;code&gt; cli_dev.bdb.role = config_dict['CLIDevice']['role']&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#000080;"&gt;&lt;code&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;code&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;However, this gives me an error after the second run of the script since the &lt;span style="background-color:#ffff00;"&gt;bdb&lt;/span&gt; is already in running mode. How can I anticipate this? Is there a way to do a previous check if the dongle is already running the coordinator mode?&lt;/span&gt;&lt;/div&gt;
&lt;h4 id="mcetoc_1f8co810o1"&gt;&lt;strong&gt;2. To list the devices connected I need to run the&amp;nbsp;&lt;span style="background-color:#ffff00;"&gt;match_desc&lt;/span&gt; command, my question is, how can I discover the devices connected without knowing in advance the implemented clusters? I want something like a broadcast command without knowing the implemented clusters.&amp;nbsp;&lt;/strong&gt;&lt;/h4&gt;
&lt;h4 id="mcetoc_1f8co89jc2"&gt;&lt;strong&gt;3. In the README file is explained how can I read an attribute of a given cluster. However, it would be nice if it was possible to subscribe to the attribute changes. Is it possible? Running directly the CLI using the COM port I was able to do it using the &lt;span style="background-color:#ffff00;"&gt;zdo bind on&lt;/span&gt; and&lt;span style="background-color:#ffff00;"&gt; zcl subscribe on&lt;/span&gt; commands....&amp;nbsp;&lt;/strong&gt;&lt;/h4&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Thank you in advance,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Fernando Fontes&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee CLI wrapper</title><link>https://devzone.nordicsemi.com/thread/315575?ContentTypeID=1</link><pubDate>Wed, 16 Jun 2021 11:08:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1b46589-d0fb-4783-b799-eca6d4d2999b</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Fernando,&lt;/p&gt;
&lt;p&gt;I am happy to help. Do not hesitate to ask if you have any more problems with the Zigbee CLI wrapper.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee CLI wrapper</title><link>https://devzone.nordicsemi.com/thread/315195?ContentTypeID=1</link><pubDate>Mon, 14 Jun 2021 15:05:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d75a6828-f202-42c5-aa26-057f702f5ae0</guid><dc:creator>Fernando Fontes</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;No, I just have installed it.&lt;/p&gt;
&lt;p&gt;I will download it now.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee CLI wrapper</title><link>https://devzone.nordicsemi.com/thread/315129?ContentTypeID=1</link><pubDate>Mon, 14 Jun 2021 12:25:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97a119cd-fa42-4833-82f4-7fbbb4d3a811</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Fernando,&lt;/p&gt;
&lt;p&gt;Did you download the files from&amp;nbsp;&lt;a href="https://pypi.org/project/zb-cli-wrapper/"&gt;https://pypi.org/project/zb-cli-wrapper/&lt;/a&gt;? In the download you will find a&amp;nbsp;README file, which explains how to use the CLI wrapper, and the different functions you can use. The demo script (MQTT Zigbee gateway application) can be found in the &amp;quot;example&amp;quot; folder in the download. This example also has a README file with explanations.&lt;/p&gt;
&lt;p&gt;The example that you should program to your DK is the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_tz_v4.1.0/zigbee_example_cli_agent.html"&gt;CLI Agent example&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>