/**
 * @file obc_icd.h
 *
 * @brief This file contains function prototypes and data definitions that helps
 * to create a OBC application
 */

#ifndef OBC_SAMP_APP_ICD_H_
#define OBC_SAMP_APP_ICD_H_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "ipcc_common.h"
#include "ipcc_lib_common.h"
//#include "comms_al.h"

#ifdef __cplusplus
extern "C" {
#endif
/**@}*/
/**\name C standard macros */
#ifndef NULL
#ifdef __cplusplus
#define NULL                                      0
#else
#define NULL                            ((void *) 0)
#endif
#endif


#define OBC_SOCK_RX_PORT_ADDR   5004
#define OBC_SOCK_RX_IP_ADDR     "192.168.10.2"

#define OBC_SOCK_TX_PORT_ADDR   5003
#define OBC_SOCK_TX_IP_ADDR     "192.168.10.2"

typedef struct
{
    uint32 addr;
    uint32 port;
    s_ipcc_frame *ipcc_frame;
} obc_server_param;

void obc_icd_socket_listen_server_thread (void * params);
void obc_get_icd_cmd_id_thread (void * params);
void obc_encode_icd_cmd(uint16 cmd_id, uint16 vm_id, uint8_t *tc_data);
void obc_icd_socket_send (uint8 *data, uint16 data_len);
int obc_icd_print_data( s_ipcc_frame * ipcc_frame);
void obc_icd_app_socket_server_init(uint32 addr, uint32 port, s_ipcc_frame *ipcc_orig);
void obc_icd_validate_seq_num(uint16 actual_seq_no);
void obc_icd_rsp_enc_socket_server_thread(void *params);
int32_t tcp_send(uint32_t addr, uint32_t port, uint8_t *data, uint32_t size);
int ipcc_send_ipc_msg_pld(uint16_t msg_id, uint16 dst_id, uint8_t *pld, uint8_t pld_size, uint16 src_id);
void obc_icd_vm_pwr_ctrl(uint16_t _vm_id,uint8_t _on_off);
void obc_icd_ps_stgd_tc(uint32_t _stgd_tc_id);
void set_enc_id_indicate(uint16_t rsp_enc_id);
void obc_file_rx_init(void);
uint8 obc_get_eps_chnl_id_from_pld_hw_id(uint16 pld_hw_id);
#ifdef __cplusplus
}
#endif
#endif /*OBC_SAMP_APP_ICD_H_*/
