/**
 * @file ftci.h
 *
 * @brief This file contains function prototypes and data definitions that
 * helps to preapre FTCI frame and transmit FTCI frame
 *
 * @copyright Copyright 2023 Antaris, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

#ifndef SRC_TX_REQUEST_PREPARE_H_
#define SRC_TX_REQUEST_PREPARE_H_
#include "stdio.h"
#include "string.h"
#include <stdlib.h>

#include "data_type.h"
#include "message_frame_def.h"
#include "tc_tm_sample.h"
#include "upload_def.h"

/******************************************************************************/
/*                    Declaration of exported variables                       */
/******************************************************************************/

extern s_transfer_info tx_info;
extern uint8_t session_id;
extern s_string_info dest_path_name_info;
extern s_string_info ftci_frame_info;

/******************************************************************************/
/*               Declaration of exported function prototypes                  */
/******************************************************************************/

/**
 * @brief This function used to prepare ftci frame based on two operation mode such as
 * file and data mode
 *
 *
 * @param[in]  void  : none
 *
 * @return none
 * @retval void : none
 *
 */
void ftci(void);

/**
 * @brief This function used to determine number of fields required to accomadate the file/data
 * size
 * For example,  3 bytes is required to encode the file size 3760 in FTCI frame. so this function
 * will find the no of fields required to hold file size in FTCI frame.
 *
 *
 * @param[in]  size  : input file/data size
 *
 * @return field length for size
 * @retval 0 => 1 to 255,   1 => 256 to 4095,  2 => 4097 to 65535 , 3 => 65536 - 1048575
 */
uint8_t ftci_determine_size_field_holding_len(uint32_t size);

/**
 * @brief This function used to initialize ftci
 *
 *
 * @param[in]  void  : none
 *
 * @return none
 * @retval void : none
 *
 */
void ftci_init(void);

/**
 * @brief This function used to encode FTCI frame with required inputs
 * File name, file size, MTU size, input data buffer to send, data size
 * which will be encoded in frame
 *
 *
 * @param[in]  void  : none
 *
 * @return none
 * @retval void : none
 *
 */
void ftci_encode_ftciframe(void);

#endif /*SRC_TX_REQUEST_PREPARE_H_ */
