/**
 * @file comms_sband_xlink_s_tctm_hdlr.c
 *
 * @brief This file has the S-Band driver FSM implemenation and the relevant functions
 *
 * @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.
 *
 */
/*********************************************************************/
#include <stdio.h>
#include "sm_api.h"
#include "comms_sband_sim.h"
#include "comms_sband_init.h"
#include "comms_ipc.h"
#include "comms_csw.h"
#include "exo_common.h"
#include "comms_sband_xlink_ss.h"
#include "comms_sband_xlink_api.h"
#include "comms_sband_api_map.h"
#include "tc_tm_mngr.h"
#include "logger.h"
#include "comms_sband_xlink_sock.h"
#include "comms_sband_intf.h"
#include "comms_sband_csp.h"
#include "sdr_app_main.h"
#include "exo_io_al_rtc_common.h"
#include "exo_io_al_sos_timer.h"
#include "exo_tctm_ipc.h"

/*** Xlink_Sband_TX_RX Frame detected via UDP ***/
extern uint32 PLACE_IN_EXT_RAM_MEM rx_udp_frame; ///< Received UDP frames counter
extern uint32 PLACE_IN_EXT_RAM_MEM tx_udp_frame; ///< Transmitted UDP frames counter
extern uint32 PLACE_IN_EXT_RAM_MEM sband_xlink_rf_pwr_global; ///< S-band RF power setting


extern SERVICE_DEVICE_CONF_STRUCT PLACE_IN_EXT_RAM_MEM	 sband_serv_device_conf; ///< S-band service device configuration
extern SERVICE_HOUSE_KEEP_STRUCT  PLACE_IN_EXT_RAM_MEM   sband_serv_house_keep; ///< S-band service housekeeping data
extern SERVICE_IP_ADR_STRUCT      PLACE_IN_EXT_RAM_MEM   sband_serv_ip_adr; ///< S-band service IP address settings  
extern SERVICE_DVBS2_CONF_STRUCT  PLACE_IN_EXT_RAM_MEM   sband_serv_dvbs2_cfg; ///< S-band service DVB-S2 configuration
extern SERVICE_FEATURE_SELECT_STRUCT PLACE_IN_EXT_RAM_MEM sband_serv_feature_select; ///< S-band service feature selection
extern SERVICE_XPA_INF_STRUCT        PLACE_IN_EXT_RAM_MEM sband_serv_xpa_inf; ///< S-band service XPA info
extern SERVICE_VERSION_STRUCT_GET    PLACE_IN_EXT_RAM_MEM sband_serv_version_get; ///< S-band service version info
extern s_sband_periodic_get_tm PLACE_IN_EXT_RAM_MEM xlink_sband_tm_store; ///< S-band periodic telemetry storage
extern uint8_t s_comms_hk_upd_id; ///< Communications HK update ID
extern uint8_t is_comms_hk_upd_id_fill; ///< Communications HK update ID filled flag

uint8_t PLACE_IN_EXT_RAM_MEM sband_tm_buff[300] = {0}; ///< S-band TM buffer
extern s_comms_tx_gen_cfg PLACE_IN_EXT_RAM_MEM sband_s_tx_cfg; ///< S-band TX config 
extern s_comms_rx_gen_cfg PLACE_IN_EXT_RAM_MEM sband_s_rx_cfg; ///< S-band RX config 
extern s_comms_xlinks_tx_cfg PLACE_IN_EXT_RAM_MEM iqs_tx_cfg_global; ///< S-band crosslink TX config
extern s_comms_xlinks_rx_cfg PLACE_IN_EXT_RAM_MEM iqs_rx_cfg_global; ///< S-band crosslink RX config
extern s_comms_xlinks_tx_cfg PLACE_IN_EXT_RAM_MEM iqs_tx_cfg_rb;///< S-band rollback TX config
extern s_comms_xlinks_rx_cfg PLACE_IN_EXT_RAM_MEM iqs_rx_cfg_rb;///< S-band rollback RX config
extern s_comms_xlinks_gnd_cnt_duration PLACE_IN_EXT_RAM_MEM iqs_gnd_cont_dur_glob;//IQS global ground contact duration
extern s_comms_xlinks_dev_prd_key PLACE_IN_EXT_RAM_MEM iqs_prod_key_glob;//IQS global product key
extern s_comms_tx_tm PLACE_IN_EXT_RAM_MEM tx_tm_cfg; ///< S-band TX TM config
s_comms_rx_tm_xlink PLACE_IN_EXT_RAM_MEM rx_tm_cfg; ///< S-band RX TM config
extern s_comms_tm_prop PLACE_IN_EXT_RAM_MEM  xlink_sys_param; ///< S-band system parameters
extern s_sdr_tmr_cfg PLACE_IN_EXT_RAM_MEM sband_tmr_cfg; ///< S-band timer configs

extern uint8_t PLACE_IN_EXT_RAM_MEM comms_csw_rx_buf[512]; ///< CSW RX buffer
extern uint8_t PLACE_IN_EXT_RAM_MEM comms_otsu_gs_contact; ///< OTS/U ground contact flag
extern uint8_t PLACE_IN_EXT_RAM_MEM comms_sband_first_gs_contact; ///< First S-band ground contact flag
extern float PLACE_IN_EXT_RAM_MEM avg_rssi[MAX_RX_CH];// SBAND rssi average
extern uint32 sband_lastProductKey[4];
extern uint32 sband_oldProductKey[4];

/** S_Band driver configuration readback */
extern s_comms_tx_cfg PLACE_IN_EXT_RAM_MEM tx_cfg_rb; ///< S-band TX config readback
extern s_comms_rx_cfg PLACE_IN_EXT_RAM_MEM rx_cfg_rb; ///< S-band RX config readback
extern s_comms_sys_cfg PLACE_IN_EXT_RAM_MEM sys_cfg_rb; ///< S-band system config readback

extern os_timer_handle_ptr PLACE_IN_EXT_RAM_MEM sband_beacon_enb_timer; ///< S-band beacon enable timer
extern os_timer_handle_ptr PLACE_IN_EXT_RAM_MEM sband_beacon_timer; ///< S-band beacon timer

extern uint16_t PLACE_IN_EXT_RAM_MEM version_info_size; ///< S-band version info size

uint8_t PLACE_IN_EXT_RAM_MEM beacon_en = 1; //TODO put in NMVM
sys_time_date_s PLACE_IN_EXT_RAM_MEM  tim_get_tc_tm; ///< Time/date for TC/TM

uint8_t PLACE_IN_EXT_RAM_MEM rx_rssi_tm = 0; ///< RX RSSI telemetry flag

uint8_t bch_dec_param[3];

/**
 * @brief Handle xlink S-band TC/TM packet.
 *
 * This function provides handling of a received xlink S-band 
 * telemetry/telecommand packet. It validates the packet header
 * and payload length, then processes the packet based on whether 
 * it is a TC or TM packet. TC packets are validated against the
 * expected sequence number, then dispatched to the appropriate
 * subsystem handler. TM packets are stored in the telemetry 
 * buffer for later transmission. Sanity checks are performed
 * throughout to discard invalid packets.
 *
 * @param msg_id Message ID indicating TC or TM
 * @param pld_len Length of the packet payload data
 * @param pld_ptr Pointer to the packet payload
*/
void comms_xlink_s_tctm_hdlr(uint16_t msg_id,uint16_t pld_len, void *pld_ptr)
{
    float rssi[4];
    int32_t doppler[2];
    uint32_t fpga_mode = 0;
    uint8_t *tc_tm_data;
    uint8_t  status = 0;
    uint16_t tm_size = 0;
    uint32_t size = 0;
    uint8_t rx_sel = 0;

    DEBUG_CPRINT(("\n COMMS_SBAND_TC_TMHDLR \n"));

    tc_tm_data = (uint8*)pld_ptr;
#ifdef COMMS_TIME_DEBUG
    get_crnt_time_date(&tim_get_tc_tm);
    DEBUG_CPRINT(("\nIQS TIME TC_TM_ENT %d:%d:%d Msg_id - %d",tim_get_tc_tm.hour, tim_get_tc_tm.minute, tim_get_tc_tm.seconds, msg_id ));
    log_id_with_four_arg(LOG_INFO_L1,LOG_COMMS,IQS_TIME_TC_TM_ENT__MSG_ID__u8_,tim_get_tc_tm.hour, tim_get_tc_tm.minute, tim_get_tc_tm.seconds, msg_id );
#endif

    switch(msg_id)
    {
        case TC_SBAND_GET_TM_STORE:

            xlink_sband_tm_store.cnt_hk_id = 0;
            status = 0;
            if(is_comms_hk_upd_id_fill == 1)
            {
                xlink_sband_tm_store.cnt_hk_id = MAX_SBAND_PERIODIC_TM;
            }
            else
            {
                xlink_sband_tm_store.cnt_hk_id = s_comms_hk_upd_id ;
            }

            size = (sizeof(s_sband_periodic_tm)*xlink_sband_tm_store.cnt_hk_id) +1 ; //sizeof(s_sband_periodic_get_tm)
            sband_tc_tm_get_rsp_hdlr(TM_SBAND_GET_TM_STORE,status,size,(uint8_t*)&xlink_sband_tm_store);

            is_comms_hk_upd_id_fill = 0;
            s_comms_hk_upd_id = 0;
            break;

        case TC_SET_COMMS_TX_CFG:

            os_memcpy(&sband_s_tx_cfg, &tc_tm_data[TC_PLD_IDX],sizeof(s_comms_tx_gen_cfg));
            comms_sband_xlink_tx_cpy();
            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);

            sband_serv_device_conf.RfeFreq.TxFreq[0] = iqs_tx_cfg_global.tx_freq/1000;
            sband_serv_device_conf.RfeFreq.TxFreq[1] = iqs_tx_cfg_global.tx_freq/1000;
            sband_serv_device_conf.XmtCtr0.Modulat_0 = (iqs_tx_cfg_global.tx_type + 1) & 0x07;
            sband_serv_device_conf.XmtCtr0.Modulat_1 = (iqs_tx_cfg_global.tx_type + 1) & 0x07;
            //sband_serv_device_conf.SymbFreq.XmtSymbFreq = iqs_tx_cfg_global.tx_rate & 0xffff;
            sband_serv_dvbs2_cfg.RollOffVal_0 = iqs_tx_cfg_global.tx_rolloff & 0x07;
            //sband_serv_device_conf.XmtCtr4.RsMode = iqs_tx_cfg_global.tx_rs & 0xf;
            sband_serv_device_conf.XmtCtr0.Fec_0 = iqs_tx_cfg_global.tx_cc & 0x07;
            sband_serv_device_conf.XmtCtr0.Fec_1 = iqs_tx_cfg_global.tx_cc & 0x07;
            sband_serv_device_conf.XmtCtr0.PRnd_0 = iqs_tx_cfg_global.tx_rand & 0x01;
            sband_serv_device_conf.XmtCtr0.PRnd_1 = iqs_tx_cfg_global.tx_rand & 0x01;
            sband_serv_device_conf.XmtCtr3.TrFrmSz = iqs_tx_cfg_global.tx_size & 0xFFF;

            sband_xlink_rf_pwr_global = (uint32_t)iqs_tx_cfg_global.tx_pout;
            sband_serv_device_conf.XmtCtr3.AttTxGain_0 = ((float) xlink_pwr_attn_val(sband_xlink_rf_pwr_global, (sband_serv_device_conf.RfeFreq.TxFreq[0]/1000)))*10;
            sband_serv_device_conf.XmtCtr3.AttTxGain_1 = ((float) xlink_pwr_attn_val(sband_xlink_rf_pwr_global, (sband_serv_device_conf.RfeFreq.TxFreq[1]/1000)))*10;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);

            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_TX_CFG,status);
            break;

        case TC_SET_COMMS_RX_CFG:

            os_memcpy(&sband_s_rx_cfg, &tc_tm_data[TC_PLD_IDX],sizeof(s_comms_rx_gen_cfg));
            comms_sband_xlink_rx_cpy();
            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);

            sband_serv_device_conf.RfeFreq.RxFreq[0] = iqs_rx_cfg_global.rx_freq/1000;
            sband_serv_device_conf.RfeFreq.RxFreq[1] = iqs_rx_cfg_global.rx_freq/1000;
            sband_serv_device_conf.RcvCtrCh[0].Modulat = (iqs_rx_cfg_global.rx_type + 1) & 0x07;
            sband_serv_device_conf.RcvCtrCh[1].Modulat = (iqs_rx_cfg_global.rx_type + 1) & 0x07;
            //sband_serv_device_conf.SymbFreq.RcvSymbFreq = iqs_rx_cfg_global.rx_rate;
            //sband_serv_device_conf.RcvCtrCh[0].Fec = iqs_rx_cfg_global.rx_cc & 0x07;
            //sband_serv_device_conf.RcvCtrCh[1].Fec = iqs_rx_cfg_global.rx_cc & 0x07;
            sband_serv_device_conf.RcvCtrCh[0].PRnd = iqs_rx_cfg_global.rx_rand & 0x01;
            sband_serv_device_conf.RcvCtrCh[1].PRnd = iqs_rx_cfg_global.rx_rand & 0x01;
            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);

            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_RX_CFG,status);
            break;

        case TC_SET_COMMS_SYS_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_ERR_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_TX_CFG:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);

            tx_cfg_rb.tx_cfg_freq = sband_serv_device_conf.RfeFreq.TxFreq[0] * 1000;
            tx_cfg_rb.tx_cfg_type = sband_serv_device_conf.XmtCtr0.Modulat_0 - 1;
            tx_cfg_rb.tx_cfg_rate = sband_serv_device_conf.SymbFreq.XmtSymbFreq;
            tx_cfg_rb.tx_cfg_rolloff = sband_serv_dvbs2_cfg.RollOffVal_0;
            tx_cfg_rb.tx_cfg_rs = sband_serv_device_conf.XmtCtr4.RsMode;
            tx_cfg_rb.tx_cfg_cc = sband_serv_device_conf.XmtCtr0.Fec_0;
            tx_cfg_rb.tx_cfg_rand = sband_serv_device_conf.XmtCtr0.PRnd_0;
            tx_cfg_rb.tx_cfg_size = sband_serv_device_conf.XmtCtr3.TrFrmSz;
            tx_cfg_rb.tx_cfg_pout = iqs_tx_cfg_global.tx_pout;
            tx_cfg_rb.tx_cfg_frames = tx_udp_frame;
            tx_cfg_rb.tx_cfg_idletime =  iqs_tx_cfg_global.tx_idletime;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG,status,sizeof(s_comms_tx_cfg),(uint8_t*)&tx_cfg_rb);
            break;

        case TC_GET_COMMS_RX_CFG:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);

            rx_cfg_rb.rx_cfg_freq = sband_serv_device_conf.RfeFreq.RxFreq[0] * 1000;
            rx_cfg_rb.rx_cfg_type = sband_serv_device_conf.RcvCtrCh[0].Modulat - 1;
            rx_cfg_rb.rx_cfg_cc = sband_serv_device_conf.RcvCtrCh[0].Fec;
            rx_cfg_rb.rx_cfg_rand = sband_serv_device_conf.RcvCtrCh[0].PRnd;
            rx_cfg_rb.rx_cfg_rate = sband_serv_device_conf.SymbFreq.RcvSymbFreq;
            rx_cfg_rb.rx_cfg_size = sband_serv_device_conf.XmtCtr3.TrFrmSz;
            rx_cfg_rb.rx_frame_lock = sband_serv_house_keep.HouseKeep.RcvInfCh[0].Sync;
            rx_cfg_rb.rx_cfg_freqerr = sband_serv_house_keep.HouseKeep.RcvInfCh[0].DopplerFreq;
            rx_cfg_rb.rx_cfg_frames = rx_udp_frame;
            rx_cfg_rb.rx_cfg_detected = rx_udp_frame;
            rx_cfg_rb.rx_cfg_rssi = comms_xlink_s_get_rssi(0);

            sband_s_rx_cfg.rx_cfg_freq = sband_serv_device_conf.RfeFreq.RxFreq[0] * 1000;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_CFG,status,sizeof(s_comms_rx_cfg),(uint8_t*)&rx_cfg_rb);
            break;

        case TC_GET_COMMS_SYS_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_TX_CFG_FREQ:
            os_memcpy(&iqs_tx_cfg_global.tx_freq, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_tx_cfg_global.tx_freq));

            sband_serv_device_conf.RfeFreq.TxFreq[0] = iqs_tx_cfg_global.tx_freq/1000;
            sband_serv_device_conf.RfeFreq.TxFreq[1] = iqs_tx_cfg_global.tx_freq/1000;
            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);

            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_TX_CFG_FREQ,status);
            break;

        case TC_SET_COMMS_TX_CFG_TYPE:

            os_memcpy(&iqs_tx_cfg_global.tx_type, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_tx_cfg_global.tx_type));
            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_serv_device_conf.XmtCtr0.Modulat_0 = (iqs_tx_cfg_global.tx_type +1) & 0x07;
            sband_serv_device_conf.XmtCtr0.Modulat_1 = (iqs_tx_cfg_global.tx_type +1) & 0x07;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_TX_CFG_TYPE,status);
            break;

        case TC_SET_COMMS_TX_CFG_RATE:

            os_memcpy(&iqs_tx_cfg_global.tx_rate, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_tx_cfg_global.tx_rate));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_serv_device_conf.SymbFreq.XmtSymbFreq = iqs_tx_cfg_global.tx_rate & 0xffff;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_TX_CFG_RATE,status);
            break;

        case TC_SET_COMMS_TX_CFG_ROLLOFF:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_TX_CFG_POUT:

            os_memcpy(&iqs_tx_cfg_global.tx_pout, &tc_tm_data[TC_PLD_IDX],sizeof(iqs_tx_cfg_global.tx_pout));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_xlink_rf_pwr_global = (uint32_t)iqs_tx_cfg_global.tx_pout;
            sband_serv_device_conf.XmtCtr3.AttTxGain_0 = ((float)xlink_pwr_attn_val(sband_xlink_rf_pwr_global, (sband_serv_device_conf.RfeFreq.TxFreq[0]/1000)))*10;
            sband_serv_device_conf.XmtCtr3.AttTxGain_1 = ((float)xlink_pwr_attn_val(sband_xlink_rf_pwr_global, (sband_serv_device_conf.RfeFreq.TxFreq[1]/1000)))*10;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_TX_CFG_POUT,status);
            break;

        case TC_SET_COMMS_TX_CFG_ALC_MODE: //To do FPGA Mode

            os_memcpy(&fpga_mode, &tc_tm_data[TC_PLD_IDX],sizeof(fpga_mode));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_serv_device_conf.XmtCtr0.Mode_0 = fpga_mode & 0x0f;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_TX_CFG_ALC_MODE,status);
            break;

        case TC_SET_COMMS_TX_CFG_RS:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_TX_CFG_CC:

            os_memcpy(&iqs_tx_cfg_global.tx_cc, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_tx_cfg_global.tx_cc));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_serv_device_conf.XmtCtr0.Fec_0 = iqs_tx_cfg_global.tx_cc & 0x07;
            sband_serv_device_conf.XmtCtr0.Fec_1 = iqs_tx_cfg_global.tx_cc & 0x07;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_TX_CFG_CC,status);
            break;

        case TC_SET_COMMS_TX_CFG_RAND:

            os_memcpy(&iqs_tx_cfg_global.tx_rand, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_tx_cfg_global.tx_rand));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_serv_device_conf.XmtCtr0.PRnd_0 = iqs_tx_cfg_global.tx_rand & 0x01;
            sband_serv_device_conf.XmtCtr0.PRnd_1 = iqs_tx_cfg_global.tx_rand & 0x01;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_TX_CFG_RAND,status);
            break;

        case TC_SET_COMMS_TX_CFG_CRC:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_TX_CFG_IDLETIME:

            os_memcpy(&iqs_tx_cfg_global.tx_idletime, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_tx_cfg_global.tx_idletime));

            status = 0;
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_TX_CFG_IDLETIME,status);
            break;

        case TC_SET_COMMS_TX_CFG_SIZE:

            os_memcpy(&iqs_tx_cfg_global.tx_size, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_tx_cfg_global.tx_size));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_serv_device_conf.XmtCtr3.TrFrmSz = iqs_tx_cfg_global.tx_size & 0xFFF;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_TX_CFG_SIZE,status);
            break;

        case TC_SET_COMMS_TX_CFG_ID:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_TX_CFG_CRYPTO:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_TX_CFG_PA_TEMPLIMIT:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_BCH_CFG:
            os_memcpy(&bch_dec_param[0], &tc_tm_data[TC_PLD_IDX], sizeof(bch_dec_param));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);

            sband_serv_device_conf.RcvCtrCh[0].BchDec = bch_dec_param[0];
            sband_serv_device_conf.RcvCtrCh[0].AccBchErr = bch_dec_param[1];
            sband_serv_device_conf.RcvCtrCh[0].BchCountMode = bch_dec_param[2];
            sband_serv_device_conf.RcvCtrCh[1].BchDec = bch_dec_param[0];
            sband_serv_device_conf.RcvCtrCh[1].AccBchErr = bch_dec_param[1];
            sband_serv_device_conf.RcvCtrCh[1].BchCountMode = bch_dec_param[2];

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_BCH_CFG,status);
            break;

        case TC_COMMS_SBAND_BEACON_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_COMMS_SBAND_BEACON_START:
            beacon_en = 1;

            status = os_timer_start(sband_beacon_timer,sband_tmr_cfg.beacon_prd_tmr);//sband_tmr_cfg.beacon_prd_tmr);
            sband_tc_tm_set_rsp_hdlr(TM_COMMS_SBAND_BEACON_START,status);
            break;

        case TC_COMMS_SBAND_BEACON_STOP:
            beacon_en = 0;

            os_timer_stop(sband_beacon_timer);
            status = os_timer_start(sband_beacon_enb_timer,sband_tmr_cfg.beacon_enb_tmr);
            sband_tc_tm_set_rsp_hdlr(TM_COMMS_SBAND_BEACON_STOP,status);
            break;

        case TC_SET_COMMS_RX_CFG_FREQ:
            os_memcpy(&iqs_rx_cfg_global.rx_freq, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_rx_cfg_global.rx_freq));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_serv_device_conf.RfeFreq.RxFreq[0] = iqs_rx_cfg_global.rx_freq/1000;
            sband_serv_device_conf.RfeFreq.RxFreq[1] = iqs_rx_cfg_global.rx_freq/1000;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_RX_CFG_FREQ,status);
            break;

        case TC_SET_COMMS_RX_CFG_TYPE:

            os_memcpy(&iqs_rx_cfg_global.rx_type, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_rx_cfg_global.rx_type));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_serv_device_conf.RcvCtrCh[0].Modulat = (iqs_rx_cfg_global.rx_type + 1) & 0x07;
            sband_serv_device_conf.RcvCtrCh[1].Modulat = (iqs_rx_cfg_global.rx_type + 1) & 0x07;
            // DEBUG_CPRINT(("\r\n#######RX Type######%hu %hu ", sband_serv_device_conf.RcvCtrCh[0].Modulat, tc_tm_data[TC_PLD_IDX]));

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF),(uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_RX_CFG_TYPE,status);
            break;

        case TC_SET_COMMS_RX_CFG_RATE:
            os_memcpy(&iqs_rx_cfg_global.rx_rate, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_rx_cfg_global.rx_rate));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_serv_device_conf.SymbFreq.RcvSymbFreq = iqs_tx_cfg_global.tx_rate & 0xffff;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_TX_CFG_RATE,status);
            break;

        case TC_SET_COMMS_RX_CFG_ROLLOFF:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_RX_CFG_AFC:

            os_memcpy(&iqs_rx_cfg_global.rx_gain, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_rx_cfg_global.rx_gain));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_serv_device_conf.RcvCtrCh[0].RxGainMax = iqs_rx_cfg_global.rx_gain;
            sband_serv_device_conf.RcvCtrCh[1].RxGainMax = iqs_rx_cfg_global.rx_gain;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_RX_CFG_AFC,status);
            break;

        case TC_SET_COMMS_RX_CFG_RS:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_RX_CFG_CC:

            os_memcpy(&iqs_rx_cfg_global.rx_cc, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_rx_cfg_global.rx_cc));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_serv_device_conf.RcvCtrCh[0].Fec = iqs_rx_cfg_global.rx_cc & 0x07;
            sband_serv_device_conf.RcvCtrCh[1].Fec = iqs_rx_cfg_global.rx_cc & 0x07;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_RX_CFG_CC,status);
            break;

        case TC_SET_COMMS_RX_CFG_RAND:

            os_memcpy(&iqs_rx_cfg_global.rx_rand, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_rx_cfg_global.rx_rand));

            sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_serv_device_conf.RcvCtrCh[0].PRnd = iqs_rx_cfg_global.rx_rand & 0x01;
            sband_serv_device_conf.RcvCtrCh[1].PRnd = iqs_rx_cfg_global.rx_rand & 0x01;

            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_RX_CFG_RAND,status);
            break;

        case TC_SET_COMMS_RX_CFG_CRC:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_RX_CFG_SIZE:

            os_memcpy(&iqs_rx_cfg_global.rx_size, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_rx_cfg_global.rx_size));

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            //sband_serv_device_conf.XmtCtr3.TrFrmSz = 1432;
            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_RX_CFG_SIZE,status);
            break;

        case TC_SET_COMMS_RX_CFG_ID:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_RX_CFG_CRYPTO:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_ASM_CFG: // TO DO TM_SET_COMMS_ASM_CFG

            os_memcpy(&iqs_tx_cfg_global.tx_rsvd1, &tc_tm_data[TC_PLD_IDX], sizeof(iqs_tx_cfg_global.tx_rsvd1));
            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);

            sband_serv_device_conf.XmtCtr0.ASMStart_1 = iqs_tx_cfg_global.tx_rsvd1 & 0xFFF;
            status = sband_proc_tc_pld((SERVICE_SET|SERVICE_DEVICE_CONF), (uint8_t*)&sband_serv_device_conf);
            sband_tc_tm_set_rsp_hdlr(TM_SET_COMMS_ASM_CFG,status);
            break;

        case TC_SET_COMMS_BOOT_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_GWDT_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_CAN_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_UART_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_CSP_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_SET_COMMS_NET_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_BCH_CFG:
            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);

            bch_dec_param[0] = sband_serv_device_conf.RcvCtrCh[0].BchDec;
            bch_dec_param[1] = sband_serv_device_conf.RcvCtrCh[0].AccBchErr;
            bch_dec_param[2] = sband_serv_device_conf.RcvCtrCh[0].BchCountMode;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_BCH_CFG,status,sizeof(bch_dec_param),(uint8_t*)&bch_dec_param);
            break;

        case TC_GET_COMMS_TX_CFG_FREQ:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_tx_cfg_rb.tx_freq = sband_serv_device_conf.RfeFreq.TxFreq[0] * 1000;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG_FREQ,status, sizeof(iqs_tx_cfg_rb.tx_freq),(uint8_t*)&iqs_tx_cfg_rb.tx_freq);
            break;

        case TC_GET_COMMS_TX_CFG_TYPE:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_tx_cfg_rb.tx_type = sband_serv_device_conf.XmtCtr0.Modulat_0 - 1;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG_TYPE,status,sizeof(iqs_tx_cfg_rb.tx_type),(uint8_t*)&iqs_tx_cfg_rb.tx_type);
            break;

        case TC_GET_COMMS_TX_CFG_RATE:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_tx_cfg_rb.tx_rate = sband_serv_device_conf.SymbFreq.XmtSymbFreq;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG_RATE,status, sizeof(iqs_tx_cfg_rb.tx_rate),(uint8_t*)&iqs_tx_cfg_rb.tx_rate);
            break;

        case TC_GET_COMMS_TX_CFG_ROLLOFF:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_tx_cfg_rb.tx_rolloff = sband_serv_dvbs2_cfg.RollOffVal_0;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG_ROLLOFF,status, sizeof(iqs_tx_cfg_rb.tx_rolloff),(uint8_t*)&iqs_tx_cfg_rb.tx_rolloff);
            break;

        case TC_GET_COMMS_TX_CFG_POUT:
#if 0
            status 			= sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            int freq 		= sband_serv_device_conf.RfeFreq.TxFreq[0]/1000;
            float pwr_atten	= xlink_pwr_attn_val(sband_xlink_rf_pwr_global, freq);
            DEBUG_CPRINT(("TX Gain Atten set at device is %d, from table %.2f", sband_serv_device_conf.XmtCtr3.AttTxGain_0, pwr_atten));
            log_id_with_one_arg(LOG_INFO_L2,LOG_COMMS,GAIN_ATTEN_SET_AT_DEVICE__u32_,sband_serv_device_conf.XmtCtr3.AttTxGain_0);
            log_id_with_float(LOG_INFO_L2,LOG_COMMS,GAIN_ATTEN_SET_FROM_TABLE__u32,pwr_atten);
            if (sband_serv_device_conf.XmtCtr3.AttTxGain_0 == pwr_atten)
            {
                DEBUG_CPRINT(("TX Gain Atten set at device is %d", sband_serv_device_conf.XmtCtr3.AttTxGain_0));
                log_id_with_one_arg(LOG_INFO_L2,LOG_COMMS,TX_GAIN0_SET_AT_DEVICE__u32_,sband_serv_device_conf.XmtCtr3.AttTxGain_0);
                DEBUG_CPRINT(("TX Gain Atten set at device is %d", sband_serv_device_conf.XmtCtr3.AttTxGain_1));
                log_id_with_one_arg(LOG_INFO_L2,LOG_COMMS,TX_GAIN1_SET_AT_DEVICE__u32_,sband_serv_device_conf.XmtCtr3.AttTxGain_1);
            }
            else
            {
                DEBUG_CPRINT(("TX Gain Atten set at device is %d different", sband_serv_device_conf.XmtCtr3.AttTxGain_0));
                log_id_with_one_arg(LOG_INFO_L2,LOG_COMMS,TX_GAIN0_SET_AT_DEVICE__u32_,sband_serv_device_conf.XmtCtr3.AttTxGain_0);
                DEBUG_CPRINT(("TX Gain Atten set at device is %d different", sband_serv_device_conf.XmtCtr3.AttTxGain_1));
                log_id_with_one_arg(LOG_INFO_L2,LOG_COMMS,TX_GAIN1_SET_AT_DEVICE__u32_,sband_serv_device_conf.XmtCtr3.AttTxGain_1);
            }

            iqs_tx_cfg_rb.tx_pout = (sband_serv_device_conf.XmtCtr3.AttTxGain_0 / 10);
#endif
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG_POUT,status, sizeof(iqs_tx_cfg_global.tx_pout),(uint8_t*)&iqs_tx_cfg_global.tx_pout);
            break;

        case TC_GET_COMMS_TX_CFG_ALC_MODE:

            status 	= sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            fpga_mode = sband_serv_device_conf.XmtCtr0.Mode_0;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG_ALC_MODE,status,sizeof(fpga_mode),(uint8_t*)&fpga_mode);
            break;

        case TC_GET_COMMS_TX_CFG_RS:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_tx_cfg_rb.tx_rs = sband_serv_device_conf.XmtCtr4.RsMode & 0x0f;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG_RS,status,sizeof(iqs_tx_cfg_rb.tx_rs),(uint8_t*)(uint8_t*)&iqs_tx_cfg_rb.tx_rs);
            break;

        case TC_GET_COMMS_TX_CFG_CC:
            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_tx_cfg_rb.tx_cc = sband_serv_device_conf.XmtCtr0.Fec_0 & 0x07;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG_CC,status,sizeof(iqs_tx_cfg_rb.tx_cc),(uint8_t*)(uint8_t*)&iqs_tx_cfg_rb.tx_cc);
            break;

        case TC_GET_COMMS_TX_CFG_RAND:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_tx_cfg_rb.tx_rand = sband_serv_device_conf.XmtCtr0.PRnd_0;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG_RAND,status, sizeof(iqs_tx_cfg_rb.tx_rand),&iqs_tx_cfg_rb.tx_rand);
            break;

        case TC_GET_COMMS_TX_CFG_CRC:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_TX_CFG_IDLETIME:

            status = 0;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG_IDLETIME,status,sizeof(iqs_tx_cfg_global.tx_idletime),(uint8_t*)&iqs_tx_cfg_global.tx_idletime);
            break;

        case TC_GET_COMMS_TX_CFG_SIZE:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_tx_cfg_rb.tx_size = sband_serv_device_conf.XmtCtr3.TrFrmSz;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG_SIZE,status, sizeof(iqs_tx_cfg_rb.tx_size),(uint8_t*)&iqs_tx_cfg_rb.tx_size);
            break;

        case TC_GET_COMMS_TX_CFG_ID:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_TX_CFG_CRYPTO:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_TX_CFG_PA_TEMPLIMIT:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_TX_CFG_FRAMES:

            status = 0;
            tx_tm_cfg.tx_cfg_frames = tx_udp_frame;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TX_CFG_FRAMES,status, sizeof(tx_tm_cfg.tx_cfg_frames), (uint8_t*)&tx_tm_cfg.tx_cfg_frames);
            break;


        case TC_GET_COMMS_TX_CFG_PWR_FWD:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_TX_CFG_PWR_RFL:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_RX_CFG_FREQ:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_rx_cfg_rb.rx_freq = sband_serv_device_conf.RfeFreq.RxFreq[0] * 1000;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_CFG_FREQ,status,sizeof(iqs_rx_cfg_rb.rx_freq),(uint8_t*)&iqs_rx_cfg_rb.rx_freq);
            break;

        case TC_GET_COMMS_RX_CFG_TYPE:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_rx_cfg_rb.rx_type = sband_serv_device_conf.XmtCtr0.Modulat_0 - 1;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_CFG_TYPE,status, sizeof(iqs_rx_cfg_rb.rx_type),(uint8_t*)&iqs_rx_cfg_rb.rx_type);
            break;

        case TC_GET_COMMS_RX_CFG_RATE:
            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_rx_cfg_rb.rx_rate = sband_serv_device_conf.SymbFreq.RcvSymbFreq;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_CFG_RATE,status, sizeof(iqs_rx_cfg_rb.rx_rate),(uint8_t*)&iqs_rx_cfg_rb.rx_rate);
            break;

        case TC_GET_COMMS_RX_CFG_ROLLOFF:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_RX_CFG_AFC:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_rx_cfg_rb.rx_gain = sband_serv_device_conf.RcvCtrCh[0].RxGainMax;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_CFG_AFC,status,sizeof(iqs_rx_cfg_rb.rx_gain),(uint8_t*)&iqs_rx_cfg_rb.rx_gain);
            break;


        case TC_GET_COMMS_RX_CFG_RS:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_rx_cfg_rb.rx_rs = 0;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_CFG_RS,status,sizeof(iqs_rx_cfg_rb.rx_rs),(uint8_t*)(uint8_t*)&iqs_rx_cfg_rb.rx_rs);
            break;


        case TC_GET_COMMS_RX_CFG_CC:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            uint32 rx_ch_fec = sband_serv_device_conf.RcvCtrCh[0].Fec;
            iqs_rx_cfg_rb.rx_cc = rx_ch_fec & 0x07;
            sband_tc_tm_get_rsp_hdlr(TC_GET_COMMS_RX_CFG_CC,status,sizeof(iqs_rx_cfg_rb.rx_cc),(uint8_t*)&iqs_rx_cfg_rb.rx_cc);
            break;

        case TC_GET_COMMS_RX_CFG_RAND:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            iqs_rx_cfg_rb.rx_rand = sband_serv_device_conf.RcvCtrCh[0].PRnd ;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_CFG_RAND,status, sizeof(iqs_rx_cfg_rb.rx_rand),(uint8_t*)&iqs_rx_cfg_rb.rx_rand);
            break;

        case TC_GET_COMMS_RX_CFG_CRC:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_RX_CFG_SIZE:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_RX_CFG_ID:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_RX_CFG_CRYPTO:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_RX_CFG_FRAMES:

            status = 0;
            rx_tm_cfg.rx_cfg_frames = rx_udp_frame;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_CFG_FRAMES,status,sizeof(rx_tm_cfg.rx_cfg_frames),(uint8_t*)&rx_tm_cfg.rx_cfg_frames);
            break;

        case TC_GET_COMMS_RX_CFG_DETECTED:
            status = 0;
            rx_tm_cfg.rx_cfg_frames = rx_udp_frame;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_CFG_DETECTED,status,sizeof(rx_tm_cfg.rx_cfg_frames),(uint8_t*)&rx_tm_cfg.rx_cfg_frames);
            break;

        case TC_GET_COMMS_RX_CFG_RSSI:
            {
                uint8_t status1= 0, status2 = 0;
                status1 = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
                status2 = sband_proc_tc(SERVICE_GET | SERVICE_HOUSE_KEEP);

                rssi[0] = comms_xlink_s_get_rssi(0);
                rssi[1] = comms_xlink_s_get_rssi(1);
                rssi[2] = comms_xlink_s_get_avg_rssi(0);
                rssi[3] = comms_xlink_s_get_avg_rssi(1);

                status |= (status1 | status2);
                sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_CFG_RSSI,status,sizeof(rssi),(uint8_t*)&rssi);
            }
            break;

        case TC_GET_COMMS_RX_CFG_FREQERR:
            status = sband_proc_tc(SERVICE_GET | SERVICE_HOUSE_KEEP);
            doppler[0] = sband_serv_house_keep.HouseKeep.RcvInfCh[0].DopplerFreq;
            doppler[1] = sband_serv_house_keep.HouseKeep.RcvInfCh[1].DopplerFreq;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_CFG_FREQERR,status,sizeof(doppler),(uint8_t*)&doppler);
            break;

        case TC_GET_COMMS_RX_CFG_SYMERR:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_RX_CFG_EBN0:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_RX_CFG_CARRIER_LOCK:

            status = sband_proc_tc(SERVICE_GET | SERVICE_HOUSE_KEEP);
            rx_tm_cfg.rx_cfg_carrier_lock = sband_serv_house_keep.HouseKeep.RcvInfCh[0].Sync;
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_CFG_CARRIER_LOCK,status,sizeof(rx_tm_cfg.rx_cfg_carrier_lock),(uint8_t*)&rx_tm_cfg.rx_cfg_carrier_lock);
            break;

        case TC_GET_COMMS_RX_FRAME_LOCK:

            status = sband_proc_tc(SERVICE_GET | SERVICE_HOUSE_KEEP);
            rx_tm_cfg.rx_frame_lock = (sband_serv_house_keep.HouseKeep.RcvInfCh[0].Sync | sband_serv_house_keep.HouseKeep.RcvInfCh[1].Sync);
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_FRAME_LOCK,status,sizeof(rx_tm_cfg.rx_cfg_carrier_lock),(uint8_t*)&rx_tm_cfg.rx_cfg_carrier_lock);
            break;

        case TC_GET_COMMS_BOOT_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_GWDT_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_CAN_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_UART_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_CSP_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_NET_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_TM_INFO:
            status = sband_proc_tc(SERVICE_GET | SERVICE_HOUSE_KEEP);
            xlink_sys_param.temp_xcvr = sband_serv_house_keep.HouseKeep.Temp.AD9361;
            xlink_sys_param.temp_mcu  = sband_serv_house_keep.HouseKeep.Temp.EthPhy;
            xlink_sys_param.temp_fpga = sband_serv_house_keep.HouseKeep.Temp.Zynq;
            xlink_sys_param.volt_vin  = sband_serv_house_keep.HouseKeep.Volt[0];
            xlink_sys_param.volt_3v3  = sband_serv_house_keep.HouseKeep.Volt[1];
            xlink_sys_param.volt_1v8  = sband_serv_house_keep.HouseKeep.Volt[2];
            xlink_sys_param.volt_1v0  = sband_serv_house_keep.HouseKeep.Volt[3];
            xlink_sys_param.volt_pa   = sband_serv_house_keep.HouseKeep.Volt[4];
            xlink_sys_param.rsvd 	  = sband_serv_house_keep.HouseKeep.Volt[5];
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_TM_INFO,status,sizeof(s_comms_tm_prop),(uint8_t*)&xlink_sys_param);
            break;

        case TC_GET_COMMS_RX_TM_INFO:


            rx_rssi_tm = (rx_rssi_tm + 1) & 0x01 ;
            rx_tm_cfg.rx_cfg_ebn0 = rx_rssi_tm ;

            status = sband_proc_tc(SERVICE_GET | SERVICE_HOUSE_KEEP);
            rx_tm_cfg.rx_cfg_frames 	= rx_udp_frame;
            rx_tm_cfg.rx_cfg_detected  	= rx_udp_frame;
            rx_tm_cfg.rx_cfg_rssi		= comms_xlink_s_get_rssi(rx_rssi_tm);
            rx_tm_cfg.rx_cfg_freqerr	= sband_serv_house_keep.HouseKeep.RcvInfCh[rx_rssi_tm].DopplerFreq;
            rx_tm_cfg.rx_cfg_carrier_lock= sband_serv_house_keep.HouseKeep.RcvInfCh[rx_rssi_tm].Sync;
            rx_tm_cfg.rx_frame_lock		= sband_serv_house_keep.HouseKeep.RcvInfCh[rx_rssi_tm].Sync;
            rx_tm_cfg.rx_sir_min		= sband_serv_house_keep.HouseKeep.RcvInfCh[rx_rssi_tm].SirMin;
            rx_tm_cfg.rx_sir_max		= sband_serv_house_keep.HouseKeep.RcvInfCh[rx_rssi_tm].SirMax;
            rx_tm_cfg.rx_bch_block_cnt  = sband_serv_house_keep.HouseKeep.RcvInfCh[rx_rssi_tm].BchBlockCount;
            rx_tm_cfg.rx_bch_err_cnt    = sband_serv_house_keep.HouseKeep.RcvInfCh[rx_rssi_tm].BchErrCount;
            rx_tm_cfg.rx_avg_rssi		= avg_rssi[rx_rssi_tm];
            sband_tc_tm_get_rsp_hdlr(TM_GET_COMMS_RX_TM_INFO,status,sizeof(rx_tm_cfg),(uint8_t*)&rx_tm_cfg);
            break;

        case TC_GET_COMMS_TX_TM_INFO:

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            tx_tm_cfg.tx_cfg_frames = tx_udp_frame;
            tx_tm_cfg.tx_cfg_pwr_rfl= sband_serv_device_conf.XmtCtr3.AttTxGain_0/10;
            sband_tc_tm_get_rsp_hdlr(TC_GET_COMMS_TX_TM_INFO,status,sizeof(tx_tm_cfg),(uint8_t*)&tx_tm_cfg);
            break;

        case TC_GET_COMMS_CSP_TM_INFO:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_COMMS_LOAD_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_COMMS_SAVE_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_COMMS_RESET_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_COMMS_LOCK_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_COMMS_UNLOCK_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_COMMS_ERASE_CFG:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_COMMS_FW_CFG:
            comms_sband_proc_fw_cfg_upd(&tc_tm_data[TC_PLD_IDX]);
            sband_send_ipc(SBAND_SDR_APP_BAT_STS_REQ, SDR_APP);

            break;

        case TC_COMMS_CUSTOM_TX:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            /*          comms_cust_pattern_rf_tx(tc_tm_data);
                        sband_csp_ping(&tc_tm_data[TC_PLD_IDX]);
                        comms_tc_tm_set_rsp_hdlr(TM_COMMS_CUSTOM_TX, 0 ,tc_tm_data);*/
            break;

        case TC_COMMS_BEACON_TX:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            break;

        case TC_GET_COMMS_BOOT_ACTIVATE:
            sband_send_ipc(SBAND_UNKNOWN_TC_TM_HDLR, COMMS_SBAND_CTLR);
            //comms_sband_xlink_beacon_data();
            //comms_sband_tx_link_alert_tm_new();
            //comms_tc_tm_set_rsp_hdlr(TM_COMMS_CSP_TX_DATA, 0 ,tc_tm_data);
            break;

        case TC_COMMS_INITIAL_SYNC:
            comms_sband_initial_sync_hdlr(tc_tm_data);
            break;

        case TC_SBAND_SET_IDLE_CFG:

            DEBUG_CPRINT(("\n\r TC_SBAND_SET_IDLE_CFG is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_SET_IDLE_CFG_IS_RECEIVED);

            tc_tm_data = (uint8*)pld_ptr;

            status = sband_proc_tc(SERVICE_SET | SERVICE_IDLE);
            break;

        case TC_SBAND_SET_RESET:

            DEBUG_CPRINT(("\n\r TC_SBAND_SET_RESET is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_SET_RESET_IS_RECEIVED);

            tc_tm_data = (uint8*)pld_ptr;

            sband_gs_contact_status_upd_itc(SBAND_TC_TM_STOP_REQ,COMMS_SBAND_IQS);
            sband_send_ipc(SBAND_RESET_CFG,COMMS_SBAND_CTLR);
            break;

        case TC_SBAND_SET_START_RF_RCV:

            DEBUG_CPRINT(("\n\r TC_SBAND_SET_START_RF_RCV is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_SET_START_RF_RCV_IS_RECEIVED);

            tc_tm_data = (uint8*)pld_ptr;

            status = sband_proc_tc_pld((SERVICE_SET | SERVICE_START_RF_RCV),&tc_tm_data[TC_PLD_IDX]);
            sband_tc_tm_set_rsp_hdlr(TM_SBAND_SET_START_RF_RCV,status);
            break;

        case TC_SBAND_SET_RF_XMT_DATA:

            DEBUG_CPRINT(("\n\r TC_SBAND_SET_RF_XMT_DATA is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_SET_RF_XMT_DATA_IS_RECEIVED);

            tc_tm_data = (uint8*)pld_ptr;

            sband_proc_tc_pld((SERVICE_SET | SERVICE_RF_XMT_DATA),&tc_tm_data[TC_PLD_IDX]);
            break;

        case TC_SBAND_SET_DVBS2_CONF:

            DEBUG_CPRINT(("\n\r TC_SBAND_SET_DVBS2_CONF is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_SET_DVBS2_CONF_IS_RECEIVED);

            tc_tm_data = (uint8*)pld_ptr;

            sband_proc_tc_pld((SERVICE_SET | SERVICE_DVBS2_CONF),&tc_tm_data[TC_PLD_IDX]);
            break;

        case TC_SBAND_SET_IP_ADR_SAVE:

            DEBUG_CPRINT(("\n\r TC_SBAND_SET_IP_ADR_SAVE is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_SET_IP_ADR_SAVE_IS_RECEIVED);

            tc_tm_data = (uint8*)pld_ptr;

            status = sband_proc_tc_pld((SERVICE_SET | SERVICE_IP_ADR_SAVE),&tc_tm_data[TC_PLD_IDX]);
            sband_tc_tm_set_rsp_hdlr(TM_SBAND_SET_IP_ADR_SAVE,status);
            break;

        case TC_SBAND_SET_IP_ADR:

            DEBUG_CPRINT(("\n\r TC_SBAND_SET_IP_ADR is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_SET_IP_ADR_IS_RECEIVED);

            tc_tm_data = (uint8*)pld_ptr;

            status = sband_proc_tc_pld((SERVICE_SET | SERVICE_IP_ADR),&tc_tm_data[TC_PLD_IDX]);
            sband_tc_tm_set_rsp_hdlr(TM_SBAND_SET_IP_ADR,status);
            break;

        case TC_SBAND_GET_IP_ADR:

            DEBUG_CPRINT(("\n\r TC_SBAND_GET_IP_ADR is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_GET_IP_ADR_IS_RECEIVED);


            tm_size = 4;
            status = sband_proc_tc(SERVICE_GET | SERVICE_IP_ADR);
            sband_tc_tm_get_rsp_hdlr(TM_SBAND_GET_IP_ADR,status,tm_size,(uint8_t*)&sband_serv_ip_adr.ip_address);
            break;

        case TC_SBAND_GET_FLAGS_CONF:

            DEBUG_CPRINT(("\n\r TC_SBAND_GET_FLAGS_CONF is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_GET_FLAGS_CONF_IS_RECEIVED);

            status = sband_proc_tc(SERVICE_GET | SERVICE_FLAGS_CONF);
            break;

        case TC_SBAND_SET_FLAGS_CONF:

            DEBUG_CPRINT(("\n\r TC_SBAND_SET_FLAGS_CONF is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_SET_FLAGS_CONF_IS_RECEIVED);

            tc_tm_data = (uint8*)pld_ptr;

            sband_proc_tc(SERVICE_SET | SERVICE_FLAGS_CONF);
            break;

        case TC_SBAND_SET_VERSION:

            DEBUG_CPRINT(("\n\r TC_SBAND_SET_VERSION is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_SET_VERSION_IS_RECEIVED);

            tc_tm_data = (uint8*)pld_ptr;

            status = sband_proc_tc_pld((SERVICE_SET | SERVICE_VERSION),&tc_tm_data[TC_PLD_IDX]);

            sband_tc_tm_set_rsp_hdlr(TM_SBAND_SET_VERSION,status);

            break;

        case TC_SBAND_GET_VERSION:
            {
                DEBUG_CPRINT(("\n\r TC_SBAND_GET_VERSION is received "));
                log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_GET_VERSION_IS_RECEIVED);
                uint8_t j = 1;

                status = sband_proc_tc(SERVICE_GET | SERVICE_VERSION);
                uint8_t cnt  = version_info_size / sizeof(VERSION_DATE_STRUCT);
                DEBUG_CPRINT(("COUNT = %d\n", cnt));
                sband_tm_buff[0] =  cnt;

                for(int i= 0; i < cnt; i++)
                {
                    os_memcpy(&sband_tm_buff[j],&sband_serv_version_get.prog_version[i],sizeof(VERSION_DATE_STRUCT));
                    j = j + sizeof(VERSION_DATE_STRUCT);
                }
                sband_tc_tm_get_rsp_hdlr(TM_SBAND_GET_VERSION,status,version_info_size + 1, sband_tm_buff);
            }
            break;

        case TC_SBAND_SET_DEVICE_CONF:

            DEBUG_CPRINT(("\n\r TC_SBAND_SET_DEVICE_CONF is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_SET_DEVICE_CONF_IS_RECEIVED);

            tc_tm_data = (uint8*)pld_ptr;

            status = sband_proc_tc_pld((SERVICE_SET | SERVICE_DEVICE_CONF),&tc_tm_data[TC_PLD_IDX]);

            sband_tc_tm_set_rsp_hdlr(TM_SBAND_SET_DEVICE_CONF,status);

            break;

        case TC_SBAND_GET_DEVICE_CONF:

            DEBUG_CPRINT(("\n\r TC_SBAND_GET_DEVICE_CONF is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_GET_DEVICE_CONF_IS_RECEIVED);

            tm_size = sizeof(SERVICE_DEVICE_CONF_STRUCT);
            tm_size = tm_size - 5*sizeof(uint32);

            status = sband_proc_tc(SERVICE_GET | SERVICE_DEVICE_CONF);
            sband_tc_tm_get_rsp_hdlr(TM_SBAND_GET_DEVICE_CONF,status,tm_size,(uint8_t*)&sband_serv_device_conf.HwPins);
            break;

        case TC_SBAND_GET_FEATURE_SELECT:

            DEBUG_CPRINT(("\n\r TC_SBAND_GET_FEATURE_SELECT is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_GET_FEATURE_SELECT_IS_RECEIVED);

            tm_size = sizeof(SERVICE_FEATURE_SELECT_STRUCT);
            tm_size = tm_size - 5*sizeof(uint32);

            status = sband_proc_tc(SERVICE_GET | SERVICE_FEATURE_SELECT);
            sband_tc_tm_get_rsp_hdlr(TM_SBAND_GET_FEATURE_SELECT,status,tm_size,(uint8_t*)&sband_serv_feature_select.feature_select);
            break;

        case TC_SBAND_GET_COMMS_TM_INFO:

            DEBUG_CPRINT(("\n\r TC_SBAND_GET_HOUSE_KEEP is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_GET_HOUSE_KEEP_IS_RECEIVED);

            tm_size = sizeof(SERVICE_HOUSE_KEEP_STRUCT);
            tm_size = tm_size - 6*sizeof(uint32);

            sband_tm_buff[0] =  MAX_HSEKEEP_VOLT_CNT;
            sband_tm_buff[1] =  MAX_HSEKEEP_RCV_INTF_CNT;
            sband_tm_buff[2] =  MAX_HSEKEEP_XMT_INTF_CNT;

            status = sband_proc_tc(SERVICE_GET | SERVICE_HOUSE_KEEP);
            os_memcpy(&sband_tm_buff[3], &sband_serv_house_keep.HouseKeep, sizeof(HOUSE_KEEP_STRUCT));
            sband_tc_tm_get_rsp_hdlr(TM_SBAND_GET_COMMS_TM_INFO,status,tm_size+3,sband_tm_buff);
            break;

        case TC_SBAND_GET_XPA_INF:

            DEBUG_CPRINT(("\n\r TC_SBAND_GET_XPA_INF is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_GET_XPA_INF_IS_RECEIVED);

            tm_size = sizeof(SERVICE_XPA_INF);
            tc_tm_data = (uint8*)pld_ptr;

            status = sband_proc_tc(SERVICE_GET | SERVICE_XPA_INF);
            sband_tc_tm_get_rsp_hdlr(TM_SBAND_GET_XPA_INF,status,tm_size,(uint8_t*)&sband_serv_xpa_inf);
            break;

        case TC_SBAND_SET_PROD_KEY:

            DEBUG_CPRINT(("\n\r TC_SBAND_SET_PROD_KEY is received "));
            log_id(LOG_INFO_L1,LOG_COMMS,TC_SBAND_SET_PROD_KEY_IS_RECEIVED);
            os_memcpy(sband_oldProductKey,sband_lastProductKey,sizeof(sband_oldProductKey));
            os_memcpy(sband_lastProductKey, &tc_tm_data[TC_PLD_IDX], sizeof(sband_lastProductKey));
            DEBUG_CPRINT((" %x-%x-%x-%x \n", sband_lastProductKey[0],sband_lastProductKey[1], sband_lastProductKey[2], sband_lastProductKey[3]));
            log_id_with_four_arg(LOG_INFO_L1,LOG_COMMS,hex__hex__hex__hex_,sband_lastProductKey[0],sband_lastProductKey[1], sband_lastProductKey[2], sband_lastProductKey[3]);

            sband_gs_contact_status_upd_itc(SBAND_TC_TM_STOP_REQ,COMMS_SBAND_IQS);
            sband_send_ipc(SBAND_PROD_KEY_CFG, COMMS_SBAND_CTLR);
            DEBUG_CPRINT(("\nPRD_KEY_UPD\n"));
            break;

        case TC_COMMS_RX_SEL_CFG:
            memcpy(&rx_sel, &tc_tm_data[TC_PLD_IDX], sizeof(uint8_t));
            status = comms_sband_rx_port_sel_enb(rx_sel);
            if(!status)
            {
                status = TC_STS_SET_SUCC;
            }
            else
            {
                status = TC_STS_SET_FAIL;
            }
            sband_tc_tm_set_rsp_hdlr(TM_COMMS_RX_SEL_CFG,status);
            break;

        case TC_COMMS_RX_SEL_DSB:
            status = comms_sband_rx_port_sel_dsb();
            if(!status)
            {
                status = TC_STS_SET_SUCC;
            }
            else
            {
                status = TC_STS_SET_FAIL;
            }
            sband_tc_tm_set_rsp_hdlr(TM_COMMS_RX_SEL_DSB,status);
            break;
    }

#ifdef COMMS_TIME_DEBUG
    get_crnt_time_date(&tim_get_tc_tm);
    DEBUG_CPRINT(("\nIQS TIME TC_TM_EXT %d:%d:%d",tim_get_tc_tm.hour, tim_get_tc_tm.minute, tim_get_tc_tm.seconds));
    log_id_with_three_arg(LOG_INFO_L1,LOG_COMMS,IQS_TIME_TC_TM_EXT__u8__u8__u8_,tim_get_tc_tm.hour, tim_get_tc_tm.minute, tim_get_tc_tm.seconds);
#endif
}
