Example #1
0
/****************************************************************************
 * @fn          ZDiagsInitStats
 *
 * @brief       Initialize the statistics table in NV or restore values from
 *              NV into the Statistics table in RAM
 *
 * @param       none.
 *
 * @return      ZSuccess - if NV data was initialized successfully.
 *              ZFailure - Otherwise
 */
uint8 ZDiagsInitStats( void )
{
  uint8 retValue = ZSuccess;

#if defined ( FEATURE_SYSTEM_STATS )
  uint8 status;

  // Initialize structure with default values, and do not try to write to NV
  // because item does not exist yet
  (void)ZDiagsClearStats( FALSE );

  status = osal_nv_item_init( ZCD_NV_DIAGNOSTIC_STATS,
                              (uint16)sizeof( DiagStatistics_t ),
                              &DiagsStatsTable );

  if ( status == NV_OPER_FAILED )
  {
    retValue = ZFailure;
  }
  else
  {
    // Item existed, restore NV values into RAM table
    if ( status == SUCCESS )
    {
      if ( NV_OPER_FAILED == ZDiagsRestoreStatsFromNV() )
      {
        retValue = ZFailure;
      }
    }
  }
#endif // FEATURE_SYSTEM_STATS

  return ( retValue );
}
Example #2
0
/****************************************************************************
 * @fn          zclDiagnostic_RestoreStatsFromNV
 *
 * @brief       Restores the statistics table from NV into the RAM table.
 *
 * @param       none.
 *
 * @return      ZSuccess - if NV data was restored from NV.
 *              ZFailure - Otherwise, NV_OPER_FAILED for failure.
 */
uint8 zclDiagnostic_RestoreStatsFromNV( void )
{
  return ( ZDiagsRestoreStatsFromNV() );
}