Jelajahi Sumber

New RestBMC & RestoreFactorySettings interface

zhangbo 5 tahun lalu
induk
melakukan
779b4ad2a6

+ 1 - 1
app/bmc/Api.c

@@ -563,4 +563,4 @@ int getSensorHistory(uint8_t sensorNum, uint8_t *phistoryBuf)
 		printf("---> can't find sensorNum!\n");
 		return -1;
 	}
-}
+}

TEMPAT SAMPAH
app/bmc/bmc_app


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

@@ -481,3 +481,11 @@ int Storlead_GetChassisInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     pRes[4] = g_BMCInfo.IndexInChassis;
     return 5;
 }
+
+
+int Storlead_RestoreFactorSettings(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    pRes[0] = CC_NORMAL;
+    //TODO:擦除Flash
+    return 5;
+}

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

@@ -228,6 +228,9 @@ websDefineAction("web_getSensorHistory", web_getSensorHistory);
 websDefineAction("getAllFanInfo", getAllFanInfo);
 websDefineAction("setFanInfo", setFanInfo);
 
+//config
+websDefineAction("restoreFactorySettings", restoreFactorySettings);
+websDefineAction("web_ResetBMC", web_ResetBMC);
 
 
 /**************** user code after goahead end************************/

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

@@ -108,6 +108,6 @@ int LIBIPMI_HL_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, FanInfo_T* pFanInfo
 //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);
 uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventRecordWithSensorName_T *pSELEntriesBuffer,uint32_t *nNumSelEntries,int timeout);
-
+uint16_t IPMICMD_ResetBMC(IPMI20_UDS_SESSION_T *pUDSSession, int timeout);
 #endif /* __LIBIPMI_STORLEAD_OEM_H__ */
 

+ 16 - 0
app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c

@@ -20,6 +20,7 @@
 #include "libipmi_StorDevice.h"
 #include "com_BmcType.h"
 #include "com_BMCCfg.h"
+#include "com_IPMI_App.h"
 
 
 OemWebFlags_T g_OemWebFlags;
@@ -766,3 +767,18 @@ uint16_t LIBIPMI_HL_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession,SELEventR
 	}
 	return (wRet);
 }
+
+uint16_t IPMICMD_ResetBMC(IPMI20_UDS_SESSION_T *pUDSSession, int timeout)
+{
+	uint16_t wRet;
+	uint32_t dwResLen;
+	uint8_t res;
+	
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
+						NETFNLUN_IPMI_APP, CMD_COLD_RESET,
+						NULL, 0,
+						(uint8_t*)&res, &dwResLen,
+						timeout);
+	
+	return (wRet);
+}

+ 4 - 0
app/goahead-3.6.5/src/web_interface/inc/config.h

@@ -3,5 +3,9 @@
 
 #include "goahead.h"
 
+void setIpAddr(Webs *wp);
+void setMacAddr(Webs *wp);
+void restoreFactorySettings(Webs *wp);
+void web_ResetBMC(Webs *wp);
 
 #endif /* __CONFIG_H__ */

+ 82 - 61
app/goahead-3.6.5/src/web_interface/src/config.c

@@ -24,68 +24,89 @@ void setMacAddr(Webs *wp)
 
 
 
-// void restoreFactorySettings(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);
+void restoreFactorySettings(Webs *wp){
+	uint16_t    wRet = LIBIPMI_E_SUCCESS;
+    IPMI20_UDS_SESSION_T    UDSSession;
+    
+	//Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+    //擦除Flash的配置区
+    //TODO
+    
+    //重启BMC
+    wRet = IPMICMD_ResetBMC(&UDSSession, DEFAULT_TIMEOUT);
+	if(wRet != 0)
+	{
+		websError(wp, 404, "Reset BMC fail!");
+	}
+
+	//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);
-// }
+    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 web_ResetBMC(Webs *wp){
+	uint16_t    wRet = LIBIPMI_E_SUCCESS;
+    IPMI20_UDS_SESSION_T    UDSSession;
+    
+	//Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+	wRet = IPMICMD_ResetBMC(&UDSSession, DEFAULT_TIMEOUT);
+	if(wRet != 0)
+	{
+		websError(wp, 404, "Reset BMC fail!");
+	}
+
+	//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);
+}