소스 검색

New Fan interface

zhangbo 5 년 전
부모
커밋
b82a54e7fd

BIN
app/bmc/bmc_app


+ 8 - 0
app/bmc/main.c

@@ -31,6 +31,7 @@
 #include "stm32f429xx.h"
 #include "com_gpio.h"
 #include "hal_interface_api.h"
+#include "com_BMCCfg.h"
 
 
 /* gloabl varible */
@@ -38,6 +39,13 @@ BMCInfo_t 	g_BMCInfo;
 pthread_t 	gThreadIDs[256];
 uint8_t		gThreadIndex = 0;
 SensorHistoryInfo_T 	gSensorHistoryInfo[SENSOR_NUMBERS];
+FanInfo_T	gFanInfo[FAN_NUMBERS] = {
+								/* Index | name | mode | level | speed  */
+									{0, {"Fan1"}, 0, 0, 0 },
+									{1, {"Fan2"}, 0, 0, 0 },
+									{2, {"Fan3"}, 0, 0, 0 },
+									{3, {"Fan4"}, 0, 0, 0 },
+								};
 
 //void *test_thread(void *var);
 //uint8_t test_flag = 0;

+ 2 - 0
app/bmc/main.h

@@ -17,6 +17,7 @@
 #include "sensor_tbl.h"
 #include "MsgHndlr.h"
 #include "hal_interface_api.h"
+#include "com_BMCCfg.h"
 /* Declare global variable */
 
 /*---------------------------------------------------------------------------*
@@ -105,5 +106,6 @@ extern TimerTaskTbl_T    		m_TimerTaskTbl [20];
 
 extern BMCInfo_t 	g_BMCInfo;
 extern SensorHistoryInfo_T 	gSensorHistoryInfo[SENSOR_NUMBERS];
+extern FanInfo_T				gFanInfo[FAN_NUMBERS];
 
 #endif /* __MAIN_H__ */

+ 2 - 0
app/bmc/msghndlr/PDKCmds.c

@@ -342,6 +342,8 @@ const CmdHndlrMap_T g_Storlead_CmdHndlr [] =
     { CMD_GET_SEL_ENTIRES,      PRIV_USER,      Storlead_GetSELEntires,     0xff,  0xAAAA  ,0xFFFF},
     { CMD_AUTHOR_VERIFY,        PRIV_USER,      Storlead_AuthorVerify,     0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_SENSOR_HISTORY,   PRIV_USER,      Storlead_GetSensorHistory,     0xff,  0xAAAA  ,0xFFFF},
+    { CMD_GET_FAN_INFO,         PRIV_USER,      Storlead_GetFanInfo,         0xff,  0xAAAA  ,0xFFFF},
+    { CMD_SET_FAN_INFO,         PRIV_USER,      Storlead_SetFanInfo,         0xff,  0xAAAA  ,0xFFFF},
     { 0x00,                     0x00,           0x00,                 0x00, 0x0000  ,  0x0000},
 };
 

+ 49 - 0
app/bmc/msghndlr/Storlead/Storlead.c

@@ -384,4 +384,53 @@ int Storlead_GetSensorHistory(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     *(pRes+2) = len&0xff;
     
     return len+3;   
+}
+
+int Storlead_GetFanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    *pRes = CC_NORMAL;
+    
+    memcpy(pRes+1, (uint8_t*)gFanInfo, FAN_NUMBERS*sizeof(FanInfo_T));
+
+    // int i;
+    // printf("=======FAN==========\n");
+    // for(i=0;i<FAN_NUMBERS*sizeof(FanInfo_T)+1;i++)
+    //     printf("%02x ", pRes[i]);
+    // printf("\n");
+
+    return FAN_NUMBERS*sizeof(FanInfo_T) + 1;   
+}
+
+int Storlead_SetFanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    uint8_t index = pReq[0];
+    uint8_t mode = pReq[1];         //0: 自动, 1:手动
+    uint8_t level = pReq[2];
+
+    *pRes = CC_NORMAL;
+    if(index >= FAN_NUMBERS)
+    {
+        printf("Invalid index %d\n", index);
+        *pRes = CC_PARAM_OUT_OF_RANGE;
+        return 1;
+    }
+
+    if(mode > 1)
+    {
+        printf("Invalid mode %d\n", mode);
+        *pRes = CC_PARAM_OUT_OF_RANGE;
+        return 1;
+    }
+
+    if(level > 100)
+        level = 100;
+
+    gFanInfo[index].mode = mode;
+
+    if(mode == 1)
+    {
+        gFanInfo[index].level = level;
+    }
+
+    return 1;
 }

+ 3 - 1
app/bmc/msghndlr/Storlead/Storlead.h

@@ -7,4 +7,6 @@ int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
 int  Storlead_GetSensorInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
 int  Storlead_GetSELEntires(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_AuthorVerify(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
-int Storlead_GetSensorHistory(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_GetSensorHistory(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_GetFanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_SetFanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);

+ 3 - 1
app/bmc/msghndlr/cmdselect.c

@@ -801,7 +801,9 @@ const NetFnCmds_T g_Storlead [] =
 	{ CMD_GET_SENSOR_INFO          ,ENABLED},
 	{ CMD_GET_SEL_ENTIRES          ,ENABLED},
 	{ CMD_AUTHOR_VERIFY          ,ENABLED},
-	{ CMD_GET_SENSOR_HISTORY          ,ENABLED},		
+	{ CMD_GET_SENSOR_HISTORY          ,ENABLED},	
+	{ CMD_GET_FAN_INFO          ,ENABLED},	
+	{ CMD_SET_FAN_INFO          ,ENABLED},	
 	{0,				0		},
 };
 

+ 9 - 0
app/common_include/com_BMCCfg.h

@@ -0,0 +1,9 @@
+#ifndef __COM_BMC_CFG_H__
+#define __COM_BMC_CFG_H__
+
+#define 	FAN_NUMBERS		4
+
+
+
+
+#endif /* __COM_BMC_CFG_H__ */

+ 10 - 0
app/common_include/com_BmcType.h

@@ -314,5 +314,15 @@ typedef struct
     uint8_t History[HISTORY_DATA_SIZE];
 } SensorHistoryInfo_T;
 
+typedef struct{
+    uint8_t index;
+    uint8_t name[MAX_ID_STR_LEN];
+    uint8_t mode;
+    uint8_t level;    //duty 0% - 100%
+    uint32_t speed;   //RPM 
+} FanInfo_T;
+
+
+
 #pragma pack()
 #endif /* __BMC_TYPE_H__ */

+ 4 - 0
app/common_include/com_IPMIDefs.h

@@ -45,6 +45,10 @@
     #define FALSE 0
 #endif    
 
+
+
+
+
 #define USERTBL_FLASH_ADDR 0x800000
 
 #define MAX_STR_LENGTH          128

+ 2 - 0
app/common_include/com_IPMI_Storlead.h

@@ -6,5 +6,7 @@
 #define CMD_GET_SEL_ENTIRES		0x2
 #define CMD_AUTHOR_VERIFY 		0x3
 #define CMD_GET_SENSOR_HISTORY  0x4
+#define CMD_GET_FAN_INFO		0x5
+#define CMD_SET_FAN_INFO		0x6
 
 #endif /* __COM_IPMI_STORLEAD_H__ */

+ 6 - 1
app/goahead-3.6.5/projects/goahead-linux-static.mk

@@ -242,6 +242,7 @@ DEPS_USER_H2 += ../common_include/com_IPMI_PEF.h
 DEPS_USER_H2 += ../common_include/com_IPMI_RMCP.h
 DEPS_USER_H2 += ../common_include/com_BmcType.h
 DEPS_USER_H2 += ../common_include/com_IPMI_Storlead.h
+DEPS_USER_H2 += ../common_include/com_BMCCfg.h
 
 
 $(BUILD)/inc/libipmi_session.h: $(DEPS_USER_H2)
@@ -393,6 +394,10 @@ $(BUILD)/inc/com_IPMI_Storlead.h: $(DEPS_USER_H2)
 	@echo '      [Copy] $(BUILD)/inc/com_IPMI_Storlead.h'
 	mkdir -p "$(BUILD)/inc"
 	cp ../common_include/com_IPMI_Storlead.h $(BUILD)/inc/com_IPMI_Storlead.h
+$(BUILD)/inc/com_BMCCfg.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/com_BMCCfg.h'
+	mkdir -p "$(BUILD)/inc"
+	cp ../common_include/com_BMCCfg.h $(BUILD)/inc/com_BMCCfg.h
 
 #
 #   LUSA, ResultUtils
@@ -503,7 +508,7 @@ DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_Sensor.h
 DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_SDRRecord.h
 DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_PEF.h
 DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_Storlead.h
-
+DEPS_USER_C2 += $(BUILD)/inc/com_BMCCfg.h
 
 
 $(BUILD)/obj/libipmi_session.o: \

+ 4 - 0
app/goahead-3.6.5/src/goahead.c

@@ -214,6 +214,10 @@ websDefineAction("resetBmc", resetBmc);
 websDefineAction("setThreshold", setThreshold);
 websDefineAction("web_getSensorHistory", web_getSensorHistory);
 
+//fan
+websDefineAction("getAllFanInfo", getAllFanInfo);
+websDefineAction("setFanInfo", setFanInfo);
+
 
 
 /**************** user code after goahead end************************/

+ 3 - 13
app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h

@@ -8,6 +8,7 @@
 
 #include "libipmi_struct.h"
 #include <stdint.h>
+#include "com_BmcType.h"
 
 #define MAX_TITLE_LEN	20
 #define MAX_TEXT_LEN		256
@@ -17,17 +18,6 @@
 
 #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{
@@ -105,7 +95,7 @@ typedef struct{
 extern OemWebFlags_T g_OemWebFlags;
 //uint16_t LIBIPMI_HL_GetIPMCSensorInfo(IPMI20_UDS_SESSION_T *pUDSSession, SenInfo_T *pSensorInfo,uint32_t *nNumSensor,int timeout);
 
-//uint16_t LIBIPMI_HL_FanCtrol( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout);
+uint16_t LIBIPMI_HL_SetFanInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout);
 //int LIBIPMI_HL_GetFanStatus( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, OemFanStatus_T *pFanStatus, int timeout);
 uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, 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);
@@ -115,7 +105,7 @@ uint16_t LIBIPMI_HL_GetSensorHistory( IPMI20_UDS_SESSION_T *pUDSSession, sensor_
 //int LIBIPMI_HL_GetIPMCCapability(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t bladeIndex, OemIPMCCapability_T* pIPMCCapability, int timeout);
 //int LIBIPMI_HL_SetBladeManageFn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t enable, int timeout);
 //int LIBIPMI_HL_GetManageWebName(IPMI20_UDS_SESSION_T *pUDSSession, char* webName, int timeout);
-//int LIBIPMI_HL_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, OemFanInfo_T* pFanInfo, int timeout);
+int LIBIPMI_HL_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, FanInfo_T* pFanInfo, int timeout);
 //int LIBIPMI_HL_GetSensorHistoryCapability(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensorNum, SensorHistoryCapability_T* pSensorHistoryCapability, int timeout);
 //int LIBIPMI_HL_GetSensorHistoryEn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t* SensorHistoryEnable, int timeout);
 //int LIBIPMI_HL_SetSensorHistoryEn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensorNum, uint8_t SensorHistoryEnable, int timeout);

+ 42 - 63
app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c

@@ -17,6 +17,7 @@
 #include "com_IPMI_Storlead.h"
 #include "libipmi_StorDevice.h"
 #include "com_BmcType.h"
+#include "com_BMCCfg.h"
 
 
 OemWebFlags_T g_OemWebFlags;
@@ -215,53 +216,21 @@ OemWebFlags_T g_OemWebFlags;
 // 	return (wRet);
 // }
 
-// uint16_t LIBIPMI_HL_FanCtrol( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout)
-// {
-// 	uint16_t wRet = 0;
-// 	uint8_t	Res[10];
-// 	uint8_t Req[10];
-// 	uint32_t dwResLen;
-// 	Req[0]	= fanIndex;
-// 	Req[1] 	= fanMode;
-// 	Req[2]	= fanLevel;
-// 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,   0x2e<<2, 0x87,
-// 													(uint8_t*)Req, 3,
-// 													(uint8_t *)Res, &dwResLen,
-// 													timeout);
-// 	return wRet;
-// }
-
-// int LIBIPMI_HL_GetFanStatus( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, OemFanStatus_T *pFanStatus, int timeout)
-// {
-// 	uint16_t wRet = 0;
-// 	uint8_t	Res[32];
-// 	uint32_t dwResLen;
-// 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,   0x2e<<2, 0x86,
-// 														(uint8_t*)&fanIndex, 1,
-// 														(uint8_t *)Res, &dwResLen,
-// 														timeout);
-// 	memset(pFanStatus->name, 0, 16);
-// 	if((wRet == 0) && (Res[0] == 0))
-// 	{
-// 		pFanStatus->index = fanIndex;
-// 		memcpy(pFanStatus->name, &Res[1], 16);
-// 		pFanStatus->level = Res[17];
-// 		pFanStatus->mode = Res[18];
-// 		pFanStatus->speed = (Res[19]<<24) | (Res[20]<<16) | (Res[21]<<8) | Res[22];
-// 	}
-// 	else
-// 	{
-// 		printf("---> LIBIPMI_HL_GetFanInfo get fan info error!\n");
-// 		pFanStatus->index = fanIndex;
-// 		memcpy(pFanStatus->name, "UNKNOWN", 7);
-// 		pFanStatus->level = 0;
-// 		pFanStatus->mode = 0;
-// 		pFanStatus->speed = 0;
-// 		return -1;
-// 	}
-	
-// 	return 0;	
-// }
+uint16_t LIBIPMI_HL_SetFanInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout)
+{
+	uint16_t wRet = 0;
+	uint8_t	Res[10];
+	uint8_t Req[10];
+	uint32_t dwResLen;
+	Req[0]	= fanIndex;
+	Req[1] 	= fanMode;
+	Req[2]	= fanLevel;
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,   NETFNLUN_IPMI_STORLEAD, CMD_SET_FAN_INFO,
+													(uint8_t*)Req, 3,
+													(uint8_t *)Res, &dwResLen,
+													timeout);
+	return wRet;
+}
 
 uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pSysInfo, int timeout)
 {
@@ -543,23 +512,33 @@ LIBIPMI_HL_GetSensorHistory( IPMI20_UDS_SESSION_T *pUDSSession, sensor_history_s
 // 	return 0;
 // }
 
-// int LIBIPMI_HL_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, OemFanInfo_T* pFanInfo, int timeout)
-// {
-// 	int wRet = 0;
-// 	uint32_t	dwResLen;
-// 	uint8_t pRes[10];
-	
-// 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-// 							0x2e<<2, 0x85,
-// 							NULL,	0,
-// 							(uint8_t*)pRes,  &dwResLen,
-// 							timeout);
-// 	if( wRet != 0 )
-// 			printf("Error LIBIPMI_HL_SetBladeManageFn\n");
+int LIBIPMI_HL_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, FanInfo_T* pFanInfo, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	*pRes = (uint8_t *)walloc(FAN_NUMBERS*sizeof(FanInfo_T) + 10);
+	
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_STORLEAD, CMD_GET_FAN_INFO,
+							NULL,	0,
+							(uint8_t*)pRes,  &dwResLen,
+							timeout);
+	if( wRet != 0 )
+	{
+		printf("Error LIBIPMI_HL_GetFanInfo\n");
+		return -1;
+	}
+
+	memcpy((uint8_t*)pFanInfo, pRes+1, FAN_NUMBERS*sizeof(FanInfo_T));
+
+	// int i;
+	// printf("==========Fan get ==========\n");
+	// for(i=0;i<FAN_NUMBERS*sizeof(FanInfo_T)+1;i++)
+	// 	printf("%02x ", pRes[i]);
+	// printf("\n");
 	
-// 	pFanInfo->fanNum = pRes[1];
-// 	return 0;
-// }
+	return 0;
+}
 
 // int LIBIPMI_HL_GetSensorHistoryCapability(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensorNum, SensorHistoryCapability_T* pSensorHistoryCapability, int timeout)
 // {

+ 3 - 0
app/goahead-3.6.5/src/web_interface/inc/fan.h

@@ -2,4 +2,7 @@
 #define __FAN_H__
 #include "goahead.h"
 
+void getAllFanInfo(Webs *wp);
+void setFanInfo(Webs *wp);
+
 #endif /* __FAN_H__ */

+ 133 - 0
app/goahead-3.6.5/src/web_interface/src/fan.c

@@ -0,0 +1,133 @@
+#include    "goahead.h"
+#include    "libipmi_IPM.h"
+#include    "com_IPMIDefs.h"
+#include    "ResultUtils.h"
+#include    "cJSON.h"
+#include    "libipmi_storlead_OEM.h"
+#include    "libsensor.h"
+#include 	"libipmi_sdr.h"
+#include 	"libipmi_sensor.h"
+#include 	"com_BMCCfg.h"
+#include    <stdio.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+
+void getAllFanInfo(Webs *wp){
+	FanInfo_T fanInfo[FAN_NUMBERS];
+	uint16_t    wRet = LIBIPMI_E_SUCCESS;
+    IPMI20_UDS_SESSION_T    UDSSession;
+    int i;
+
+	//Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+	wRet = LIBIPMI_HL_GetFanInfo( &UDSSession, fanInfo, DEFAULT_TIMEOUT);
+	if(wRet != 0)
+	{
+		websError(wp, 404, "getAllFanInfo error!");
+	}
+
+	//Close session
+    LIBIPMI_CloseSession(&UDSSession );
+
+	char *pStr;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * pJsonArry=cJSON_CreateArray();   /*创建数组*/
+    cJSON * pJsonsub;
+    cJSON_AddItemToObject(root, "data", pJsonArry);//根节点下添加
+    cJSON_AddStringToObject(root, "msg", "");
+    cJSON_AddNumberToObject(root, "code", 200);
+
+    for(i=0;i<FAN_NUMBERS;i++)
+    {
+    	cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
+        cJSON_AddNumberToObject(pJsonsub, "index", fanInfo[i].index); 
+        cJSON_AddStringToObject(pJsonsub, "name", fanInfo[i].name);
+        cJSON_AddNumberToObject(pJsonsub, "mode", fanInfo[i].mode);			//0: 自动, 1:手动
+        cJSON_AddNumberToObject(pJsonsub, "level", fanInfo[i].level);
+        cJSON_AddNumberToObject(pJsonsub, "speed", fanInfo[i].speed);
+    }
+    
+   
+    pStr = cJSON_PrintUnformatted(root);
+
+    printf("---> cJSON Str:\n%s\n", pStr);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp); 
+    websWrite(wp,"%s", pStr);
+    websFlush(wp, 0);
+    websDone(wp);
+
+    if(pStr)
+        wfree(pStr);
+    if(root)
+        cJSON_Delete(root);
+}
+
+void setFanInfo(Webs *wp){
+	uint16_t    wRet = LIBIPMI_E_SUCCESS;
+    IPMI20_UDS_SESSION_T    UDSSession;
+    int i;
+
+    char *strIndex = websGetVar(wp, "index", NULL);
+    char *strMode = websGetVar(wp, "mode", NULL);
+    char *strLevel = websGetVar(wp, "level", NULL);
+
+    uint8_t index = atoi(strIndex);
+    uint8_t mode = atoi(strMode);
+    uint8_t level = atoi(strLevel);
+
+    if(index >= FAN_NUMBERS)
+    {
+    	websError(wp, 404, "Invalid index!");
+    	return ;
+    }
+
+    if(mode > 1)
+    {
+		websError(wp, 404, "Invalid mode!");    	
+		return;
+    }
+
+    if(level > 100)
+    	level = 100;
+
+	//Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+	wRet = LIBIPMI_HL_SetFanInfo( &UDSSession, index, mode, level, DEFAULT_TIMEOUT);
+	if(wRet != 0)
+	{
+		websError(wp, 404, "getAllFanInfo error!");
+	}
+
+	//Close session
+    LIBIPMI_CloseSession(&UDSSession );
+
+	char *pStr;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    cJSON_AddStringToObject(root, "msg", "");
+    cJSON_AddNumberToObject(root, "code", 200);
+
+  
+    pStr = cJSON_PrintUnformatted(root);
+
+    printf("---> cJSON Str:\n%s\n", pStr);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp); 
+    websWrite(wp,"%s", pStr);
+    websFlush(wp, 0);
+    websDone(wp);
+
+    if(pStr)
+        wfree(pStr);
+    if(root)
+        cJSON_Delete(root);
+}