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

#ifndef COMMS_SBAND_CSP_H_
#define COMMS_SBAND_CSP_H_

#include <stdint.h>
#include <errno.h>


#ifndef S_BAND_SIM

/** SRS-4 module SRC/DST addresses*/
#define SRS4_CAN_TX_ADDRESS 10
#define SRS4_CTRL_ADDRESS 24
#define SRS4_ETH_TX_ADDRESS 12

/** SRS-4 module port numbers */
#define SRS4_CAN_TX_DATA_PORT 20
#define SRS4_CAN_RX_DATA_PORT 40

#define SRS4_ETH_TX_DATA_PORT 21
#define SRS4_ETH_RX_DATA_PORT 41

#else

#define SRS4_SPACE_ADDRESS 11
#define SRS4_CTRL_ADDRESS 24

/** SRS-4 module port numbers */
#define SRS4_CSP_TX_DATA_PORT 40
#define SRS4_CSP_RX_DATA_PORT 20

#endif

#define SRS4_CAN_MTU 1400
#define SRS4_ETH_MTU 1020


/**
* @brief This function is used for sending the CSP data via S-Band module
* This function is used for testing
*/
void sband_csp_tx_data(void);
/**
* @brief  This function is used for sending the CSP ping packets
* 
* @param tc_cmd
*/
void sband_csp_ping(uint8_t *tc_cmd);

/**
 * @brief This api transmits the tm data of length size
 *  through the can interface
 *
 *  @param tm_data : pointer to telemetry data
 *  @param len : length of the telemetry data.
 *
 */
int32_t comms_sband_send_tm(uint8_t* tm_data, uint16_t len);

/**
 * @brief This receives the tc/tm data through the can interface
 * and sends the TC/TM payload to TC-TM manager through IPC
 *
 */
int32_t comms_sband_recv_tc(void);

void comms_sband_upd_port_addr(uint8_t *csp_tx_port, uint8_t *csp_tx_addr);
void comms_sband_sim_upd_port_addr(uint8_t *csp_tx_port, uint8_t *csp_tx_addr);

#endif /* COMMS_SBAND_CSP_H_ */
