/*
 * 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_AMIOEM.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{
	uint8_t fanNum; 
} OemFanInfo_T;

typedef struct{
	uint8_t index;
	uint8_t name[16];
	uint8_t mode;
	uint8_t level;	//duty 0% - 100%
	uint32_t speed;	//RPM 
} OemFanStatus_T;


typedef struct{
	char *title;
	char *text;
}ExtraInfo_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 supportChassisManageFn;
	uint8_t chassisManageFnEnable;
	uint8_t chMCIndex;
} OemChassisInfo_T;

typedef struct{
	uint8_t status;
	uint8_t bladeName[12];
	uint8_t slotID;
	uint8_t bladePowerStatus;
} OemBladeStatus_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;
	OemBladeStatus_T bladeStatus;
} OemBladeInfo_T;

typedef struct{
	uint8_t bladeNum;
	uint8_t fanNum;
	uint8_t supportHistory;
	
} OemWebFlags_T;
#pragma pack()

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;

extern OemWebFlags_T g_OemWebFlags;
uint16_t LIBIPMI_HL_GetIPMCSensorInfo(IPMI20_SESSION_T *pSession,SenInfo_T *pSensorInfo,uint32_t *nNumSensor,int timeout);

uint16_t LIBIPMI_HL_FanCtrol( IPMI20_SESSION_T *pSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout);
int LIBIPMI_HL_GetFanStatus( IPMI20_SESSION_T *pSession, uint8_t fanIndex, OemFanStatus_T *pFanStatus, int timeout);
uint16_t LIBIPMI_HL_GetExtraInfo( IPMI20_SESSION_T *pSession, ExtraInfo_T *extraInfo, int timeout);
uint16_t LIBIPMI_HL_GetSensorHistory( IPMI20_SESSION_T *pSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR);
uint16_t LIBIPMI_HL_GetAllCards(IPMI20_SESSION_T *pSession, CardStatus_T*	pResBladeSts, int timeout);
int	 LIBIPMI_HL_GetChassisInfo(IPMI20_SESSION_T *pSession, OemChassisInfo_T* pBladeInfo, int timeout);
int 	 LIBIPMI_HL_GetBladeStatus(IPMI20_SESSION_T *pSession, OemBladeStatus_T* pBladeStatus, int timeout);
int LIBIPMI_HL_GetIPMCCapability(IPMI20_SESSION_T *pSession, uint8_t bladeIndex, OemIPMCCapability_T* pIPMCCapability, int timeout);
int LIBIPMI_HL_SetBladeManageFn(IPMI20_SESSION_T *pSession, uint8_t enable, int timeout);
int LIBIPMI_HL_GetManageWebName(IPMI20_SESSION_T *pSession, char* webName, int timeout);
int LIBIPMI_HL_GetFanInfo(IPMI20_SESSION_T *pSession, OemFanInfo_T* pFanInfo, int timeout);
int LIBIPMI_HL_GetSensorHistoryCapability(IPMI20_SESSION_T *pSession, uint8_t sensorNum, SensorHistoryCapability_T* pSensorHistoryCapability, int timeout);
//int LIBIPMI_HL_GetSensorHistoryEn(IPMI20_SESSION_T *pSession, uint8_t* SensorHistoryEnable, int timeout);
int LIBIPMI_HL_SetSensorHistoryEn(IPMI20_SESSION_T *pSession, uint8_t sensorNum, uint8_t SensorHistoryEnable, int timeout);

#endif /* __LIBIPMI_STORLEAD_OEM_H__ */

