/*
 * Brief:	Declare some functions.
 * Author:	Jimbo_zhang@outlook.com
 * Data:		2019-4-27
 */
#ifndef __LIBIPMI_STORLEAD_OEM_H__
#define __LIBIPMI_STORLEAD_OEM_H__

#include "libipmi_struct.h"
#include <stdint.h>
#include "com_BmcType.h"
#include "libipmi_StorDevice.h"
#include "com_IPMI_IPM.h"
#include "com_BMCCfg.h"

#define MAX_TITLE_LEN	20
#define MAX_TEXT_LEN		256
#define MAX_HISTORY_LEN	480
#define MAX_BLADE_NUM           32
#define MAX_FAN_NUM	8

#pragma pack(1)



typedef struct{
	char *title;
	char *text;
}SysInfo_T;


typedef struct{
	uint8_t bladeNum;	//index
	uint8_t isChmc;	//is main blade
	uint8_t IPMBAddr;	//physical ID
	uint8_t status;	//0: not install, 1: normal, 2: error
	uint8_t reserve;
} bladeStatus_T;

typedef struct{
	uint8_t complecode;	
	bladeStatus_T bdStatus[10];
} CardStatus_T;

typedef struct{
	uint8_t slotNum; //total slot numbers of chassis.
	uint8_t isChMC;		
	uint8_t chassisManageFnEnable;		//废弃了
	uint8_t curIndex;
} OemChassisInfo_T;



typedef struct{
	uint8_t supportEventLogs;
	uint8_t supportBMCDevInfo;
	uint8_t supportBMCNetworkInfo;
	uint8_t supportCPUInfo;
	uint8_t supportFanCtrl;
	uint8_t supportFRU;
	uint8_t supportRemoteCtrl;	//power on/off
} OemIPMCCapability_T;

typedef struct{
	uint8_t IPMBAddr;
	BladeStatus_T bladeStatus;
} OemBladeInfo_T;

typedef struct{
	uint8_t bladeNum;
	uint8_t fanNum;
	uint8_t supportHistory;
	
} OemWebFlags_T;

typedef struct 
{
	/*
		sensor_name array length increased from 17 to 20.
		In some cases sensor_name length is more than 17 characters. webgo was giving some special character to web page in those cases and webpage was giving some weird behaviour when it found that special character.
	*/
    uint8_t sensor_num;
    char sensor_name[ 20 ];
    float sensor_history[ 480 ];
    
}sensor_history_st;

typedef struct{
	uint8_t isSupportSensorHistory;
	uint8_t SensorHistoryEnable;
} SensorHistoryCapability_T;

#pragma pack()

extern OemWebFlags_T g_OemWebFlags;
extern uint8_t gIPMBAddr[BLADE_NUMBERS];
extern uint8_t gChassisManageEn;
//uint16_t LIBIPMI_HL_GetIPMCSensorInfo(IPMI20_UDS_SESSION_T *pUDSSession, SenInfo_T *pSensorInfo,uint32_t *nNumSensor,int timeout);

uint16_t LIBIPMI_HL_SetFanInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout);
uint16_t IPMC_SetFanInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout);
uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pSysInfo, int timeout);
uint16_t IPMC_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, SysInfo_T *pSysInfo, int timeout);
uint16_t LIBIPMI_HL_GetSensorHistory( IPMI20_UDS_SESSION_T *pUDSSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR);
int 	 LIBIPMI_HL_GetAllBladeStatus(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t chassisManageEn, BladeStatus_T* pBladeStatus, int timeout);
int LIBIPMI_HL_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, FanInfo_T* pFanInfo, int timeout);
int IPMC_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, FanInfo_T* pFanInfo, int timeout);
uint16_t Storlead_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
	SELEventRecordWithSensorName_T *pSELEntriesBuffer,uint32_t *nNumSelEntries,int timeout);
uint16_t IPMICMD_ResetBMC(IPMI20_UDS_SESSION_T *pUDSSession, int timeout);
uint16_t IPMC_ResetBMC(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, int timeout);
uint16_t IPMICMD_SetLanInfo(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t index, LanInfo_T *pLanInfo, int timeout);
uint16_t IPMICMD_GetLanInfo(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t index, LanInfo_T *pLanInfo, int timeout);
uint16_t IPMICMD_restoreFactorySettings(IPMI20_UDS_SESSION_T *pUDSSession, int timeout);
uint16_t IPMC_restoreFactorySettings(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, int timeout);
int LIBIPMI_IPMC_GetDeviceID(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, GetDevIDRes_T *DevIDRes, int timeout);
#endif /* __LIBIPMI_STORLEAD_OEM_H__ */

