/**
 * @file adcs_bsk_sim.c
 *
 * @brief This file contains basilisk integration functionality.
 *
 * @copyright Copyright 2023 Antaris, Inc.
 */
/*********************************************************************/

#include "adcs_vapi.h"
#include "adcs_bsk_sim.h"
#include "adcs_vapi_common.h"
#include "adcs_va.h"
#include "eps_ctrlr.h"

#define ADCS_BSK_SOF1   (0x1f)  ///< Basilisk start of frame 1
#define ADCS_BSK_SOF2   (0x7f)  ///< Basilisk start of frame 2
#define ADCS_BSK_EOF1   (0x1f)  ///< Basilisk end of frame 1
#define ADCS_BSK_EOF2   (0xff)  ///< Basilisk end of frame 2

// Extern global variable from VSIM
extern uint8 PLACE_IN_EXT_RAM_MEM adcs_bypass_tlm_buffer[1024];

/**
 * @brief Adcs Global structure decleration
 */
extern s_adcs_ctx adcs_ctx;
static os_timer_handle_ptr thruster_enb_timer = NULL;

/**
 * @brief Callback function for thruster on duration timer
 */
void thruster_enb_timeout_cb(void* args)
{
    eps_ctrl_en_chnl(HW_PROP_UNIT_THRUSTER, PWR_OFF);
}

/**
 * @brief Function to config power status of sensors & actuators
 */
e_adcs_status adcs_vapi_power_on(s_adcs_ctx *adcs_ctx,
        s_adcs_pwr_cmd *pwr_on_off_req)
{
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;

        // value assignment to variables
        data_len = sizeof(s_adcs_pwr_cmd);

        // Memory allocation
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != pwr_on_off_req)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],pwr_on_off_req,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_PWR,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }

        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set TLE parameter
 */
e_adcs_status adcs_vapi_set_tle_params(s_adcs_ctx *adcs_ctx,\
        s_adcs_tle *tle_params)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;

        // value assignment to variables
        data_len = sizeof(s_adcs_tle);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != tle_params)
        {
            // To verify valid payload present before copying to frame
            os_memcpy(&api_buffer[0],tle_params,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_TLE,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }

        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set current time to ADCS
 */
e_adcs_status adcs_vapi_set_utc_time(s_adcs_ctx *adcs_ctx, \
        s_adcs_time *utc_time)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;

        // value assignment to variables
        data_len = sizeof(s_adcs_time);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != utc_time)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],utc_time,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_UTC,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }

        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to Clear Error
 */
e_adcs_status adcs_vapi_set_clear_error(s_adcs_ctx *adcs_ctx)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 api_buffer = 0;

        // Transmit data through socket for basilisk simulator
        status = adcs_send_cmd(API_REQ_CLEAR_ERROR,&api_buffer,data_len);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to Save orbit parameters
 */
e_adcs_status adcs_vapi_set_save_orbit(s_adcs_ctx *adcs_ctx)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 api_buffer = 0;

        // Transmit data through socket for basilisk simulator
        status = adcs_send_cmd(API_REQ_SAVE_ORBIT,&api_buffer,data_len);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}
/**
 * @brief Function to set adcs sensors parameter
 */
e_adcs_status adcs_vapi_set_sensor_params(s_adcs_ctx *adcs_ctx,\
        e_adcs_sensor_type sensor_type,uint8_t sensor_id,\
        u_adcs_sensor_config *sensor_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint16 api_len = 0;

        switch(sensor_type) // Selecting Specific sensor for its payload length
        {
            case ADCS_MAG:          // Magnetometer
            {
                data_len = sizeof(s_adcs_mgmtr_cfg);
            }
            break;
            case ADCS_COARSE_SUN:   // Coarse momentum sensor
            {
                data_len = sizeof(s_adcs_css_cfg);
            }
            break;
            case ADCS_NADIR_SENS:   // Nadir pointing sensor
            {
                data_len = sizeof(s_adcs_nadir_cfg);
            }
            break;
            case ADCS_RED_MAG:      // Redundant Magnetometer
            {
                data_len = sizeof(s_adcs_mgmtr_cfg);
            }
            break;
            case ADCS_FINE_SUN:     // Fine momentum sensor
            {
                data_len = sizeof(s_adcs_fss_cfg);
            }
            break;
            case ADCS_STAR_SENS:    // Star tracking sensor
            {
                data_len = sizeof(s_adcs_star_trkr_cfg);
            }
            break;
            default:                // Invalid type selected
            {
                data_len = 0;
            }
            break;
        }

        api_len = data_len + 2;
        // Memory allocation for payload
        uint8 *api_buffer = (uint8*) os_malloc(api_len);

        api_buffer[0] = (uint8_t)sensor_type; // Selecting Sensor type
        api_buffer[1] = sensor_id; // Sensor ID configuration

        // To verify valid payload present before copying to frame
        if((data_len > 0) && (NULL != sensor_cfg))
        {
            os_memcpy(&api_buffer[2],sensor_cfg,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Transmit data through socket for basilisk simulator
        status = adcs_send_cmd(API_REQ_SENSORS_CFG,api_buffer,api_len);

        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}


/**
 * @brief Function to set adcs acutator parameter
 */
e_adcs_status adcs_vapi_set_actuator_params(s_adcs_ctx *adcs_ctx,\
        e_adcs_actuator_type actuator_type,uint8_t actuator_id,\
        u_adcs_acutator_config *actuator_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint16 api_len = 0;

        // Selecting Specific actuator for its payload length
        switch(actuator_type)
        {
            case ADCS_WHEEL:        // Reaction Wheel
            {
                data_len = sizeof(s_adcs_rw_cfg);
            }
            break;
            case ADCS_MAG_TORQUER:  // Magnetorquer
            {
                data_len = sizeof(s_adcs_mgntrqr_cfg);
            }
            break;
            case ADCS_THRUSTER:     // Thruster
            {
                /*
                 * TODO Currently Thruster not yet planned will be updated in
                 * future
                 */
                data_len = 0;
            }
            break;
            default:                // Invalid type selected
            {
                data_len = 0;
            }
            break;
        }

        api_len = data_len + 2;
        // Memory allocation for payload
        uint8 *api_buffer = (uint8*) os_malloc(api_len);

        api_buffer[0] = (uint8_t)actuator_type; // Selecting Actuator type
        api_buffer[1] = actuator_id;   // Actuator id configuration

        // To verify valid payload present before copying to frame
        if((data_len > 0) && (NULL != actuator_cfg))
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[2],actuator_cfg,data_len);
        }
        else
        {
            // No Action Retun failure
        }

        // Transmit data through socket for basilisk simulator
        status = adcs_send_cmd(API_REQ_ACTUATORS_CFG,api_buffer,api_len);

        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set control mode parameters
 */
e_adcs_status adcs_vapi_set_ctrl_mode(s_adcs_ctx *adcs_ctx,
        s_adcs_ctrl_mode *ctrl_mode_param,\
        u_control_mode_param *ctrl_cfg_parm)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if((NULL != adcs_ctx) && (NULL != ctrl_mode_param)
            && (NULL != ctrl_cfg_parm))
    {
        // Variable declaration
        uint16 data_len = 0;
        uint16 api_len = 0;
        uint8 *api_buffer = NULL;
        DEBUG_CPRINT(("control %d timeout %d\n",
                ctrl_mode_param->ctrl_mode,ctrl_mode_param->time_out));

        // Selecting Specific control mode for its payload length
        switch(ctrl_mode_param->ctrl_mode)
        {
            case ADCS_CTRL_MODE_THREE_AXIS:         // 3axis stabilization
            {
                data_len = sizeof(s_adcs_attitude_angl);
            }
            break;
            case ADCS_CTRL_MODE_TARGET_TRACKING:    // Target tracking
            {
                data_len = sizeof(s_adcs_trck_target);
            }
            break;
            case ADCS_CTRL_MODE_NADIR_POINTING:     // Nadir pointing
            {
                data_len = sizeof(uint32_t);
            }
            break;
            case ADCS_CTRL_MODE_NONE:                   // No control mode
            {
                /*
                 * Since these modes doesn't have any input parameters
                 * assigning length to zero
                 */
                data_len = 0;
            }
            break;
            case ADCS_CTRL_MODE_DETUMBLING:             // Detumbling
            {
                /*
                 * Since these modes doesn't have any input parameters
                 * assigning length to zero
                 */
                data_len = 0;
            }
            break;
            case ADCS_CTRL_MODE_Y_SPIN_STABILIZATION:   // Y Spin Stabilization
            {
                /*
                 * Since these modes doesn't have any input parameters
                 * assigning length to zero
                 */
                data_len = 0;
            }
            break;
            case ADCS_CTRL_MODE_Z_SPIN_STABILIZATION:   // Z Spin Stabilization
            {
                /*
                 * Since these modes doesn't have any input parameters
                 * assigning length to zero
                 */
                data_len = 0;
            }
            break;
            case ADCS_CTRL_MODE_SUN_POINTING:           // Sun pointing
            {
                /*
                 * Since these modes doesn't have any input parameters
                 * assigning length to zero
                 */
                data_len = 0;
                ctrl_mode_param->time_out = 0;   //Set timeout is 0
            }
            break;
            case ADCS_CTRL_MODE_CUSTOM:                 // Custom control mode
            {
                /*
                 * Since these modes doesn't have any input parameters
                 * assigning length to zero
                 */
                data_len = 0;
            }
            break;
            default:                                   // Invalid Mode selected
            {
                data_len = 0;
            }
            break;
        }

        // Adding up payload length with control mode configuration length
        api_len = data_len + sizeof(s_adcs_ctrl_mode);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(api_len);

        // To verify valid payload present before copying to frame
        // Copy control mode data to api_buffer
        os_memcpy(&api_buffer[0],ctrl_mode_param,sizeof(s_adcs_ctrl_mode));
        /*
         *  verifying validity of the payload with length and pointer
         *  before copying
         */
        if((data_len > 0) && (NULL != ctrl_cfg_parm))
        {
            // Copy control input data to api_buffer
            os_memcpy(&api_buffer[sizeof(s_adcs_ctrl_mode)],ctrl_cfg_parm,\
                    data_len);
        }
        else
        {
            // No Action Retun failure
        }

        // Transmit data through socket for basilisk simulator
        status = adcs_send_cmd(API_REQ_CTRL_MODE,api_buffer,api_len);

        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to initiate Reset
 */
e_adcs_status adcs_vapi_set_reset(s_adcs_ctx *adcs_ctx,\
        s_adcs_reset *reset_params)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_reset);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != reset_params)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],reset_params,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_RESET,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }

        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to handle basilisk bypass command
 */
e_adcs_status adcs_basilisk_bypass_mode(uint8 *tx_data, uint8 *rx_data,
        uint16 tx_size, uint16 *rx_size)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_ID_ERROR;
    if((NULL != tx_data) && (NULL != rx_data) && (NULL != rx_size))
    {
        // Variable declaration
        uint16 size = 0;
        if((tx_data[2] >= 0) && (tx_data[2] < 128))  ///Api Request
        {
            if(tx_data[2] == 34)
            {
                status = adcs_vapi_thruster_cmd(&adcs_ctx,\
                        (s_adcs_thruster_cmd*)&tx_data[3]);
            }
            else
            {
                size = tx_size - 5;
                // Transmit data through socket for basilisk simulator
                status = adcs_send_cmd(tx_data[2], &tx_data[3],size);
            }
            DEBUG_CPRINT(("Command return status:- %d\n",status));
            rx_data[0] = ADCS_BSK_SOF1;
            rx_data[1] = ADCS_BSK_SOF2;
            rx_data[2] = tx_data[2];
            rx_data[3] = status;
            rx_data[4] = ADCS_BSK_EOF1;
            rx_data[5] = ADCS_BSK_EOF2;
            *rx_size = 6;

        }
        else if((tx_data[2] > 127) && (tx_data[2] <= 254)) ///Api Responce
        {
            // Get buffer length for telemetry Id
            size = adcs_get_tlm_size(tx_data[2]);
            // Receive data through socket for basilisk simulator
            status = adcs_requesttlm(tx_data[2], adcs_bypass_tlm_buffer, size);
            if(OPERATION_SUCCESS == status)
            {
                rx_data[0] = ADCS_BSK_SOF1;
                rx_data[1] = ADCS_BSK_SOF2;
                rx_data[2] = tx_data[2];
                os_memcpy(&rx_data[3], adcs_bypass_tlm_buffer, size);
                rx_data[size + 3] = ADCS_BSK_EOF1;
                rx_data[size + 4] = ADCS_BSK_EOF2;
                *rx_size = size + 5;
                status = OPERATION_SUCCESS;
            }
            else
            {
                // No Action Retun failure
            }

        }
        else
        {
            /**
             *  TC or TM id cannot be greater than 255 for adcs
             *  Return the status as TC_TM_ERROR
             */
        }
    }
    else
    {
        // No Action Retun failure
    }

    return status;
}

/**
 * @brief Function to set moment of inertia
 */
e_adcs_status adcs_vapi_set_mom_interia(s_adcs_ctx *adcs_ctx,\
        s_adcs_moi *moi_params)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_moi);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != moi_params)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],moi_params,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_MOI,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Magnetometer mode
 */
e_adcs_status adcs_vapi_set_magnetometer_mode(s_adcs_ctx *adcs_ctx,\
        uint8_t magmtr_mode)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(magmtr_mode);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // Copy data to api_buffer
        os_memcpy(&api_buffer[0],&magmtr_mode,data_len);

        // Transmit data through socket for basilisk simulator
        status = adcs_send_cmd(API_REQ_MAGMTR_MODE_OPER,api_buffer,\
                data_len);
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Gyro configuration
 */
e_adcs_status adcs_vapi_set_gyro_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_gyro_cfg *gyro_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_gyro_cfg);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != gyro_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],gyro_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_GYRO_CFG,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set CSS configuration
 */
e_adcs_status adcs_vapi_set_css_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_css_cfg *css_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_css_cfg);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != css_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],css_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_CSS_CFG,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Star Tracker configuration
 */
e_adcs_status adcs_vapi_set_star_trkr_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_star_trkr_cfg *star_trkr_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_star_trkr_cfg);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != star_trkr_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],star_trkr_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_STAR_TRAC_CFG,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Magnetometer configuration
 */
e_adcs_status adcs_vapi_set_mgmtr_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_mgmtr_cfg *mgmtr_cfg_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_mgmtr_cfg);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != mgmtr_cfg_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],mgmtr_cfg_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_MAGMTR_CFG,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Redundant Magnetometer configuration
 */
e_adcs_status adcs_vapi_set_red_mgmtr_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_mgmtr_cfg *red_mgmtr_cfg_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_mgmtr_cfg);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != red_mgmtr_cfg_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],red_mgmtr_cfg_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_REDUN_MAGMTR_CFG,api_buffer,\
            data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Magnetometer boom
 */
e_adcs_status adcs_vapi_set_mgmtr_boom(s_adcs_ctx *adcs_ctx,\
        s_adcs_mgmtr_boom *mgmtr_boom_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_mgmtr_boom);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != mgmtr_boom_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],mgmtr_boom_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_MAG_BOOM,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Magnetorquer output
 */
e_adcs_status adcs_vapi_set_mgntrqr_out(s_adcs_ctx *adcs_ctx,\
        s_adcs_mgntrqr_out *mgntrqr_out_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_mgntrqr_out);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != mgntrqr_out_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],mgntrqr_out_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_MGNTRQR_OUT,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Reaction wheel speed
 */
e_adcs_status adcs_vapi_set_rw_speed(s_adcs_ctx *adcs_ctx,\
        uint8 rw_id, s_adcs_rw_speed *rw_speed)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;

        // value assignment to variables
        data_len = sizeof(s_adcs_rw_speed) + sizeof(rw_id);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != rw_speed)
        {
            // Assign RW Count
            api_buffer[0] = rw_id;
            // Copy data to api_buffer
            os_memcpy(&api_buffer[1], rw_speed, sizeof(s_adcs_rw_speed));
            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_RW_SPEED,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Magnetorquer configuration
 */
e_adcs_status adcs_vapi_set_mgntrqr_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_mgntrqr_cfg *mgntrqr_cfg_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_mgntrqr_cfg);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != mgntrqr_cfg_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],mgntrqr_cfg_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_MGNTRQR_CFG,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Reaction wheel configuration
 */
e_adcs_status adcs_vapi_set_rw_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_rw_cfg *rw_cfg_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_rw_cfg);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != rw_cfg_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],rw_cfg_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_RW_CFG,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Detumble control parameters
 */
e_adcs_status adcs_vapi_set_detumble_ctrl(s_adcs_ctx *adcs_ctx,\
        s_adcs_detumble_ctrl *detumble_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_detumble_ctrl);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != detumble_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],detumble_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_DETUMBLE_CTRL,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Y axis Reaction wheel control
 */
e_adcs_status adcs_vapi_set_y_rw_ctrl(s_adcs_ctx *adcs_ctx,\
        s_adcs_y_rw_ctrl *y_rw_ctrl)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_y_rw_ctrl);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != y_rw_ctrl)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],y_rw_ctrl,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_Y_RW_CTRL,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Z axis Reaction wheel control
 */
e_adcs_status adcs_vapi_set_z_rw_ctrl(s_adcs_ctx *adcs_ctx,\
        s_adcs_z_rw_ctrl *z_rw_ctrl)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_z_rw_ctrl);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != z_rw_ctrl)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],z_rw_ctrl,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_Z_RW_CTRL,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Reaction wheel control
 */
e_adcs_status adcs_vapi_set_rw_ctrl(s_adcs_ctx *adcs_ctx,\
        s_adcs_rw_ctrl *rw_ctrl)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_rw_ctrl);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != rw_ctrl)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],rw_ctrl,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_RW_CTRL,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set tracking control gain
 */
e_adcs_status adcs_vapi_set_trck_ctrl_gain(s_adcs_ctx *adcs_ctx,\
        s_adcs_trck_ctrl_gain *trck_ctrl_gain)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_trck_ctrl_gain);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != trck_ctrl_gain)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],trck_ctrl_gain,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_TRCK_CTRL_GAIN,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set attitude angle parameters
 */
e_adcs_status adcs_vapi_set_attitude_angle(s_adcs_ctx *adcs_ctx,\
        s_adcs_attitude_angl *att_angle)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_attitude_angl);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != att_angle)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],att_angle,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_ATTITUDE_ANGL,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set target tracking parameters
 */
e_adcs_status adcs_vapi_set_trgt_trck(s_adcs_ctx *adcs_ctx,\
        s_adcs_trck_target *trck_trgt_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_trck_target);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != trck_trgt_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],trck_trgt_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_TRCK_TARGET,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set inertial reference
 */
e_adcs_status adcs_vapi_set_inrt_ref(s_adcs_ctx *adcs_ctx,\
        s_adcs_inrt_ref *inrt_ref_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_inrt_ref);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != inrt_ref_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],inrt_ref_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_INRTL_REF,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set estimation mode
 */
e_adcs_status adcs_vapi_set_est_mode(s_adcs_ctx *adcs_ctx,\
        s_adcs_est_mode *est_mode)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_est_mode);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != est_mode)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],est_mode,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_EST_MODE,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set estimation parameters
 */
e_adcs_status adcs_vapi_set_est_param(s_adcs_ctx *adcs_ctx,\
        s_adcs_est_param *est_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_est_param);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != est_param)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],est_param,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_EST_PARAM,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Fine sun sensor configuration
 */
e_adcs_status adcs_vapi_set_fss_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_fss_cfg *fss_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_fss_cfg);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != fss_cfg)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],fss_cfg,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_FSS_CFG,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to set Nadir configuration
 */
e_adcs_status adcs_vapi_set_nadir_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_nadir_cfg *nadir_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *api_buffer = NULL;
        
        // value assignment to variables
        data_len = sizeof(s_adcs_nadir_cfg);

        // Memory allocation for payload
        api_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != nadir_cfg)
        {
            // Copy data to api_buffer
            os_memcpy(&api_buffer[0],nadir_cfg,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_NADIR_CFG,api_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }
        // Free allocated memory
        os_free(api_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to config Thruster command
 */
e_adcs_status adcs_vapi_thruster_cmd(s_adcs_ctx *adcs_ctx,
        s_adcs_thruster_cmd *thruster_cmd)
{
    e_adcs_status status = OPERATION_FAILURE;
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;
        uint8 *data_buffer = NULL;

        // value assignment to variables
        data_len = sizeof(s_adcs_thruster_cmd);

        // Memory allocation
        data_buffer = (uint8*) os_malloc(data_len);

        // To verify valid payload present before copying to frame
        if(NULL != thruster_cmd)
        {
            if(thruster_cmd->thruster_state == 1)
            {
                eps_ctrl_en_chnl(HW_PROP_UNIT_THRUSTER, PWR_ON);
                if(thruster_enb_timer == NULL)
                {
                    os_timer_create(&thruster_enb_timer,"thruster_enb_timeout",\
                            ONESHOT,thruster_enb_timeout_cb,NULL);
                    os_delay(100);
                }
                else
                {
                }
                os_timer_start(thruster_enb_timer,\
                        (os_tick_time_t)(thruster_cmd->time_out * 1000));
            }
            else
            {
                eps_ctrl_en_chnl(HW_PROP_UNIT_THRUSTER, PWR_OFF);
            }

            // Copy data to data_buffer
            os_memcpy(&data_buffer[0],thruster_cmd,data_len);

            // Transmit data through socket for basilisk simulator
            status = adcs_send_cmd(API_REQ_THRUSTER_CMD,data_buffer,data_len);
        }
        else
        {
            // No Action Retun failure
        }

        // Free allocated memory
        os_free(data_buffer);
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get Identification
 */
e_adcs_status adcs_vapi_get_id(s_adcs_ctx *adcs_ctx,\
        s_adcs_id *id_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_id);

        // To verify valid payload present before copying to frame
        if(NULL != id_param)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_ID, (uint8_t*)id_param,\
            data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get State
 */
e_adcs_status adcs_vapi_get_state(s_adcs_ctx *adcs_ctx,\
        s_adcs_state *crnt_state)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_state);

        // To verify valid payload present before copying to frame
        if(NULL != crnt_state)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_STATE, (uint8_t*)crnt_state,\
            data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get TLE Configuration
 */
e_adcs_status adcs_vapi_get_tle(s_adcs_ctx *adcs_ctx,\
        s_adcs_tle *tle_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_tle);

        // To verify valid payload present before copying to frame
        if(NULL != tle_param)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_TLE, (uint8_t*)tle_param,\
            data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get Moment of inertia Matrix
 */
e_adcs_status adcs_vapi_get_moi(s_adcs_ctx *adcs_ctx,\
        s_adcs_moi *moi_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_moi);

        // To verify valid payload present before copying to frame
        if(NULL != moi_param)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_MOI, (uint8_t*)moi_param,\
            data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get power configuration
 */
e_adcs_status adcs_vapi_get_power(s_adcs_ctx *adcs_ctx,\
        s_adcs_pwr_cmd *pwr_cmd)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_pwr_cmd);

        // To verify valid payload present before copying to frame
        if(NULL != pwr_cmd)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_PWR, (uint8_t*)pwr_cmd,\
            data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get magnetic field vector
 */
e_adcs_status adcs_vapi_get_mag_vector(s_adcs_ctx *adcs_ctx,\
        s_adcs_mag_vector *mag_vector)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_mag_vector);

        // To verify valid payload present before copying to frame
        if(NULL != mag_vector)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_MAG_FIELD_VEC,\
            (uint8_t*)mag_vector, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get CSS vector
 */
e_adcs_status adcs_vapi_get_css_sun_vector(s_adcs_ctx *adcs_ctx,\
        s_adcs_sun_vector *css_sun)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_sun_vector);

        // To verify valid payload present before copying to frame
        if(NULL != css_sun)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_CSS_VEC, (uint8_t*)css_sun,\
            data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get FSS vector
 */
e_adcs_status adcs_vapi_get_fss_sun_vector(s_adcs_ctx *adcs_ctx,\
        s_adcs_sun_vector *fss_sun)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_sun_vector);

        // To verify valid payload present before copying to frame
        if(NULL != fss_sun)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_FSS_VEC, (uint8_t*)fss_sun,\
            data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get Nadir vector
 */
e_adcs_status adcs_vapi_get_nadir_vector(s_adcs_ctx *adcs_ctx,\
        s_adcs_nadir_vector *nadir_vec)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_nadir_vector);

        // To verify valid payload present before copying to frame
        if(NULL != nadir_vec)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_NADIR_VEC, (uint8_t*)nadir_vec,\
            data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get Sensor rate
 */
e_adcs_status adcs_vapi_get_sensor_rate(s_adcs_ctx *adcs_ctx,\
        s_adcs_rate_sens *sens_rate)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_rate_sens);

        // To verify valid payload present before copying to frame
        if(NULL != sens_rate)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_SENSOR_RATE,\
            (uint8_t*)sens_rate, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get star tracker body vector
 */
e_adcs_status adcs_vapi_get_star_body(s_adcs_ctx *adcs_ctx, uint8_t star_id,\
        s_adcs_star_trkr_body *star_body)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_star_trkr_body);

        // To verify valid payload present before copying to frame
        if(NULL != star_body)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_STAR_TRKR_BVEC,\
            (uint8_t*)star_body, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get star trackere orbit vector
 */
e_adcs_status adcs_vapi_get_star_orbit(s_adcs_ctx *adcs_ctx, uint8_t star_id,\
        s_adcs_star_trkr_orbit *star_orbit)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_star_trkr_orbit);

        // To verify valid payload present before copying to frame
        if(NULL != star_orbit)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_STAR_TRKR_OVEC,\
            (uint8_t*)star_orbit, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw nadir sensor meaurement
 */
e_adcs_status adcs_vapi_get_raw_nadir(s_adcs_ctx *adcs_ctx,\
        s_adcs_nadir_sens *raw_nadir)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_nadir_sens);

        // To verify valid payload present before copying to frame
        if(NULL != raw_nadir)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_NADIR_SEN,\
            (uint8_t*)raw_nadir, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw fine sun sensor measurement
 */
e_adcs_status adcs_vapi_get_raw_fss(s_adcs_ctx *adcs_ctx,\
        s_adcs_fss_sens *raw_fss)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_fss_sens);

        // To verify valid payload present before copying to frame
        if(NULL != raw_fss)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_FSS_SEN,\
            (uint8_t*)raw_fss, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw magnetometer measurement
 */
e_adcs_status adcs_vapi_get_raw_magmtr(s_adcs_ctx *adcs_ctx,\
        s_adcs_raw_mgmtr *raw_mgmtr)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_raw_mgmtr);

        // To verify valid payload present before copying to frame
        if(NULL != raw_mgmtr)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_MAGMTR,\
            (uint8_t*)raw_mgmtr, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw GPS staus
 */
e_adcs_status adcs_vapi_get_raw_gps_status(s_adcs_ctx *adcs_ctx,\
        s_adcs_gps_s *raw_gps)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_gps_s);

        // To verify valid payload present before copying to frame
        if(NULL != raw_gps)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_GPS_STS,\
            (uint8_t*)raw_gps, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw GPS time
 */
e_adcs_status adcs_vapi_get_raw_gps_time(s_adcs_ctx *adcs_ctx,\
        s_adcs_gps_time *raw_gps_time)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_gps_time);

        // To verify valid payload present before copying to frame
        if(NULL != raw_gps_time)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_GPS_TIME,\
            (uint8_t*)raw_gps_time, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw GPS X axis
 */
e_adcs_status adcs_vapi_get_raw_gps_x(s_adcs_ctx *adcs_ctx,\
        s_adcs_gps_x *raw_gps_x)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_gps_x);

        // To verify valid payload present before copying to frame
        if(NULL != raw_gps_x)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_GPS_X,\
            (uint8_t*)raw_gps_x, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw GPS Y axis
 */
e_adcs_status adcs_vapi_get_raw_gps_y(s_adcs_ctx *adcs_ctx,\
        s_adcs_gps_y *raw_gps_y)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_gps_y);

        // To verify valid payload present before copying to frame
        if(NULL != raw_gps_y)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_GPS_Y,\
            (uint8_t*)raw_gps_y, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw GPS Z axis
 */
e_adcs_status adcs_vapi_get_raw_gps_z(s_adcs_ctx *adcs_ctx,\
        s_adcs_gps_z *raw_gps_z)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_gps_z);

        // To verify valid payload present before copying to frame
        if(NULL != raw_gps_z)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_GPS_Z,\
            (uint8_t*)raw_gps_z, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get star magnitude
 */
e_adcs_status adcs_vapi_get_star_magnitude(s_adcs_ctx *adcs_ctx,\
        s_adcs_star_trkr_mag *star_trkr_mag)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_star_trkr_mag);

        // To verify valid payload present before copying to frame
        if(NULL != star_trkr_mag)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_STAR_MAG,\
            (uint8_t*)star_trkr_mag, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get star performance
 */
e_adcs_status adcs_vapi_get_star_performance(s_adcs_ctx *adcs_ctx,\
        s_adcs_star_trkr_perform *star_perform)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_star_trkr_perform);

        // To verify valid payload present before copying to frame
        if(NULL != star_perform)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_STAR_PERFORM,\
            (uint8_t*)star_perform, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get star timing
 */
e_adcs_status adcs_vapi_get_star_timing(s_adcs_ctx *adcs_ctx,\
        s_adcs_star_trkr_timing *star_timing)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_star_trkr_timing);

        // To verify valid payload present before copying to frame
        if(NULL != star_timing)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_STAR_TIMING,\
            (uint8_t*)star_timing, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw sensor measurement
 */
e_adcs_status adcs_vapi_get_raw_sensor_measure(s_adcs_ctx *adcs_ctx,\
        s_adcs_raw_sensor *raw_sensor)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_raw_sensor);

        // To verify valid payload present before copying to frame
        if(NULL != raw_sensor)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_SENS,\
            (uint8_t*)raw_sensor, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw GPS measurement
 */
e_adcs_status adcs_vapi_get_raw_gps_measure(s_adcs_ctx *adcs_ctx,\
        s_adcs_raw_gps *raw_gps)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_raw_gps);

        // To verify valid payload present before copying to frame
        if(NULL != raw_gps)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_GPS,\
            (uint8_t*)raw_gps, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw star tracker measurement
 */
e_adcs_status adcs_vapi_get_raw_star_measure(s_adcs_ctx *adcs_ctx,\
        s_adcs_raw_star_trkr *raw_star_measure)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_raw_star_trkr);

        // To verify valid payload present before copying to frame
        if(NULL != raw_star_measure)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_STAR_TRAC,\
            (uint8_t*)raw_star_measure, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw star tracker data
 */
e_adcs_status adcs_vapi_get_raw_star_data(s_adcs_ctx *adcs_ctx,uint8_t star_id,
        s_adcs_raw_star_trkr_data *raw_star_data)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_raw_star_trkr);

        // To verify valid payload present before copying to frame
        if(NULL != raw_star_data)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_STAR_RDATA,\
            (uint8_t*)raw_star_data, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw secondary magnetometer measurement
 */
e_adcs_status adcs_vapi_get_sec_raw_magmtr_measure(s_adcs_ctx *adcs_ctx,\
        s_adcs_raw_mgmtr *raw_mgmtr)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_raw_mgmtr);

        // To verify valid payload present before copying to frame
        if(NULL != raw_mgmtr)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_SEC_MAGMTR,\
            (uint8_t*)raw_mgmtr, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get raw sensor rates
 */
e_adcs_status adcs_vapi_get_raw_rates(s_adcs_ctx *adcs_ctx,\
        s_adcs_raw_rate_sens *raw_rates)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_raw_rate_sens);

        // To verify valid payload present before copying to frame
        if(NULL != raw_rates)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RAW_SENS_RATE,\
            (uint8_t*)raw_rates, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get star tracker estimation rate
 */
e_adcs_status adcs_vapi_get_star_est_rate(s_adcs_ctx *adcs_ctx,\
        s_adcs_star_est_rate *star_est_rate)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_star_est_rate);

        // To verify valid payload present before copying to frame
        if(NULL != star_est_rate)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_STAR_EST_RATE,\
            (uint8_t*)star_est_rate, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get sensor current
 */
e_adcs_status adcs_vapi_get_sensor_current(s_adcs_ctx *adcs_ctx,\
        s_adcs_sens_cur *sens_current)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_sens_cur);

        // To verify valid payload present before copying to frame
        if(NULL != sens_current)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_SENS_CUR,\
            (uint8_t*)sens_current, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get adcs consumed current measurement
 */
e_adcs_status adcs_vapi_get_con_current_measure(s_adcs_ctx *adcs_ctx,\
        s_adcs_current *con_current_measure)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_current);

        // To verify valid payload present before copying to frame
        if(NULL != con_current_measure)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_CON_CUR,\
            (uint8_t*)con_current_measure, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get reaction wheel current
 */
e_adcs_status adcs_vapi_get_rw_current(s_adcs_ctx *adcs_ctx,\
        uint8 rw_cnt, s_adcs_rw_cur *rw_current)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 tm_data_len = 0;
        uint8* tm_data_buffer = NULL;
        uint8* data_buffer = NULL;
        uint16 data_len = 0;

        // value assignment to variables
        tm_data_len = (sizeof(s_adcs_rw_cur) * rw_cnt) + sizeof(rw_cnt);
        data_len = sizeof(rw_cnt) + sizeof(uint8);

        // Allocate memory
        data_buffer = (uint8*)os_malloc(data_len);
        tm_data_buffer = (uint8*)os_malloc(tm_data_len);

        // To verify valid payload present before copying to frame
        if(NULL != rw_current && NULL != data_buffer && NULL != tm_data_buffer)
        {
            data_buffer[0] = API_RESP_RW_CUR;
            data_buffer[1] = rw_cnt;

            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm_wt_data(data_buffer, data_len,\
                    (uint8_t*)tm_data_buffer, tm_data_len);
            os_memcpy(rw_current, &tm_data_buffer[1], tm_data_len-1);
        }
        else
        {
            // No Action Retun failure
        }

        // Free allocated memory
        if(NULL != data_buffer && NULL != tm_data_buffer)
        {
            os_free(data_buffer);
            os_free(tm_data_buffer);
        }
        else
        {
            // No Action Retun failure
        }
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get adcs temperature
 */
e_adcs_status adcs_vapi_get_temperature(s_adcs_ctx *adcs_ctx,\
        s_adcs_temperature *temperature)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_temperature);

        // To verify valid payload present before copying to frame
        if(NULL != temperature)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_TEMP,\
            (uint8_t*)temperature, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get rate sensor temperature
 */
e_adcs_status adcs_vapi_get_rate_sensor_temperature(s_adcs_ctx *adcs_ctx,\
        s_adcs_rate_temperature *rate_sens_temperature)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_rate_temperature);

        // To verify valid payload present before copying to frame
        if(NULL != rate_sens_temperature)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_SENS_RATE_TEMP,\
            (uint8_t*)rate_sens_temperature, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get power and temperature measurement
 */
e_adcs_status adcs_vapi_get_power_temperature(s_adcs_ctx *adcs_ctx,\
        s_adcs_cur_temp *power_temperature)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_cur_temp);

        // To verify valid payload present before copying to frame
        if(NULL != power_temperature)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_POW_TEMP,\
            (uint8_t*)power_temperature, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get gyro configuration
 */
e_adcs_status adcs_vapi_get_gyro_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_gyro_cfg *gyro_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_gyro_cfg);

        // To verify valid payload present before copying to frame
        if(NULL != gyro_cfg)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_GYRO_CFG,\
            (uint8_t*)gyro_cfg, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get star tracker configuration
 */
e_adcs_status adcs_vapi_get_star_trkr_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_star_trkr_cfg *star_trkr_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_star_trkr_cfg);

        // To verify valid payload present before copying to frame
        if(NULL != star_trkr_cfg)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_STAR_TRAC_CFG,\
            (uint8_t*)star_trkr_cfg, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get magnetometer configuration
 */
e_adcs_status adcs_vapi_get_mgmtr_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_mgmtr_cfg *mgmtr_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_mgmtr_cfg);

        // To verify valid payload present before copying to frame
        if(NULL != mgmtr_cfg)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_MAGMTR_CFG,\
            (uint8_t*)mgmtr_cfg, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get coarse sun sensor configuration
 */
e_adcs_status adcs_vapi_get_css_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_css_cfg *css_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_css_cfg);

        // To verify valid payload present before copying to frame
        if(NULL != css_cfg)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_CSS_CFG,\
            (uint8_t*)css_cfg, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get fine sun sensor configuration
 */
e_adcs_status adcs_vapi_get_fss_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_fss_cfg *fss_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_fss_cfg);

        // To verify valid payload present before copying to frame
        if(NULL != fss_cfg)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_FSS_CFG,\
            (uint8_t*)fss_cfg, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get nadir configuration
 */
e_adcs_status adcs_vapi_get_nadir_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_nadir_cfg *nadir_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_nadir_cfg);

        // To verify valid payload present before copying to frame
        if(NULL != nadir_cfg)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_NADIR_CFG,\
            (uint8_t*)nadir_cfg, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get redudent magnetometer configuration
 */
e_adcs_status adcs_vapi_get_red_mgmtr_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_mgmtr_cfg *red_magmtr_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_mgmtr_cfg);

        // To verify valid payload present before copying to frame
        if(NULL != red_magmtr_cfg)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RED_MAGMTR_CFG,\
            (uint8_t*)red_magmtr_cfg, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get magnetorquer configuration
 */
e_adcs_status adcs_vapi_get_mgntrqr_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_mgntrqr_cfg *mgntrqr_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_mgntrqr_cfg);

        // To verify valid payload present before copying to frame
        if(NULL != mgntrqr_cfg)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_MGNTRQR_CFG,\
            (uint8_t*)mgntrqr_cfg, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get reaction wheel configuration
 */
e_adcs_status adcs_vapi_get_rw_cfg(s_adcs_ctx *adcs_ctx,\
        s_adcs_rw_cfg *rw_cfg)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_rw_cfg);

        // To verify valid payload present before copying to frame
        if(NULL != rw_cfg)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RW_CFG,\
            (uint8_t*)rw_cfg, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get detumble control parameters
 */
e_adcs_status adcs_vapi_get_detumble_param(s_adcs_ctx *adcs_ctx,\
        s_adcs_detumble_ctrl *detumble_ctrl_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_detumble_ctrl);

        // To verify valid payload present before copying to frame
        if(NULL != detumble_ctrl_param)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_DETUMBLE_CTRL,\
            (uint8_t*)detumble_ctrl_param, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get Y reaction wheel control
 */
e_adcs_status adcs_vapi_get_y_rw_ctrl(s_adcs_ctx *adcs_ctx,\
        s_adcs_y_rw_ctrl *y_rw_ctrl)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_y_rw_ctrl);

        // To verify valid payload present before copying to frame
        if(NULL != y_rw_ctrl)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_Y_RW_CTRL,\
            (uint8_t*)y_rw_ctrl, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get reaction wheel control
 */
e_adcs_status adcs_vapi_get_rw_ctrl(s_adcs_ctx *adcs_ctx,\
        s_adcs_rw_ctrl *rw_ctrl)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_rw_ctrl);

        // To verify valid payload present before copying to frame
        if(NULL != rw_ctrl)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_RW_CTRL, (uint8_t*)rw_ctrl,\
            data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get tracking control gain
 */
e_adcs_status adcs_vapi_get_trck_ctrl_gain(s_adcs_ctx *adcs_ctx,\
        s_adcs_trck_ctrl_gain *trck_ctrl_gain)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_trck_ctrl_gain);

        // To verify valid payload present before copying to frame
        if(NULL != trck_ctrl_gain)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_TRCK_CTRL_GAIN,\
            (uint8_t*)trck_ctrl_gain, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get attitude angle
 */
e_adcs_status adcs_vapi_get_attitude(s_adcs_ctx *adcs_ctx,\
        s_adcs_attitude_angl *attitude_angle)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_attitude_angl);

        // To verify valid payload present before copying to frame
        if(NULL != attitude_angle)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_ATTITUDE_ANGL,\
            (uint8_t*)attitude_angle, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get target tracking parameters
 */
e_adcs_status adcs_vapi_get_target_track(s_adcs_ctx *adcs_ctx,\
        s_adcs_trck_target *trck_trget)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_trck_target);

        // To verify valid payload present before copying to frame
        if(NULL != trck_trget)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_TRCK_TARGET,\
            (uint8_t*)trck_trget, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get inertial reference
 */
e_adcs_status adcs_vapi_get_inertial_ref(s_adcs_ctx *adcs_ctx,\
        s_adcs_inrt_ref *inrt_ref)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_inrt_ref);

        // To verify valid payload present before copying to frame
        if(NULL != inrt_ref)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_INRTL_REF,\
            (uint8_t*)inrt_ref, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get estimation paremeters
 */
e_adcs_status adcs_vapi_get_est_param(s_adcs_ctx *adcs_ctx,\
        s_adcs_est_param *est_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_est_param);

        // To verify valid payload present before copying to frame
        if(NULL != est_param)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_EST_PARAM,\
            (uint8_t*)est_param, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get sattelite position ECI
 */
e_adcs_status adcs_vapi_get_eci_postition(s_adcs_ctx *adcs_ctx,\
        s_adcs_eci_position *eci_position)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_eci_position);

        // To verify valid payload present before copying to frame
        if(NULL != eci_position)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_POS_ECI,\
            (uint8_t*)eci_position, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get sattelite velocity
 */
e_adcs_status adcs_vapi_get_sat_velocity(s_adcs_ctx *adcs_ctx,\
        s_adcs_eci_velocity *eci_velocity)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_eci_velocity);

        // To verify valid payload present before copying to frame
        if(NULL != eci_velocity)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_VEL,\
            (uint8_t*)eci_velocity, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get sattelte position LLH
 */
e_adcs_status adcs_vapi_get_llh_psition(s_adcs_ctx *adcs_ctx,\
        s_adcs_trck_target *llh_position)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_trck_target);

        // To verify valid payload present before copying to frame
        if(NULL != llh_position)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_POS_LLH,\
            (uint8_t*)llh_position, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get estimation rates
 */
e_adcs_status adcs_vapi_get_est_rate(s_adcs_ctx *adcs_ctx,\
        s_adcs_est_rate *est_rate)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_est_rate);

        // To verify valid payload present before copying to frame
        if(NULL != est_rate)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_EST_RATE,\
            (uint8_t*)est_rate, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get estimated quaternion
 */
e_adcs_status adcs_vapi_get_est_qutrn(s_adcs_ctx *adcs_ctx,\
        s_adcs_est_qutrn *est_qutrn)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_est_qutrn);

        // To verify valid payload present before copying to frame
        if(NULL != est_qutrn)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_EST_QUTRN,\
            (uint8_t*)est_qutrn, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get ECEF sattelite position
 */
e_adcs_status adcs_vapi_get_ecef_position(s_adcs_ctx *adcs_ctx,\
        s_adcs_eci_position *ecef_poistion)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_eci_position);

        // To verify valid payload present before copying to frame
        if(NULL != ecef_poistion)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_ECEF_POS,\
            (uint8_t*)ecef_poistion, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get moduled magnetic field vector
 */
e_adcs_status adcs_vapi_get_mog_mag_vector(s_adcs_ctx *adcs_ctx,\
        s_adcs_mag_vector *mod_mag_vector)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_mag_vector);

        // To verify valid payload present before copying to frame
        if(NULL != mod_mag_vector)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_MODL_MAG,\
            (uint8_t*)mod_mag_vector, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get moduled sun vector
 */
e_adcs_status adcs_vapi_get_mod_sun_vector(s_adcs_ctx *adcs_ctx,\
        s_adcs_sun_vector *mod_sun_vector)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_sun_vector);

        // To verify valid payload present before copying to frame
        if(NULL != mod_sun_vector)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_MODL_SUN,\
            (uint8_t*)mod_sun_vector, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get estimated gyro measurement
 */
e_adcs_status adcs_vapi_get_est_gyro_measure(s_adcs_ctx *adcs_ctx,\
        s_adcs_est_gyro *est_gyro)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_est_gyro);

        // To verify valid payload present before copying to frame
        if(NULL != est_gyro)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_EST_GYRO,\
            (uint8_t*)est_gyro, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get estimation innovation
 */
e_adcs_status adcs_vapi_get_est_innovation(s_adcs_ctx *adcs_ctx,\
        s_adcs_est_innovn *est_innovn)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_est_innovn);

        // To verify valid payload present before copying to frame
        if(NULL != est_innovn)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_EST_INNOVN,\
            (uint8_t*)est_innovn, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get quaternion error vector
 */
e_adcs_status adcs_vapi_get_qutrn_error(s_adcs_ctx *adcs_ctx,\
        s_adcs_qutr_error *qutrn_error)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_qutr_error);

        // To verify valid payload present before copying to frame
        if(NULL != qutrn_error)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_QUTR_ERROR,\
            (uint8_t*)qutrn_error, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get quaternion covariance
 */
e_adcs_status adcs_vapi_get_qutrn_covr(s_adcs_ctx *adcs_ctx,\
        s_adcs_qutr_covr *qutrn_covr)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_qutr_covr);

        // To verify valid payload present before copying to frame
        if(NULL != qutrn_covr)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_QUTR_COVR,\
            (uint8_t*)qutrn_covr, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get angular rate covariance
 */
e_adcs_status adcs_vapi_get_ang_rate_covr(s_adcs_ctx *adcs_ctx,\
        s_adcs_angl_rate_covr *ang_rate_covr)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(s_adcs_angl_rate_covr);

        // To verify valid payload present before copying to frame
        if(NULL != ang_rate_covr)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_ANGL_COVR,\
            (uint8_t*)ang_rate_covr, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get Commanded Reaction wheel speed
 */
e_adcs_status adcs_vapi_get_rw_speed_cmd(s_adcs_ctx *adcs_ctx,\
        uint8 rw_cnt, s_adcs_rw_speed *rw_cmd)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 tm_data_len = 0;
        uint8* tm_data_buffer = NULL;
        uint8* data_buffer = NULL;
        uint16 data_len = 0;

        // value assignment to variables
        tm_data_len = sizeof(rw_cnt) + (sizeof(s_adcs_rw_speed) * rw_cnt);
        data_len = sizeof(rw_cnt) + sizeof(uint8);

        // Allocate memory
        data_buffer = (uint8*)os_malloc(data_len);
        tm_data_buffer = (uint8*)os_malloc(tm_data_len);

        // To verify valid payload present before copying to frame
        if(NULL != rw_cmd && NULL != data_buffer && NULL != tm_data_buffer)
        {
            data_buffer[0] = API_RESP_RW_SPEED;
            data_buffer[1] = rw_cnt;

            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm_wt_data(data_buffer, data_len,\
                    tm_data_buffer, tm_data_len);
            os_memcpy(rw_cmd, &tm_data_buffer[1], tm_data_len-1);
        }
        else
        {
            // No Action Retun failure
        }

        // Free allocated memory
        if(NULL != data_buffer && NULL != tm_data_buffer)
        {
            os_free(data_buffer);
            os_free(tm_data_buffer);
        }
        else
        {
            // No Action Retun failure
        }
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get Measured Reaction wheel speed
 */
e_adcs_status adcs_vapi_get_rw_speed_measure(s_adcs_ctx *adcs_ctx,\
        uint8 rw_cnt,  s_adcs_rw_speed *rw_measure)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 tm_data_len = 0;
        uint8* tm_data_buffer = NULL;
        uint8* data_buffer = NULL;
        uint16 data_len = 0;

        // value assignment to variables
        tm_data_len = sizeof(rw_cnt) + (sizeof(s_adcs_rw_speed) * rw_cnt);
        data_len = sizeof(rw_cnt) + sizeof(uint8);

        // Allocate memory
        data_buffer = (uint8*)os_malloc(data_len);
        tm_data_buffer = (uint8*)os_malloc(tm_data_len);

        // To verify valid payload present before copying to frame
        if(NULL != rw_measure && NULL != data_buffer && NULL != tm_data_buffer)
        {
            data_buffer[0] = API_RESP_RW_SPEED_MEASURE;
            data_buffer[1] = rw_cnt;

            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm_wt_data(data_buffer, data_len,\
                    tm_data_buffer, tm_data_len);
            os_memcpy(rw_measure, &tm_data_buffer[1], tm_data_len-1);
        }
        else
        {
            // No Action Retun failure
        }

        // Free allocated memory
        if(NULL != data_buffer && NULL != tm_data_buffer)
        {
            os_free(data_buffer);
            os_free(tm_data_buffer);
        }
        else
        {
            // No Action Retun failure
        }
    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function to get Control Mode
 */
e_adcs_status adcs_vapi_get_control_mode(s_adcs_ctx *adcs_ctx,\
        uint8 *cntrl_mode, u_control_mode_param *control_mode_param)
{
    // Return variable assigning to FAIL status
    e_adcs_status status = API_FAIL;

    // ADCS Context verification
    if(NULL != adcs_ctx)
    {
        // Variable declaration
        uint16 data_len = 0;

        // value assignment to variables
        data_len = sizeof(u_control_mode_param) + sizeof(uint8);

        // To verify valid payload present before copying to frame
        if(NULL != cntrl_mode)
        {
            // Request Telemetry data through socket from basilisk simulator
            status = adcs_requesttlm(API_RESP_CTRL_MODE,\
            (uint8_t*)cntrl_mode, data_len);
        }
        else
        {
            // No Action Retun failure
        }

    }
    else
    {
        // No Action Retun failure
    }
    return status;
}

/**
 * @brief Function Returns the length of telemetry by Id.
 */
int16_t bsk_get_tlm_len(uint8_t tlm_id)
{
    int16_t length = 0;
    switch(tlm_id)
    {
        case API_RESP_ID:                // Get Identification
        {
            length = sizeof(s_adcs_id);
        }
        break;
        case API_RESP_STATE:             // Get ADCS state
        {
            length = sizeof(s_adcs_state);
        }
        break;
        case API_RESP_TLE:               // Get TLE
        {
            length = sizeof(s_adcs_tle);
        }
        break;
        case API_RESP_MOI:               // Get moment of inetria
        {
            length = sizeof(s_adcs_moi);
        }
        break;
        case API_RESP_PWR:               // Get power configuration
        {
            length = sizeof(s_adcs_pwr_cmd);
        }
        break;
        case API_RESP_MAG_FIELD_VEC:     // Get magnetic field vector
        {
            length = sizeof(s_adcs_mag_vector);
        }
        break;
        case API_RESP_CSS_VEC:           // Get CSS vector
        {
            length = sizeof(s_adcs_sun_vector);
        }
        break;
        case API_RESP_FSS_VEC:           // Get FSS vector
        {
            length = sizeof(s_adcs_sun_vector);
        }
        break;
        case API_RESP_NADIR_VEC:         // Get nadir vector
        {
            length = sizeof(s_adcs_nadir_vector);
        }
        break;
        case API_RESP_SENSOR_RATE:       // Get sensor rate
        {
            length = sizeof(s_adcs_rate_sens);
        }
        break;
        case API_RESP_STAR_TRKR_BVEC:    // Get star tracker body vector
        {
            length = sizeof(s_adcs_star_trkr_body);
        }
        break;
        case API_RESP_STAR_TRKR_OVEC:    // Get star trackere orbit vector
        {
            length = sizeof(s_adcs_star_trkr_orbit);
        }
        break;
        case API_RESP_RAW_NADIR_SEN:     // Get raw nadir sensor meaurement
        {
            length = sizeof(s_adcs_nadir_sens);
        }
        break;
        case API_RESP_RAW_FSS_SEN:  // Get raw fine sun sensor measurement
        {
            length = sizeof(s_adcs_fss_sens);
        }
        break;
        case API_RESP_RAW_MAGMTR:   // Get raw magnetometer measurement
        {
            length = sizeof(s_adcs_raw_mgmtr);
        }
        break;
        case API_RESP_RAW_GPS_STS:       // Get raw GPS staus
        {
            length = sizeof(s_adcs_gps_s);
        }
        break;
        case API_RESP_RAW_GPS_TIME:      // Get raw GPS time
        {
            length = sizeof(s_adcs_gps_time);
        }
        break;
        case API_RESP_RAW_GPS_X:         // Get raw GPS X axis
        {
            length = sizeof(s_adcs_gps_x);
        }
        break;
        case API_RESP_RAW_GPS_Y:         // Get raw GPS Y axis
        {
            length = sizeof(s_adcs_gps_y);
        }
        break;
        case API_RESP_RAW_GPS_Z:         // Get raw GPS Z axis
        {
            length = sizeof(s_adcs_gps_z);
        }
        break;
        case API_RESP_STAR_MAG:          // Get star magnitude
        {
            length = sizeof(s_adcs_star_trkr_mag);
        }
        break;
        case API_RESP_STAR_PERFORM:      // Get star performance
        {
            length = sizeof(s_adcs_star_trkr_perform);
        }
        break;
        case API_RESP_STAR_TIMING:       // Get star timing
        {
            length = sizeof(s_adcs_star_trkr_timing);
        }
        break;
        case API_RESP_RAW_SENS:          // Get raw sensor measurement
        {
            length = sizeof(s_adcs_raw_sensor);
        }
        break;
        case API_RESP_RAW_GPS:           // Get raw GPS measurement
        {
            length = sizeof(s_adcs_raw_gps);
        }
        break;
        case API_RESP_RAW_STAR_TRAC:    // Get raw star tracker measurement
        {
            length = sizeof(s_adcs_raw_star_trkr);
        }
        break;
        case API_RESP_STAR_RDATA:        // Get raw star tracker data
        {
            length = sizeof(s_adcs_raw_star_trkr);
        }
        break;
        case API_RESP_RAW_SEC_MAGMTR:    // Get raw secondary magnetometer
        {
            length = sizeof(s_adcs_raw_mgmtr);
        }
        break;
        case API_RESP_RAW_SENS_RATE:     // Get raw sensor rates
        {
            length = sizeof(s_adcs_raw_rate_sens);
        }
        break;
        case API_RESP_STAR_EST_RATE:    // Get star tracker estimation rate
        {
            length = sizeof(s_adcs_star_est_rate);
        }
        break;
        case API_RESP_SENS_CUR:          // Get sensor current
        {
            length = sizeof(s_adcs_sens_cur);
        }
        break;
        case API_RESP_CON_CUR:  // Get adcs consumed current measurement
        {
            length = sizeof(s_adcs_current);
        }
        break;
        case API_RESP_RW_CUR:            // Get reaction wheel current
        {
            length = sizeof(s_adcs_rw_cur);
        }
        break;
        case API_RESP_TEMP:              // Get adcs temperature
        {
            length = sizeof(s_adcs_temperature);
        }
        break;
        case API_RESP_SENS_RATE_TEMP:    // Get rate sensor temperature
        {
            length = sizeof(s_adcs_rate_temperature);
        }
        break;
        case API_RESP_POW_TEMP:     // Get power and temperature measurement
        {
            length = sizeof(s_adcs_cur_temp);
        }
        break;
        case API_RESP_GYRO_CFG:          // Get gyro configuration
        {
            length = sizeof(s_adcs_gyro_cfg);
        }
        break;
        case API_RESP_STAR_TRAC_CFG:     // Get star tracker configuration
        {
            length = sizeof(s_adcs_star_trkr_cfg);
        }
        break;
        case API_RESP_MAGMTR_CFG:        // Get magnetometer configuration
        {
            length = sizeof(s_adcs_mgmtr_cfg);
        }
        break;
        case API_RESP_CSS_CFG:           // Get CSS configuration
        {
            length = sizeof(s_adcs_css_cfg);
        }
        break;
        case API_RESP_FSS_CFG:           // Get FSS configuration
        {
            length = sizeof(s_adcs_fss_cfg);
        }
        break;
        case API_RESP_NADIR_CFG:         // Get Nadir configuration
        {
            length = sizeof(s_adcs_nadir_cfg);
        }
        break;
        case API_RESP_RED_MAGMTR_CFG:    // Get Redudant magnetometer
        {
            length = sizeof(s_adcs_mgmtr_cfg);
        }
        break;
        case API_RESP_MGNTRQR_CFG:       // Get magnetorquer configuration
        {
            length = sizeof(s_adcs_mgntrqr_cfg);
        }
        break;
        case API_RESP_RW_CFG:           // Get reaction wheel configuration
        {
            length = sizeof(s_adcs_rw_cfg);
        }
        break;
        case API_RESP_DETUMBLE_CTRL:     // Get detumble parameters
        {
            length = sizeof(s_adcs_detumble_ctrl);
        }
        break;
        case API_RESP_Y_RW_CTRL:         // Get Y reaction wheel control
        {
            length = sizeof(s_adcs_y_rw_ctrl);
        }
        break;
        case API_RESP_RW_CTRL:           // Get reaction wheel control
        {
            length = sizeof(s_adcs_rw_ctrl);
        }
        break;
        case API_RESP_TRCK_CTRL_GAIN:    // Get tracking control gain
        {
            length = sizeof(s_adcs_trck_ctrl_gain);
        }
        break;
        case API_RESP_ATTITUDE_ANGL:     // Get attitude angle
        {
            length = sizeof(s_adcs_attitude_angl);
        }
        break;
        case API_RESP_TRCK_TARGET:       // Get target tracking parameters
        {
            length = sizeof(s_adcs_trck_target);
        }
        break;
        case API_RESP_INRTL_REF:         // Get inertial reference
        {
            length = sizeof(s_adcs_inrt_ref);
        }
        break;
        case API_RESP_EST_PARAM:         // Get estimation paremeters
        {
            length = sizeof(s_adcs_est_param);
        }
        break;
        case API_RESP_POS_ECI:           // Get sattelite position ECI
        {
            length = sizeof(s_adcs_eci_position);
        }
        break;
        case API_RESP_VEL:               // Get sattelite velocity
        {
            length = sizeof(s_adcs_eci_velocity);
        }
        break;
        case API_RESP_POS_LLH:           // Get sattelte position LLH
        {
            length = sizeof(s_adcs_trck_target);
        }
        break;
        case API_RESP_EST_RATE:          // Get estimation rates
        {
            length = sizeof(s_adcs_est_rate);
        }
        break;
        case API_RESP_EST_QUTRN:         // Get estimated quaternion
        {
            length = sizeof(s_adcs_est_qutrn);
        }
        break;
        case API_RESP_ECEF_POS:          // Get ECEF sattelite position
        {
            length = sizeof(s_adcs_eci_position);
        }
        break;
        case API_RESP_MODL_MAG:     // Get moduled magnetic field vector
        {
            length = sizeof(s_adcs_mag_vector);
        }
        break;
        case API_RESP_MODL_SUN:          // Get moduled sun vector
        {
            length = sizeof(s_adcs_sun_vector);
        }
        break;
        case API_RESP_EST_GYRO:          // Get estimated gyro measurement
        {
            length = sizeof(s_adcs_est_gyro);
        }
        break;
        case API_RESP_EST_INNOVN:        // Get estimation innovation
        {
            length = sizeof(s_adcs_est_innovn);
        }
        break;
        case API_RESP_QUTR_ERROR:        // Get quaternion error vector
        {
            length = sizeof(s_adcs_qutr_error);
        }
        break;
        case API_RESP_QUTR_COVR:         // Get quaternion covariance
        {
            length = sizeof(s_adcs_qutr_covr);
        }
        break;
        case API_RESP_ANGL_COVR:         // Get angular rate covariance
        {
            length = sizeof(s_adcs_angl_rate_covr);
        }
        break;
        case API_RESP_CTRL_MODE:
        {
            length = 1; 
            length += sizeof(u_control_mode_param);
        }
        break;
        case API_RESP_RW_SPEED:
        {
            length = sizeof(s_adcs_rw_speed);
        }
        break;
        case API_RESP_RW_SPEED_MEASURE:
        {
            length = sizeof(s_adcs_rw_speed);
        }
        break;
        default:
        {
            length = 0;
        }
        break;
    }
    return length;
}
