/**
 * @file comms_uhf_main.h
 *
 * @brief This file has the control blocks, enumeration and function prototypes of SDR control layer of S-Band module
 *
 * @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 COMMS_UHF_UHF_MAIN_H
#define COMMS_UHF_UHF_MAIN_H

#include "exo_osal.h"
#include "exo_ral_cmn.h"
#include "exo_ral_mem_management.h"
#include "exo_types.h"


typedef float f32;
typedef double f64;

#ifdef __cplusplus
extern "C" {
#endif

#define UHF_5MIN_TIMER 5*60*1000
#define PERI_UHF_HK_SYNC_ID 	32
///COMMS error codes
#define  COMMS_UHF_UHF_IPC_READ_ERROR                       -20
#define  COMMS_UHF_UHF_IPC_WRITE_ERROR                      -21
#define  COMMS_UHF_UHF_INVALID_COMMAND                      -10
#define  COMMS_UHF_UHF_NULL_PTR                              -1
#define  COMMS_UHF_OPERATION_SUCCESS                     1
#define  COMMS_UHF_IPC_OK                                2

#define UHF_ADC_NUM_CHANNELS 10
#define UHF_MAX_PLD      251
#define UHF_CMD_REB_TIMER 300
#define UHF_CMD_TIM_OUT_TIMER 1000
#define UHF_CMD_RESEND_TIMER 2000
/**
  * @brief  comms State in enum definition
  */
typedef enum
{
     COMMS_UHF_INIT_STATE,       ///< Comms module initializes from reset state
     COMMS_UHF_BOOT_STATE,        ///< comms booting state
     COMMS_UHF_DFU_STATE,         ///< device firmware will be updated during this state
     COMMS_UHF_CFG_STATE,         ///< comms configuration state
     COMMS_UHF_CALIB_STATE,       ///< comms calibration state
     COMMS_UHF_SLEEP_IDLE_STATE,  ///< comms initialize sleep and idle state
     COMMS_UHF_ACTIVE_STATE,      ///< comms active state
     COMMS_UHF_SAFE_MODE_STATE,   ///< comms initialize safe mode state
     COMMS_UHF_ERROR_STATE,       ///< comms error state
     COMMS_UHF_BYPASS_STATE,      ///< comms bypass state
     COMMS_UHF_MAX_NUM_STATE
}e_comms_uhf_state;

//socket details
typedef struct comms_uhf_sock_info
{
    char ip_addr[16];
    char port_num[5];
}s_comms_uhf_sock_info;

/**
  * @brief comms CSP TM Structure definition
  */
typedef struct  __attribute__((packed))
{
    uint16_t mtu;              //!< Maximum Transmission Unit of interface
    uint16_t reserved;
    uint32_t tx;               //!< Successfully transmitted packets
    uint32_t rx;               //!< Successfully received packets
    uint32_t tx_error;         //!< Transmit errors (packets)
    uint32_t rx_error;         //!< Receive errors, e.g. too large message
    uint32_t drop;             //!< Dropped packets
    uint32_t autherr;          //!< Authentication errors (packets)
    uint32_t frame;            //!< Frame format errors (packets)
    uint32_t txbytes;          //!< Transmitted bytes
    uint32_t rxbytes;          //!< Received bytes
}s_comms_uhf_csp_tm_details;

typedef struct  __attribute__((packed))
{
    s_comms_uhf_csp_tm_details csp_int[3];
    uint32_t csp_err_nomem	;             /**< Not enough memory */
    uint32_t csp_err_inval	;             /**< Invalid argument */
    uint32_t csp_err_timedout	;             /**< Operation timed out */
    uint32_t csp_err_used	;             /**< Resource already in use */
    uint32_t csp_err_notsup	;             /**< Operation not supported */
    uint32_t csp_err_busy	;             /**< Device or resource busy */
    uint32_t csp_err_already	;             /**< Connection already in progress */
    uint32_t csp_err_reset	;             /**< Connection reset */
    uint32_t csp_err_nobufs	;             /**< No more buffer space available */
    uint32_t csp_err_tx		;             /**< Transmission failed */
    uint32_t csp_err_driver	;             /**< Error in driver layer */
    uint32_t csp_err_again	;             /**< Resource temporarily unavailable */
    uint32_t csp_err_hmac	;             /**< HMAC failed */
    uint32_t csp_err_xtea	;             /**< XTEA failed */
    uint32_t csp_err_crc32	;             /**< CRC32 failed */
    uint32_t csp_err_sfp	;             /**< SFP protocol error or inconsistency */
}s_comms_uhf_csp_tm;

typedef struct  __attribute__((packed))
{
    uint8_t chan_num ;
    uint8_t mod_type ;
    uint8_t sync_mode ;
    uint8_t enb_dc_filter ;
    uint8_t fec_enb ;
    uint8_t preamble_num ;
    uint8_t manchester_enable;
    uint8_t rsvd;
    float   base_freq;
    float   if_freq;
    float   chan_spacing ;
    float   freq_ofst ;
    float   data_rate ;
    float   channel_bw ;
    float   freq_dev;
} s_uhf_rf_tx_cfg;

typedef struct  __attribute__((packed))
{
    uint8_t chan_num ;
    uint8_t mod_type ;
    uint8_t sync_mode ;
    uint8_t enb_dc_filter ;
    uint8_t fec_enb ;
    uint8_t preamble_num ;
    uint8_t manchester_enable;
    uint8_t rx_attenuation;
    float   base_freq;
    float   if_freq;
    float   chan_spacing ;
    float   freq_ofst ;
    float   data_rate ;
    float   channel_bw ;
    float   freq_dev;
    float rx_sync_time_out ;
} s_uhf_rf_rx_cfg;

typedef struct  __attribute__((packed))
{
     uint16_t demod_sync_word ;
     uint8_t max_pkt_len ;
     uint8_t whitening_enb ;
     uint8_t pkt_fmt ;
     uint8_t crc_enb ;
     uint8_t pkt_len_cfg ;
     uint8_t device_addr;
}
s_uhf_rf_tx_pkt_cfg;

typedef struct  __attribute__((packed))
{
     uint16_t demod_sync_word ;
     uint8_t max_pkt_len ;
     uint8_t whitening_enb ;
     uint8_t pkt_fmt ;
     uint8_t crc_enb ;
     uint8_t pkt_len_cfg ;
     uint8_t device_addr;
}
s_uhf_rf_rx_pkt_cfg;

typedef struct  __attribute__((packed))
{
     uint8_t max_dvga_gain ;
     uint8_t max_lna_gain ;
     uint8_t lna_sel ;
     uint8_t filter_len ;
     uint8_t power_table_sel;
     uint8_t rf_output_power ;
}
s_uhf_rf_pwr_cfg;

typedef struct  __attribute__((packed))
{
    uint32_t uptime ;
    uint32_t uart0_rx_count ;
    uint32_t uart1_rx_count ;
    uint8_t rx_mode ;
    uint8_t tx_mode ;
}
s_uhf_rf_base_tm;

typedef struct  __attribute__((packed))
{
    uint32_t uptime ;
    uint32_t uart0_rx_count ;
    uint32_t uart1_rx_count ;
    uint8_t rx_mode ;
    uint8_t tx_mode ;
    int16_t adc[10] ;
    int8_t last_rssi ;
    uint8_t last_lqi;
    int8_t last_freqest ;
    uint32_t pkt_sent ;
    uint32_t cs_count ;
    uint32_t pkt_good ;
    uint32_t pkt_rejected_checksum ;
    uint32_t pkt_rejected_reserved ;
    uint32_t pkt_rejected_other ;
    uint32_t reserved0 ;
    //uint32_t reserved1 ;
    uint32_t custom0;
    uint32_t custom1;
}
s_uhf_rf_full_tm;

typedef struct  __attribute__((packed))
{
	uint8_t gs_first_contact;
	uint8_t otsu_first_contact;
	uint8_t beacon_tx_timeout;
	uint8_t beacon_tx_interval;
	uint32_t beacon_mode_timeout;
	uint8_t beacon_payload_len;
	uint8_t tx_win_timeout;
	uint8_t rx_win_timeout;
	uint32_t last_uptime;
	uint8_t fw_aes_key[32];

}s_uhf_general_param_global;

/**
  * @brief  comms event in enum definition
  */
typedef enum
{
    COMMS_UHF_BOOT_REQ,             ///< comms boot request
    COMMS_UHF_BOOT_STS,             ///< comms boot status
    COMMS_UHF_RESET_REQ,            ///< comms reset request
    COMMS_UHF_RESET_RSP,            ///< comms reset response
    COMMS_UHF_RESET_NOTF,           ///< comms reset notification
    COMMS_UHF_ACTIVE_REQ,           ///< comms active request
    COMMS_UHF_ACTIVE_RSP,           ///< comms active response
    COMMS_UHF_ACTIVE_NOTF,          ///< comms active notification
    COMMS_UHF_SLEEP_REQ,            ///< comms sleep request
    COMMS_UHF_SLEEP_RSP,            ///< comms sleep response
    COMMS_UHF_SLEEP_NOTF,           ///< comms sleep notification
    COMMS_UHF_DFU_REQ,              ///< comms device firmware request
    COMMS_UHF_DFU_RSP,              ///< comms device firmware response
    COMMS_UHF_DFU_NOTF,             ///< comms device firmware notification
    COMMS_UHF_HEALTH_DATA_REQ,      ///< comms health data request
    COMMS_UHF_HEALTH_DATA_RSP,      ///< comms health data response
    COMMS_UHF_HEALTH_DATA_NOTF,     ///< comms health data notification
    COMMS_UHF_LOG_CFG_REQ,          ///< comms log configuration request
    COMMS_UHF_LOG_CFG_STS,          ///< comms log configuration status
    COMMS_UHF_TX_CFG_REQ,           ///< comms transmit configuration request
    COMMS_UHF_TX_CFG_STS,           ///< comms transmit configuration status
    COMMS_UHF_RX_CFG_REQ,           ///< comms receive configuration request
    COMMS_UHF_RX_CFG_STS,           ///< comms receive configuration status
    COMMS_UHF_SYS_CFG_REQ,
    COMMS_UHF_SYS_CFG_STS,
    COMMS_UHF_FE_CFG_REQ,           ///< comms feed configuration request
    COMMS_UHF_FE_CFG_STS,           ///< comms feed configuration status
    COMMS_UHF_CALIB_REQ,            ///< comms calibration request
    COMMS_UHF_CALIB_STS,            ///< comms calibration status
    COMMS_UHF_FRMWR_UPDT_REQ,       ///< comms framework update request
    COMMS_UHF_FRMWR_UPDT_STS,       ///< comms framework update status
    COMMS_UHF_TX_REQ,               ///< comms transmit request
    COMMS_UHF_TX_STS,               ///< comms transmit status
    COMMS_UHF_RX_REQ,               ///< comms receive request
    COMMS_UHF_RX_STS,               ///< comms receive status
    COMMS_UHF_IDLE_REQ,             ///< comms idle request
    COMMS_UHF_IDLE_STS,             ///< comms idle status
    COMMS_UHF_TX_RX_REQ,            ///< comms transmit and receive request
    COMMS_UHF_TX_RX_STS,            ///< comms transmit and receive status
}e_comms_uhf_event;

typedef enum
{
    COMMS_UHF_EXTRNL_SET_TX_CFG_REQ = 100, ///< comms external tx configuration set request
    COMMS_UHF_EXTRNL_SET_TX_CFG_STS,       ///< comms external tx configuration set status
    COMMS_UHF_EXTRNL_GET_TX_CFG_REQ,       ///< comms external tx configuration get request
    COMMS_UHF_EXTRNL_GET_TX_CFG_STS,       ///< comms external tx configuration get status
    COMMS_UHF_EXTRNL_SET_RX_CFG_REQ,       ///< comms external rx configuration set request
    COMMS_UHF_EXTRNL_SET_RX_CFG_STS,       ///< comms external rx configuration set status
    COMMS_UHF_EXTRNL_GET_RX_CFG_REQ,       ///< comms external rx configuration get request
    COMMS_UHF_EXTRNL_GET_RX_CFG_STS,       ///< comms external rx configuration get status
    COMMS_UHF_EXTRNL_SET_SYS_CFG_REQ,      ///< comms external sys configuration set request
    COMMS_UHF_EXTRNL_SET_SYS_CFG_STS,      ///< comms external sys configuration set status
    COMMS_UHF_EXTRNL_GET_SYS_CFG_REQ,      ///< comms external sys configuration get request
    COMMS_UHF_EXTRNL_GET_SYS_CFG_STS,      ///< comms external sys configuration get status
}e_comms_uhf_extrnl_event;

/**
  * @brief param option in comms
  */
typedef enum
{
    COMMS_UHF_FALSE,
    COMMS_UHF_TRUE
}e_comms_uhf_param_opt_sts;

/**
  * @brief  tx,rx simentaneously run in comms
  */
typedef enum
{
    COMMS_UHF_TX_MODE,             ///< mode in comms transmit
    COMMS_UHF_RX_MODE,             ///< mode in comms receiving
    COMMS_UHF_TX_RX_MODE           ///< mode for both comms transmit and receive
}e_comms_uhf_tx_rx_mode;

/**
  * @brief  It selects type of primary and secondary boot mode
  */
typedef enum
{
    COMMS_UHF_BOOT_MODE_PRIMARY,       ///< select the primary boot mode
    COMMS_UHF_BOOT_MODE_SECONDARY      ///< select the secondary boot mode
}e_comms_uhf_boot_mode;
/**
  * @brief  It define the various calibration type
  */
typedef enum
{
    COMMS_UHF_TX_CALIB_MODE,     ///< execute tx calibration mode
    COMMS_UHF_RX_CALIB_MODE,     ///< execute rx calibration mode
    COMMS_UHF_FE_CALIB_MODE,     ///< execute fe calibration mode
    COMMS_UHF_CALIB_ALL          ///< calibrate the all mode
}e_comms_uhf_calib_type;
/**
  * @brief  Read all telemetry or param telemetry
  */
typedef enum
{
    COMMS_UHF_READ_TM_ALL,        ///< comms read telemetry all
    COMMS_UHF_READ_TM_PARAM       ///< comms read telemetry parameter
}e_comms_uhf_tm_type;
/**
  * @brief  Read DFU trigger all or trigger particular parameter
  */
typedef enum
{
    COMMS_UHF_DFU_TRIGGER_ALL,        ///< comms dfu trigger all
    COMMS_UHF_DFU_TRIGGER_PARAM      ///< comms dfu trigger param
}e_comms_uhf_dfu_type;

typedef enum
{
    COMMS_UHF_RESET_SUCCESS,
    COMMS_UHF_RESET_FAILURE
}e_comms_uhf_reset_sts;

typedef enum
{
    COMMS_UHF_BOOT_CFG_SUCCESS,
    COMMS_UHF_BOOT_CFG_FAILURE

}e_comms_uhf_boot_cfg_sts;

/**
  * @brief  comms tc id enum definition
  */
/*
typedef enum
{
    TC_COMMS_UHF_GET_TM_INFO = 800,
    TC_COMMS_UHF_SET_CFG,
    TC_COMMS_UHF_SET_TX_CFG,
    TC_COMMS_UHF_GET_TX_CFG,
    TC_COMMS_UHF_SET_RX_CFG,
    TC_COMMS_UHF_GET_RX_CFG,
    TC_COMMS_UHF_SET_TX_PKT_CFG,
    TC_COMMS_UHF_GET_TX_PKT_CFG,
    TC_COMMS_UHF_SET_RX_PKT_CFG,
    TC_COMMS_UHF_GET_RX_PKT_CFG,
    TC_COMMS_UHF_SET_PWR_CFG,
    TC_COMMS_UHF_GET_PWR_CFG,
	TC_COMMS_UHF_BEACON_CFG,
	TC_COMMS_UHF_BEACON_TX_ST,
	TC_COMMS_UHF_BEACON_TX_STOP,
	TC_COMMS_UHF_BEACON_DATA,
	TC_COMMS_UHF_FW_CFG,
	TC_COMMS_UHF_FW_CFG_ACTIVATE,
	TC_COMMS_UHF_CSP_TM_INFO,
	TC_COMMS_UHF_GET_TM_STORE,
	TC_COMMS_UHF_SET_CALLSIGN,
	TC_COMMS_UHF_GET_CALLSIGN,
	TC_COMMS_UHF_INITIAL_SYNC

}e_comms_uhf_tc_id;

*/
/**
  * @brief  comms tm id enum definition
  */
/*
typedef enum
{
    TM_COMMS_UHF_GET_TM_INFO = 800,
    TM_COMMS_UHF_SET_CFG,
    TM_COMMS_UHF_SET_TX_CFG,
    TM_COMMS_UHF_GET_TX_CFG,
    TM_COMMS_UHF_SET_RX_CFG,
    TM_COMMS_UHF_GET_RX_CFG,
    TM_COMMS_UHF_SET_TX_PKT_CFG,
    TM_COMMS_UHF_GET_TX_PKT_CFG,
    TM_COMMS_UHF_SET_RX_PKT_CFG,
    TM_COMMS_UHF_GET_RX_PKT_CFG,
    TM_COMMS_UHF_SET_PWR_CFG,
    TM_COMMS_UHF_GET_PWR_CFG,
	TM_COMMS_UHF_BEACON_CFG,
	TM_COMMS_UHF_BEACON_TX_ST,
	TM_COMMS_UHF_BEACON_TX_STOP,
	TM_COMMS_UHF_BEACON_DATA,
	TM_COMMS_UHF_FW_CFG,
	TM_COMMS_UHF_FW_CFG_ACTIVATE,
	TM_COMMS_UHF_CSP_TM_INFO,
	TM_COMMS_UHF_GET_TM_STORE,
	TM_COMMS_UHF_SET_CALLSIGN,
	TM_COMMS_UHF_GET_CALLSIGN,
	TM_COMMS_UHF_INITIAL_SYNC

}e_comms_uhf_tm_id;
*/


/**
 * @brief It decides the comms tx config success or failure.
 */
typedef enum
{
    COMMS_UHF_TX_CFG_SUCCESS=0,  ///< tx comms config is success
    COMMS_UHF_TX_CFG_FAILURE=1    ///< tx comms config is fail
}e_comms_uhf_tx_cfg_sts;
/**
 * @brief It decides Rx comms config success or failure.
*/
typedef enum
{
    COMMS_UHF_RX_CFG_SUCCESS=0,  ///< rx comms config is success
    COMMS_UHF_RX_CFG_FAILURE=1    ///< rx comms config is fail
}e_comms_uhf_rx_cfg_sts;
/**
 * @brief It decides system config succeeds or fails.
*/
typedef enum
{
    COMMS_UHF_SYS_CFG_SUCCESS=0,   ///< comms  system config is success
    COMMS_UHF_SYS_CFG_FAILURE=1     ///< comms system config is fail
}e_comms_uhf_sys_cfg_sts;
/**
 * @brief It decides calibration trigger is a success or failure.
*/
typedef enum
{
    COMMS_UHF_CALIB_TRGR_SUCCESS=0,   ///< comms calibration trigger is success
    COMMS_UHF_CALIB_TRGR_FAILURE=1     ///< comms calibration trigger is fail
}e_comms_uhf_calib_trgr_sts;
/**
 * @brief It decides comms tx_rx enable is a success or failure.
*/
typedef enum
{
    COMMS_UHF_TX_RX_ENBL_SUCCESS=0,    ///< enable comms tx_rx is success
    COMMS_UHF_TX_RX_ENBL_FAILURE=1      ///< enable comms tx_rx is fail
}e_comms_uhf_tx_rx_enbl_sts;
/**
 * @brief It decides whether the comms DFU trigger is a success or failure.
*/
typedef enum
{
    COMMS_UHF_DFU_TRGR_SUCCESS=0,      ///< comms trigger DFU is success
    COMMS_UHF_DFU_TRGR_FAILURE=1        ///< comms trigger DFU is fail
}e_comms_uhf_dfu_trgr_sts;
/**
 * @brief It decides whether read telemetry is a success or failure.
*/
typedef enum
{
    COMMS_UHF_READ_TM_SUCCESS=0,     ///< comms read telemetry is success
    COMMS_UHF_READ_TM_FAILURE=1       ///< comms read telemetry is fail
}e_comms_uhf_read_tm_sts;

/// comms operation status
typedef enum
{
    COMMS_UHF_RESET_DONE,
    COMMS_UHF_RESET_FAIL,
    COMMS_UHF_BYPASS_RQST,
    COMMS_UHF_BOOT_DONE,
    COMMS_UHF_BOOT_FAIL,
    COMMS_UHF_DFU_DONE,
    COMMS_UHF_DFU_FAIL,
    COMMS_UHF_LOG_CFG_DONE,
    COMMS_UHF_LOG_CFG_FAIL,
    COMMS_UHF_TX_CFG_DONE,
    COMMS_UHF_TX_CFG_FAIL,
    COMMS_UHF_RX_CFG_DONE,
    COMMS_UHF_RX_CFG_FAIL,
    COMMS_UHF_FE_CFG_DONE,
    COMMS_UHF_FE_CFG_FAIL,
    COMMS_UHF_CALIB_DONE,
    COMMS_UHF_CALIB_FAIL,
    COMMS_UHF_SLEEP_DONE,
    COMMS_UHF_SLEEP_FAIL,
    COMMS_UHF_TX_DONE,
    COMMS_UHF_TX_FAIL,
    COMMS_UHF_RX_DONE,
    COMMS_UHF_RX_FAIL,
    COMMS_UHF_TX_RX_DONE,
    COMMS_UHF_TX_RX_FAIL,
    COMMS_UHF_IDLE_DONE,
    COMMS_UHF_IDLE_FAIL,
    COMMS_UHF_REINIT_TMR_EXP,
}e_comms_uhf_et;


/**
 * @brief UHF buffered TM information queue id
 */
typedef enum
{
	UHF_TM_PROP_QUEUE_ID,
        UHF_TM_MAX_QUEUE_ID
}uhf_buff_fw_queue_id;

/**
* @brief This function create the COMMS state and event threads 
*
* @return Thread status
*/
int32_t comms_uhf_csw_init(void);
/**
* @brief This function step-by-step process the COMMS states to the help
* of event thread request
*
* @param param : unused pointer
*/
void comms_uhf_csw_main(void *param);

/**
* @brief This api Initialize the UHF sync.
*/
void uhf_initial_sync_cb(void);

/**
 * @brief This function is the callback function for the SBAND rx sync periodic timer
 *        This sync will be used to store parameter for every 2mins
 */
//void sband_periodic_tm_stor_cb(void)
void uhf_tm_periodic_stor_cb(void);

/**
* @brief This API monitor tx uhf ground contact
*/
void uhf_tx_on_cb(void);

/**
* @brief This API handle the comms finite states machine
*
* @param state   : current state
* @param msg_id  : Identity of state
* @param payload : pointer to payload
*
* @return state
*/
uint8_t comms_uhf_fsm_hdlr_fn(uint8_t state,uint16_t msg_id, void *payload);

/**
* @brief This function handle comms initialization state
*
* @param msg_id  : Identity of state
* @param payload : Pointer to payload
*
* @return state of comms
*/
uint8_t comms_uhf_init_state_hdlr(uint16_t msg_id, void *payload);

/**
* @brief This function handle the comms boot state
*
* @param msg_id  : Identity of state
* @param payload : Pointer to payload
*
* @return state of comms
*/
uint8_t comms_uhf_boot_state_hdlr(uint16_t msg_id, void *payload);

/**
* @brief This function handles comms DFU states
*
* @param msg_id  : Identity of state
* @param payload : Pointer to payload
*
* @return state of comms
*/
uint8_t comms_uhf_dfu_state_hdlr(uint16_t msg_id, void *payload);

/**
* @brief This function handle comms configuration states
*
* @param msg_id  : Identity of state
* @param payload : Pointer to payload
*
* @return state of comms
*/
uint8_t comms_uhf_cfg_state_hdlr(uint16_t msg_id, void *payload);

/**
* @brief This function handle comms calibration state
*
* @param msg_id  : Identity of state
* @param payload : Pointer to payload
*
* @return state of comms
*/
uint8_t comms_uhf_calib_state_hdlr(uint16_t msg_id, void *payload);

/**
* @brief This API handle the comms idle state
*
* @param msg_id  : Identity of state
* @param payload : Pointer to payload
*
* @return state of comms
*/
uint8_t comms_uhf_sleep_idle_state_hdlr(uint16_t msg_id, void *payload);
/**
* @brief This API handle the comms active states
*
* @param msg_id  : Identity of state
* @param payload : Pointer to payload
*
* @return state of comms
*/
uint8_t comms_uhf_active_state_hdlr(uint16_t msg_id, void *payload);

/**
* @brief This functions handle the comms safe mode state
*
* @param msg_id  : Identity of state
* @param payload : Pointer to payload
*
* @return safe mode state
*/
uint8_t comms_uhf_safe_mode_state_hdlr(uint16_t msg_id, void *payload);

/**
* @brief This function handle the comms error state
*
* @param msg_id  : Identity of state
* @param payload : Pointer to payload
*
* @return Error state
*/
uint8_t comms_uhf_error_state_hdlr(uint16_t msg_id, void *payload);
/**
* @brief This function handling Bypass the comms states
*
* @param msg_id  : Identity of state
* @param payload : Pointer to payload
*
* @return state of comms
*/
uint8_t comms_uhf_bypass_state_hdlr(uint16_t msg_id, void *payload);
/**
* @brief This function send the uhf ground contact status
*
* @param state : uhf state
*/
void uhf_gs_contact_status_upd_itc(uint16_t state, uint8_t radio_id);
/**
* @brief This function send the uhf ground contact status
*
* @param state : uhf state
*/
void uhf_gs_contact_status_upd(uint16_t state);

/**
* @brief This function check the uhf ground contact
*
* @return uhf ground contact
*/
uint8_t is_uhf_gs_contact_valid(void);

/**
* @brief This function monitor and report the uhf health
*/
void uhf_health_report_tm(void);

/**
 * @brief This function monitor and report the uhf health
 */
void comms_uhf_health_report_tm(void);

/**
* @brief Callback function for TX sync timer
*/
void uhf_tx_sync_cb(void);

void send_otsu_uhf_gssync_sts(uint8_t sts);

/**
 * @brief This function used to reqquest queue to push the health data 
 */
void tc_uhf_buff_fw_req_queue(uint32 instance_size, uint32 num_of_instance, uint8 queue_id);

/**
 * @brief This function used to enqueue the data into the health metric queue
 */

void tc_uhf_buff_fw_enqueue_req(uint8* data, uint8 queue_id);

void comms_uhf_cmd_rsp_timeout_recovery_handling(void);
void uhf_reinit_exp_hdlr(void);

#ifdef __cplusplus
}
#endif

#endif /*COMMS_UHF_MAIN_H */
