/**
 * @file sdr_app_ipc.h
 *
 * @brief This file has the function prototypes of IPC message transfer with other layers
 *
 * @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 SDR_APP_IPC_H
#define SDR_APP_IPC_H

#include "exo_osal.h"
#include "exo_ral_cmn.h"

#ifdef __cplusplus
extern "C" {
#endif

/* MACROS FOR S BAND */
#define MIN_BEACON_NORMAL_ENB_TMR  0
#define MAX_BEACON_NORMAL_ENB_TMR  4294967295

#define DEFAULT_BEACON_NORMAL_ENB_TMR_2 3600000
#define DEFAULT_BEACON_NORMAL_ENB_TMR_3  5400000

#define MIN_BEACON_NORMAL_PRD_TMR 0
#define MAX_BEACON_NORMAL_PRD_TMR  4294967295

#define DEFAULT_BEACON_NORMAL_PRD_TMR_2 60000
#define DEFAULT_BEACON_NORMAL_PRD_TMR_3 120000

#define MIN_BEACON_NORMAL_REP_TMR 0
#define MAX_BEACON_NORMAL_REP_TMR  4294967295

#define DEFAULT_BEACON_NORMAL_REP_TMR_2 2000
#define DEFAULT_BEACON_NORMAL_REP_TMR_3 2000

#define MIN_BEACON_SAFE_ENB_TMR 0
#define MAX_BEACON_SAFE_ENB_TMR 4294967295

#define DEFAULT_BEACON_SAFE_ENB_TMR_2  7200000
#define DEFAULT_BEACON_SAFE_ENB_TMR_3  18000000

#define MIN_BEACON_SAFE_PRD_TMR 0
#define MAX_BEACON_SAFE_PRD_TMR 4294967295

#define DEFAULT_BEACON_SAFE_PRD_TMR_2  120000
#define DEFAULT_BEACON_SAFE_PRD_TMR_3  10800000

#define MIN_BEACON_SAFE_REP_TMR 0
#define MAX_BEACON_SAFE_REP_TMR 4294967295

#define DEFAULT_BEACON_SAFE_REP_TMR_2 5000
#define DEFAULT_BEACON_SAFE_REP_TMR_3 300000

#define MIN_SDR_NORMAL_TM_TX_TMR 0
#define MAX_SDR_NORMAL_TM_TX_TMR 4294967295

#define DEFAULT_SDR_NORMAL_TM_TX_TMR_2 120000
#define DEFAULT_SDR_NORMAL_TM_TX_TMR_3  120000

#define MIN_SDR_NORMAL_TX_ON_TMR 0
#define MAX_SDR_NORMAL_TX_ON_TMR 4294967295

#define DEFAULT_SDR_NORMAL_TX_ON_TMR_2  30000
#define DEFAULT_SDR_NORMAL_TX_ON_TMR_3  120000

#define MIN_SDR_NORMAL_RX_ON_TMR 0
#define MAX_SDR_NORMAL_RX_ON_TMR 4294967295

#define DEFAULT_SDR_NORMAL_RX_ON_TMR_2  20000
#define DEFAULT_SDR_NORMAL_RX_ON_TMR_3  20000

#define MIN_SDR_SAFE_TM_TX_TMR 0
#define MAX_SDR_SAFE_TM_TX_TMR 4294967295

#define DEFAULT_SDR_SAFE_TM_TX_TMR_2  30000
#define DEFAULT_SDR_SAFE_TM_TX_TMR_3  30000


#define MIN_SDR_SAFE_TX_ON_TMR 0
#define MAX_SDR_SAFE_TX_ON_TMR 4294967295

#define DEFAULT_SDR_SAFE_TX_ON_TMR_2   5000
#define DEFAULT_SDR_SAFE_TX_ON_TMR_3  5000

#define MIN_SDR_SAFE_RX_ON_TMR 0
#define MAX_SDR_SAFE_RX_ON_TMR 4294967295

#define DEFAULT_SDR_SAFE_RX_ON_TMR_2 300000
#define DEFAULT_SDR_SAFE_RX_ON_TMR_3 300000

#define MIN_TX_DATA_REP_CNT 0
#define MAX_TX_DATA_REP_CNT 4294967295

#define DEFAULT_TX_DATA_REP_CNT_2  3
#define DEFAULT_TX_DATA_REP_CNT_3  3

#define MIN_SDR_TM_READ_TMR 0
#define MAX_SDR_TM_READ_TMR 4294967295

#define DEFAULT_SDR_TM_READ_TMR_2 10000
#define DEFAULT_SDR_TM_READ_TMR_3 5000

#define MIN_TM_READ_DEPTH 0
#define MAX_TM_READ_DEPTH 4294967295

#define DEFAULT_TM_READ_DEPTH 120000

#define MIN_TM_SHORT_STORE_DUR 0
#define MAX_TM_SHORT_STORE_DUR 4294967295

#define DEFAULT_TM_SHORT_STORE_DUR 3600000

#define MIN_TM_LONG_STORE_DUR 0
#define MAX_TM_LONG_STORE_DUR 4294967295

#define DEFAULT_TM_LONG_STORE_DUR  18000000

#define MIN_VALID_RSSI_CNT 0
#define MAX_VALID_RSSI_CNT 255

#define DEFAULT_VALID_RSSI_CNT_3 10

#define MIN_INV_RSSI_CNT 0
#define MAX_INV_RSSI_CNT 255

#define DEFAULT_INV_RSSI_CNT_3 5

#define MIN_RSSI_MIN  0
#define MAX_RSSI_MIN  4294967295

#define DEFAULT_RSSI_MIN_3 -105

#define MIN_RSSI_TYP 0
#define MAX_RSSI_TYP 4294967295
#define DEFAULT_RSSI_TYP_3 -90

#define MIN_RSSI_PRD_TMR 0
#define MAX_RSSI_PRD_TMR 4294967295
#define DEFAULT_RSSI_PRD_TMR_3 5000

#define MIN_SHORT_RX_ON_TMR 0
#define MAX_SHORT_RX_ON_TMR 4294967295
#define DEFAULT_SHORT_RX_ON_TMR_3 30000

#define MIN_LONG_RX_ON_TMR 0
#define MAX_LONG_RX_ON_TMR 4294967295
#define DEFAULT_LONG_RX_ON_TMR_3 120000

#define MIN_TM_AUTO_READ_STS 0
#define MAX_TM_AUTO_READ_STS 4294967295
#define DEFAULT_TM_AUTO_READ_STS_3 1

#define MIN_TEMP_SENS_TYP_THRS_0 6000
#define MAX_TEMP_SENS_TYP_THRS_0 7000
#define DEFAULT_TEMP_SENS_TYP_THRS_0 6500

#define MIN_TEMP_SENS_TYP_THRS_1 6000
#define MAX_TEMP_SENS_TYP_THRS_1 7000
#define DEFAULT_TEMP_SENS_TYP_THRS_1 6500

#define MIN_TEMP_SENS_TYP_THRS_2 6000
#define MAX_TEMP_SENS_TYP_THRS_2 7000
#define DEFAULT_TEMP_SENS_TYP_THRS_2 6500

#define MIN_TEMP_SENS_MAX_THRS_0 7000
#define MAX_TEMP_SENS_MAX_THRS_0 8000
#define DEFAULT_TEMP_SENS_MAX_THRS_0 8000

#define MIN_TEMP_SENS_MAX_THRS_1 7000
#define MAX_TEMP_SENS_MAX_THRS_1 8000
#define DEFAULT_TEMP_SENS_MAX_THRS_1 8000

#define MIN_TEMP_SENS_MAX_THRS_2 7000
#define MAX_TEMP_SENS_MAX_THRS_2 8000
#define DEFAULT_TEMP_SENS_MAX_THRS_2 8000

#define MIN_VOLT_SENS_TYP_THRS_0 95
#define MAX_VOLT_SENS_TYP_THRS_0 95
#define DEFAULT_VOLT_SENS_TYP_THRS_0 95

#define MIN_VOLT_SENS_TYP_THRS_1 180
#define MAX_VOLT_SENS_TYP_THRS_1 180
#define DEFAULT_VOLT_SENS_TYP_THRS_1 180

#define MIN_VOLT_SENS_TYP_THRS_2 95
#define MAX_VOLT_SENS_TYP_THRS_2 95
#define DEFAULT_VOLT_SENS_TYP_THRS_2 100

#define MIN_VOLT_SENS_TYP_THRS_3 100
#define MAX_VOLT_SENS_TYP_THRS_3 100
#define DEFAULT_VOLT_SENS_TYP_THRS_3 100

#define MIN_VOLT_SENS_TYP_THRS_4 180
#define MAX_VOLT_SENS_TYP_THRS_4 180
#define DEFAULT_VOLT_SENS_TYP_THRS_4 180
 
#define MIN_VOLT_SENS_TYP_THRS_5 135
#define MAX_VOLT_SENS_TYP_THRS_5 135
#define DEFAULT_VOLT_SENS_TYP_THRS_5 135

#define MIN_VOLT_SENS_MIN_THRS_0 75
#define MAX_VOLT_SENS_MIN_THRS_0 75
#define DEFAULT_VOLT_SENS_MIN_THRS_0 75

#define MIN_VOLT_SENS_MIN_THRS_1 160
#define MAX_VOLT_SENS_MIN_THRS_1 160
#define DEFAULT_VOLT_SENS_MIN_THRS_1 160

#define MIN_VOLT_SENS_MIN_THRS_2 75
#define MAX_VOLT_SENS_MIN_THRS_2 75
#define DEFAULT_VOLT_SENS_MIN_THRS_2 75

#define MIN_VOLT_SENS_MIN_THRS_3 80
#define MAX_VOLT_SENS_MIN_THRS_3 80
#define DEFAULT_VOLT_SENS_MIN_THRS_3 80

#define MIN_VOLT_SENS_MIN_THRS_4 160
#define MAX_VOLT_SENS_MIN_THRS_4 160
#define DEFAULT_VOLT_SENS_MIN_THRS_4 160

#define MIN_VOLT_SENS_MIN_THRS_5 115
#define MAX_VOLT_SENS_MIN_THRS_5 115
#define DEFAULT_VOLT_SENS_MIN_THRS_5 115

#define MIN_VOLT_SENS_MAX_THRS_0 115
#define MAX_VOLT_SENS_MAX_THRS_0 115
#define DEFAULT_VOLT_SENS_MAX_THRS_0 115

#define MIN_VOLT_SENS_MAX_THRS_1 200
#define MAX_VOLT_SENS_MAX_THRS_1 200
#define DEFAULT_VOLT_SENS_MAX_THRS_1 200

#define MIN_VOLT_SENS_MAX_THRS_2 115
#define MAX_VOLT_SENS_MAX_THRS_2 115
#define DEFAULT_VOLT_SENS_MAX_THRS_2 115

#define MIN_VOLT_SENS_MAX_THRS_3 120
#define MAX_VOLT_SENS_MAX_THRS_3 120
#define DEFAULT_VOLT_SENS_MAX_THRS_3 120

#define MIN_VOLT_SENS_MAX_THRS_4 200
#define MAX_VOLT_SENS_MAX_THRS_4 200
#define DEFAULT_VOLT_SENS_MAX_THRS_4 200

#define MIN_VOLT_SENS_MAX_THRS_5 155
#define MAX_VOLT_SENS_MAX_THRS_5 155
#define DEFAULT_VOLT_SENS_MAX_THRS_5 155



/**
* @brief Abstracted API for SDR APP layer that sends message payload
*  to destination thread using os IPC functionalities
*
* @param msg_id : Identity of data
* @param dest : destination id
*/
void sdr_app_send_ipc(uint16_t msg_id, uint16_t dest);

/**
* @brief Abstracted API for SDR APP layer that sends message payload
*  to destination thread using os IPC functionalities
*
* @param msg_id : Identity of data
* @param dest : destination id
*/
void sdr_app_send_ipc_pld(uint16_t msg_id, uint16_t dest, uint16_t pld_size, uint8_t *pld_ptr);

/**
 * @brief This function handles the sdr_app telecommand, telemetry set response
 */
void sdr_app_tc_tm_set_rsp_hdlr(uint16_t msg_id, int32_t status);

/**
 * @brief This function handles the sdr_app telecommand, telemetry get response
 */
void sdr_app_tc_tm_get_rsp_hdlr(uint16_t msg_id,int32_t status, uint16_t size, uint8_t *tm_pld);

/**
* @brief  This function is used for write the SDR APP configuration to NVM memory
*/
void comms_sdr_cfg_nvm_write(void);

/**
* @brief  This function is used for reading the SDR APP configuration parameters from NVM memory
*/
void comms_sdr_cfg_nvm_read(void);

/**
* @brief  This function is used for reading the UHF configuration parameters from NVM memory
*/
void sdr_app_send_ipc_pld_custom_tx(uint16_t radio_id, uint16_t dest, uint16_t pld_size, uint8_t *pld_ptr);

/**
* @brief  This function is used for write the SDR APP configuration to NVM memory
*/
void comms_sdr_cfg_nvm_write_sdr_cfg(void);

/**
* @brief  This function is used for write the SDR status to NVM memory
*/
void comms_sdr_cfg_nvm_write_sdr_sts(void);

/**
* @brief  This function is used for write the SDR APP timer configuration to NVM memory
*/
void comms_sdr_cfg_nvm_write_tmr_cfg(void);

/**
* @brief  This function is used for write the SDR APP tm configuration to NVM memory
*/
void comms_sdr_cfg_nvm_write_tm_cfg(void);

/**
* @brief  This function is used for write the SDR APP RSSI computation configuration to NVM memory
*/
void comms_sdr_cfg_nvm_write_rssi_cfg(void);

/**
* @brief  This function is used for write the SDR APP system monitor configuration to NVM memory
*/
void comms_sdr_cfg_nvm_write_sens_cfg(void);

#ifdef __cplusplus
}
#endif
#endif /*SDR_APP_IPC_H */
