瀏覽代碼

add web_getRuntime interface

zhangbo 3 年之前
父節點
當前提交
8e14c871b7

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

@@ -235,6 +235,7 @@ websDefineAction("web_GetLanInfo", web_GetLanInfo);
 websDefineAction("web_SetLanInfo", web_SetLanInfo);
 websDefineAction("checkLoginStatus", checkLoginStatus);
 websDefineAction("logout", logout);
+websDefineAction("web_GetRunTime", web_GetRunTime);
 /**************** user code after goahead end************************/
 #if ME_UNIX_LIKE && !MACOSX
     /*

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

@@ -7,5 +7,6 @@ void restoreFactorySettings(Webs *wp);
 void web_ResetBMC(Webs *wp);
 void web_GetLanInfo(Webs *wp);
 void web_SetLanInfo(Webs *wp);
+void web_GetRunTime(Webs *wp);
 
 #endif /* __CONFIG_H__ */

+ 32 - 0
app/goahead-3.6.5/src/web_interface/src/config.c

@@ -325,6 +325,38 @@ void web_SetLanInfo(Webs *wp){
 }
 
 
+void web_GetRunTime(Webs *wp){
+    uint16_t    wRet = LIBIPMI_E_SUCCESS;
+    IPMI20_UDS_SESSION_T    UDSSession;
+    uint8_t target_addr;
+    uint32_t    TotalRunTime = 1000;    //模块总运行时间,单位: 分钟
+    uint32_t    CurRunTime = 50;        //模块本次运行时间,单位: 分钟
+   
+    
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    cJSON_AddNumberToObject(data, "TotalRunTime", TotalRunTime);
+    cJSON_AddNumberToObject(data, "CurRunTime", CurRunTime);
+    cJSON_AddStringToObject(root, "msg", "");
+    cJSON_AddNumberToObject(root, "code", 200);
+
+    char *pStr;
+    pStr = cJSON_PrintUnformatted(root);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp); 
+    websWrite(wp,"%s", pStr);
+    websFlush(wp, 0);
+    websDone(wp);
+    printf("cJSON:%s\n", pStr);
+
+    if(pStr)
+        wfree(pStr);
+    if(root)
+        cJSON_Delete(root);
+}
+
 /*
     index = 0,1,2,3,4,5
 */

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

@@ -59,7 +59,6 @@ void getAllFanInfo(Webs *wp){
 
     for(i=0;i<MAX_FAN_NUMS;i++)
     {
-        printf("===> %d %s %d %d %d \n", fanInfo[i].index,fanInfo[i].name,fanInfo[i].mode,fanInfo[i].level,fanInfo[i].speed);
         if(fanInfo[i].index != 0xff)
         {
         	cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/