Bladeren bron

all ipmc interfance ok

zhangbo 3 jaren geleden
bovenliggende
commit
ae5b0cd7f2

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

@@ -624,7 +624,6 @@ uint16_t IPMC_restoreFactorySettings(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t
 	Req[6] = CMD_RESTORE_FACTORY_SET;	
 	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
 
-	//dwResLen = sizeof(GetDevIDRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
 											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
 											Req,8,

+ 113 - 77
app/goahead-3.6.5/src/web_interface/src/config.c

@@ -22,15 +22,31 @@ uint8_t ip2dec(const char *strIp, uint8_t index);
 void restoreFactorySettings(Webs *wp){
 	uint16_t    wRet = LIBIPMI_E_SUCCESS;
     IPMI20_UDS_SESSION_T    UDSSession;
+    uint8_t target_addr;
     
 	//Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
-    //擦除Flash的配置区
-    IPMICMD_restoreFactorySettings(&UDSSession, DEFAULT_TIMEOUT);
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        //擦除Flash的配置区
+        wRet = IPMICMD_restoreFactorySettings(&UDSSession, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_restoreFactorySettings(&UDSSession, target_addr, DEFAULT_TIMEOUT);
+    }
     
     //重启BMC
-    wRet = IPMICMD_ResetBMC(&UDSSession, DEFAULT_TIMEOUT);
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_ResetBMC(&UDSSession, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_ResetBMC(&UDSSession, target_addr,DEFAULT_TIMEOUT);
+    }
 	if(wRet != 0)
 	{
 		websError(wp, 404, "Reset BMC fail!");
@@ -39,23 +55,22 @@ void restoreFactorySettings(Webs *wp){
 	//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);
 
-  
+    char *pStr;
     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);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -67,11 +82,20 @@ void restoreFactorySettings(Webs *wp){
 void web_ResetBMC(Webs *wp){
 	uint16_t    wRet = LIBIPMI_E_SUCCESS;
     IPMI20_UDS_SESSION_T    UDSSession;
+    uint8_t target_addr;
     
 	//Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
-	wRet = IPMICMD_ResetBMC(&UDSSession, DEFAULT_TIMEOUT);
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+	   wRet = IPMICMD_ResetBMC(&UDSSession, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_ResetBMC(&UDSSession, target_addr, DEFAULT_TIMEOUT);
+    }
 	if(wRet != 0)
 	{
 		websError(wp, 404, "Reset BMC fail!");
@@ -80,23 +104,22 @@ void web_ResetBMC(Webs *wp){
 	//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);
 
-  
+    char *pStr;
     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);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -104,13 +127,13 @@ void web_ResetBMC(Webs *wp){
         cJSON_Delete(root);
 }
 
-
 void web_GetLanInfo(Webs *wp){
     uint16_t    wRet = LIBIPMI_E_SUCCESS;
     IPMI20_UDS_SESSION_T    UDSSession;
     LanInfo_T   LanInfo;
     uint8_t index = 0;
     char *EthName = websGetVar(wp, "eth", NULL);
+    uint8_t target_addr;
 
     if(strcmp(EthName, "eth0") == 0)
     {
@@ -125,16 +148,25 @@ void web_GetLanInfo(Webs *wp){
     //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
-    wRet = IPMICMD_GetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
-    if(wRet != 0)
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_GetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            websError(wp, 404, "Get Lan Info fail!");
+        }
+    }
+    else
     {
-        websError(wp, 404, "Get Lan Info fail!");
+        memset(&LanInfo, 0, sizeof(LanInfo_T));
+        strcpy(LanInfo.EthName, "--");
     }
 
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
 
-    char *pStr;
+    
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
@@ -177,15 +209,15 @@ void web_GetLanInfo(Webs *wp){
         LanInfo.DefaultGW[2], LanInfo.DefaultGW[3]);
     cJSON_AddStringToObject(data, "defaultgw", strGw);
 
+    char *pStr;
     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);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -199,6 +231,7 @@ void web_SetLanInfo(Webs *wp){
     IPMI20_UDS_SESSION_T    UDSSession;
     LanInfo_T   LanInfo;
     uint8_t index = 0;
+    uint8_t target_addr;
     
     char *EthName = websGetVar(wp, "eth", NULL);    //eth0
     char *strMode = websGetVar(wp, "mode", NULL);   //static DHCP
@@ -225,83 +258,86 @@ void web_SetLanInfo(Webs *wp){
         return;
     }
 
-    strcpy(LanInfo.EthName, EthName);
-    if((strcmp(strMode, "static") == 0) || (strcmp(strMode, "Static") == 0) 
-        || (strcmp(strMode, "STATIC") == 0))
-    {
-        LanInfo.IPAddrSrc = STATIC_IP_SOURCE;  //0:unspecified 1:Static 2:DHCP  3:BIOS 4:other    
-    }
-    else if((strcmp(strMode, "DHCP") == 0) || (strcmp(strMode, "Dhcp") == 0 )
-        || (strcmp(strMode, "dhcp") == 0))
-    {
-        LanInfo.IPAddrSrc = DHCP_IP_SOURCE;    
-    }
-    else if((strcmp(strMode, "BIOS") == 0) || (strcmp(strMode, "Bios") == 0 )
-        || (strcmp(strMode, "bios") == 0))
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
     {
-        LanInfo.IPAddrSrc = BIOS_IP_SOURCE;    
-    }
-    else
-    {
-        LanInfo.IPAddrSrc = BMC_OTHER_SOURCE;  
-    }
+        strcpy(LanInfo.EthName, EthName);
+        if((strcmp(strMode, "static") == 0) || (strcmp(strMode, "Static") == 0) 
+            || (strcmp(strMode, "STATIC") == 0))
+        {
+            LanInfo.IPAddrSrc = STATIC_IP_SOURCE;  //0:unspecified 1:Static 2:DHCP  3:BIOS 4:other    
+        }
+        else if((strcmp(strMode, "DHCP") == 0) || (strcmp(strMode, "Dhcp") == 0 )
+            || (strcmp(strMode, "dhcp") == 0))
+        {
+            LanInfo.IPAddrSrc = DHCP_IP_SOURCE;    
+        }
+        else if((strcmp(strMode, "BIOS") == 0) || (strcmp(strMode, "Bios") == 0 )
+            || (strcmp(strMode, "bios") == 0))
+        {
+            LanInfo.IPAddrSrc = BIOS_IP_SOURCE;    
+        }
+        else
+        {
+            LanInfo.IPAddrSrc = BMC_OTHER_SOURCE;  
+        }
+
+        LanInfo.IPAddr[0] = ip2dec(strIp, 0);
+        LanInfo.IPAddr[1] = ip2dec(strIp, 1);
+        LanInfo.IPAddr[2] = ip2dec(strIp, 2);
+        LanInfo.IPAddr[3] = ip2dec(strIp, 3);
+        
+        LanInfo.BroadCast[0] = ip2dec(strBrdCast, 0);
+        LanInfo.BroadCast[1] = ip2dec(strBrdCast, 1);
+        LanInfo.BroadCast[2] = ip2dec(strBrdCast, 2);
+        LanInfo.BroadCast[3] = ip2dec(strBrdCast, 3);
+
+        LanInfo.NetMask[0] = ip2dec(strMask, 0);
+        LanInfo.NetMask[1] = ip2dec(strMask, 1);
+        LanInfo.NetMask[2] = ip2dec(strMask, 2);
+        LanInfo.NetMask[3] = ip2dec(strMask, 3);
+
+        LanInfo.DefaultGW[0] = ip2dec(strGw, 0);
+        LanInfo.DefaultGW[1] = ip2dec(strGw, 1);
+        LanInfo.DefaultGW[2] = ip2dec(strGw, 2);
+        LanInfo.DefaultGW[3] = ip2dec(strGw, 3);
+
+        LanInfo.MACAddr[0] = mac2hex(strMac, 0);
+        LanInfo.MACAddr[1] = mac2hex(strMac, 1);
+        LanInfo.MACAddr[2] = mac2hex(strMac, 2);
+        LanInfo.MACAddr[3] = mac2hex(strMac, 3);
+        LanInfo.MACAddr[4] = mac2hex(strMac, 4);
+        LanInfo.MACAddr[5] = mac2hex(strMac, 5);
+        
+        //Create session
+        LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
-    LanInfo.IPAddr[0] = ip2dec(strIp, 0);
-    LanInfo.IPAddr[1] = ip2dec(strIp, 1);
-    LanInfo.IPAddr[2] = ip2dec(strIp, 2);
-    LanInfo.IPAddr[3] = ip2dec(strIp, 3);
-    
-    LanInfo.BroadCast[0] = ip2dec(strBrdCast, 0);
-    LanInfo.BroadCast[1] = ip2dec(strBrdCast, 1);
-    LanInfo.BroadCast[2] = ip2dec(strBrdCast, 2);
-    LanInfo.BroadCast[3] = ip2dec(strBrdCast, 3);
-
-    LanInfo.NetMask[0] = ip2dec(strMask, 0);
-    LanInfo.NetMask[1] = ip2dec(strMask, 1);
-    LanInfo.NetMask[2] = ip2dec(strMask, 2);
-    LanInfo.NetMask[3] = ip2dec(strMask, 3);
-
-    LanInfo.DefaultGW[0] = ip2dec(strGw, 0);
-    LanInfo.DefaultGW[1] = ip2dec(strGw, 1);
-    LanInfo.DefaultGW[2] = ip2dec(strGw, 2);
-    LanInfo.DefaultGW[3] = ip2dec(strGw, 3);
-
-    LanInfo.MACAddr[0] = mac2hex(strMac, 0);
-    LanInfo.MACAddr[1] = mac2hex(strMac, 1);
-    LanInfo.MACAddr[2] = mac2hex(strMac, 2);
-    LanInfo.MACAddr[3] = mac2hex(strMac, 3);
-    LanInfo.MACAddr[4] = mac2hex(strMac, 4);
-    LanInfo.MACAddr[5] = mac2hex(strMac, 5);
-    
-    //Create session
-    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+        wRet = IPMICMD_SetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            websError(wp, 404, "Reset BMC fail!");
+        }
 
-    wRet = IPMICMD_SetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
-    if(wRet != 0)
-    {
-        websError(wp, 404, "Reset BMC fail!");
+        //Close session
+        LIBIPMI_CloseSession(&UDSSession );
     }
 
-    //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);
 
-  
+    char *pStr;
     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);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);

+ 21 - 10
app/goahead-3.6.5/src/web_interface/src/dashboard.c

@@ -119,8 +119,8 @@ void getDeviceInfo(Webs *wp){
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("cJSON:%s\n", pStr);
 
-    printf("---> cJSON Str:\n%s\n", pStr);
     if(pStr)
         wfree(pStr);
     if(root)
@@ -191,7 +191,7 @@ void getSysInfo(Webs *wp){
     websWrite(wp,"%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
-    printf("---> cJSON Str:\n%s\n", pStr);
+    printf("cJSON:%s\n", pStr);
 
 sys_info_end: 
     if(sysInfo.title)
@@ -342,9 +342,20 @@ void getSensorInfo(Webs *wp){
             sprintf(minReading, "%.3f", pSensorBuff->min_reading);
 
             cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
+            // cJSON_AddNumberToObject(pJsonsub, "Num", pSensorBuff->sensor_num); 
+            // cJSON_AddStringToObject(pJsonsub, "Nam", pSensorBuff->sensor_name);
+            // cJSON_AddStringToObject(pJsonsub, "rad", reading);      /* 给对象增加内容 */    
+            // cJSON_AddStringToObject(pJsonsub, "lnr", lownr);                                        
+            // cJSON_AddStringToObject(pJsonsub, "lct", lowct);   
+            // cJSON_AddStringToObject(pJsonsub, "lnc", lownc);                                                       
+            // cJSON_AddStringToObject(pJsonsub, "hnc", highnc);                 
+            // cJSON_AddStringToObject(pJsonsub, "hct", highct);   
+            // cJSON_AddStringToObject(pJsonsub, "hnr", highnr);  
+            // cJSON_AddStringToObject(pJsonsub, "max", maxReading);  
+            // cJSON_AddStringToObject(pJsonsub, "min", minReading);  
+
             cJSON_AddNumberToObject(pJsonsub, "sensorNum", pSensorBuff->sensor_num); 
             cJSON_AddStringToObject(pJsonsub, "sensorName", pSensorBuff->sensor_name);
-
             cJSON_AddStringToObject(pJsonsub, "reading", reading);      /* 给对象增加内容 */    
             cJSON_AddStringToObject(pJsonsub, "lownr", lownr);                                        
             cJSON_AddStringToObject(pJsonsub, "lowct", lowct);   
@@ -355,7 +366,7 @@ void getSensorInfo(Webs *wp){
             cJSON_AddStringToObject(pJsonsub, "maxReading", maxReading);  
             cJSON_AddStringToObject(pJsonsub, "minReading", minReading);  
 
-            switch(pSensorBuff->sensor_units[1])    //sensorUinits2
+            switch(pSensorBuff->sensor_units[1])    //sensorUinits2 //uit
             {
             case 0: cJSON_AddStringToObject(pJsonsub, "unit", "unspecified"); break;                    
             case 1: cJSON_AddStringToObject(pJsonsub, "unit", "degree C"); break;
@@ -368,7 +379,7 @@ void getSensorInfo(Webs *wp){
             default: cJSON_AddStringToObject(pJsonsub, "unit", "unknown"); break;
             }
 
-            switch(pSensorBuff->sensor_state)
+            switch(pSensorBuff->sensor_state)   //sta
             {
             case 0x1:  cJSON_AddStringToObject(pJsonsub, "state", "ok"); cJSON_AddStringToObject(pJsonsub, "status", "1"); break;
             case 0x2:  cJSON_AddStringToObject(pJsonsub, "state", "Upper Non-Critical"); cJSON_AddStringToObject(pJsonsub, "status", "2"); break;    
@@ -395,7 +406,7 @@ void getSensorInfo(Webs *wp){
         websWrite(wp, pStr);
         websFlush(wp, 0);
         websDone(wp);
-        printf("---> cJSON Str:\n%s\n", pStr);
+        printf("cJSON:%s\n", pStr);
 
         if(root)
             cJSON_Delete(root);
@@ -510,7 +521,7 @@ void getAllBladeInfo(Webs *wp){
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
-    printf("---> cJSON Str:\n%s\n", pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -542,7 +553,7 @@ void setBladeManage(Webs *wp){
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
-    printf("---> cJSON Str:\n%s\n", pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -569,7 +580,7 @@ void getBladeManage(Webs *wp){
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
-    printf("---> cJSON Str:\n%s\n", pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -634,7 +645,7 @@ void getChassisInfo(Webs *wp){
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
-    printf("---> cJSON Str:\n%s\n", pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);

+ 2 - 2
app/goahead-3.6.5/src/web_interface/src/fan.c

@@ -78,7 +78,7 @@ void getAllFanInfo(Webs *wp){
     websWrite(wp,"%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
-    printf("---> cJSON Str:\n%s\n", pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -151,7 +151,7 @@ void setFanInfo(Webs *wp){
     websWrite(wp,"%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
-    printf("---> cJSON Str:\n%s\n", pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);

+ 3 - 3
app/goahead-3.6.5/src/web_interface/src/fru.c

@@ -178,7 +178,7 @@ void getFruChassisInfo(Webs *wp)
     websWrite(wp, "%s", pStr); 
     websFlush(wp, 0);	//wait for all data to be written to the socket 
     websDone(wp);
-    printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
+    printf("cJSON: %s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -317,7 +317,7 @@ void getFruBoardInfo(Webs *wp)
     websWrite(wp, "%s", pStr);     
     websFlush(wp, 0);	//wait for all data to be written to the socket 
     websDone(wp);
-    printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -455,7 +455,7 @@ void getFruProductInfo(Webs *wp)
     websWrite(wp, "%s", pStr); 
     websFlush(wp, 0);	
     websDone(wp);
-    printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);

+ 24 - 27
app/goahead-3.6.5/src/web_interface/src/fw_update.c

@@ -44,35 +44,34 @@ void prepareDevice(Webs *wp)
         //Do nothing
     } 
 
-    char *pStr;
+    
     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);
-//    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);
-
+    websDone(wp);
+    printf("cJSON:%s\n", pStr);
+ 
     if(pStr)
         wfree(pStr);
     if(root)
         cJSON_Delete(root);
     
-    websDone(wp);
     printf("Update Firmware: Prepare Device Ok.\n");
 }
 
 /* 
     接收上传的固件
 */
-
 void uploadFirmware(Webs *wp)
 {
     WebsKey         *s;
@@ -100,27 +99,27 @@ void uploadFirmware(Webs *wp)
         //Do nothing
     }
 
-    char *pStr;
+    
     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);
-//    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);
+    websDone(wp);
+    printf("cJSON:\n%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
     if(root)
         cJSON_Delete(root);
-    
-    websDone(wp);
 }
 
 /*
@@ -130,7 +129,6 @@ void uploadFirmware(Webs *wp)
 void updateFlash(Webs *wp)
 {
     printf("Update Firmware: Update Flash...\n");
-    //TODO: 
     uint8_t cmd[50] = {0};
     progress = 0;
 
@@ -147,28 +145,28 @@ void updateFlash(Webs *wp)
         //Do nothing
     }
 
-    char *pStr;
+    
     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);
-//    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);
+    websDone(wp);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
     if(root)
         cJSON_Delete(root);
     
-    websDone(wp);
     printf("Update Firmware: Update Flash ok.\n");
 }
 
@@ -209,21 +207,20 @@ void getUpdateProgress(Webs *wp)
         sprintf(progressStr, "100");
     }
 
-    char *pStr;
+    
     cJSON * root =  cJSON_CreateObject();
     cJSON_AddStringToObject(root, "progress", progressStr);
     cJSON_AddNumberToObject(root, "code", 200);
     
-
+    char *pStr;
     pStr = cJSON_PrintUnformatted(root);
-
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
-    //websWriteHeader(wp, "getUpdateProgress");
     websWriteEndHeaders(wp);
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("cJSON:%s\n", pStr);
     
     if(pStr)
         wfree(pStr);
@@ -272,21 +269,20 @@ void getVerifyStatus(Webs *wp)
     }
 
 
-    char *pStr;
+    
     cJSON * root =  cJSON_CreateObject();
     cJSON_AddStringToObject(root, "verify", verigyStr);
     cJSON_AddNumberToObject(root, "code", 200);
     
-
+    char *pStr;
     pStr = cJSON_PrintUnformatted(root);
-
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
-    //websWriteHeader(wp, "getUpdateProgress");
     websWriteEndHeaders(wp);
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -303,11 +299,12 @@ void resetBmc(Webs *wp)
     ((0x3<<30) | (__MAJOR__<<16) | (__MAGIC__<<8) | __CMD__)
 #define RESET_MCU                       GENERATE_CMD(IOCTL_MAGIC, MAJOR_PLATFORM, 2)
 
-    printf("Update Firmware: Reset BMC...\n");
+    
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);
     websDone(wp);
+    printf("Update Firmware: Reset BMC...\n");
 
 //    wp->index = TEST_INDEX;
     target_addr = gIPMBAddr[wp->index];

+ 2 - 2
app/goahead-3.6.5/src/web_interface/src/remote_control.c

@@ -91,7 +91,7 @@ void chassisPwrCtrl(Webs *wp){
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);	
     websDone(wp);
-    printf("---> cJSON Str: %d\n%s\n", strlen(pStr), pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -147,7 +147,7 @@ void getChassisStatus(Webs *wp)
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);	
     websDone(wp);
-    printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
+    printf("cJSON:%s\n",pStr);
 
     if(pStr)
         wfree(pStr);

+ 18 - 19
app/goahead-3.6.5/src/web_interface/src/sel.c

@@ -57,7 +57,7 @@ void Web_ClearSEL(Webs *wp)
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
-    printf("---> cJSON Str:\n%s\n", pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -137,7 +137,7 @@ void GetAllSELEntriesSorted(Webs *wp)
             websWrite(wp, pStr);
             websFlush(wp, 0);
             websDone(wp);
-            printf("---> pStr %d: %s\n", strlen(pStr), pStr);
+            printf("cJSON:%s\n", pStr);
             
             if(root)
                 cJSON_Delete(root);
@@ -187,17 +187,17 @@ void GetAllSELEntriesSorted(Webs *wp)
                 {
                     break;
                 }
-                // cJSON_AddNumberToObject(pJsonsub, "1", SELEventData.hdr.ID);
-                // cJSON_AddNumberToObject(pJsonsub, "2", SELEventData.hdr.Type);
-                // cJSON_AddNumberToObject(pJsonsub, "3", SELEventData.hdr.TimeStamp);
-                // cJSON_AddNumberToObject(pJsonsub, "4", SELEventData.GenID[0]);
-                // cJSON_AddNumberToObject(pJsonsub, "5", SELEventData.GenID[1]);
-                // cJSON_AddNumberToObject(pJsonsub, "6", SELEventData.EvMRev);
-                // cJSON_AddNumberToObject(pJsonsub, "7", SELEventData.SensorType);
-                // cJSON_AddNumberToObject(pJsonsub, "8", SELEventData.EvtDirType);
-                // cJSON_AddNumberToObject(pJsonsub, "9", SELEventData.EvtData1);
-                // cJSON_AddNumberToObject(pJsonsub, "a", SELEventData.EvtData2);
-                // cJSON_AddNumberToObject(pJsonsub, "b", SELEventData.EvtData3);
+                // cJSON_AddNumberToObject(pJsonsub, "D1", SELEventData.hdr.ID);
+                // cJSON_AddNumberToObject(pJsonsub, "D2", SELEventData.hdr.Type);
+                // cJSON_AddNumberToObject(pJsonsub, "D3", SELEventData.hdr.TimeStamp);
+                // cJSON_AddNumberToObject(pJsonsub, "D4", SELEventData.GenID[0]);
+                // cJSON_AddNumberToObject(pJsonsub, "D5", SELEventData.GenID[1]);
+                // cJSON_AddNumberToObject(pJsonsub, "D6", SELEventData.EvMRev);
+                // cJSON_AddNumberToObject(pJsonsub, "D7", SELEventData.SensorType);
+                // cJSON_AddNumberToObject(pJsonsub, "D8", SELEventData.EvtDirType);
+                // cJSON_AddNumberToObject(pJsonsub, "D9", SELEventData.EvtData1);
+                // cJSON_AddNumberToObject(pJsonsub, "D10", SELEventData.EvtData2);
+                // cJSON_AddNumberToObject(pJsonsub, "D11", SELEventData.EvtData3);
 
                 cJSON_AddNumberToObject(pJsonsub, "RecordID", SELEventData.hdr.ID);
                 cJSON_AddNumberToObject(pJsonsub, "RecordType", SELEventData.hdr.Type);
@@ -282,7 +282,7 @@ void GetAllSELEntriesSorted(Webs *wp)
     websWrite(wp, pStr);
     websFlush(wp, 0);
     websDone(wp);
-    printf("---> pStr %d: %s\n", strlen(pStr), pStr);
+    printf("cJSON:%s\n",pStr);
     
     if(root)
         cJSON_Delete(root);
@@ -363,23 +363,22 @@ void SetTime(Webs *wp)
     //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);
 
-  
+    char *pStr;
     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);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -453,7 +452,7 @@ void GetTime(Webs *wp)
     websWrite(wp,"%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
-    printf("---> cJSON Str:\n%s\n", pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);

+ 4 - 11
app/goahead-3.6.5/src/web_interface/src/server_health.c

@@ -33,8 +33,8 @@ void setThreshold(Webs *wp){
     int   SensorNumber = atoi(strSensorNumber);
     uint8_t target_addr;
 
-    printf(" %s, %s %s %s, %s %s %s = %d, %f %f %f %f %f %f \n", strSensorNumber, strUNC, strUC, strUNR, strLNC, strLC, 
-    	strLNR,  SensorNumber, UNC, UC, UNR, LNC, LC, LNR );
+    // printf(" %s, %s %s %s, %s %s %s = %d, %f %f %f %f %f %f \n", strSensorNumber, strUNC, strUC, strUNR, strLNC, strLC, 
+    // 	strLNR,  SensorNumber, UNC, UC, UNR, LNC, LC, LNR );
 
     uint8_t  *data_buffer = (uint8_t*)walloc(255);
     FullSensorRec_T	*sdr_record = (FullSensorRec_T*) data_buffer;
@@ -85,11 +85,6 @@ void setThreshold(Webs *wp){
     pReqSetSensorThreshold->LowerCritical = sdr_convert_sensor_value_to_raw(sdr_record, LC);
     pReqSetSensorThreshold->LowerNonRecoverable = sdr_convert_sensor_value_to_raw(sdr_record, LNR);
     
-    // printf("---> Num %d, Name: %s, raw: %d, %d, %d, %d, %d, %d\n", 
-    // 	pReqSetSensorThreshold->SensorNum, sdr_record->IDStr,
-    // 	pReqSetSensorThreshold->UpperNonCritical, pReqSetSensorThreshold->UpperCritical, 
-    // 	pReqSetSensorThreshold->UpperNonRecoverable, pReqSetSensorThreshold->LowerNonCritical, 
-    // 	pReqSetSensorThreshold->LowerCritical, pReqSetSensorThreshold->LowerNonRecoverable);
     if(target_addr == 0x20)
     {
         wRet = IPMICMD_SetSensorThreshold( &UDSSession, pReqSetSensorThreshold, pResSetSensorThreshold, DEFAULT_TIMEOUT);
@@ -117,7 +112,7 @@ void setThreshold(Webs *wp){
     websWrite(wp,"%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
-    printf("---> cJSON Str:\n%s\n", pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -180,8 +175,6 @@ void webGetSensorHistory(Webs *wp)
 
     pSensorHistory->sensor_num = SensorNumber;
     strcpy(pSensorHistory->sensor_name, sdr_record->IDStr);
-    printf("sensor_num: %d, sensor_name: %s\n", pSensorHistory->sensor_num, pSensorHistory->sensor_name);
-        
     if(target_addr == 0x20)
     {
         wRet = IPMI_GetSensorHistory(&UDSSession, SensorNumber, (uint8_t*)historyBuf, DEFAULT_TIMEOUT);
@@ -268,7 +261,7 @@ void webGetSensorHistory(Webs *wp)
     websWrite(wp, pStr);
     websFlush(wp, 0);
     websDone(wp);
-    printf("---> cJSON Str:\n%s\n", pStr);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);

+ 17 - 41
app/goahead-3.6.5/src/web_interface/src/user.c

@@ -33,8 +33,6 @@ PUBLIC bool websVerifyPasswordFromBMC(Webs *wp)
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
 
-    gChassisManageEn = 1;
-
     return success;
 }
 
@@ -51,8 +49,6 @@ void getAllUserInfo(Webs *wp){
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
 
-    char *pStr;
-    int code = 200;
     cJSON * root =  cJSON_CreateObject();
     cJSON  *pJsonArry,*pJsonsub;
     pJsonArry=cJSON_CreateArray();   /*创建数组*/
@@ -63,20 +59,19 @@ void getAllUserInfo(Webs *wp){
     		cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject());
     		cJSON_AddNumberToObject(pJsonsub, "userid", userInfoTbl[i].UserId); 
     		cJSON_AddStringToObject(pJsonsub, "username", userInfoTbl[i].UserName); 
-   
     	}
     }
-
     cJSON_AddItemToObject(root, "data", pJsonArry);
-    pStr = cJSON_PrintUnformatted(root);
 
-//    printf("---> cJSON Str:\n%s\n", pStr);
+    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);
@@ -93,22 +88,8 @@ void setUserPassword(Webs *wp){
     char *useridstr = websGetVar(wp, "userid", NULL);
     uint8_t userid = atoi(useridstr);
 
-    // printf("---> setUserPassword, userid: %d, username: %s,  password: %s\n",
-    // 	userid, username, password);
-    //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
-    // //verify old password
-    // if(LIBIPMI_AuthorVerify(&UDSSession, username, oldpassword, DEFAULT_TIMEOUT) != TRUE)
-    // {
-    // 	printf("Verify oldpassword error!\n" );
-    // 	//Close session
-    // 	LIBIPMI_CloseSession(&UDSSession );
-    // 	websError(wp, 404, "Verify oldpassword error!");
-    // 	return;
-    // }
-
-    //printf("Verify oldpassword success!\n" );
     //set new password
     if(0 != LIBIPMI_SetPassword(&UDSSession, userid, password, DEFAULT_TIMEOUT))
     {
@@ -118,28 +99,25 @@ void setUserPassword(Webs *wp){
     	websError(wp, 404, "Set user password fail!");    	
     	return;
     }
-    //printf("Set user password success!\n" );
   
     //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);
     
-   
+    char *pStr;
     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);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -201,25 +179,21 @@ void addUser(Webs *wp){
     //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);
-    // cJSON_AddNumberToObject(data, "userid", userid);
-    // cJSON_AddStringToObject(data, "username", username);
-    // cJSON_AddStringToObject(data, "password", password);
    
+    char *pStr;
     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);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -250,7 +224,6 @@ void delUser(Webs *wp){
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
 
-    char *pStr;
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
@@ -258,15 +231,15 @@ void delUser(Webs *wp){
     cJSON_AddNumberToObject(root, "code", 200);
     cJSON_AddNumberToObject(data, "userid", userid);
    
+    char *pStr;
     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);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -277,13 +250,15 @@ void delUser(Webs *wp){
 
 void checkLoginStatus(Webs *wp){
     char *loginStatus = (char*) websGetSessionVar(wp, "loginStatus", 0);
-    char *pStr;
+    
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
     cJSON_AddStringToObject(root, "msg", "");
     cJSON_AddNumberToObject(root, "code", 200);
     cJSON_AddStringToObject(data, "loginStatus", loginStatus);
+
+    char *pStr;
     pStr = cJSON_PrintUnformatted(root);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
@@ -291,6 +266,7 @@ void checkLoginStatus(Webs *wp){
     websWrite(wp,"%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("cJSON:%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -301,23 +277,23 @@ void checkLoginStatus(Webs *wp){
 void logout(Webs *wp){
     websSetSessionVar(wp, "loginStatus", "failed");
     char *loginStatus = (char*) websGetSessionVar(wp, "loginStatus", 0);
-    char *pStr;
+    
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
     cJSON_AddStringToObject(root, "msg", "");
     cJSON_AddNumberToObject(root, "code", 200);
     cJSON_AddStringToObject(data, "loginStatus", loginStatus);
-    printf("---> come Str:\n");
-    pStr = cJSON_PrintUnformatted(root);
 
-    printf("---> cJSON Str:\n%s\n", pStr);
+    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);