Prechádzať zdrojové kódy

add Web_SetModIdentifyOn/off

zhangbo 3 rokov pred
rodič
commit
ec536c5a99

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

@@ -236,6 +236,9 @@ websDefineAction("web_SetLanInfo", web_SetLanInfo);
 websDefineAction("checkLoginStatus", checkLoginStatus);
 websDefineAction("logout", logout);
 websDefineAction("web_GetRunTime", web_GetRunTime);
+websDefineAction("web_SetModIdentifyOn", web_SetModIdentifyOn);
+websDefineAction("web_SetModIdentifyOff", web_SetModIdentifyOff);
+
 /**************** user code after goahead end************************/
 #if ME_UNIX_LIKE && !MACOSX
     /*

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

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

+ 85 - 2
app/goahead-3.6.5/src/web_interface/src/config.c

@@ -336,8 +336,91 @@ void web_GetRunTime(Webs *wp){
     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(data, "TotalRunTime", "129 hour 40 min");
+    cJSON_AddStringToObject(data, "CurRunTime", "1 hour 3 min");
+    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);
+}
+
+void web_SetModIdentifyOn(Webs *wp){
+    uint16_t    wRet = LIBIPMI_E_SUCCESS;
+    IPMI20_UDS_SESSION_T    UDSSession;
+    uint8_t target_addr;
+    char *strTime = websGetVar(wp, "timeSelect", NULL);    //
+    int timeSelect = atoi(strTime);
+    uint8_t identifySec = 0;
+
+    switch(timeSelect)
+    {
+        case 0: //15s
+            identifySec = 15;
+            break;
+        case 1: //30s
+            identifySec = 30;
+            break;
+        case 2: //60s
+            identifySec = 60;
+            break;
+        case 3: //120s
+            identifySec = 120;
+            break;
+        case 4: //forever
+            identifySec = 0xff;
+            break;
+        default:
+            identifySec = 15;
+            break;
+    }
+
+    printf("---> identify on Sec = %d\n", identifySec);
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    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);
+}
+
+void web_SetModIdentifyOff(Webs *wp){
+    uint16_t    wRet = LIBIPMI_E_SUCCESS;
+    IPMI20_UDS_SESSION_T    UDSSession;
+    uint8_t target_addr;
+    uint8_t identifySec = 0;
+
+
+    printf("---> identify off Sec = %d\n", identifySec);
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);//根节点下添加
     cJSON_AddStringToObject(root, "msg", "");
     cJSON_AddNumberToObject(root, "code", 200);