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.

CC2652P: How to read the NWK frame counter?

Part Number: CC2652P

A customer wants to read the NWK frame counter for the purpose of backing up the network information. I looked into the examples and found that it is stored in the NVID ZCD_NV_EX_NWK_SEC_MATERIAL_TABLE. My question is that if the NWK frame counter is written to the NV every time it is incremented? Can I get the frame counter by reading the NVID in my application?

BR,

Shuyang

  • Hi Shuyang,

    You have the right idea, as ZDApp_SaveNwkKey updates the ZCD_NV_EX_NWK_SEC_MATERIAL_TABLE with the frame counter on each ZDO_FRAMECOUNTER_CHANGE event.  ZDO_FRAMECOUNTER_CHANGE is most commonly set while securing/unsecuring a NWK layer packet.  The frame counter is incremented by MAX_NWK_FRAMECOUNTER_CHANGES + NWK_FRAMECOUNTER_CHANGES_RESTORE_DELTA during ZDApp_RestoreNwkSecMaterial to account for instances where the NV memory may not have been updated immediately before a system reset and thus needs to compensate to ensure that it is not using a lower frame counter values than before it reset.  Please refer to SWRA671 for saving/backing up network information.

    Regards,
    Ryan

  • Hi Ryan,

    "ZDO_FRAMECOUNTER_CHANGE is most commonly set while securing/unsecuring a NWK layer packet."

    Does the stack set ZDO_FRAMECOUNTER_CHANGE automatically? I tried to set a breakpoint at the case event == ZDO_FRAMECOUNTER_CHANGE in ZDApp_ProcessSecEvent(), and found it is only triggered once during the network formation.

    How can I monitor every incrementing of the NWK frame counter?

    BR,

    Shuyang

  • Hi Shuyang,

    The ZDO_FRAMECOUNTER_CHANGE does not occur automatically but you will probably have to wait MAX_NWK_FRAMECOUNTER_CHANGES packets before it is saved to NV.  It wouldn't be reasonably to save to NV on each frame counter change.  You can use SSP_ReadNwkActiveKey to obtain the nwkActiveKeyItems -> frameCounter for the most updated value.

    Regards,
    Ryan