|
@@ -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);
|
|
|
|
+}
|
|
|
|
|
|
|
|
|