This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Adding ZNP in a ZC project, observing ZCL data with ZTool log

Other Parts Discussed in Thread: Z-STACK

Hi,

I use two Z-Stack examples:

zed_temperaturesensor
zc_thermostat

By default they work fine, I see packets in the sniffer:

ZCL Identify Query
ZCL Identify Response (from ZC)
ZCL Report Attributes
ZCL Default Response (from ZC)

But after implementing ZNP in the zc_thermostat project, ZC doesn't send ZCL responses, so I see only packets from ZED:

ZCL Identify Query
ZCL Report Attributes

Question 1: Why does ZC stop sending ZCL responses?

Question 2: How to get ZCL Report Attributes data in the ZTool log window?

P.S. I used the topic https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread/f/zigbee-thread-forum/696699/ccs-cc2652r-ztool-and-mt-feature-for-zigbee-pluggin-1-0-60 to add ZNP in the zed_thermostat project.

  • Ok, it looks like when ZNP_NPI is enabled, then "sampleApp_task()" and "zclSampleThermostat_process_loop()" are not used. That is why ZC doesn't send ZCL responses.

    But how to make ZNP forward incoming data to ZTool via UART?

  • Do you register endpoint and its simple descriptor to ZNP through ZTool?

  • I paired ZC and ZED in their default build. Then I have another ZC build where ZNP is added and I flashed the ZC-ZNP build over the default one. So ZC and ZED are still assocoated in the NV memory after that. Then I sent APP_CNF_BDB_START_COMMISSIONING (Network Steering) to the ZC-ZNP and I saw in the sniffer that they restored the link and there are periodic Data Request, Ack, ZCL Identify, ZCL Report packets. So it looks good. I sent only this single command just to kick the ZC, because it doesn't answer to the ZED without this command.

    But I want to see the ZCL Report in the ZTool log.

    Should I register an endpoint and descriptor? How could I do it?

  • Here is the current guide on adding the MT interface to your application, since technically a ZNP device would not have an application (as it is hosted by a separate device).  Be sure to define MT_AF_CB_FUNC or else you won't receive the AF_INCOMING_MSG callback.  You can refer to the MT API for more information.

    Regards,
    Ryan

  • I see a few defines that are not included in the guide text, but present on the screenshot in the guide:

    ZTOOL_P1
    MT_TASK
    MT_NWK_FUNC
    MT_NWK_CB_FUNC

    Should I add them?

  • ZTOOL_P1 is most likely deprecated and not needed if you already have the NPI layer operational.  MT_TASK is unnecessary and MT_NWK_* definitions are only needed if you desire to interact with the NWK layer and subsequent APIs.

    Regards,
    Ryan

  • Let me explain from the very beginning what I want to get.

    I have two projects zc_thermostat and zed_temperaturesensor.

    I want to get the same functionality, but receive the data from the zed_temperaturesensor in the ZTool log.

    When I follow the guide and add all these NPI and MT_* definitions, I see that the coordinator doesn't work as ZC-thermostat more, it doesn't send any ZCL responses to ZED. I found that it happens because the internal zcl application is not active when ZNP_NPI is defined. I removed the ZNP_NPI, but it didn't help. I run the debugger and found that the zcl application is activated and incoming ZCL Identify Query packets from ZED are received, but when ZC handles them it gets result AF_TX_OPTIONS_NONE from the function zclGetClusterOption(), so zclFindClusterOption( endpoint, clusterID ) can't find the 8 endpoint for the Identify Cluster 0x0003. But I didn't change the example sources. I only added the MT_* and NPI definitions in the Predefined Symbols.

    So my questions are how to keep the zc_thermostat functionality and show data from zed_temperaturesensor in the ZTool?

  • Thank you for the detailed explanation in regards to your debug efforts.  ZNP_NPI should definitely not be defined to allow the application task to run.  NPI should be defined to create its task and process host messages.  I'm seeing an error in the User's Guide instructions: CUI_DISABLE should be defined but BOARD_DISPLAY_USE_UART should not.  The ZCL layer should be registered through zclSampleThermostat_Init, do any of these functions return an error?  The ZCL should also be completely separate from NPI functionality.  Did you add the MT and NPI folders to the example project and include the search paths inside the project properties?

    Regards,
    Ryan

  • Yes, I've seen the error in the guide. All defines in my project look correct, MT, NPI folders and mt_, npi_ sources are added. The project compiled well and ZTool commands work.

    I've repeated my testing. My fault was that I didn't clear NV memory for testing the znp build. So some results were unexpected. Now I erased the chip completely and flashed it with zc_thermostat znp build. The "znp build" is the build where I added MT, NPI folders/sources/including and MT, NPI defines according to the guide you have mentioned. Then I started commissioning as it is described in the guide https://sunmaysky.blogspot.com/2017/02/use-ztool-z-stack-30-znp-to-set-up.html and I have got zed_temperaturesensor and zc_thermostate (with MT/NPI) working.

    Then I setup a breakpoint in the zcl_ProcessMessageMSG() procedure to catch COMMAND_IDENTIFY_IDENTIFY_QUERY and found during debugging step by step that identifyTime = 0 in the zcl_general.c, that is why ZC doesn't send zclGeneral_SendIdentifyQueryResponse().

    What command should I send with ZTool to make ZC identifying itself and make identifyTime > 0 to let it answer with Identify Query Response?

    P.S. When I run the default zc_thermostate build (without MT and NPI) the identifyTime is not 0 and zc_thermostate sends Query Response. So adding MT interface breaks something.

  • Thanks for the update Alex.  Using APP_CNF_BDB_START_COMMISSIONING with a Finding&Binding (0x08) CommissioningMode will start the Identify timer.  This is done by default in the ZC thermostat example code after pushing button 1 or using the CUI so you could debug to determine how BDB_COMMISSIONING_MODE_FINDING_BINDING is voided from zclSampleLight_BdbCommissioningModes.

    Regards,
    Ryan

  • Thanks, Ryan. Now it works, but zc_thermostat gets stuck after receiving ZCL Report Attributes. I found that it happens, because the zc_thermostat periodically calls zclSampleThermostat_UpdateLedState() and when zc_thermostate updates zclSampleThermostat_LocalTemperature value, it tries to update LED state. Although leds are not initialized, because CUI is disabled. So it is a bug in the example.

    I fixed it wrapping zclSampleThermostat_UpdateLedState() code with #ifndef CUI_DISABLE ... #endif and it works now.

    Now I have the next question:

    How to send the ZCL Report Attributes from ZNP to ZTool via UART? Or which command should I send with ZTool to retrieve the ZCL Report Attributes from ZNP?

  • Thanks Alex, I have informed the Software Development Team so that this can be corrected in the future.  I think instances where zclSampleThermostat_LocalTemperature is used should depend on CUI_DISABLE, similar to UI_UpdateBdbStatusLine.  zclSampleThermostat_LocalTemperature should probably be encased by CUI_DISABLE as well so that build errors would occur if the code attempted to use it.

    If your application does not form a bind on the temperature sensor for automatic attribute reporting, then you would have to imitate a ZCL packet using AF_DATA_REQUEST.  It would then be received by the destination device with AF_INCOMING_MSG.

    Regards,
    Ryan

  • As I've said already, zed_temperaturesensor sends periodical ZCL Report Attributes with the current temperature value. And zc_thermostat answers with ZCL Default Response.

    Also I've tried sending AF_DATA_REQUEST to read attributes and I see in the sniffer that zc_thermostat sends ZCL Read Attributes and zed_temperature sensor answers with ZCL Read Attributes Response with temperature attribute is in the ZCL frame payload.

    But in both cases I see nothing in the ZTool log window, only my commands and responses.

    I guess that there should be something like AF_INCOMING_MSG, but it is not.

    How to make zc_thermostat znp forward the Attributes data to ZTool log?

  • You might need to add the following code in zclSampleThermostat_processAfIncomingMsgInd to make AF incoming message data to output to UART.

    MT_AfIncomingMsg( (void *)&afMsg );

  • Thank you very much! It works.