瀏覽代碼

submit some modify

lusa 5 年之前
父節點
當前提交
566b1d8a26
共有 3 個文件被更改,包括 134 次插入168 次删除
  1. 0 77
      app/goahead-5.1.0/src/goahead.c
  2. 0 88
      app/goahead-5.1.0/src/route.c
  3. 134 3
      app/goahead-5.1.0/src/web_interface/src/dashboard.c

+ 0 - 77
app/goahead-5.1.0/src/goahead.c

@@ -52,83 +52,6 @@ static void actionTest(Webs *wp);
 // static void personInfoAction(Webs *wp);
 
 
-static void buy(Webs *wp)
-{
-    cchar    *name, *age;
-    name = websGetVar(wp, "name", NULL);
-    age = websGetVar(wp, "age", NULL);
-     logmsg(2, "----------------------------11-----------------");
-    logmsg(2, "name value is : %s", name );
-     logmsg(2, "age value is : %s", age );
-    websSetStatus(wp, 200);
-    websWriteHeaders(wp, -1, 0);
-    websWriteEndHeaders(wp);
-   
-    websWrite(wp, "Name %s", name);
-    websWrite(wp, "age %s", age); 
-    websFlush(wp, 0);
-    websDone(wp);
-}
-
-
-
-// /*
-//     Implement /action/actionTest. Parse the form variables: name, address and echo back.
-//  */
-static void actionTest(Webs *wp)
-{
-
-
-logmsg(2, "--------------------ggggggggg----------------");
-
-    uint16_t    wRet = LIBIPMI_E_SUCCESS;
-    GetDevIDRes_T   DeviceID;
-    char BuildTime[30] = {0};
-    char FwVersion[10] = {0};
-    //Create session
-    LIBIPMI_CreateSession(&wp->ipmi_session, 10);
-    sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
-    wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
-    if (wRet == LIBIPMI_E_SUCCESS)
-    {
-        sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
-    }
-    printf("BuildTime: %s\n", BuildTime);
-    printf("FwVersion: %s\n", FwVersion);
-    //Close session
-    LIBIPMI_CloseSession(&wp->ipmi_session );
-    // cchar *pStr;
-    // int code = 200;
-    // cJSON * root =  cJSON_CreateObject();
-    // cJSON * data =  cJSON_CreateObject();
-    // // cJSON * next =  cJSON_CreateObject();
-    // cJSON_AddItemToObject(root, "data", data);//根节点下添加
-    // cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
-    // cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
-    // cJSON_AddStringToObject(data, "BuildTime", BuildTime);
-    // cJSON_AddStringToObject(data, "FwVersion", FwVersion);
-
-    // pStr = cJSON_Print(root);
-
-    // printf("first json:\n%s\n", pStr);
-
-
-
-    cchar   *name, *address;
-
-    name = websGetVar(wp, "name", NULL);
-    address = websGetVar(wp, "address", NULL);
-    websSetStatus(wp, 200);
-    websWriteHeaders(wp, -1, 0);
-    websWriteEndHeaders(wp);
-    websWrite(wp, "Name %s", name);
-    websFlush(wp, 0);
-    websDone(wp);
-}
-
-
-
-
 /*********************************** Code *************************************/
 
 MAIN(goahead, int argc, char **argv, char **envp)

+ 0 - 88
app/goahead-5.1.0/src/route.c

@@ -84,94 +84,6 @@ void personInfoAction(Webs *wp)
 }
 
 
-/*获取设备信息*/
-void getDeviceInfo(Webs *wp){
-    logmsg(2, "--------------------ggggggggg----------------");
-
-    uint16_t    wRet = LIBIPMI_E_SUCCESS;
-    GetDevIDRes_T   DeviceID;
-    char BuildTime[30] = {0};
-    char FwVersion[10] = {0};
-    //Create session
-    LIBIPMI_CreateSession(&wp->ipmi_session, 10);
-    sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
-    wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
-    if (wRet == LIBIPMI_E_SUCCESS)
-    {
-        sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
-    }
-    printf("BuildTime: %s\n", BuildTime);
-    printf("FwVersion: %s\n", FwVersion);
-    //Close session
-    LIBIPMI_CloseSession(&wp->ipmi_session );
-    char *pStr;
-    int code = 200;
-    cJSON * root =  cJSON_CreateObject();
-    cJSON * data =  cJSON_CreateObject();
-    // cJSON * next =  cJSON_CreateObject();
-    cJSON_AddItemToObject(root, "data", data);//根节点下添加
-    cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
-    cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
-    cJSON_AddStringToObject(data, "BuildTime", BuildTime);
-    cJSON_AddStringToObject(data, "FwVersion", FwVersion);
-
-    pStr = cJSON_Print(root);
-
-    printf("first json:\n%s\n", pStr);
-    logmsg(2, "-----------------------jso1n----------------------%s", pStr);
-    websSetStatus(wp, 200);
-    websWriteHeaders(wp, -1, 0);
-    websWriteEndHeaders(wp); 
-    websWrite(wp, "[ {\"name\":\"kangkang\",\"age\":\"12\",\"gender\":\"male\"}, {\"name\":\"Jane\",\"age\":\"14\",\"gender\":\"female\"}]");
-    websDone(wp);
-    // retrun 1;
-}
-/*获取设备信息*/
-void getDeviceInfoBak(Webs *wp){
-    logmsg(2, "--------------------ggggggggg----------------");
-
-    uint16_t    wRet = LIBIPMI_E_SUCCESS;
-    GetDevIDRes_T   DeviceID;
-    char BuildTime[30] = {0};
-    char FwVersion[10] = {0};
-    //Create session
-    LIBIPMI_CreateSession(&wp->ipmi_session, 10);
-    sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
-    wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
-    if (wRet == LIBIPMI_E_SUCCESS)
-    {
-        sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
-    }
-    printf("BuildTime: %s\n", BuildTime);
-    printf("FwVersion: %s\n", FwVersion);
-    //Close session
-    LIBIPMI_CloseSession(&wp->ipmi_session );
-    cchar *pStr;
-    int code = 200;
-    cJSON * root =  cJSON_CreateObject();
-    cJSON * data =  cJSON_CreateObject();
-    // cJSON * next =  cJSON_CreateObject();
-    cJSON_AddItemToObject(root, "data", data);//根节点下添加
-    cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
-    cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
-    cJSON_AddStringToObject(data, "BuildTime", BuildTime);
-    cJSON_AddStringToObject(data, "FwVersion", FwVersion);
-
-    pStr = cJSON_Print(root);
-
-    printf("first json:\n%s\n", pStr);
-    logmsg(2, "-----------------------jso1n----------------------%s", pStr);
-
-    websSetStatus(wp, 200);
-    websWriteHeaders(wp, -1, 0);
-    websWriteEndHeaders(wp); 
-    websWrite(wp, "[ {\"name\":\"kangkang\",\"age\":\"12\",\"gender\":\"male\"}, {\"name\":\"Jane\",\"age\":\"14\",\"gender\":\"female\"}]");
-    websFlush(wp, 0);
-    websDone(wp);
-}
-
-
-
 
 /************************************ Code ************************************/
 /*

+ 134 - 3
app/goahead-5.1.0/src/web_interface/src/dashboard.c

@@ -1,27 +1,158 @@
 #include    "goahead.h"
 #include    "libipmi_IPM.h"
 #include    "com_IPMIDefs.h"
+#include    "ResultUtils.h"
+#include    "cJSON.h"
+/*获取设备信息*/
 
 /*获取设备信息*/
 void getDeviceInfo(Webs *wp){
+    logmsg(2, "--------------------ggggggggg----------------");
+
     uint16_t    wRet = LIBIPMI_E_SUCCESS;
     GetDevIDRes_T   DeviceID;
     char BuildTime[30] = {0};
     char FwVersion[10] = {0};
-
     //Create session
     LIBIPMI_CreateSession(&wp->ipmi_session, 10);
-
     sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
     wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
     if (wRet == LIBIPMI_E_SUCCESS)
     {
         sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
     }
+    printf("BuildTime: %s\n", BuildTime);
+    printf("FwVersion: %s\n", FwVersion);
+    //Close session
+    LIBIPMI_CloseSession(&wp->ipmi_session );
+    char *pStr;
+    int code = 200;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    // cJSON * next =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
+    cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
+    cJSON_AddStringToObject(data, "BuildTime", BuildTime);
+    cJSON_AddStringToObject(data, "FwVersion", FwVersion);
+
+    pStr = cJSON_Print(root);
+
+    printf("first json:\n%s\n", pStr);
+    logmsg(2, "-----------------------jso1n----------------------%s", pStr);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp); 
+    websWrite(wp, "[ {\"name\":\"kangkang\",\"age\":\"12\",\"gender\":\"male\"}, {\"name\":\"Jane\",\"age\":\"14\",\"gender\":\"female\"}]");
+    websDone(wp);
+    // retrun 1;
+}
+
+
+
+
+/*获取设备信息*/
+void getDeviceInfoBak(Webs *wp){
+    logmsg(2, "--------------------ggggggggg----------------");
 
+    uint16_t    wRet = LIBIPMI_E_SUCCESS;
+    GetDevIDRes_T   DeviceID;
+    char BuildTime[30] = {0};
+    char FwVersion[10] = {0};
+    //Create session
+    LIBIPMI_CreateSession(&wp->ipmi_session, 10);
+    sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
+    wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
+    if (wRet == LIBIPMI_E_SUCCESS)
+    {
+        sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
+    }
     printf("BuildTime: %s\n", BuildTime);
     printf("FwVersion: %s\n", FwVersion);
+    //Close session
+    LIBIPMI_CloseSession(&wp->ipmi_session );
+    cchar *pStr;
+    int code = 200;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    // cJSON * next =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
+    cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
+    cJSON_AddStringToObject(data, "BuildTime", BuildTime);
+    cJSON_AddStringToObject(data, "FwVersion", FwVersion);
 
+    pStr = cJSON_Print(root);
+
+    printf("first json:\n%s\n", pStr);
+    logmsg(2, "-----------------------jso1n----------------------%s", pStr);
+
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp); 
+    websWrite(wp, "[ {\"name\":\"kangkang\",\"age\":\"12\",\"gender\":\"male\"}, {\"name\":\"Jane\",\"age\":\"14\",\"gender\":\"female\"}]");
+    websFlush(wp, 0);
+    websDone(wp);
+}
+
+
+
+static void buy(Webs *wp)
+{
+    cchar    *name, *age;
+    name = websGetVar(wp, "name", NULL);
+    age = websGetVar(wp, "age", NULL);
+     logmsg(2, "----------------------------11-----------------");
+    logmsg(2, "name value is : %s", name );
+     logmsg(2, "age value is : %s", age );
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp);
+   
+    websWrite(wp, "Name %s", name);
+    websWrite(wp, "age %s", age); 
+    websFlush(wp, 0);
+    websDone(wp);
+}
+
+
+
+// /*
+//     Implement /action/actionTest. Parse the form variables: name, address and echo back.
+//  */
+static void actionTest(Webs *wp)
+{
+
+
+logmsg(2, "--------------------ggggggggg----------------");
+
+    uint16_t    wRet = LIBIPMI_E_SUCCESS;
+    GetDevIDRes_T   DeviceID;
+    char BuildTime[30] = {0};
+    char FwVersion[10] = {0};
+    //Create session
+    LIBIPMI_CreateSession(&wp->ipmi_session, 10);
+    sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
+    wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
+    if (wRet == LIBIPMI_E_SUCCESS)
+    {
+        sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
+    }
+    printf("BuildTime: %s\n", BuildTime);
+    printf("FwVersion: %s\n", FwVersion);
     //Close session
     LIBIPMI_CloseSession(&wp->ipmi_session );
-}
+   
+    cchar   *name, *address;
+
+    name = websGetVar(wp, "name", NULL);
+    address = websGetVar(wp, "address", NULL);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp);
+    websWrite(wp, "Name %s", name);
+    websFlush(wp, 0);
+    websDone(wp);
+}
+
+