/**
 * @file mfcc_sample_app.h
 *
 * @brief This file contains function prototypes and data definitions that
 * helps to create, send and receive TC TM frames
 *
 * @copyright Copyright 2023 Antaris, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef _MFCC_SAMPLE_APP_H_
#define _MFCC_SAMPLE_APP_H_

#include "exo_types.h"
#include "exo_osal_mem_management.h"
#include "exo_osal_common.h"

#define ENBL_DBG_PRNT               (1)              ///< Macro for enabling debug prints

/// TC Socket interface parameter configurations
#define MFCC_TC_SOCKET_IP_ADDR      ("192.168.10.2") ///< IP address of socket used for TC transmission
#define MFCC_TC_SOCKET_PORT_ADDR    (5001)           ///< Port address of socket used for TC transmission

/// TM Socket interface parameter configurations
#define MFCC_TM_SOCKET_IP_ADDR      ("192.168.10.2") ///< IP address of socket used for TM reception
#define MFCC_TM_SOCKET_PORT_ADDR    (5002)           ///< Port address of socket used for TM transmission

/// TC_TM Frame Parameter configurations
#define MAX_TC_BUFF_SIZE            (1024)           ///< Maximum TC buffer size allocation
#define MAX_TM_BUFF_SIZE            (1024)           ///< Maximum TM buffer size allocation
#define TC_FRAME_SOF                (0xA5)           ///< Start of frame definition for TC
#define RECV_SAT_ID                 (0x01)           ///< Satellite ID value
#define CRYPTO_ENCRYP_ENBL          (0x30)           ///< Encryption configuration value
#define SOURCE_GROUND_STN_ID        (0x01)           ///< Ground station ID value
#define TC_QOS_CFG                  (0x01)           ///< TC_TM Quality of Service configuration value
#define TC_SOURCE_ID                (0x01)           ///< TC Source ID configuration value
#define TC_DESTINATION_ID           (0x01)           ///< TC Destination ID configuration value

/**
 * @brief This API creates socket interface to receive Telemetry data
 *
 * @param[in] params    : Unused parameter
 *
 * @return None
 */
void mfcc_tm_listener_thread(void * params);

/**
 * @brief This API creates socket interface to send Telecommand data
 *
 * @param[in] params    : Unused parameter
 *
 * @return None
 */
void mfcc_tc_send_thread(void *params);

/**
 * @brief This API parses the received Telemetry information
 *
 * @param[in] tm_stream_data   : contains the TM binary data stream
 *
 * @return Result of API execution status
 * @retval 0 -> Success / other values -> Error.
 */
int mfcc_tm_parser(uint8 *tm_stream_data);

/**
 * @brief This API validates the sequence number of received TM data
 *
 * @param[in] actual_seq_no    : Sequence number of received TM data frame
 *
 * @return None
 */
void validate_seq_num(uint16 actual_seq_no);

/**
 * @brief Creates 2 threads to handle MFCC TC and TM.
 *
 * @return Result of thread creation status
 * @retval ral_success -> Thread creation is success
 *         ral_error -> THread creation is failure
 */
os_status_t tc_tm_sample_mfcc_main(void);
#endif
