/*
 * HHT_Parameters.h
 *
 *  Created on: Jul 2, 2021
 *      Author: 217432
 */

#ifndef HHT_PARAMETERS_H_
#define HHT_PARAMETERS_H_

#include "stddef.h"
#include "stdbool.h"
#include "stdio.h"
#include "stdint.h"
#include "stdlib.h"

/////* IP address configuration. */
//#define configIP_ADDR0 10
//#define configIP_ADDR1 0
//#define configIP_ADDR2 0
//#define configIP_ADDR3 10
//
///* Netmask configuration. */
//#define configNET_MASK0 255
//#define configNET_MASK1 255
//#define configNET_MASK2 255
//#define configNET_MASK3 0
//
///* Gateway address configuration. */
//#define configGW_ADDR0 10
//#define configGW_ADDR1 0
//#define configGW_ADDR2 0
//#define configGW_ADDR3 100

#define TxPort 5000
#define RxPort 6000

uint8_t configIP_ADDR0=10,configIP_ADDR1=0,configIP_ADDR2=0,configIP_ADDR3=10;
uint8_t configNET_MASK0=255,configNET_MASK1=255,configNET_MASK2=255,configNET_MASK3=0;
uint8_t configGW_ADDR0=10,configGW_ADDR1=0,configGW_ADDR2=0,configGW_ADDR3=100;


uint8_t config_IP_BUC_ADDR0=10,config_IP_BUC_ADDR1=0,config_IP_BUC_ADDR2=0,config_IP_BUC_ADDR3=2;
uint8_t config_NET_BUC_MASK0,config_NET_BUC_MASK1,config_NET_BUC_MASK2,config_NET_BUC_MASK3;
uint8_t config_GW_BUC_ADDR0,config_GW_BUC_ADDR1,config_GW_BUC_ADDR2,config_GW_BUC_ADDR3;

uint8_t Ethernet_Update_Flag=1;


//int BUC_Ping_Status;
// System Info Screen Parameters
typedef struct
{
	uint8_t 	System_ID;
	uint8_t  	BUC_Status;
	uint8_t	 	FWD_RF_POWER;
	uint8_t	 	Sys_Fault_Status;
	uint8_t 	Sys_FW_Version[3];
	uint8_t 	Sys_SW_Version[3];
}Sys_Info_Param;

//System Information Screen Parameters
char gui_System_ID[10],gui_Buc_Status[10],gui_RF_FWD_POWER[10],gui_Sys_Fault_Status[10];
char gui_HHC_SW_VER_P1[10]="2.0",gui_SYS_SW_VER_P2[10],gui_SYS_SW_VER_P3[10];
char gui_HHC_FW_VER_P1[10]="31.00",gui_SYS_FW_VER_P2[10],gui_SYS_FW_VER_P3[10];

//Buc Info Screen Parameters
typedef struct
{
	int8_t		BUC_ID[10];
	uint8_t		BUC_Serial_Num[3];
	uint8_t 	BUC_SW_Version[5];
	uint8_t 	BUC_FW_Version[5];
	uint8_t		BUC_Manufacture_Date[12];
	//uint8_t		BUC_Manufacture_Month;
	//uint8_t		BUC_Manufacture_Year;
}BUC_Info_Param;

//BUC Information Screen Parameters
uint8_t gui_BUC_ID1[15];
char gui_BUC_ID2[2],gui_BUC_ID3[2],gui_BUC_ID4[2],gui_BUC_ID5[2],gui_BUC_ID6[2],gui_BUC_ID7[2];
char gui_BUC_ID8[2],gui_BUC_ID9[2],gui_BUC_ID10[2],gui_BUC_ID11[2],gui_BUC_ID12[2],gui_BUC_ID13[2];
char gui_BUC_ID13[2],gui_BUC_ID14[2],gui_BUC_ID15[2];

char gui_BUC_Serial_Num_P1[5],gui_BUC_Serial_Num_P2[5],gui_BUC_Serial_Num_P3[5];
char gui_BUC_SW_VER_P1[5],gui_BUC_SW_VER_P2[10],gui_BUC_SW_VER_P3[5],gui_BUC_SW_VER_P4[10],gui_BUC_SW_VER_P5[5];
char gui_BUC_FW_VER_P1[5],gui_BUC_FW_VER_P2[10],gui_BUC_FW_VER_P3[5],gui_BUC_FW_VER_P4[10],gui_BUC_FW_VER_P5[5];
char gui_BUC_Manuf_Date_P1[15],gui_BUC_Manuf_Date_P2[5],gui_BUC_Manuf_Date_P3[5],gui_BUC_Manuf_Date_P4[5],gui_BUC_Manuf_Date_P5[5];
char gui_BUC_Manuf_Date_P6[5],gui_BUC_Manuf_Date_P7[5],gui_BUC_Manuf_Date_P8[5],gui_BUC_Manuf_Date_P9[5],gui_BUC_Manuf_Date_P10[5];
char gui_BUC_Manuf_Date_P11[5],gui_BUC_Manuf_Date_P12[5];

//Buc Control Screen Parameters
typedef struct
{
	uint8_t		attenution_ctrl;			//Editable
	uint8_t		Ext_10MHz_Ref_Src;			//Editable
	uint8_t		RF_Mute_Ctrl;				//Editable
}BUC_Ctrl_Param;

//BUC Control Screen Parameters
char Backup_gui_attenution_ctrl[10],gui_Ext_10MHz_Ref_Src[5],gui_RF_Mute_Ctrl[5],gui_attenution_ctrl[10];
int  gui_attenution_ctrl_int;
int  udp_Ext_10MHz_Ref_Src,udp_RF_Mute_Ctrl;
uint8_t RF_Mute_Switch_Value,Ext_Ref_Src_10MHz_Switch_Value;

//Buc Status Screen Parameters
typedef struct
{
	uint8_t		RF_FWD_Power_Status[5];
	uint8_t		Ext_10Mhz_Src_Status;
	//uint8_t		Reset_Status;
}BUC_Status_Param;

//BUC Status Screen Parameters
char gui_RF_FWD_Power_Status_P1[10],gui_RF_FWD_Power_Status_P2[5],gui_RF_FWD_Power_Status_P3[5],gui_RF_FWD_Power_Status_P4[5];
char gui_RF_FWD_Power_Status_P5[5];
char gui_Ext_10Mhz_Src_Status[10],gui_Reset_Status[5];
int Ext_10Mhz_Src_Status_Screen_Value,RF_Mute_Status_Screen_Value;


//Buc Health Screen Parameters
typedef struct
{
	uint8_t		RF_FWD_Power_Alarm_Health;
	uint8_t		Input_Power_Health;
	uint8_t		PLO_Lock_Status_Health;
	uint8_t		LO_Power_Level_Health;
	uint8_t		L_Band_Input_OverDrive_Health;
	uint8_t		Fan_Health;
	uint8_t		VSWR_Alarm_Health;
	uint8_t		DC_24V_health;
	uint8_t		Sequence_Health;
	uint8_t		Temp_HPD_Health;
}BUC_Health_Param;

//BUC Health Screen Parameters
char gui_RF_FWD_Power_Alarm_Health[10],gui_Input_Power_Health[10],gui_PLO_Lock_Status_Health[10];
char gui_LO_Power_Level_Health[10],gui_L_Band_Input_OverDrive_Health[10],gui_Fan_Health[10];
char gui_VSWR_Alarm_Health[10],gui_DC_24V_health[10],gui_Sequence_Health[10],gui_Temp_HPD_Health[10];

char gui_Screen_Param_Default[10]="NO-DATA";
char gui_Screen_Param_Default_number[10]="0";

//Buc Maintainance Screen Parameters
typedef struct
{
	uint8_t		Low_Power_Sel_Switch;
	uint8_t		RF_Mute_Status;
	uint8_t		BUC_Status;
	uint8_t		DC_Input_Current[5];
	uint8_t		Temp_HPD[5];
	uint8_t		Temp_PS[5];
}BUC_Maintainance_Param;

//BUC Maintainance Screen Parameters
char gui_Low_Power_Sel_Switch[5],gui_RF_Mute_Status[5],gui_BUC_Status[5];
char gui_DC_Input_Current_P1[10],gui_DC_Input_Current_P2[5],gui_DC_Input_Current_P3[5],gui_DC_Input_Current_P4[5],gui_DC_Input_Current_P5[5];
char gui_Temp_HPD_P1[10],gui_Temp_HPD_P2[5],gui_Temp_HPD_P3[5],gui_Temp_HPD_P4[5],gui_Temp_HPD_P5[5];
char gui_Temp_PS_P1[10],gui_Temp_PS_P2[5],gui_Temp_PS_P3[5],gui_Temp_PS_P4[5],gui_Temp_PS_P5[5];


//Buc Network Settings Screen Parameters
typedef struct
{
	uint8_t		BUC_IP[15];			//Editable
	uint8_t		BUC_Subnet[15];		//Editable
	uint8_t		BUC_Gateway[15];		//Editable
}BUC_Net_Sett_Param;

int first_Sys_Master_Enable;
//Buc Network Settings Screen Parameters
char gui_BUC_IP_Addr1[20],gui_BUC_IP_Addr2[5],gui_BUC_IP_Addr3[5],gui_BUC_IP_Addr4[5],gui_BUC_IP_Addr5[5];
char gui_BUC_IP_Addr6[5],gui_BUC_IP_Addr7[5],gui_BUC_IP_Addr8[5],gui_BUC_IP_Addr9[5],gui_BUC_IP_Addr10[5];
char gui_BUC_IP_Addr11[5],gui_BUC_IP_Addr12[5],gui_BUC_IP_Addr13[5],gui_BUC_IP_Addr14[5],gui_BUC_IP_Addr15[5];

char gui_BUC_Subnet_Addr1[20],gui_BUC_Subnet_Addr2[5],gui_BUC_Subnet_Addr3[5],gui_BUC_Subnet_Addr4[5],gui_BUC_Subnet_Addr5[5];
char gui_BUC_Subnet_Addr6[5],gui_BUC_Subnet_Addr7[5],gui_BUC_Subnet_Addr8[5],gui_BUC_Subnet_Addr9[5],gui_BUC_Subnet_Addr10[5];
char gui_BUC_Subnet_Addr11[5],gui_BUC_Subnet_Addr12[5],gui_BUC_Subnet_Addr13[5],gui_BUC_Subnet_Addr14[5],gui_BUC_Subnet_Addr15[5];

char gui_BUC_Gateway_Addr1[20],gui_BUC_Gateway_Addr2[5],gui_BUC_Gateway_Addr3[5],gui_BUC_Gateway_Addr4[5],gui_BUC_Gateway_Addr5[5];
char gui_BUC_Gateway_Addr6[5],gui_BUC_Gateway_Addr7[5],gui_BUC_Gateway_Addr8[5],gui_BUC_Gateway_Addr9[5],gui_BUC_Gateway_Addr10[5];
char gui_BUC_Gateway_Addr11[5],gui_BUC_Gateway_Addr12[5],gui_BUC_Gateway_Addr13[5],gui_BUC_Gateway_Addr14[5],gui_BUC_Gateway_Addr15[5];

//BUC User Login Screen Parameters
typedef struct
{
	uint8_t		BUC_UserName[1];		//Editable
	uint8_t		BUC_Password[1];		//Editable
}BUC_User_Login_Info;

//BUC User Login Screen Parameters
char gui_BUC_UserName[15],gui_BUC_Password[15];


//BUC Sys Info Screen Parameters
typedef struct
{
	uint8_t		BUC_SelfMaster;			//Editable
	uint8_t		BUC_Reboot;				//Editable
	uint8_t		BUC_SaveConfig;			//Editable
}BUC_Sys_Param;

//BUC Sys Info Screen Parameters
char gui_BUC_SelfMaster[5],gui_BUC_Reboot[5],gui_BUC_SaveConfig[5];
int udp_Self_Master_Enable_Disable_Status;

//Buc Setup Screen Parameters
typedef struct
{
	BUC_Info_Param			stBucInfoParam;
	//BUC_Ctrl_Param			stBucCtrlParam;
	BUC_Status_Param		stBucStatusParam;
	BUC_Health_Param		stBucHealthParam;
	BUC_Maintainance_Param	stBucMaintainanceParam;
	BUC_Net_Sett_Param		stBucNetSettParam;
	BUC_User_Login_Info		stBucUserLoginInfo;
	BUC_Sys_Param			stBucSysParam;
}BUC_Setup_Param;

//HHT Network Settings Screen Parameters
typedef struct
{
	uint8_t		HHT_IP[4];
	uint8_t		HHT_Subnet[4];
	uint8_t		HHT_Gateway[4];
}HHT_Net_Sett_param;


//HHT Network Settings Parameters
char gui_HHT_IP_Addr1[10],gui_HHT_IP_Addr2[10],gui_HHT_IP_Addr3[10],gui_HHT_IP_Addr4[10];
char gui_HHT_Subnet_Addr1[10],gui_HHT_Subnet_Addr2[10],gui_HHT_Subnet_Addr3[10],gui_HHT_Subnet_Addr4[10];
char gui_HHT_Gateway_Addr1[10],gui_HHT_Gateway_Addr2[10],gui_HHT_Gateway_Addr3[10],gui_HHT_Gateway_Addr4[10];
//HHT General Settings Screen Parameters

typedef struct
{
	uint8_t			HHT_Battery;
	uint8_t			HHT_Display;
	uint8_t			HHT_Reboot;
	uint8_t			HHT_Factory_Reset;
	uint8_t			Date[3];
	uint8_t			Time[3];
}HHT_Gen_Sett_Param;

//General Settings Screen Parameters
char gui_HHT_Battery[5],gui_HHT_Display[5],gui_HHT_Reboot[5],gui_HHT_Factory_Reset[5];
char gui_Date_Day[10],gui_Date_Month[10],gui_Date_Year[10];
char gui_Time_Hour[10],gui_Time_Min[10],gui_Time_Sec[10];

typedef struct __attribute__ ((packed)) HHT_Parameters{
	//Sys_Info_Param 			st_Sys_Info_Param;
	BUC_Setup_Param 			st_BUC_SetUp_Param;
	HHT_Net_Sett_param			st_HHT_Net_Sett_Param;
	HHT_Gen_Sett_Param			st_HHT_Gen_Sett_Param;
}HHT_Parameters;

HHT_Parameters st_HHT_Parameters;


typedef struct __attribute__ ((packed)) HHT_BUC_REQUEST
{
	uint8_t  HHT_BUC_REQUEST_msg[20];
}HHT_BUC_REQUEST;

HHT_BUC_REQUEST st_HHT_BUC_REQUEST;

typedef struct
{
	//char		Updated_BUC_ID[20];
	uint8_t		Updated_Rf_Attn_Ctrl;
	uint8_t		Updated_Ext_10Mhz_Ref_Src_Ctrl;
	uint8_t		Updated_Rf_Mute_Ctrl;
	uint8_t		Updated_Reset;
	uint8_t		Updated_Buc_IP_Addr[4];
	uint8_t		Updated_Buc_SubNet_Addr[4];
	uint8_t		Updated_Buc_Gateway_Addr[4];
	uint8_t		Updated_Buc_Self_Master;
	uint8_t		Updated_Buc_Reboot;
}GUI_Updated_Parameters;

GUI_Updated_Parameters st_GUI_Updated_Parameters;

// Updated Parameters Structure

//Added for Sending Set Parameters at a time one parameter
uint8_t BUC_INFO_ID_UPDATE=5;
uint8_t RF_DIGITAL_ATTN=0;
uint8_t EXT_10MHZ_REF_SRC=9;
uint8_t RF_MUTE_CTRL_SW_STATUS=10;
uint8_t BUC_IP_SETTINGS=17;
uint8_t BUC_SELF_MASTER=20;
uint8_t BUC_REBOOT=16;

typedef struct
{
	uint8_t		ID_BUC_INFO_ID_UPDATE;
	uint8_t		Updated_BUC_ID[20];
}GUI_Updated_BUC_Info_ID;

GUI_Updated_BUC_Info_ID st_GUI_Updated_BUC_Info_ID;

typedef struct
{
	uint8_t		ID_RF_DIGITAL_ATTN;
	uint8_t		Updated_Rf_Attn_Ctrl;
}GUI_Updated_RF_Attn_Ctrl;

GUI_Updated_RF_Attn_Ctrl st_GUI_Updated_RF_Attn_Ctrl;

typedef struct
{
	uint8_t		ID_EXT_10MHZ_REF_SRC;
	uint8_t		Updated_Ext_10Mhz_Ref_Src_Ctrl;
}GUI_Updated_Ext_10Mhz_Ref_Src_Ctrl;

GUI_Updated_Ext_10Mhz_Ref_Src_Ctrl st_GUI_Updated_Ext_10Mhz_Ref_Src_Ctrl;

typedef struct
{
	uint8_t		ID_RF_MUTE_CTRL_SW_STATUS;
	uint8_t		Updated_Rf_Mute_Ctrl;
}GUI_Updated_Rf_Mute_Ctrl;

GUI_Updated_Rf_Mute_Ctrl st_GUI_Updated_Rf_Mute_Ctrl;


typedef struct
{
	uint8_t		ID_BUC_IP_SETTINGS;
	uint8_t		Updated_Buc_IP_Addr[4];
	uint8_t		Updated_Buc_SubNet_Addr[4];
	uint8_t		Updated_Buc_Gateway_Addr[4];
}GUI_Updated_Buc_IP_Sett;

GUI_Updated_Buc_IP_Sett st_GUI_Updated_Buc_IP_Sett;

typedef struct
{
	uint8_t		ID_BUC_SELF_MASTER;
	uint8_t		Updated_Buc_Self_Master;
}GUI_Updated_Buc_Self_Master;

GUI_Updated_Buc_Self_Master st_GUI_Updated_Buc_Self_Master;

typedef struct
{
	uint8_t		ID_BUC_REBOOT;
	uint8_t		Updated_Buc_Reboot;
}GUI_Updated_Buc_Reboot;

GUI_Updated_Buc_Reboot st_GUI_Updated_Buc_Reboot;



int BC=0;

#define gui_ACTIVE_DESC 		"ACTIVE"
#define gui_STANDBY_DESC		"STAND BY"
#define gui_NORMAL_DESC			"NORMAL"
#define gui_FAULT_DESC			"FAULT"
#define gui_HEALTHY_DESC		"OK"
#define gui_UNHEALTHY_DESC		"NOT OK"
#define gui_ON_DESC				"ON"
#define gui_OFF_DESC			"OFF"
#define gui_INTERNAL_DESC    	"INTERNAL"
#define gui_EXTERNAL_DESC		"EXTERNAL"
#define gui_ACTIVE_DESC    		"ACTIVE"
#define gui_SLEEP_DESC			"SLEEP"

int g_SYS_ID_VALUE_INT,g_SYS_ID_VALUE_INT_P1,g_SYS_ID_VALUE_INT_P2,g_SYS_ID_VALUE_INT_P3;
char *g_SYS_ID_VALUE_INT_TOK1,*g_SYS_ID_VALUE_INT_TOK2,*g_SYS_ID_VALUE_INT_TOK3;
char a[10],g_SYS_ID_VALUE_STR_P1[10],g_SYS_ID_VALUE_STR_P2[10],g_SYS_ID_VALUE_STR_P3[10];

char g_Rx_SYS_FW_VER[10];
uint8_t g_Rx_PS_ON_OFF_CTRL;
char g_Rx_PS_ON_OFF_CTRL_STR[10];
char g_Rx_HHT_IP_Addr[20];
int Buc_Ctrl_SAVE_Flag;
int BUC_Info_Buc_ID_Save_Flag;
char gui_BUC_Info_ID[20];
char gui_BUC_Info_ID_Default[20]="BEL-BUC-BUC-001";
uint8_t Buc_ctrl_RF_attn_ctrl_save_flag,Buc_ctrl_RF_attn_ctrl_value;
int Buc_ctrl_Ext_10MHz_Ref_Src_save_flag,Buc_ctrl_Ext_10MHz_Ref_Src_switch_value;
int Buc_ctrl_RF_Mute_save_flag,Buc_ctrl_RF_Mute_switch_value;
uint8_t BUC_Status_Reset_GUI_Flag,BUC_Status_Reset_GUI_Value;

int BUC_Net_Sett_Save_Flag,BUC_Net_Sett_Save_Value,BUC_Net_Validate_Flag;
char gui_update_Buc_net_IP_Addr[20],gui_update_Buc_net_SubNet_Addr[20],gui_update_Buc_net_gateway_Addr[20];
char gui_update_Buc_net_IP_Addr_validate[20],gui_update_Buc_net_SubNet_Addr_validate[20],gui_update_Buc_net_gateway_Addr_validate[20];
uint8_t Buc_extract_ipAddr[4],Buc_extract_SubNet_Addr[4],Buc_extract_Gateway_Addr[4];

int BUC_User_Login_Save_Flag,BUC_User_Login_Save_Value;
int BUC_Sys_Self_Master_Flag,BUC_Sys_Self_Master_Value;
int BUC_Sys_Reboot_Flag,BUC_Sys_Reboot_Value;
int BUC_Sys_SaveConfig_Flag,BUC_Sys_SaveConfig_Value;

int HHT_Net_Sett_Save_Flag,HHT_Net_Sett_Save_Value,HHT_Net_Validate_Flag;
char gui_update_HHT_net_IP_Addr[20],gui_update_HHT_net_SubNet_Addr[20],gui_update_HHT_net_gateway_Addr[20];
char gui_update_HHT_net_IP_Addr_validate[20],gui_update_HHT_net_SubNet_Addr_validate[20],gui_update_HHT_net_gateway_Addr_validate[20];
uint8_t HHT_extract_ipAddr[4],HHT_extract_SubNet_Addr[4],HHT_extract_Gateway_Addr[4];

int HHT_Gen_Save_Flag,HHT_Gen_Save_Value;
int HHT_Reboot_Flag,HHT_Reboot_Value;
int HHT_Factory_Reset_Flag,HHT_Factory_Reset_Value;

int BUC_Sys_Self_Master_Value_counter=0,Buc_ctrl_Ext_10MHz_Ref_Src_switch_value_counter,Buc_ctrl_RF_Mute_switch_value_counter;


//Backup Buffer Data Structures
uint8_t Backup_gui_BUC_ID1[15];
char Backup_gui_BUC_Serial_Num[5];
char Backup_gui_BUC_SW_VER_P1[10],Backup_gui_BUC_FW_VER_P1[10],Backup_gui_BUC_Manuf_Date[15];

char Backup_gui_attenution_ctrl[10];
char Backup_gui_RF_FWD_Power_Status_P1[10],Backup_gui_Ext_10Mhz_Src_Status[10];

//BUC Health Screen Parameters
char Backup_gui_RF_FWD_Power_Alarm_Health[15],Backup_gui_Input_Power_Health[15],Backup_gui_PLO_Lock_Status_Health[15];
char Backup_gui_LO_Power_Level_Health[15],Backup_gui_L_Band_Input_OverDrive_Health[15],Backup_gui_Fan_Health[15];
char Backup_gui_VSWR_Alarm_Health[15],Backup_gui_DC_24V_health[15],Backup_gui_Sequence_Health[15],Backup_gui_Temp_HPD_Health[15];

//BUC Maintainance Screen Parameters
char Backup_gui_Low_Power_Sel_Switch[10],Backup_gui_RF_Mute_Status[10],Backup_gui_BUC_Status[10];
char Backup_gui_DC_Input_Current[10],Backup_gui_Temp_HPD[10],Backup_gui_Temp_PS[10];

//BUC Net Settings Screen Parameters
char Backup_gui_BUC_IP_Addr1[15],Backup_gui_BUC_Subnet_Addr1[15],Backup_gui_BUC_Gateway_Addr1[15];


uint32_t g_TxPktCnt,g_Tx_Updated_PktCnt,g_RxPktCnt_Total,g_Rx_Param_from_BUC_Pkt_Cnt,g_Rx_ACK_from_BUC_Pkt;
uint32_t g_Prev_RxPktCnt_Total,g_TxPktCnt_Prev;
int Parameter_UDP_Pkt_from_BUC_Received,Parameter_UDP_Pkt_from_BUC_Stopped;
int ACK_UDP_Pkt_from_BUC_Received,UDP_Pkt_Received;
int Update_Pkt_Sent_Flag=0;
int Ethernet_Link_Status=0;
int Battery_Percentage;
char str_Battery_Percentage[5];
char str_Battery_Conn_Status[5];
int Buc_health_Status_button_clicked;
#endif /* HHT_PARAMETERS_H_ */
