/*
 * suspend_resume.h
 *
 *  Created on: 05-Oct-2022
 *      Author: Invcuser52
 */

#ifndef _INC_SUSPEND_RESUME_H_
#define _INC_SUSPEND_RESUME_H_


#include "file_transfer.h"
#include "ftfci.h"


typedef enum sus_res_state
{
	state_suspend,
	state_suspend_ack,
	state_resume,
	state_resume_ack,
	no_suspend_reusume
}e_sus_res_state;


typedef enum suspend_type
{
	suspend_by_timeout,
	suspend_by_savecontext,
}e_suspend_type;


typedef enum avtive_type
{
	sus_res_master,
	sus_res_slave,
	no_master_slave
}e_avtive_type;

typedef struct suspend_resume_info
{
	eSystemState fsm_state_save;
	e_sus_res_state state;
	e_suspend_type type;
	uint8_t resume_time;
	e_avtive_type active_sts;
	uint16_t timeout_time_save;
	uint16_t request_clear_flag;
	uint8_t sus_res_rqst_retry_count;
	uint8_t rqst_retry_flag;
	e_sus_res_state sus_res_state_copy;
	uint8_t sus_savctxt_ack_sent;
}s_suspend_resume_info;


extern s_suspend_resume_info s_sus_res_info;


void ft_suspend(ft_request susp_type, uint16_t timeoout_time, uint8_t ack_set);
void ft_resume(uint8_t resume_type, uint8_t ack_set );
e_sus_res_state ft_get_suspend_resume_sts(void);
void init_sus_res(void);
void ft_savecontext_ack(uint8_t ack);
void ft_set_master_slave(e_avtive_type set);
e_avtive_type ft_get_master_slave_status(void);
void ft_set_suspend_resume_sts(e_sus_res_state set);
e_sus_res_state ft_get_state_before_suspend(void);
void ft_sus_res_handler(void);
void ft_terminate(ft_request ter_option, uint8_t ack);
void ft_cancel_ftp(void);
void ft_check_suspend_status(void);
void clear_sus_res_req_retry_cntr(void);
void sus_res_clear_pending_rqst(void);
uint8_t ft_sus_res_request_clrflg_sts(void);

/* debug functions */
#ifdef FT_SUSRES_TEST
void ft_sus_res_debug_init(void);
void ft_sus_res_debug_deinit(void);
#endif

#endif /* FILE_TRANS_REL_V1_SAMPLE_APPS_GS_SAMPLE_APP_INC_SUSPEND_RESUME_H_ */
