/**
 * @file obc_intf_ctrl_msg.h
 *
 * @brief This file contains function prototypes and data definitions that helps
 * to create a OBC interface control message
 */

#ifndef OBC_INTF_CTRL_MSG_H_
#define OBC_INTF_CTRL_MSG_H_

/* Includes ------------------------------------------------------------------*/
#include "exo_types.h"
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "gps_app.h"


/**
 *  @brief TC data frame macros for IPCC messages
 */


#define TFTP_START_TC_DATA_FRAME          58           	/* 4Byte - IP, 2Byte - Port, 1Byte- File transfer mode, 51Byte-File name */
#define TFTP_FILE_DEL_TC_DATA_FRAME       101           /* 1Byte - To indicate no of files to delete , 100Byte - For Files names */

/**
 *  @brief  CRRN Header Length macro
 */
#define ICM_HDR_LEN         (4U)

/**
 *  @brief  ICM Encoder Decoder API Execution status macros
 */
#define ICM_OK                   (0)      ///< Success return value
#define ICM_NULL_PTR             (-1)     ///< Null pointer return value
#define ICM_DEC_HDLR_UNASIGN     (-2)     ///< ICM Decoder handler not assigned
#define ICM_RSP_ENC_HDLR_UNASIGN (-3)     ///< ICM Response Encoder handler not assigned

/**
 *  @brief  CRRN Header field parameter macros
 */
#define CRRN_TYPE_POS       (26U)
#define CRRN_TYPE_MASK      (0x3U << CRRN_TYPE_POS)
#define CRRN_ID_POS         (16U)
#define CRRN_ID_MASK        (0x3FF << CRRN_ID_POS)
#define CRRN_DATA_LEN_POS   (0U)
#define CRRN_DATA_LEN_MASK  (0xFFFFU << CRRN_DATA_LEN_POS)

/**
 *  @brief  Payload Server Magic Keyword macro
 */
#define PS_MAGIC_VAL        (0x50534F4E)

/**
 * @brief structure that holds the interface message header
 *
 * Bit Name    Value Description
 * 31:28  Reserved
 * 27:26  CRRN Type
 * 25:16  CRRN ID
 * 15:0   Data Length Indicator
 */
typedef struct _icm_header
{
    int crrn_type;
    int crrn_id;
    int data_len;
}icm_header_s;

/*!
 *  @brief This enum holds the enumeration values of CRRN type
 */
typedef enum _icm_crrn_type
{
    CRRN_TYPE_CMD = 0,
    CRRN_TYPE_REQ,
    CRRN_TYPE_RSP,
    CRRN_TYPE_NTF,
    CRRN_TYPE_INVLD
}icm_crrn_type;

/*!
 *  @brief This enum holds the enumeration values of CRRN ID
 */
typedef enum _icm_crrn_id
{
    OBC_PS_PWR_OFF_CMD = 1,
    OBC_PS_PLD_HW_PWR_OFF_CMD = 2,
    OBC_PS_VM_PWR_OFF_CMD = 3,
    OBC_PS_VM_PWR_ON_CMD = 4,
    OBC_PS_TC_TM_MSG_CMD = 5,
    OBC_PS_FTP_MSG_CMD = 6,
    OBC_PS_KEEP_ALIVE_REQ = 7,
    OBC_PS_GS_PASS_NTF = 8,
    OBC_PS_STATE_UPDT_NTF = 9,
    OBC_PS_RADIO_PWR_ON_NTF = 10,
    OBC_PS_RADIO_PWR_OFF_NTF= 11,
    OBC_PS_OBC_KEEP_ALIVE_NTF= 12,
    OBC_PS_OBC_APP_ID_LIST_NTF= 13,
    OBC_PS_OBC_HW_ID_LIST_NTF= 14,
    OBC_PS_SSD_SEL_NTF= 15,
    OBC_PS_OBC_FIRM_UPDT_NTF= 16,
    OBC_PS_OBC_RST_RECV_UPDT_NTF= 17,
    OBC_PS_OBC_HW_ERR_RECOV_NTF= 18,
    OBC_PS_PS_APP_ID_LIST_REQ= 19,
    OBC_PS_PS_APP_PRI_LIST_REQ= 20,
    OBC_PS_PS_HW_ID_LIST_REQ= 21,
    OBC_PS_PS_HW_PRI_LIST_REQ= 22,
    OBC_PS_STAGED_TC_CMD = 23,
    OBC_PS_XBAND_CMD = 24,
    OBC_PS_UTC_TIME_CMD = 25,
    OBC_PS_MAX_ICD= 26,
	OBC_PS_TEMP_INFO= 27,
	OBC_PS_TIME_INFO= 28,
	OBC_PS_CHIP_INFO= 29,
	OBC_PS_EXT_MEM= 30,
	OBC_PS_GET_SBAND_FIRM_FILES=31,
	OBC_PS_SBAND_FIRM_TFTP_STRT=32,
	OBC_PS_DEL_SBAND_FIRM_FILE=33,
	OBC_PS_CURR_TIME_NTF=34,
	OBC_PS_GNSS_LOC_NTF=35,
	OBC_PS_GNSS_TLE_DATA_NTF=36,
	OBC_PS_GNSS_COMPUTE_TLE=37,
	

    PS_OBC_TRGT_POINT_REQ = 200,
    PS_OBC_GNSS_LOC_REQ,
    PS_OBC_GET_CURR_TIME_REQ,
    PS_OBC_KEEP_ALIVE_REQ,
    PS_OBC_SCHD_PS_PWR_ON_REQ,
    PS_OBC_OBC_APP_ID_LIST_REQ,
    PS_OBC_OBC_APP_QoS_PRI_LIST_REQ,
    PS_OBC_OBC_HW_ID_LIST_REQ,
    PS_OBC_RADIO_PWR_ON_REQ,
    PS_OBC_SSD_SEL_REQ,
    PS_OBC_RADIO_PWR_OFF_CMD,
    PS_OBC_RADIO_RX_ENBL_DSBL_CMD,
    PS_OBC_REG_ORBIT_TRIG_CMD,
    PS_OBC_REG_GRND_STN_PASS_NTF_CMD,
    PS_OBC_RADIO_TX_ENBL_DSBL_CMD,
    PS_OBC_STATE_UPDT_NTF,
    PS_OBC_PWR_ON_HNDSK_NTF,
    PS_OBC_KEEP_ALIVE_NTF,
    PS_OBC_RADIO_DATA_TX_CPLT_NTF,
    PS_OBC_SSD_ERR_NTF,
    PS_OBC_PS_FIRM_UPDT_NTF,
    PS_OBC_PLD_HW_FIRM_UPDT_NTF,
    PS_OBC_VM_FIRM_UPDT_NTF,
    PS_OBC_PS_RST_RECV_UPDT_NTF,
    PS_OBC_PS_APP_ID_LIST_NTF,
    PS_OBC_PS_HW_ID_LIST_NTF,
    PS_OBC_PS_HW_ERR_RECOV_NTF,
    PS_OBC_PS_SHUTDOWN_NTF,
    PS_OBC_PS_HW_PWR_ON_CMD,
    PS_OBC_PS_HW_PWR_OFF_CMD,
	PS_OBC_SBAND_FIRM_TFTP_CPLT,
	PS_OBC_GNSS_PRD_LOC_REQ,
	PS_OBC_GNSS_TLE_DATA_REQ,
	PS_OBC_GNSS_PRD_TLE_DATA_REQ,

    PS_OBC_MAX_ICD,

    OBC_PS_SIMU_PS_PWR_ON_CMD = 1000,

    ICM_CRRN_ID_MAX = 1023
}icm_crrn_id;

/*!
 *  @brief This structure holds the TC TM parameters information
 */
typedef struct _icm_tc_pld_info
{
    uint16 tc_id;
    uint8 src_id;
    uint8 dst_id;
    uint8 *tc_pld_buff;
    uint16 tc_pld_len;
}icm_tc_pld_info_s;

/*!
 *  @brief This structure holds the TC TM parameters information
 */
typedef struct _icm_tm_pld_info
{
    uint16 tm_id;
    uint8 src_id;
    uint8 dst_id;
    uint8 *tm_pld_buff;
    uint16 tm_pld_len;
}icm_tm_pld_info_s;

/*!
 *  @brief This structure holds the PS shutdown request parameters information
 */
typedef struct _icm_ps_pwr_off_info
{
    uint8 shut_tmr_min;
    uint8 shut_tmr_sec;
    uint16 shut_tmr_ms;
    uint8 shut_purpose;
}icm_ps_pwr_off_info_s;

/*!
 *  @brief This structure holds the ground station pass notification information
 */
typedef struct _icm_gs_pass_info
{
    uint8 rem_tmr_min;
    uint8 rem_tmr_sec;
    uint16 rem_tmr_ms;
    uint8 radio_comm_intf_type;
}icm_gs_pass_info_s;

/*!
 *  @brief This structure holds the payload hardware shutdown parameter information
 */
typedef struct _icm_pld_hw_pwr_off_info
{
    uint16 pld_hw_id;
    uint8 shut_tmr_min;
    uint8 shut_tmr_sec;
    uint16 shut_tmr_ms;
    uint8 shut_purpose;
}icm_pld_hw_pwr_off_info_s;

/*!
 *  @brief This structure holds the payload Virtual Machine shutdown parameter information
 */
typedef struct _icm_vm_pwr_off_info
{
    uint16 vm_id;
    uint8 shut_tmr_min;
    uint8 shut_tmr_sec;
    uint16 shut_tmr_ms;
    uint8 shut_purpose;
}icm_vm_pwr_off_info_s;

/*!
 *  @brief This structure holds the Target Pointing request parameter information
 */
typedef struct _icm_trgt_pt_req
{
    float lat;
    float longit;
    float alt;
    uint8 pld_hw_id;
    uint8 act_tmr_min;
    uint8 act_tmr_sec;
    uint16 act_tmr_ms;
}icm_trgt_pt_req_s;

/*!
 *  @brief This structure holds the parameter information for orbit trigger
 *  registration
 */
typedef struct _icm_reg_orbt_trig
{
    float lat;
    float longit;
    float alt;
    uint8 pld_hw_id;
    uint8 alrt_tmr_min;
    uint8 alrt_tmr_sec;
    uint16 alrt_tmr_ms;
}icm_reg_orbt_trig_s;

/*!
 *  @brief This structure holds the parameter information for ground station
 *  pass notification
 */
typedef struct _icm_reg_grnd_stn_ps_ntf
{
    uint8 pld_hw_id;
    uint8 grnd_stn_id;
    uint8 alrt_tmr_min;
    uint8 alrt_tmr_sec;
    uint16 alrt_tmr_ms;
    uint8 purpose;
}icm_reg_grnd_stn_ps_ntf_s;

/*!
 *  @brief This structure holds the location information response
 */
typedef struct _icm_gnss_loc_info
{
    uint8 status;
    float lat;
    float longit;
    float alt;
}icm_gnss_loc_info_s;

/*!
 *  @brief This structure holds the SSD error information
 */
typedef struct _ssd_err_info
{
    uint8 err_type;
    uint8 sect_id;
}s_ssd_err_info;

typedef struct
{
    uint8 reset_recovery_state;
    uint8 reset_type;
}__attribute__((__packed__))obc_rst_recv_updt;

typedef struct
{
    uint8 shutdown_timer_minutes;
    uint8 shutdown_timer_seconds;
    uint16 shutdown_timer_milliseconds;
}__attribute__((__packed__))ps_shutdown_ntf;

typedef struct
{
    uint8 timer_seconds;
    uint8 timer_minutes;
    uint8 timer_hours;
    uint8 timer_days;
}__attribute__((__packed__))schd_ps_pwr_on_req;

typedef struct
{
    uint8 pwr_on_rsp;
    uint8 pwr_on_retry_req_dur;
}__attribute__((__packed__))obc_radio_pwr_on;

typedef struct
{
    uint8 radio_mod_id;
    uint8 radio_rx_enable_disable;
}__attribute__((__packed__))radio_rx_enbl_dsbl;

typedef struct
{
    uint8 min;
    uint8 hour;
    uint8 mday;
    uint8 mon;
    uint32 year;
    uint8 wday;
    uint16 yday;
    uint8 isday;
}__attribute__((__packed__))obc_get_curr_time;

typedef struct
{
    uint8_t hour;
    uint8_t min;
    uint8_t sec;
    uint8_t date;
    uint8_t month;
    uint16_t year;
    uint8_t reserved;
}__attribute__((__packed__))obc_ps_rtc_time_s;

typedef struct
{
	uint16_t year;
	uint8_t month;
	uint8_t date;
	uint8_t hour;
	uint8_t min;
	uint8_t sec;
	uint8_t reserved;
}__attribute__((__packed__))obc_ps_utc_time_s;

/*!
 *  @brief This enum holds the enumeration values of types of SSD error
 */
typedef enum _ssd_err_type
{
    SSD_ACC_FAIL,
    BAD_SECTOR,
    SSD_MAX_ERR
}e_ssd_err_type;

/*!
 *  @brief This enum holds the enumeration values of PS Firmware update status
 */
typedef enum _ps_fm_updt_sts
{
    PS_FM_UPDT_STRT,
    PS_FM_UPDT_CPLT,
    PS_INVLD_FM_STS
}e_ps_fm_updt_sts;

/*!
 *  @brief This enum holds the enumeration values of Payload Hardware Firmware update status
 */
typedef enum _pld_hw_fm_updt_sts
{
    PLD_HW_FM_UPDT_STRT,
    PLD_HW_FM_UPDT_CPLT,
    PLD_HW_INVLD_FM_STS
}e_pld_hw_fm_updt_sts;

/*!
 *  @brief This enum holds the enumeration values of Payload Virtual Machine Firmware update status
 */
typedef enum _vm_fm_updt_sts
{
    VM_FM_UPDT_STRT,
    VM_FM_UPDT_CPLT,
    VM_INVLD_FM_STS
}e_vm_fm_updt_sts;

/*!
 *  @brief This enum holds the enumeration values of status of reset recovery
 */
typedef enum _ps_rcv_ste
{
    PS_RST_RCV_STRT,
    PS_RST_RCV_CPLT,
    PS_INVLD_RST_RCV_STS
}e_ps_rcv_ste;

/*!
 *  @brief This enum holds the enumeration values of Types of Reset
 */
typedef enum _ps_rst_type
{
    PS_SOFT_RST,
    PS_WDT_RST,
    PS_MAX_RST
}e_ps_rst_type;

/*!
 *  @brief This enum holds the enumeration values of Radio Module Interface
 */
typedef enum _icm_radio_comm_type
{
    ICM_RD_COMM_SBAND = 0,
    ICM_RD_COMM_XBAND,
    ICM_RD_COMM_INVDL
}icm_radio_comm_type;

/*!
 *  @brief This enum holds the enumeration values of power states of compute nodes
 */
typedef enum _icm_node_ste_type
{
    ICM_NODE_STE_ACT = 0,
    ICM_NODE_STE_PWR_SAVE,
    ICM_NODE_STE_INVLD
}icm_node_ste_type;

/*!
 *  @brief This enum holds the enumeration values of Shutdown purpose
 */
typedef enum _icm_shut_purpose
{
    ICM_SP_SYS_SHUT = 0,
    ICM_SP_LOW_BTRY,
    ICM_SP_RST_RCVRY,
    ICM_SP_OVR_TEMP,
    ICM_SP_INVLD
}icm_shut_purpose;

#if 0
/*!
 *  @brief This enum holds the enumeration values of Payload HW ID
 */
typedef enum _icm_pld_hw_id
{
    ICM_PLD_HW_ID_AICRAFT = 0,
    ICM_PLD_HW_ID_NETRA,
    ICM_PLD_HW_ID_TRANSCELESTIAL,
    ICM_PLD_HW_ID_ZES,
    ICM_PLD_HW_ID_SAYAR_LABS,
    ICM_PLD_HW_ID_INVLD
}icm_pld_hw_id;
#endif

/*********************************************************************************/
/************** Command, Request, Notification Encoder Functions *****************/
/*********************************************************************************/

/*!
 * @brief This API encodes the Interface Control Messsage for
 * PS power off command
 *
 * @param[in] ppoi     : Structure instance of icm_ps_pwr_off_info_s
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_pwr_off_cmd_enc (uint8 **data, uint16* len, icm_ps_pwr_off_info_s *ppoi);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * PS keep alive request from OBC
 *
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_keep_alive_req_enc (uint8 **data, uint16* len);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * PS APP ID list request from OBC
 *
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_ps_app_id_list_req_enc (uint8 **data, uint16* len);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * Ground station pass notification request
 *
 * @param[in] gpi      : Structure instance of icm_gs_pass_info_s
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_ps_app_id_list_req_enc (uint8 **data, uint16* len);

int8 obc_ps_ps_app_pri_list_req_enc(uint8 **data, uint16* len);

int8 obc_ps_ps_hw_id_list_req_enc(uint8 **data, uint16* len);

int8 obc_ps_ps_hw_pri_list_req_enc(uint8 **data, uint16* len);

int8 ps_obc_obc_app_id_list_rsp_enc(uint8** data, uint16* len,uint8* buff_data,uint8 buf_len);

int8 ps_obc_obc_hw_id_list_rsp_enc(uint8** data, uint16* len,uint8* buff_data,uint8 buf_len);

int8 ps_obc_obc_app_qos_pri_list_rsp_enc(uint8** data, uint16* len,uint8* buff_data,uint8 buf_len);

int8 obc_ps_gs_pass_ntf_enc (uint8 **data, uint16* len, icm_gs_pass_info_s *gpi);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * OBC state update notification
 *
 * @param[in] ste_info : Enumeration value of power states of compute nodes
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_state_updt_ntf (uint8 **data, uint16* len, uint8 ste_info);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * Radio power ON notification from OBC to PS
 *
 * @param[in] radio_id : Enumeration value of Radio module ID
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_radio_pwr_on_ntf_enc (uint8 **data, uint16* len, uint8 radio_id);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * Radio power OFF notification from OBC to PS
 *
 * @param[in] radio_id : Enumeration value of Radio module ID
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_radio_pwr_off_ntf_enc (uint8 **data, uint16* len, uint8 radio_id);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * OBC alive notification to PS
 *
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_obc_keep_alive_ntf_enc (uint8 **data, uint16* len);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * OBC notification of APP ID list
 *
 * @param[in] app_id_info_buff  : Buffer pointer that points to APP ID information
 * @param[in] buf_len  : Length of the buffer
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_obc_app_id_list_ntf_enc (uint8 **data, uint16* len, uint8* app_id_info_buff, uint32 buf_len);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * OBC notification of HW ID list
 *
 * @param[in] hw_id_info_buff  : Buffer pointer that points to HW ID information
 * @param[in] buf_len  : Length of the buffer
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_obc_hw_id_list_ntf_enc (uint8 **data, uint16* len, uint8* hw_id_info_buff, uint32 buf_len);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * Payload Hardware power off command
 *
 * @param[in] phw_poi  : Structure instance of icm_pld_hw_pwr_off_info_s
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_pld_hw_pwr_off_cmd (uint8 **data, uint16* len, icm_pld_hw_pwr_off_info_s *phw_poi);

int8 obc_ps_obc_rst_recv_updt_ntf_enc (uint8 **data, uint16* len, obc_rst_recv_updt* rru);

int8 obc_ps_obc_frim_updt_ntf_enc (uint8 **data, uint16* len, uint8 frim_updt_state);


/*********************************************************************************/
/************** Command, Request, Notification Decoder Functions *****************/
/*********************************************************************************/

/*!
 * @brief This API has the default handling for messages for which decoder
 * are not assigned
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 icm_default_data_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the CRRN ID when response is received
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_icm_crrn_id_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API maps the ICM CRRN decoder function pointers
 * to respective CRRN ID
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 icm_data_dec_hdlr_map(void);

/*!
 * @brief This API decodes the Interface Control Message of
 * Target pointing request from PS
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_trgt_pt_req_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS keep alive request to OBC
 */
int8 ps_obc_keep_alive_req_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * registration request for alert when specified orbit is reached
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_reg_orbit_trig_cmd_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * registration request for ground station pass alert
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_reg_grnd_stn_pass_ntf_cmd_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * Radio module TX enable disable control command
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_radio_tx_enbl_dsbl_cmd_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS node state update notification
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_ste_updt_ntf_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS power on handshake notification
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_pwr_on_hndske_ntf_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS keep alive notification
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_keep_alive_ntf_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS radio data transmission complete notification
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_radio_data_tx_cplt_ntf_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS notification of SSD error
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_ssd_err_ntf_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS notification PS firmware update status
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_ps_firm_updt_ntf_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS notification Payload hardware firmware update status
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_pld_hw_firm_updt_ntf_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS notification of Payload Virtual Machine firmware update status
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_vm_firm_updt_ntf_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS notification of PS reset recovery notification
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_ps_rst_rcv_ntf_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS notification of PS APP ID list information
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_ps_app_id_list_ntf_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS notification of PS HW ID list information
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_ps_hw_id_list_ntf_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS hardware power on command
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_ps_hw_pwr_on_cmd_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS hardware power off command
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_ps_hw_pwr_off_cmd_dec(const uint8 *data, uint16 len);

int8 ps_obc_radio_rx_enbl_dsbl_cmd_dec(const uint8 *data, uint16 len);

int8 ps_obc_radio_pwr_off_cmd_dec(const uint8 *data, uint16 len);

int8 ps_obc_radio_pwr_on_req_dec(const uint8 *data, uint16 len);

int8 ps_obc_obc_hw_id_req_dec(const uint8 *data, uint16 len);

int8 ps_obc_obc_app_id_list_req_dec(const uint8 *data, uint16 len);

int8 ps_obc_obc_app_qos_pri_list_req_dec(const uint8 *data, uint16 len);

int8 obc_ps_obc_hw_err_recov_ntf_rsp_dec(const uint8 *data, uint16 len);

int8 obc_ps_ps_app_id_list_rsp_dec(const uint8 *data, uint16 len);

int8 obc_ps_ps_app_pri_list_rsp_dec(const uint8 *data, uint16 len);

int8 obc_ps_ps_hw_id_list_rsp_dec(const uint8 *data, uint16 len);

int8 obc_ps_ps_hw_pri_list_rsp_dec(const uint8 *data, uint16 len);

int8 ps_obc_ps_shutdown_ntf_dec(const uint8 *data, uint16 len);

int8 ps_obc_ps_hw_err_recov_ntf_dec(const uint8 *data, uint16 len);

int8 ps_obc_schd_ps_pwr_on_req_dec(const uint8 *data, uint16 len);

int8 ps_obc_sband_firm_tftp_cplt_ntf_dec(const uint8 *data, uint16 len);

int8 ps_obc_gnss_loc_req_dec(const uint8 *data, uint16 len);

int8 ps_obc_get_curr_time_req_dec(const uint8 *data, uint16 len);

int8 ps_obc_gnss_prd_loc_req_dec(const uint8 *data, uint16 len);

int8 ps_obc_gnss_tle_data_req_dec(const uint8 *data, uint16 len);

int8 ps_obc_gnss_prd_tle_data_req_dec(const uint8 *data, uint16 len);


/*!
 * @brief This API encodes the Interface Control Messsage for
 * payload VM power off command
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_vm_pwr_off_cmd (uint8 **data, uint16* len, icm_vm_pwr_off_info_s *poi);
/*!
 * @brief This API encodes the Interface Control Messsage for
 * payload VM power off command
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_vm_pwr_on_cmd_enc (uint8 **data, uint16* len, uint16 ps_vm_id);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * TC TM Message from OBC to PS
 *
 * @param[out] data     : Data buffer containing encoded CRRN data
 * @param[out] len      : Length of the data buffer
 * @param[in] tc_tm_data_ptr:  Pointer containing TC TM data buffer address
 * @param[in] tc_tm_data_len:  Length of TC TM data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_tc_tm_msg_cmd_enc (uint8 **data, uint16* len, \
        icm_tc_pld_info_s *tc_pld_info);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * Simulation of event OBC Powering ON PS
 */
int8 obc_ps_simu_ps_pwr_on_cmd_enc (uint8 **data, uint16* len);
int8 obc_ps_get_temp_info_enc(uint8 **data, uint16* len);
int8 obc_ps_get_time_info_enc(uint8 **data, uint16* len);
int8 obc_ps_get_chip_info_enc(uint8 **data, uint16* len);
int8 obc_ps_get_ext_mem_enc(uint8 **data, uint16* len);

/*!
 * @brief This API encodes the Interface Control Messsage for
 * IQS Firmware update
 * 1.To start file transfer to IQS from PS
 *
 */
int8 obc_ps_sband_firm_tftp_strt(uint8 **data, uint16* len, uint8* pld_data);
int8 obc_ps_get_sband_firm_files(uint8 **data, uint16* len);
int8 obc_ps_del_sband_firm_file(uint8 **data, uint16* len, uint8* pld_data);

/*********************************************************************************/
/************************* Response Decoder Functions ****************************/
/*********************************************************************************/

/*!
 * @brief This API decodes the Interface Control Message of
 * PS shutdown response
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_pwr_off_rsp_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS Payload hardware power off response
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_pld_hw_pwr_off_rsp_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS Payload Virtual Machine power off response
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_vm_pwr_off_rsp_dec(const uint8 *data, uint16 len);
int8 obc_ps_vm_pwr_on_rsp_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS Payload Virtual Machine power off response
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_vm_pwr_on_rsp_dec(const uint8 *data, uint16 len);


/*!
 * @brief This API decodes the Interface Control Message of
 * TC_TM response from PS
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_tc_tm_msg_rsp_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS keep alive response
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_keep_alive_rsp_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS response for ground station pass alert
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_grnd_stn_ps_rsp_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS response for Radio power on notification
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_radio_pwr_on_ntf_rsp_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API decodes the Interface Control Message of
 * PS response for Radio power off notification
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_radio_pwr_off_ntf_rsp_dec(const uint8 *data, uint16 len);

/*!
 * @brief This API handles the decoding of Interface control message of
 * OBC alive notification alert to PS
 *
 * @param[in] data     : Data buffer containing encoded CRRN data
 * @param[in] len      : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 obc_ps_obc_keep_alive_ntf_dec(const uint8 *data, uint16 len);

int8 obc_ps_obc_frim_updt_ntf_rsp_dec(const uint8 *data, uint16 len);

int8 obc_ps_obc_rst_recv_updt_ntf_rsp_dec(const uint8 *data, uint16 len);

/*********************************************************************************/
/************************* Response Encoder Functions ****************************/
/*********************************************************************************/

/*!
 * @brief This API encodes the default response for Interface Control Messsage
 * for which response encoder are not assigned.
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 icm_default_rsp_enc_hdlr(void);

/*!
 * @brief This API encodes the response for Interface Control Messsage of
 * Target pointing request
 *
 * @param[in] rsp_sts  : Contains the configuration response status
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_trgt_pt_rsp_enc(uint8** data, uint16* len, uint8 rsp_sts);

/*!
 * @brief This API encodes the response for Interface Control Messsage of
 * GNNS location sharing request from PS
 *
 * @param[in] rsp_sts  : Contains the configuration response status
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_gnss_loc_rsp_enc(uint8** data, uint16* len, gps_loc_info *gli);

/*!
 * @brief This API encodes the response for Interface Control Messsage of
 * PS keep alive request
 *
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_keep_alive_rsp_enc(uint8** data, uint16* len);

/*!
 * @brief This API encodes the response for Interface Control Messsage of
 * alert request for specified orbit from PS
 *
 * @param[in] rsp_sts  : Contains the configuration response status
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_reg_orbit_trig_rsp_enc(uint8** data, uint16* len, uint8 reg_rsp);

/*!
 * @brief This API encodes the response for Interface Control Messsage of
 * ground station alert request from PS
 *
 * @param[in] rsp_sts  : Contains the configuration response status
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_reg_grnd_stn_ps_ntf_rsp_enc(uint8** data, uint16* len, uint8 reg_rsp);

/*!
 * @brief This API encodes the response for Interface Control Messsage of
 * power ON handshake notification from PS
 *
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_pwr_on_hndske_ntf_rsp_enc(uint8** data, uint16* len);

/*!
 * @brief This API encodes the response for Interface Control Messsage of
 * radio data transmission complete notification from PS
 *
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 * @param[in] rsp     : notification response value
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_radio_data_tx_cplt_ntf_rsp_enc(uint8** data, uint16* len, uint8 rsp);

/*!
 * @brief This API encodes the response for Interface Control Messsage of
 * SSD error notification from PS
 *
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 * @param[in] rsp     : notification response value
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_ssd_err_ntf_rsp_enc(uint8** data, uint16* len, uint8 rsp);

/*!
 * @brief This API encodes the response for Interface Control Messsage of
 * PS hardware power on request from PS
 *
 * @param[in] rsp_sts  : Contains the configuration response status
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_ps_hw_pwr_on_rsp_enc(uint8** data, uint16* len, uint8 rsp, uint8 retry_tmr);

/*!
 * @brief This API encodes the response for Interface Control Messsage of
 * PS hardware power off request from PS
 *
 * @param[in] rsp_sts  : Contains the configuration response status
 * @param[out] data    : Data buffer containing encoded CRRN data
 * @param[out] len     : Length of the data buffer
 *
 * @return Result of API execution status
 * @retval Zero -> Success
 * @retval Negative -> Error.
 */
int8 ps_obc_ps_hw_pwr_off_rsp_enc(uint8** data, uint16* len, uint8 rsp);

int8 ps_obc_schd_ps_pwr_on_rsp_enc(uint8** data, uint16* len,uint8 schld_res);

int8 ps_obc_radio_pwr_off_rsp_enc(uint8** data, uint16* len,uint8 pwr_off_rsp);

int8 ps_obc_get_curr_time_rsp_enc(uint8** data, uint16* len, uint32_t time_epoch);

int8 ps_obc_radio_pwr_on_rsp_enc(uint8** data, uint16* len,obc_radio_pwr_on* rpo);

int8 ps_obc_ps_hw_err_recov_ntf_rsp_enc(uint8** data, uint16* len, uint8 rsp);

int8 ps_obc_ps_shutdown_ntf_rsp_enc(uint8** data, uint16* len, uint8 rsp_typ);

int8 ps_obc_radio_rx_enbl_dsbl_rsp_enc(uint8** data, uint16* len,uint8 rx_enbl_dsbl_rsp);

int8 ps_obc_gnss_prd_loc_rsp_enc(uint8** data, uint16* len, uint8 sts);
int8 ps_obc_gnss_tle_data_rsp_enc(uint8** data, uint16* len, gps_tle_data *tle);
int8 ps_obc_gnss_prd_tle_data_rsp_enc(uint8** data, uint16* len, uint8 sts);

int8 obc_ps_obc_hw_err_recov_ntf_enc (uint8 **data, uint16* len, uint16 hw_id_rcvd);
int8 obc_ps_ftp_msg_cmd_enc (uint8 **data, uint16* len, icm_tc_pld_info_s *tc_pld_info);
int8 obc_ps_ftp_msg_rsp_dec(const uint8 *data, uint16 len);
int8 obc_ps_staged_tc_cmd_enc(uint8 **data, uint16* len, uint32 staged_tc_id);
int8 obc_ps_staged_tc_rsp_dec(const uint8 *data, uint16 len);
int8 obc_ps_xband_cmd_enc(uint8 **data, uint16* len, uint16 data_size, uint8 *data_ptr);
int8 obc_ps_xband_rsp_dec(const uint8 *data, uint16 len);
int8 obc_ps_utc_time_cfg_rsp_dec(const uint8 *data, uint16 len);
int8 obc_ps_get_temp_info_rsp_dec(const uint8 *data, uint16 len);
int8 obc_ps_get_time_info_rsp_dec(const uint8 *data, uint16 len);
int8 obc_ps_get_chip_info_rsp_dec(const uint8 *data, uint16 len);
int8 obc_ps_get_ext_mem_rsp_dec(const uint8 *data, uint16 len);
int8 obc_ps_utc_time_cfg_cmd_enc(uint8 **data, uint16* len, uint16 data_size, uint8 *data_ptr);

int8 obc_ps_curr_time_ntf_enc(uint8 **data, uint16* len, uint8_t* pld_data);
int8 obc_ps_gnss_tle_data_ntf_enc(uint8 **data, uint16* len, uint8_t* pld_data);
int8 obc_ps_gnss_loc_ntf_enc(uint8 **data, uint16* len, uint8_t* pld_data);
int8 obc_ps_gnss_compute_tle_enc(uint8 **data, uint16* len, uint8_t* pld_data);



/*This API decodes the response for file transfer initiation
 * whether successs or failure. Also decode the failure code send by PS
 */

int8 obc_ps_sband_firm_tftp_strt_res_dec(const uint8 *data, uint16 len);


/*This API decodes the list of firmware available firmware file sent by PS*/

int8 obc_ps_get_sband_firm_files_res_dec(const uint8 *data, uint16 len);

/*This API decodes the response for deletion of firmware files*/

int8 obc_ps_del_sband_firm_file_res_dec(const uint8 *data, uint16 len);

int8 obc_ps_curr_time_ntf_rsp_dec(const uint8 *data, uint16 len);

int8 obc_ps_gnss_loc_ntf_rsp_dec(const uint8 *data, uint16 len);

int8 obc_ps_gnss_tle_data_ntf_rsp_dec(const uint8 *data, uint16 len);
int8 obc_ps_gnss_compute_tle_rsp_dec(const uint8 *data, uint16 len);

#endif /*OBC_INTF_CTRL_MSG_H_*/
