/*
 * sample_app.c
 *
 *  Created on: 30-Sep-2022
 *      Author: Invcuser52
 */

#include "ft_sample_app_upload.h"

#include "stdio.h"
#include "notify_apps.h"
#include "file_transfer.h"
#include "ft_sample_app_dwnld.h"
#include "get_input.h"
#include "upload_def.h"
#include "download_def.h"
#include "ftfci_decode.h"
#include "ftci_decode.h"
#include "segmentation.h"
#include "suspend_resume.h"
#include <unistd.h>
#include <time.h>
#include "ft_debug.h"
#include "es_intf_ctrl_msg.h"
//#include "sample_app_dwnld_obc.h"



//#define APP_ID 0x1234

extern uint8_t *gui_savecontext_ptr;
extern uint16 savecontext_size;

uint8_t init_start=0;


static uint8_t mode_select;
uint8_t suspend_context_activated = 0;
uint8_t file_tx_running = 0;
uint8_t RC_flag =0;

#define INPUT_BULKDAT_BUF_LEn 1024

uint8_t bulk_data_buffer[INPUT_BULKDAT_BUF_LEn] =
{
		97,88,167,110,163,221,24,23,12,15,56,111,41,190,181,110,100,5,253,135,227,127,181,110,50,35,119,
		206,84,250,112,75,14,52,153,222,75,9,74,194,53,183,18,182,10,164,172,229,162,157,210,167,159,161,
		90,70,30,103,17,180,105,187,85,230,194,224,18,106,185,190,203,5,64,172,150,5,238,175,144,145,74,
		132,113,2,191,244,7,173,240,185,226,64,114,48,15,174,239,35,230,182,172,20,125,169,50,64,74,208,
		243,64,99,182,150,97,181,220,174,140,105,210,240,194,210,98,254,241,198,196,234,94,178,71,8,120,
		253,57,216,178,59,254,193,154,11,180,47,183,28,75,16,243,110,126,198,100,186,89,1,245,75,60,111,
		248,241,22,220,9,40,79,203,106,3,189,116,173,66,138,127,8,202,35,39,201,233,203,110,116,88,178,53,
		71,108,6,226,101,75,188,203,49,120,46,154,98,143,121,71,57,137,41,62,210,171,176,124,28,224,47,13,
		55,38,181,188,31,247,130,99,223,162,143,36,114,248,77,199,131,149,60,215,238,129,179,76,86,5,101,
		197,93,1,2,250,103,153,44,96,119,162,56,44,112,125,6,142,102,127,197,250,64,134,185,40,120,196,18,
		238,53,51,208,1,146,9,180,63,18,45,101,227,49,224,35,145,110,49,84,50,227,8,85,94,120,112,168,18,
		118,155,232,202,222,101,128,53,125,164,133,63,147,241,195,53,23,148,181,56,216,247,93,79,181,63,81,
		119,53,77,192,32,133,128,136,236,61,40,173,27,64,254,37,211,15,222,137,179,14,169,176,209,94,247,202,
		148,180,110,114,211,67,23,82,118,223,220,215,27,18,150,44,106,63,63,133,123,67,41,175,174,38,38,49,
		250,177,46,30,98,155,136,227,116,154,72,209,224,193,76,164,217,197,134,11,93,39,91,181,183,4,196,127,
		44,106,33,87,58,1,202,93,76,4,155,62,18,65,252,189,64,141,180,47,194,172,206,112,70,226,66,49,228,58,
		248,59,99,75,126,8,210,238,208,1,74,53,231,204,11,67,215,76,181,92,195,71,48,223,145,164,105,102,226,
		137,94,54,194,61,11,185,45,176,67,8,120,16,53,154,188,58,24,13,38,62,139,244,155,28,159,200,142,59,
		212,198,236,231,135,238,12,44,255,183,149,50,6,65,112,24,115,100,219,157,25,202,209,39,201,131,82,
		120,80,184,145,202,134,2,75,121,120,67,242,20,195,78,30,142,249,184,7,134,236,42,242,191,54,130,101,
		217,167,200,122,140,181,112,107,51,150,94,14,169,166,181,83,79,123,27,194,123,41,121,45,7,49,68,176,5,
		38,26,209,79,113,137,126,44,250,201,163,90,68,235,151,140,96,100,30,39,41,174,158,42,150,206,111,86,
		65,123,61,74,147,12,43,122,224,99,95,12,67,36,241,105,74,19,174,42,40,107,4,109,239,10,10,223,129,38,
		212,45,126,140,49,147,254,6,85,9,69,145,37,74,211,207,144,28,43,2,247,55,244,36,68,3,178,124,4,48,115,
		75,170,172,206,120,238,142,203,92,223,40,244,13,227,164,225,231,80,123,74,57,113,19,117,64,186,169,
		175,21,47,209,221,191,237,2,222,233,104,32,245,1,21,241,100,11,73,104,40,117,12,212,105,68,44,128,
		200,226,27,90,248,90,26,67,237,74,76,182,67,178,135,62,215,52,151,147,39,172,45,208,189,206,237,169,
		98,21,237,43,63,99,129,28,94,169,78,227,68,91,9,183,109,169,92,240,23,69,38,145,156,130,230,157,57,
		68,160,39,121,183,20,217,235,169,165,24,145,248,112,144,92,131,46,71,61,239,136,178,133,101,156,30,
		86,241,53,154,127,251,214,175,76,182,181,28,218,188,117,177,183,26,135,88,64,88,166,57,14,64,152,85,
		23,43,78,221,178,225,180,92,16,183,142,20,68,8,136,208,153,3,233,148,230,144,6,69,58,152,140,251,48,68,57,99,56,126,184,40,181,144,56,90,112,145,205,113,9,218,85,117,1,210,248,183,232,128,177,123,61,214,174,146,9,195,138,10,74,174,137,32,151,208,135,213,94,13,156,211,68,83,137,82,120,125,158,213,33,217,86,23,234,105,163,82,123,39,40,227,149,159,141,27,95,190,118,86,16,140,67,167,1,108,86,250,244,36,16,126,222,84,58,185,207,160,182,177,42,130,95,202,147,142,6,17,244,99,31,246,117,13,29,247,32,37,180,139,194,165,66,238,220,81,145,197,113,145,130,93,187,89,73,156,127,158,194,12,168,59,150,251,208,48,91,8,190,31,211,111,207,100,103,145,56,149,37,70
};


void display_ft_sts()
{
	uint8_t percentage_upload;
	uint8_t err_code;

	percentage_upload = ft_get_upload_percentage_compl();
	err_code = ft_get_error_sts();
	printf("\r\nFT status:  Upload Comp Percent:%d | Error Code:%d\r\n",percentage_upload,err_code);

}




/*
 *
 *  Application API which will be invoked during file transmission by FT framework
 *
 */
void app1234_notificataion_api_upld(ft_notification_info *ft_sts)
{
	uint16_t u16cnt;
	e_avtive_type node_act_type;
	uint8_t ret_sts;

	static uint8_t nack_test = 1;

	time_t tm;
	time(&tm);

	printf("App notification API invoked !!!!\n");
    printf("Current Date/Time = %s\n",ctime(&tm));

	if(ft_sts->status == transfer_upload_success)
	{
		printf("1. upload success\n");
		init_start = 0;
		//file_tx_running = 0;
	}
	else if(ft_sts->status == crc_error)
	{
		printf("1. upload failed/ CRC error\n");
		init_start = 0;
		//file_tx_running = 0;

	}
	else if(ft_sts->status == transfer_suspended)
	{
		printf("1. upload suspended by receiver [Timeout mode]\n");
		display_ft_sts();
	}
	else if(ft_sts->status == transfer_suspended_savecontext)
	{
		printf("1. upload suspended by receiver [Savecontext Mode]\n");

		gui_savecontext_ptr = malloc(ft_sts->context_info.context_info_size);
		if(gui_savecontext_ptr != NULL)
		{
			savecontext_size = ft_sts->context_info.context_info_size;
			printf("2. context data size: %d\n",savecontext_size);
			printf("3. context data : ");
			for (u16cnt = 0; u16cnt < savecontext_size; u16cnt++)
			{
				gui_savecontext_ptr[u16cnt] = ft_sts->context_info.context_info_buf_ptr[u16cnt];
				//printf("%x ",gui_savecontext_ptr[u16cnt]);
			}
			display_context_info();

			node_act_type = ft_get_master_slave_status();
			if(node_act_type == sus_res_slave)
			{
				if(nack_test != 0)
				{
					ft_transfer_request(Suspend_Savecontext_ack_rqst,0);
					init_start = 0;
					//file_tx_running = 0;
				}
				else
				{
					ft_transfer_request(Suspend_Savecontext_nack_rqst,0);
					nack_test = 1;
				}
			}
		}
	}
	else if(ft_sts->status == transfer_resumed_restorecontext)
	{
		printf("1. upload resumed by receiver [Savecontext Mode]\n");
		ret_sts = ft_resume_context(gui_savecontext_ptr,savecontext_size);
		if(ret_sts == 0)
		{
			free(gui_savecontext_ptr);
			//init_start = 1;
		}
		else
		{
			printf("Resume-SaveContext Error %d\n",ret_sts);
		}
	}
	else if(ft_sts->status == transfer_resumed)
	{
		printf("1. upload resumed back by receiver\n");
	}
	else if(ft_sts->status == tx_terminated_suspend_timeout_expired)
	{
		printf("1. upload Terminated due to suspend timeout expired\n");
		init_start = 0;
		//file_tx_running = 0;

	}
	else if(ft_sts->status == transfer_suspend_accepted)
	{
		printf("1. upload Suspend - Timeout mode Accepted by Receiver\n");
		display_ft_sts();
	}
	else if(ft_sts->status == transfer_suspend_savecontext_accepeted)
	{
		printf("1. upload Suspend - Save context mode Accepted by Receiver\n");

		gui_savecontext_ptr = malloc(ft_sts->context_info.context_info_size);
		if(gui_savecontext_ptr != NULL)
		{
			savecontext_size = ft_sts->context_info.context_info_size;
			printf("2. context data size: %d\n",savecontext_size);
			printf("3. context data : ");
			for (u16cnt = 0; u16cnt < savecontext_size; u16cnt++)
			{
				gui_savecontext_ptr[u16cnt] = ft_sts->context_info.context_info_buf_ptr[u16cnt];
				//printf("%x ",gui_savecontext_ptr[u16cnt]);
			}
			display_context_info();

			node_act_type = ft_get_master_slave_status();
			if(node_act_type == sus_res_slave)
			{
				if(nack_test != 0)
				{
					ft_transfer_request(Suspend_Savecontext_ack_rqst,0);
				}
				else
				{
					/* send NACK to check suspend context is aborted */
					ft_transfer_request(Suspend_Savecontext_nack_rqst,0);
					nack_test = 1;
				}
			}
			else
			{
				/* go back to input mode to intaite another FT */
				init_start = 0;
				//file_tx_running = 0;

				display_ft_sts();
			}
		}
	}
	else if(ft_sts->status == transfer_resume_accepted)
	{
		printf("1. upload Resume - Timeout mode Accepted by Receiver\n");
	}
	else if(ft_sts->status == transfer_resume_savecontext_accepeted)
	{
		printf("1. upload Resume - Savecontext mode Accepted by Receiver\n");
		init_start = 1;
	}
	else if(ft_sts->status == transfer_upload_ready)
	{
		printf("1. Receiver ready for Download\n");
	}
	else if(ft_sts->status == invalid_receiver_app_id)
	{
		printf("1. Upload request cancelled - Receiver API not registered !!!\n");
		init_start = 0;
		//file_tx_running = 0;
	}
	else if(ft_sts->status == transfer_upload_rejected)
	{
		printf("1. Upload request rejected - Issue in FTCI decoding in Rx node !!!\n");
		init_start = 0;
	}
	else if(ft_sts->status == transmission_terminated_receiver_not_responsive)
	{
		printf("1. Upload Terminated due to Receiver not responsive !!!\n");
		init_start = 0;
		//file_tx_running = 0;
	}
	else if(ft_sts->status == transmission_terminated_by_rx_node)
	{
		printf("1. download Terminated by Receiver node\n");
		init_start = 0;
	}
	else if(ft_sts->status == transfer_suspend_tout_not_accepted)
	{
		printf("1. suspend timeout request not completed\n");
	}
	else if(ft_sts->status == transfer_suspend_savecontext_failed)
	{
		printf("1. suspend savecontext request not completed\n");
	}
	else if(ft_sts->status == transfer_rseume_tout_not_accepted)
	{
		printf("1. resume timeout request not completed\n");
	}
	else if(ft_sts->status == transfer_resume_restorecontext_failed)
	{
		printf("1. resume savecontext request not completed\n");
	}
	else if(ft_sts->status == transfer_suspended_savecontext_etended_sts)
	{
		printf("1. Suspend savecontxt request 100%% completed\n");
	}
	else
	{
		printf("Invalid Notification not processed\n");

	}

	printf("\n-------------/End/---------------\n\n");

}





static uint8_t get_ft_input()
{
	uint16_t mtu;
	uint8_t ret_sts;
	char loc_str[200];

	printf("\r\nEnter input file name\r\n");
	scanf("%s",loc_str);
	ret_sts = ft_get_sender_file_name_path(loc_str);
	if (ret_sts != 1)
	{
		return 0;
	}

	printf("\r\nEnter MTU size in bytes (max->164)\r\n");
	scanf("%hu", &mtu);
	printf("MTU size set: %u\r\n", mtu);
	ft_get_mtu_size(mtu);
	ft_transfer_request(Start_Transmission_rqst,0);
	return ret_sts;
}



static uint8_t get_bulk_data_input()
{
	uint16_t mtu;
	uint8_t ret_sts=1;

	printf("\r\nInput buffer \"bulk_data_buffer\" selected\r\n");
	ft_get_bulk_data_input_buffer(bulk_data_buffer,INPUT_BULKDAT_BUF_LEn);

	printf("\r\nEnter MTU size in bytes\r\n");
	scanf("%hu", &mtu);
	printf("MTU size set: %u\r\n", mtu);
	ft_get_mtu_size(mtu);
	ft_transfer_request(Start_Transmission_rqst,0);
	return ret_sts;
}








void debug_inputHandler(void)
{
	uint8_t ret=0;

	if (mode_select == 0)
	{
		while(ret ==0)
		{
			ret = get_ft_input();
		}
	}
	else if (mode_select == 1)
	{

		while(ret ==0)
		{
			ret = get_bulk_data_input();
		}

	}
}



void config_seqloss_detct_mode(void)
{
	uint8_t ret=0;
    uint32 tst_id;

	while(ret ==0)
	{
	    printf("Select Seq loss detection mode\n 1 = Seq loss detection enabled\n 0 = Disabled\n");
	    scanf(" %d", &tst_id);
	    getchar();
		ret = ft_sequenceLoss_mode_select((uint8_t)tst_id);
	}
}




void debug_select_mode()
{
	uint8_t ret=0;
	char input_str[50] = "FILE";

	while(ret == 0)
	{
		printf("\r\nEnter Mode >> FILE or DATA ?\r\n");
		scanf("%s",input_str);
		if (strcmp(input_str, "FILE") == 0)
		{
			printf("File mode selected\r\n");
			ret = ft_mode_select(0);
			mode_select = 0;
		}
		else if (strcmp(input_str, "DATA") == 0)
		{
			printf("Bulk data mode selected\r\n");
			ft_mode_select(1);
			ret = 1;
			mode_select = 1;
		}
		else
		{
			printf("Invalid mode, Enter again\r\n");
		}

	}

}



void app1234_file_transfer_initiate(void)
{
	uint8_t ret=0;
	char input_str[5];
	RC_flag = 0;
	uint16_t tst_id;
	while(ret == 0)
	{
		printf("\r\nSelect Node >> SENDER or RECEIVER ?\n");
		printf("	Enter SEN to work as SENDER node\n");
		printf("	Enter RCV to work as RECEIVER node\n");
		printf("	Enter RCT to Restore Context of previous FT session if any\n");
		printf("	Enter EX  to exit from FT\n");
		printf("	Enter BK  to back to other options\n");



		scanf("%s",input_str);
		if (strcmp(input_str, "SEN") == 0)
		{
			printf("SENDER selected\r\n");

			ret = ft_register_sender_app(TM_SRC_PS, app1234_notificataion_api_upld);
			if(ret != 0)
			{
				ft_get_app_id(TM_SRC_PS);
		//		ft_mode_select("FILE");
		//		ft_get_sender_file_name_path("file1.txt");
		//		ft_get_mtu_size(250);
		//		ft_transfer_request(Start_Transmission_rqst,0);

				debug_select_mode();
				config_seqloss_detct_mode();
				debug_inputHandler();
			}
		}
		else if (strcmp(input_str, "RCV") == 0)
		{
			printf("RECEIVER selected\r\n");
#ifdef FT_OBC
            ft_register_obc_trasnmitter_cblk(ft_payload_obc);
            ft_register_obc_flashbusy_sts_cblk(obc_flash_handler_busycheck);
#endif
			sample_app_regisration_dwld();
			ret = 1;
			init_start = 1;
		}
		else if (strcmp(input_str, "RCT") == 0)
		{
			RC_flag = 1;
			ret = 1;
			init_start = 1;
			ft_register_sender_app(TM_SRC_PS, app1234_notificataion_api_upld);
		}
		else if (strcmp(input_str, "EX") == 0)
		{
			ret = 1;
			file_tx_running = 0;
		}
		else if (strcmp(input_str, "BK") == 0)
		{
			init_start = 1;
			ret = 1;
		}
		else if (strcmp(input_str, "DB") == 0)
		{
	        printf("Enter Debug Options\n");
	        printf("Debug Type 1 - Get FTM general status\n");
	        printf("Debug Type 2 - Reset FTM\n");
	        printf("Debug Type 3 - Terminate FTM operation\n");
	        scanf(" %hd", &tst_id);
	        getchar();

	        if(1 == tst_id)
	        {
	        	ft_encode_debug_request(e_ft_debug_gen_status);
	        }
	        if(2 == tst_id)
	        {
	        	ft_encode_debug_request(e_ft_reset);
	        }
	        if(3 == tst_id)
	        {
	        	ft_encode_debug_request(e_ft_debug_terminate);
	        }
	        else
	        {
		        printf("Invalid input..\n");
	        }

			ret = 1;
			file_tx_running = 0;
		}
		else if (strcmp(input_str, "FTD1") == 0)
		{
			printf("\r\nft_sus_res_debug_skip_all_sus_req selected \r\n");
			ft_sus_res_debug_skip_all_sus_req();
			sleep(2);
		}
		else if (strcmp(input_str, "FTD2") == 0)
		{
			printf("\r\ft_sus_res_debug_enable_all_sus_req selected \r\n");
			ft_sus_res_debug_enable_all_sus_req();
			sleep(2);

		}
		else if (strcmp(input_str, "FTD3") == 0)
		{
			printf("\r\ft_sus_res_debug_skip_all_sus_ack selected \r\n");
			ft_sus_res_debug_skip_all_sus_ack();
			sleep(2);

		}
		else if (strcmp(input_str, "FTD4") == 0)
		{
			printf("\r\ft_sus_res_debug_enable_all_sus_ack selected \r\n");
			ft_sus_res_debug_enable_all_sus_ack();
			sleep(2);

		}
		else if (strcmp(input_str, "FTD5") == 0)
		{
			printf("\r\ft_sus_res_debug_skip_all_res_req selected \r\n");
			ft_sus_res_debug_skip_all_res_req();
			sleep(2);

		}
		else if (strcmp(input_str, "FTD6") == 0)
		{
			printf("\r\ft_sus_res_debug_enable_all_res_req selected \r\n");
			ft_sus_res_debug_enable_all_res_req();
			sleep(2);

		}
		else if (strcmp(input_str, "FTD7") == 0)
		{
			printf("\r\ft_sus_res_debug_skip_all_res_ack selected \r\n");
			ft_sus_res_debug_skip_all_res_ack();
			sleep(2);

		}
		else if (strcmp(input_str, "FTD8") == 0)
		{
			printf("\r\ft_sus_res_debug_enable_all_res_ack selected \r\n");
			ft_sus_res_debug_enable_all_res_ack();
			sleep(2);

		}
		else if (strcmp(input_str, "FTD9") == 0)
		{
			printf("\r\ft_sus_res_debug_enable selected \r\n");
			ft_sus_res_debug_enable();
			sleep(2);

		}
		else if (strcmp(input_str, "FTD10") == 0)
		{
			printf("\r\ft_sus_res_debug_disable selected \r\n");
			ft_sus_res_debug_disable();
			sleep(2);

		}
		else
		{
			ret = 0;
	        printf("Invalid input..\n");
		}
	}

}



void app1234_thread(void)
{
	char input_str[50] = "FILE";
	e_ft_current_process ft_state;
	uint16_t timeout;
	file_tx_running= 1;
	uint8_t ret_sts;


	while(1)
	{
		if(file_tx_running == 0)
		{
			break;
		}
		usleep(2000);

		if(init_start == 0)
		{
			app1234_file_transfer_initiate();

			printf("\r\nEnter interrupt options\n");
			printf("1. \"STxx\" >> Suspend with timeout mode , here \"xx\" denotes timeout value in range 10-99 in seconds\n");
			printf("2. \"RT\"   >> Resume - timeout mode\n");
			printf("3. \"SCT\"  >> Suspend with savecontext mode\n");
		//	printf("4. \"RC\" >> Resume with savecontext mode\n");
		}

		ft_state =  get_file_transfer_state();
		if(ft_state != ft_process_na || init_start != 0)
		{
			init_start = 1;

			if(RC_flag != 1)
			{
				scanf("%s",input_str);
			}
			else
			{
				input_str[0] = 'R';
				input_str[1] = 'C';
				input_str[2] = 'T';
				input_str[3] = '\0';
				RC_flag = 0;
			}

			if(ft_state != ft_process_na || suspend_context_activated == 1)
			{

				if ((input_str[0] == 'S') && (input_str[1] == 'T'))
				{
					//timeout = ((input_str[2]-48)*10) + (input_str[3]-48);
					timeout =  atoi(&input_str[2]);
					if(timeout < 30)
					{
						timeout = 30;
					}
					else if(timeout > 65535)
					{
						timeout = 65535;
					}
					printf("\r\nSuspend-Timeout mode selected - %d seconds\r\n",timeout);
					ft_transfer_request(Suspend_Timeout_Mode_rqst,timeout);
				}
				else if (strcmp(input_str, "RT") == 0)
				{
					printf("\r\nResume-Timeout mode selected \r\n");
					ft_transfer_request(Resume_Timeout_Mode_rqst,0);
				}
				else if (strcmp(input_str, "SCT") == 0)
				{
					printf("\r\nSuspend-SaveContext mode selected \r\n");
					/*
					 * here the timeout time will be used by other node
					 */
					ft_transfer_request(Suspend_Savecontext_Mode_rqst,20);
					suspend_context_activated = 1;
				}
				else if (strcmp(input_str, "RCT") == 0)
				{
					printf("\r\nResume-Context mode selected \r\n");
					ft_contextsave_info *c_inf = (ft_contextsave_info*)gui_savecontext_ptr;
					if(c_inf->tx_mode == 1)
					{
						printf("\r\nResume-SaveContext mode [Bulkdata] selected \r\n");
						printf("Mem address passing 0x%lux of size %d \n",c_inf->bulkdata_mem_addr,c_inf->bulkdata_len);
						ft_get_bulk_data_input_buffer((uint8_t*)c_inf->bulkdata_mem_addr,c_inf->bulkdata_len);
					}
					else
					{
						printf("\r\nResume-SaveContext mode [File] selected \r\n");
					}
					ret_sts = ft_resume_context(gui_savecontext_ptr,savecontext_size);
					if(ret_sts == 0)
					{
						suspend_context_activated = 0;
						init_start = 1;
					}
					else
					{
						printf("Resume-SaveContext Error %d\n",ret_sts);

					}
				}
				else if (strcmp(input_str, "TT") == 0)
				{
					printf("\r\nTerminate transmission selected \r\n");
					ft_transfer_request(Terminate_Transmission_rqst,0);
					init_start = 0;
				}
				else if (strcmp(input_str, "FS") == 0)
				{
					display_ft_sts();

				}
				else if (strcmp(input_str, "FTD1") == 0)
				{
					printf("\r\nft_sus_res_debug_skip_all_sus_req selected \r\n");
					ft_sus_res_debug_skip_all_sus_req();
					sleep(2);
				}
				else if (strcmp(input_str, "FTD2") == 0)
				{
					printf("\r\ft_sus_res_debug_enable_all_sus_req selected \r\n");
					ft_sus_res_debug_enable_all_sus_req();
					sleep(2);

				}
				else if (strcmp(input_str, "FTD3") == 0)
				{
					printf("\r\ft_sus_res_debug_skip_all_sus_ack selected \r\n");
					ft_sus_res_debug_skip_all_sus_ack();
					sleep(2);

				}
				else if (strcmp(input_str, "FTD4") == 0)
				{
					printf("\r\ft_sus_res_debug_enable_all_sus_ack selected \r\n");
					ft_sus_res_debug_enable_all_sus_ack();
					sleep(2);

				}
				else if (strcmp(input_str, "FTD5") == 0)
				{
					printf("\r\ft_sus_res_debug_skip_all_res_req selected \r\n");
					ft_sus_res_debug_skip_all_res_req();
					sleep(2);

				}
				else if (strcmp(input_str, "FTD6") == 0)
				{
					printf("\r\ft_sus_res_debug_enable_all_res_req selected \r\n");
					ft_sus_res_debug_enable_all_res_req();
					sleep(2);

				}
				else if (strcmp(input_str, "FTD7") == 0)
				{
					printf("\r\ft_sus_res_debug_skip_all_res_ack selected \r\n");
					ft_sus_res_debug_skip_all_res_ack();
					sleep(2);

				}
				else if (strcmp(input_str, "FTD8") == 0)
				{
					printf("\r\ft_sus_res_debug_enable_all_res_ack selected \r\n");
					ft_sus_res_debug_enable_all_res_ack();
					sleep(2);

				}
				else if (strcmp(input_str, "FTD9") == 0)
				{
					printf("\r\ft_sus_res_debug_enable selected \r\n");
					ft_sus_res_debug_enable();
					sleep(2);

				}
				else if (strcmp(input_str, "FTD10") == 0)
				{
					printf("\r\ft_sus_res_debug_disable selected \r\n");
					ft_sus_res_debug_disable();
					sleep(2);

				}
				else
				{
					printf("\r\nInvalid suspend/resume selection \r\n");

				}
			}
			else
			{
				printf("No ongoing transmission..\n");
			}



		}
	}
}



void sender_app_regist(void)
{
	ft_register_sender_app(TM_SRC_PS, app1234_notificataion_api_upld);
}


uint8_t get_ft_running_sts(void)
{
	return file_tx_running;
}
