<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[T-Zigbee motion alarm and measure voltage]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I am building a custom Zigbee device and trying to send a motion alarm and voltage measurement report using the zbhci_ZclSendReportCmd command. I am using clusters IAS Zone (0x0500) and Electrical Measurement (0x0B04) for that, but not sure what the data structure should look like. I assume i need to send some kind of a stuct (ZCL_DATA_TYPE_STRUCT or ZCL_DATA_TYPE_ARRAY). Any help will be appreciated.</p>
]]></description><link>https://www.community.lilygo.cc/topic/648/t-zigbee-motion-alarm-and-measure-voltage</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Mar 2026 21:07:41 GMT</lastBuildDate><atom:link href="https://www.community.lilygo.cc/topic/648.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 07 Sep 2023 22:37:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to T-Zigbee motion alarm and measure voltage on Mon, 25 Sep 2023 10:58:20 GMT]]></title><description><![CDATA[<p dir="auto">FYI, I'm finding this, <a href="https://www.nxp.com/docs/en/user-guide/JN-UG-3115.pdf" rel="nofollow ugc">https://www.nxp.com/docs/en/user-guide/JN-UG-3115.pdf</a>, quite a useful reference.  For example see chapter 18 on an example of sychronising time by querying an attribute.</p>
]]></description><link>https://www.community.lilygo.cc/post/1220</link><guid isPermaLink="true">https://www.community.lilygo.cc/post/1220</guid><dc:creator><![CDATA[papadeltasierra]]></dc:creator><pubDate>Mon, 25 Sep 2023 10:58:20 GMT</pubDate></item><item><title><![CDATA[Reply to T-Zigbee motion alarm and measure voltage on Wed, 20 Sep 2023 07:39:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://www.community.lilygo.cc/uid/1050">@papadeltasierra</a> <strong>This could all be wrong!</strong></p>
<h1>Zigbee Gateway Controller (ZGC) Protocol</h1>
<h2>One of Two Ways!</h2>
<p dir="auto">The ZGC processing either:</p>
<ol>
<li>Processes attrbutes directly into variables or</li>
<li>Processes attributes into structures that can then be serialized and passed over the zhci interface.</li>
</ol>
<p dir="auto">Standard processing ot <code>time</code> attributes is an example of <em>straight to variable</em> whilst processing of <code>scene</code> attributes is an example of <em>process to structure then serialize</em>.</p>
<h2>Time Processing from the bottom up</h2>
<ul>
<li>There are no example of using the time attributes in the <a href="http://wiki.telink-semi.cn/tools_and_sdk/Zigbee/Zigbee_SDK.zip" rel="nofollow ugc">Telink ZigBee SDK</a>.</li>
<li>10 attributes are defined in <code>zcl_time.h</code>.</li>
<li>Refer to the <a href="https://zigbeealliance.org/wp-content/uploads/2021/10/07-5123-08-Zigbee-Cluster-Library.pdf" rel="nofollow ugc">ZigBee Cluster Library</a>, section 3.12, Time.
<ul>
<li>Attributes are defined in 3.12.2.2, Attributes.</li>
</ul>
</li>
</ul>
<p dir="auto">Since <code>time</code> only has attributes and no commands, it appears that the processing used by <code>scene</code> is not required as only a single attribute is ever requested or received.</p>
<blockquote>
<p dir="auto">It is not clear how we might be expected to pass this information over the <code>zbhci</code>.</p>
</blockquote>
<h2>Scheme Processing from the bottom up</h2>
<p dir="auto"><code>zbhciTx</code> sends the serialized <code>scene</code> information to the <code>zbhci</code> client over a serial port.</p>
<ul>
<li>zbhciTx(ZBHCI_CMD_ZCL_SCENE_REMOVE_ALL_RSP, pBuf - array, array);
<ul>
<li>sampleGW_zclRemoveAllSceneRspCmdHandler
<ul>
<li>status_t sampleGW_sceneCb
<ul>
<li>g_sampleGwClusterList[]
<ul>
<li>ZCL_CLUSTER_GEN_SCENES, = 0x0005<br />
MANUFACTURER_CODE_NONE, = 0<br />
0, NULL, zcl_scene_register,		sampleGW_sceneCb</li>
<li>zcl_register(<br />
SAMPLE_GW_ENDPOINT,<br />
SAMPLE_GW_CB_CLUSTER_NUM, g_sampleGwClusterList);</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3>Registering ZigBee Clusters and Decoding</h3>
<ul>
<li><code>zcl_register()</code> called from <code>user_app_init()</code></li>
<li><code>zcl_register()</code> passed list of cluster definition structures of type <code>zcl_specClusterInfo_t</code></li>
</ul>
<h4>Using Time as an Example...</h4>
<blockquote>
<p dir="auto">This works differently to <em>Scenes</em> - why</p>
</blockquote>
<ul>
<li><code>time_attrTbl[]</code> defines time attributes and the location of storage variables
<ul>
<li>Type is <code>zclAttrInfo_t</code></li>
</ul>
</li>
<li><code>zcl_time_attrNum</code> defines the number of time attributes</li>
</ul>
<blockquote>
<p dir="auto">There appears to be no references to these variables!</p>
<p dir="auto"><strong>But see <code>g_sampleGwClusterList[]</code> which seems to use one, or the other, ways of relating to the attributes.  Compare <code>Time</code> to <code>Scene</code>.</strong></p>
</blockquote>
<ul>
<li><code>zcl_specClusterInfo_t</code>
<ul>
<li>Uses <strong>either</strong> of:
<ul>
<li><code>zclAttrInfo_t *attrTbl</code>, table of attributes (<code>Time</code> uses this)</li>
<li><code>cluster_forAppCb_t clusterAppCb</code>, cluster processing commands (<code>Scene</code> uses this)</li>
</ul>
</li>
</ul>
</li>
</ul>
<blockquote>
<p dir="auto">If we want CloudSMETS to send the UTC time (and BST?) to the ESP32-C3 then we probably want to use a <code>cluster_forAppCb_t</code> instead of the attribute table.</p>
</blockquote>
<h4>Using Scenes as an Example...</h4>
<blockquote>
<p dir="auto">This works differently to <em>Time</em> - why?</p>
<p dir="auto">Note that much of this appears to be available for SMETS via <code>zcl_metering.c</code> already.</p>
</blockquote>
<ul>
<li><code>zcl_scene_register()</code> is passed
<ul>
<li><code>zcl_scene_register()</code> is defined in <code>zcl_scene.c</code> and registers the <code>Cluster Identifier</code> (<a href="https://zigbeealliance.org/wp-content/uploads/2021/10/07-5123-08-Zigbee-Cluster-Library.pdf" rel="nofollow ugc">ZigBee Cluster Library</a>, 3.7.1.3), the <code>zcl_scene_cmdHandler</code>,</li>
<li><code>zcl_scene_cmdHandler()</code> is a method in zcl_scene.c and splits command processing between directions e.g. is this a response to a request sent from Service-to-Client or a request being received from Client-to-Server</li>
</ul>
</li>
<li>if <code>zcl_scene_register()</code> succeeds in registering the cluster, it calls <code>zcl_scene_updateSceneCntAttr()</code> which appears to reach current scene attributes.</li>
</ul>
<blockquote>
<p dir="auto">Does this mean that the <code>sampleGW_sceneCb</code> doesn't need to check for direction?</p>
</blockquote>
<ul>
<li>
<p dir="auto"><code>sampleGW_sceneCb</code> is passed</p>
<ul>
<li><code>sampleGW_sceneCb</code> is a handler for the Scenes command/cluster</li>
<li>A <code>cmdId</code> distinguishes how to decode each incoming message</li>
<li>Filtering:
<ul>
<li><em>is this for the gateway</em> (at least in the `sampleGateway`` example)</li>
<li><em>is this in the Client-to-Server</em> direction?</li>
</ul>
</li>
<li><code>cmdID</code>s have defined values in <code>zcl_scene.h</code></li>
<li><code>cmdID</code>s match the <code>Commands Received</code> definitions in the <a href="https://zigbeealliance.org/wp-content/uploads/2021/10/07-5123-08-Zigbee-Cluster-Library.pdf" rel="nofollow ugc">ZigBee Cluster Library</a>, section 3.7.2.4 and responses are the same IDs are requests.</li>
</ul>
</li>
<li>
<p dir="auto">Incoming requesrts are passed to handlers such as <code>zcl_addScenePrc()</code> whch calls parsers such as <code>zcl_addSceneParse()</code></p>
</li>
<li>
<p dir="auto"><code>zcl_addSceneParse()</code> parses the request into a structure</p>
</li>
<li>
<p dir="auto">Then stuff happens and we send a response.</p>
</li>
</ul>
<blockquote>
<p dir="auto">But what about the attribute to field references that we elsewhere?  Are there two different ways to handle data?</p>
</blockquote>
<h2>Over UART...</h2>
<h3>Packet format</h3>
<ul>
<li>0x55</li>
<li>Type (16 bits)</li>
<li>Length (16 bits)</li>
<li>CRC (8 bits)</li>
<li>Data (n bytes)</li>
<li>0xAA</li>
</ul>
<h3>Data Format</h3>
<ul>
<li>Source address (16 bits)</li>
<li>Source endpoint (8 bits)</li>
<li>Destination endpoint (8 bits)</li>
<li>Sequence number (8 bits)</li>
<li>Message data (variable)</li>
</ul>
<blockquote>
<p dir="auto">Can we just relay the <code>Message data</code> to Azure?  Sghouold be OK providing we teach Azure about the structure of the data that we are sending it.</p>
<p dir="auto">We will also need to make sure that we send a length field and some sort of identifier.  See the UART thing above so perhaps we forward the entire packet?</p>
</blockquote>
<h3>Message Data</h3>
<ul>
<li>Seems to be a representation of the data received over ZigBee but might not precisely match an attribute.</li>
<li>Not clear how this works other than for a gateway!</li>
<li>Not clear how notifications might work; but perhaps we can replicate this for a gateway?</li>
</ul>
<h4>Message Data Format: Scene Table as an Example</h4>
<ul>
<li><a href="https://zigbeealliance.org/wp-content/uploads/2021/10/07-5123-08-Zigbee-Cluster-Library.pdf" rel="nofollow ugc">ZigBee Cluster Library</a>, 3.7.2.3, defines <code>Scene Table</code></li>
<li><a href="http://wiki.telink-semi.cn/tools_and_sdk/Zigbee/Zigbee_SDK.zip" rel="nofollow ugc">Telink ZigBee SDK</a> defines a <code>viewSceneRsp_t</code> structure in <code>zcl_scene.h</code> that mirrors the definition of the <code>Scene Table</code></li>
<li><a href="http://wiki.telink-semi.cn/tools_and_sdk/Zigbee/Zigbee_SDK.zip" rel="nofollow ugc">Telink ZigBee SDK</a> <code>sampleGW_zclViewSceneRspCmdHandler</code> method in <code>zcl_sampleGatewayCb.c</code>, creates the message data from the <code>viewSceneRsp_t</code> structure, allowing for zero-length data.</li>
</ul>
<p dir="auto">[ESP-C3]: ??? insert ref here ???</p>
]]></description><link>https://www.community.lilygo.cc/post/1205</link><guid isPermaLink="true">https://www.community.lilygo.cc/post/1205</guid><dc:creator><![CDATA[papadeltasierra]]></dc:creator><pubDate>Wed, 20 Sep 2023 07:39:02 GMT</pubDate></item><item><title><![CDATA[Reply to T-Zigbee motion alarm and measure voltage on Wed, 20 Sep 2023 07:36:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://www.community.lilygo.cc/uid/1137">@jrossouw</a> Not sure how much you know about ZigBee but I'd doing a similar project but with the smart energy cluster. This is what I THINK you might need to do based on my current investigations.  If you find this works, or is wrong and find the right way, please share!</p>
<ul>
<li>The sample applications register callbacks for the clusters that they use</li>
<li>The callbacks can refer to commands or to simple read/write attributes and the parameters given when registering the callbacks differ for each</li>
<li>For command based stuff, the structures for the requests and/or responses match the definitions in the ZigBee specifications but not all attributes are always read out so the structure might be incomplete but the registration effectively says which attributes to extract and which to ignore</li>
<li>The ZigBee documentation that I have been referring to is this: <a href="https://zigbeealliance.org/wp-content/uploads/2019/12/07-5123-06-zigbee-cluster-library-specification.pdf" rel="nofollow ugc">https://zigbeealliance.org/wp-content/uploads/2019/12/07-5123-06-zigbee-cluster-library-specification.pdf</a></li>
<li>I will copy my notes into another reply but they are very sparse and MAY BE WRONG!</li>
</ul>
<p dir="auto">Good luck and do share what you find out.  Maybe we can all produce some useful documentation on this when we are finished :-).</p>
]]></description><link>https://www.community.lilygo.cc/post/1204</link><guid isPermaLink="true">https://www.community.lilygo.cc/post/1204</guid><dc:creator><![CDATA[papadeltasierra]]></dc:creator><pubDate>Wed, 20 Sep 2023 07:36:40 GMT</pubDate></item></channel></rss>