<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Wireless MCU中的主题 Re: JN-SW-4170: How does direct Zigbee binding work?</title>
    <link>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1307124#M11361</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/187847"&gt;@grafalex&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I am not sure if I am following your request.&lt;/P&gt;
&lt;P&gt;You are looking for the Bind Request Cluster ID? Am I right? This will be 0x0021 by the spec.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mario&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jul 2021 18:04:38 GMT</pubDate>
    <dc:creator>mario_castaneda</dc:creator>
    <dc:date>2021-07-13T18:04:38Z</dc:date>
    <item>
      <title>JN-SW-4170: How does direct Zigbee binding work?</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1291329#M11251</link>
      <description>&lt;P&gt;I created a simple light switch device that is supposed to work with zigbee2mqtt server as a coordinator. So far my device can join the network, and report on/off attribute change. Everything looks clear so far.&lt;/P&gt;&lt;P&gt;Currently I am trying to understand how binding works, and have a lot of questions. My use case is pretty straightforward: I want my device (which is basically a switch) to send On/Off commands to a bound device (another switch).&lt;/P&gt;&lt;P&gt;First off, I am not using BDB Find and Bind procedures. The coordinator (zigbee2mqtt) sends my device a very specific&amp;nbsp;ZPS_EVENT_ZDO_BIND message, that explicitly requests 'please bind device endpoint #1 OnOff cluster to the other device 0x0123456789ABCDEF endpoint #2'. From what I see in BDB API there is no such API to bind 2 specific devices - instead it runs find and bind procedures on initiator and some target, without providing a possibility to specify which target and which cluster I would like to bind.&lt;/P&gt;&lt;P&gt;I tried to play with binding functions provided by a low level zigbee stack, such as using&amp;nbsp;ZPS_eAplZdoBind(). My first confusion is that&amp;nbsp;ZPS_EVENT_ZDO_BIND message does not deliver ClusterID to my code, while I clearly see clusterID in the Bind Request I am seeing in the sniffer.&lt;/P&gt;&lt;P&gt;Anyhow, My code currently looks like this (I hardcoded the cluster ID):&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;void&lt;/SPAN&gt; handleZdoBindEvent(ZPS_tsAfZdoBindEvent * pEvent)&lt;BR /&gt;{&lt;BR /&gt;    uint16 shortAddr = pEvent-&amp;gt;u8DstAddrMode == ZPS_E_ADDR_MODE_IEEE ?&lt;BR /&gt;                        ZPS_u16AplZdoLookupAddr(pEvent-&amp;gt;uDstAddr.u64Addr) :&lt;BR /&gt;                        pEvent-&amp;gt;uDstAddr.u16Addr;&lt;BR /&gt;    uint64 ieeeAddr = pEvent-&amp;gt;u8DstAddrMode == ZPS_E_ADDR_MODE_IEEE ?&lt;BR /&gt;                                                pEvent-&amp;gt;uDstAddr.u64Addr :&lt;BR /&gt;                                                ZPS_u64AplZdoLookupIeeeAddr(pEvent-&amp;gt;uDstAddr.u16Addr);&lt;BR /&gt;&lt;BR /&gt;    ZPS_teStatus status = ZPS_eAplZdoBind(GENERAL_CLUSTER_ID_ONOFF,&lt;BR /&gt;                                          pEvent-&amp;gt;u8SrcEp,&lt;BR /&gt;                                          shortAddr,&lt;BR /&gt;                                          ieeeAddr,&lt;BR /&gt;                                          pEvent-&amp;gt;u8DstEp);&lt;BR /&gt;    DBG_vPrintf(TRUE, &lt;SPAN&gt;"Binding&lt;/SPAN&gt; &lt;SPAN&gt;SrcEP=%d&lt;/SPAN&gt; &lt;SPAN&gt;to&lt;/SPAN&gt; &lt;SPAN&gt;DstEP=%d&lt;/SPAN&gt; &lt;SPAN&gt;Status=%d\n"&lt;/SPAN&gt;&lt;SPAN&gt;, pEvent-&amp;gt;u8SrcEp, pEvent-&amp;gt;u8DstEp, status);&lt;BR /&gt;&lt;/SPAN&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;void&lt;/SPAN&gt; handleZdoEvents(ZPS_tsAfEvent* psStackEvent)&lt;BR /&gt;{&lt;BR /&gt;...&lt;BR /&gt;&lt;SPAN&gt; switch&lt;/SPAN&gt;(psStackEvent-&amp;gt;eType)&lt;BR /&gt;...&lt;BR /&gt;        &lt;SPAN&gt;case&lt;/SPAN&gt;&lt;SPAN&gt; ZPS_EVENT_ZDO_BIND:&lt;BR /&gt;&lt;/SPAN&gt;            handleZdoBindEvent(&amp;amp;psStackEvent-&amp;gt;uEvent.sZdoBindEvent);&lt;BR /&gt;            &lt;SPAN&gt;break&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;The ZPS_eAplZdoBind() function returns success code. I see a record in binding table&lt;/P&gt;&lt;PRE&gt;Binding table (size=16)&lt;BR /&gt;AddrOrLkUp=0001 ClusterID=0006 addrMode=3 SrcEP=2 DstEP=1&lt;/PRE&gt;&lt;P&gt;Unfortunately, despite binding was ok, my device does not trigger any target device actions. Moreover the only thing I see in the sniffer is that device just reports its status change to the coordinator, but no other messages to any other devices&lt;/P&gt;&lt;P&gt;Just to be clear, my device reports switch state change as follows:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;void&lt;/SPAN&gt; reportStateChange()&lt;BR /&gt;{&lt;BR /&gt;    &lt;SPAN&gt;//&lt;/SPAN&gt; &lt;SPAN&gt;Destination&lt;/SPAN&gt; &lt;SPAN&gt;address&lt;/SPAN&gt; &lt;SPAN&gt;-&lt;/SPAN&gt; &lt;SPAN&gt;0x0000&lt;/SPAN&gt; &lt;SPAN&gt;(coordinator)&lt;BR /&gt;&lt;/SPAN&gt;    tsZCL_Address addr;&lt;BR /&gt;    addr.uAddress.u16DestinationAddress = &lt;SPAN&gt;0x0000&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;    addr.eAddressMode = E_ZCL_AM_SHORT;&lt;BR /&gt;&lt;BR /&gt;    DBG_vPrintf(TRUE, &lt;SPAN&gt;"Reporting&lt;/SPAN&gt; &lt;SPAN&gt;attribute&lt;/SPAN&gt; &lt;SPAN&gt;EP=%d&lt;/SPAN&gt; &lt;SPAN&gt;value=%d...&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;, getEndpointId(), sSwitch.sOnOffServerCluster.bOnOff);&lt;BR /&gt;&lt;/SPAN&gt;    PDUM_thAPduInstance myPDUM_thAPduInstance = hZCL_AllocateAPduInstance();&lt;BR /&gt;    teZCL_Status status = eZCL_ReportAttribute(&amp;amp;addr,&lt;BR /&gt;                                               GENERAL_CLUSTER_ID_ONOFF,&lt;BR /&gt;                                               E_CLD_ONOFF_ATTR_ID_ONOFF,&lt;BR /&gt;                                               getEndpointId(),&lt;BR /&gt;                                               &lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;                                               myPDUM_thAPduInstance);&lt;BR /&gt;    PDUM_eAPduFreeAPduInstance(myPDUM_thAPduInstance);&lt;BR /&gt;    DBG_vPrintf(TRUE, &lt;SPAN&gt;"status:&lt;/SPAN&gt; &lt;SPAN&gt;%02x\n"&lt;/SPAN&gt;&lt;SPAN&gt;, status);&lt;BR /&gt;&lt;/SPAN&gt;}&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;What am I doing wrong here? Maybe I should explicitly report state change to all bound devices somehow? From what I see&amp;nbsp;eZCL_ReportAttribute() just packs the report to a PDU instance and send to the coordinator - there is no code that is processing binding table and sending bound devices any other reports.&lt;/P&gt;&lt;P&gt;Any other recommendations?&lt;/P&gt;&lt;P&gt;My &lt;A href="https://github.com/grafalex82/hellozigbee/tree/hello_zigbee_binding" target="_self"&gt;code is here&lt;/A&gt;, if this helps&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 10:54:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1291329#M11251</guid>
      <dc:creator>grafalex</dc:creator>
      <dc:date>2021-06-11T10:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: JN-SW-4170: How does direct Zigbee binding work?</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1293628#M11262</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/187847"&gt;@grafalex&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I hope you are doing great.&lt;/P&gt;
&lt;P&gt;I have been reading about the issue that you are facing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please provide the sniffer log that you have about this behavior?&lt;/P&gt;
&lt;P&gt;What is the AN that you are working on?&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mario&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 23:10:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1293628#M11262</guid>
      <dc:creator>mario_castaneda</dc:creator>
      <dc:date>2021-06-16T23:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: JN-SW-4170: How does direct Zigbee binding work?</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1301015#M11307</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/86938"&gt;@mario_castaneda&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thank you for your reply. I have some progress on this, and already solved a few issues in this code over the last couple weeks:&lt;/P&gt;&lt;P&gt;- My switch should send OnOff commands to control other devices, not reports. This is vaguely mentioned in the documentation, but without an accent.&amp;nbsp;&lt;/P&gt;&lt;P&gt;- The switch should have a client OnOff cluster to be able to send commands to other devices&lt;/P&gt;&lt;P&gt;- Commands should be sent with&amp;nbsp;E_ZCL_AM_BOUND addressing mode, and not&amp;nbsp;E_ZCL_AM_SHORT&lt;/P&gt;&lt;P&gt;After these changes my device is now able to control other OnOff device on the network (smart switch, relay, or light).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using&amp;nbsp;JN-UG-3113,&amp;nbsp;JN-UG-3114, and JN-UG-3115 as a source of information, as well as Zigbee Specifications. Perhaps this is described in some AN document - I'll appreciate if you could point me to the one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the same time I am still confused with NXP Zigbee API. Here is a dump of Bind Request the coordinator is sending to my device&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="grafalex_0-1625127300426.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/148481iD7A3F995C9CE81A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="grafalex_0-1625127300426.png" alt="grafalex_0-1625127300426.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this request you can clearly see Cluster ID field. And this ID should be eventually passed to&amp;nbsp;ZPS_eAplZdoBind(). Unfortunately Zigbee Stack does not deliver this cluster ID to the ZDO handler. There is simply no such a field in&amp;nbsp;ZPS_tsAfZdoBindEvent structure&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;typedef&lt;/SPAN&gt; &lt;SPAN&gt;struct&lt;/SPAN&gt; {&lt;BR /&gt;    ZPS_tuAddress uDstAddr;&lt;BR /&gt;    uint8 u8DstAddrMode;&lt;BR /&gt;    uint8 u8SrcEp;&lt;BR /&gt;    uint8 u8DstEp;&lt;BR /&gt;} ZPS_tsAfZdoBindEvent;&lt;/PRE&gt;&lt;P&gt;Is there a way to obtain ClusterID value included in the Bind Request message?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 08:20:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1301015#M11307</guid>
      <dc:creator>grafalex</dc:creator>
      <dc:date>2021-07-01T08:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: JN-SW-4170: How does direct Zigbee binding work?</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1307124#M11361</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/187847"&gt;@grafalex&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I am not sure if I am following your request.&lt;/P&gt;
&lt;P&gt;You are looking for the Bind Request Cluster ID? Am I right? This will be 0x0021 by the spec.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mario&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 18:04:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1307124#M11361</guid>
      <dc:creator>mario_castaneda</dc:creator>
      <dc:date>2021-07-13T18:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: JN-SW-4170: How does direct Zigbee binding work?</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1309339#M11382</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/86938"&gt;@mario_castaneda&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;Let me rephrase. I am talking about ID of the cluster to bind. E.g. My device may implement various clusters - On/Off, thermometer, OTA, but I would like to bind specifically On/Off one.&lt;/P&gt;&lt;P&gt;As per Zigbee specification Bind request message looks like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="grafalex_0-1626514258388.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/150108iBC28BDE5DE593B93/image-size/medium?v=v2&amp;amp;px=400" role="button" title="grafalex_0-1626514258388.png" alt="grafalex_0-1626514258388.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you clearly see, there is ClusterID field. In the sniffer screenshot you can see this field as well (set to 0x0006 On/Off). From what I see this low level zigbee message is converted to&amp;nbsp;&lt;SPAN&gt;ZPS_tsAfZdoBindEvent structure, that has everything, except for Cluster ID.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I even disassembled the stack code, and looks like parsing low level Bind request message and converting it to&amp;nbsp;&lt;SPAN&gt;ZPS_tsAfZdoBindEvent happens in&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;bAplZdoBindUnbindServerProcessApdu(). Unfortunately this function comes without sources, so I cannot fix it myself.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So the question is: would it be possible to add ClusterID field to&amp;nbsp;&lt;SPAN&gt;ZPS_tsAfZdoBindEvent? You have all needed information for this already.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 09:35:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1309339#M11382</guid>
      <dc:creator>grafalex</dc:creator>
      <dc:date>2021-07-17T09:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: JN-SW-4170: How does direct Zigbee binding work?</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1310047#M11388</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/187847"&gt;@grafalex&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Please look at the next event you could get the Cluster Id that you are looking for.&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;        case BDB_EVENT_FB_CHECK_BEFORE_BINDING_CLUSTER_FOR_TARGET:
            DBG_vPrintf(TRACE_APP_BDB,"APP-BDB: Check For Binding Cluster %04x\n",
                        psBdbEvent-&amp;gt;uEventData.psFindAndBindEvent-&amp;gt;uEvent.u16ClusterId);
            break;&lt;/LI-CODE&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mario&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 20:14:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/JN-SW-4170-How-does-direct-Zigbee-binding-work/m-p/1310047#M11388</guid>
      <dc:creator>mario_castaneda</dc:creator>
      <dc:date>2021-07-19T20:14:52Z</dc:date>
    </item>
  </channel>
</rss>

