|
@@ -30,7 +30,7 @@ void getDeviceInfo(Webs *wp){
|
|
|
|
|
|
|
|
|
//Create session
|
|
|
- LIBIPMI_CreateSession(&UDSSession, 10);
|
|
|
+ LIBIPMI_CreateSession(&UDSSession, 10000);
|
|
|
|
|
|
//get build time
|
|
|
sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
|
|
@@ -40,6 +40,12 @@ void getDeviceInfo(Webs *wp){
|
|
|
if (wRet == LIBIPMI_E_SUCCESS)
|
|
|
{
|
|
|
sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
|
|
|
+
|
|
|
+
|
|
|
+ printf("BuildTime: %s\n", BuildTime);
|
|
|
+ printf("FwVersion: %s\n", FwVersion);
|
|
|
+ printf("MacAddr: %s\n", MacAddr);
|
|
|
+ printf("IpAddr: %s\n", IpAddr);
|
|
|
}
|
|
|
|
|
|
//Close session
|
|
@@ -91,6 +97,7 @@ void getDeviceInfo(Webs *wp){
|
|
|
// }
|
|
|
// close(sock);
|
|
|
|
|
|
+
|
|
|
char *pStr = malloc(500);
|
|
|
char *dataStr = malloc(200);
|
|
|
char msgStr[10] = "\"\"";
|
|
@@ -99,6 +106,7 @@ void getDeviceInfo(Webs *wp){
|
|
|
sprintf(dataStr, "{\"buildTime\":\"%s\",\"fwVersion\":\"%s\",\"macAddr\":\"%s\",\"ipAddr\":\"%s\"}", \
|
|
|
BuildTime, FwVersion, MacAddr, IpAddr);
|
|
|
|
|
|
+
|
|
|
sprintf(pStr, "{\"data\": %s,\"msg\":%s,\"code\": %s}", \
|
|
|
dataStr, msgStr, codeStr);
|
|
|
|
|
@@ -116,11 +124,13 @@ void getDeviceInfo(Webs *wp){
|
|
|
|
|
|
//pStr = cJSON_Print(root);
|
|
|
|
|
|
- printf("json str:\n%s\n", pStr);
|
|
|
+
|
|
|
websSetStatus(wp, 200);
|
|
|
websWriteHeaders(wp, -1, 0);
|
|
|
websWriteEndHeaders(wp);
|
|
|
- websWrite(wp, "%s", pStr);
|
|
|
+ //websWrite(wp, "[");
|
|
|
+ websWrite(wp, pStr);
|
|
|
+ //websWrite(wp, "]");
|
|
|
websFlush(wp, 0);
|
|
|
websDone(wp);
|
|
|
|
|
@@ -132,6 +142,9 @@ void getDeviceInfo(Webs *wp){
|
|
|
|
|
|
/*获取系统信息*/
|
|
|
void getSysInfo(Webs *wp){
|
|
|
+
|
|
|
+
|
|
|
+ printf("lisentid value is %d\n", wp->listenSid);
|
|
|
int wRet;
|
|
|
SysInfo_T sysInfo;
|
|
|
uint8_t Req[5] = {0,0,0,0,0};
|
|
@@ -159,38 +172,49 @@ void getSysInfo(Webs *wp){
|
|
|
memset(sysInfo.text, 0, MAX_TEXT_LEN);
|
|
|
|
|
|
//Create session
|
|
|
- wRet = LIBIPMI_CreateSession(&UDSSession, 10);
|
|
|
+ wRet = LIBIPMI_CreateSession(&UDSSession, 10000);
|
|
|
|
|
|
LIBIPMI_HL_GetSysInfo(&UDSSession, &sysInfo, DEFAULT_TIMEOUT);
|
|
|
|
|
|
//Close session
|
|
|
- LIBIPMI_CloseSession(&UDSSession );
|
|
|
+ // LIBIPMI_CloseSession(&UDSSession );
|
|
|
|
|
|
printf("Title: %s\n", sysInfo.title);
|
|
|
printf("Text: %s\n", sysInfo.text);
|
|
|
|
|
|
|
|
|
- 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, "title", sysInfo.title);
|
|
|
- cJSON_AddStringToObject(data, "text", sysInfo.text);
|
|
|
+ // 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, "title", sysInfo.title);
|
|
|
+ // cJSON_AddStringToObject(data, "text", sysInfo.text);
|
|
|
|
|
|
- pStr = cJSON_Print(root);
|
|
|
+ // pStr = cJSON_Print(root);
|
|
|
|
|
|
+
|
|
|
+ char *pStr;
|
|
|
+
|
|
|
+ char *testStr;
|
|
|
+ testStr = malloc(500);
|
|
|
+ //sprintf(testStr, "{data: {\"Version\": \"%s\", \"MAC\": \"%s\", \"IP\": \"%s\"}, \"msg\":\"\"}", FwVersion, MacAddr, IpAddr);
|
|
|
+
|
|
|
+ sprintf(testStr, "{\"data\": {\"buildTime\":\"%s\",\"fwVersion\":\"%s\",\"macAddr\":\"%s\",\"ipAddr\":\"%s\"},\"msg\":\"\",\"code\": %d}", \
|
|
|
+ "BuildTime", "FwVersion", "MacAddr", "IpAddr", 200);
|
|
|
+
|
|
|
+ pStr = testStr;
|
|
|
printf("first json:\n%s\n", pStr);
|
|
|
logmsg(2, "-----------------------sys----------------------%s", pStr);
|
|
|
- websSetStatus(wp, WEBS_KEEP_ALIVE);
|
|
|
+ websSetStatus(wp, 200);
|
|
|
websWriteHeaders(wp, -1, 0);
|
|
|
websWriteEndHeaders(wp);
|
|
|
- websWrite(wp, pStr);
|
|
|
+ websWrite(wp,"%s", pStr);
|
|
|
+ websFlush(wp, 0);
|
|
|
websDone(wp);
|
|
|
- sleep(1);
|
|
|
sys_info_end:
|
|
|
if(sysInfo.title)
|
|
|
free(sysInfo.title);
|
|
@@ -198,8 +222,8 @@ sys_info_end:
|
|
|
free(sysInfo.text);
|
|
|
|
|
|
free(pStr);
|
|
|
- cJSON_Delete(root);
|
|
|
- cJSON_Delete(data);
|
|
|
+ // cJSON_Delete(root);
|
|
|
+ // cJSON_Delete(data);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -237,7 +261,7 @@ void getSensorInfo(Webs *wp){
|
|
|
IPMI20_UDS_SESSION_T UDSSession;
|
|
|
|
|
|
//Create session
|
|
|
- wRet = LIBIPMI_CreateSession(&UDSSession, 10);
|
|
|
+ wRet = LIBIPMI_CreateSession(&UDSSession, 10000);
|
|
|
|
|
|
/* Get number of SEL records in the system at this time */
|
|
|
wRet = LIBIPMI_HL_GetSensorCount(&UDSSession,&nSensors,DEFAULT_TIMEOUT);
|
|
@@ -347,6 +371,14 @@ void getSensorInfo(Webs *wp){
|
|
|
|
|
|
logmsg(2, "-----------------------sensor----------------------");
|
|
|
|
|
|
+ websSetStatus(wp, 200);
|
|
|
+ websWriteHeaders(wp, -1, 0);
|
|
|
+ websWriteEndHeaders(wp);
|
|
|
+ //websWrite(wp, "[");
|
|
|
+ websWrite(wp, ">>>>>>>>>>>>>>>>>>>>>");
|
|
|
+ //websWrite(wp, "]");
|
|
|
+ //websFlush(wp, 0);
|
|
|
+ websDone(wp);
|
|
|
// websSetStatus(wp, WEBS_KEEP_ALIVE);
|
|
|
// websWriteHeaders(wp, -1, 0);
|
|
|
// websWriteEndHeaders(wp);
|
|
@@ -403,6 +435,49 @@ void buy(Webs *wp)
|
|
|
// /*
|
|
|
// Implement /action/actionTest. Parse the form variables: name, address and echo back.
|
|
|
// */
|
|
|
+// void actionTest(Webs *wp)
|
|
|
+// {
|
|
|
+
|
|
|
+// printf("sid value is >>>>>>>>>>>>>: %d<<<<<<<<<<<\n", wp->sid);
|
|
|
+// IPMI20_UDS_SESSION_T UDSSession;
|
|
|
+// GetDevIDRes_T DeviceID;
|
|
|
+
|
|
|
+// //Create session
|
|
|
+// printf("actionTest!\n");
|
|
|
+// LIBIPMI_CreateSession(&UDSSession, 10);
|
|
|
+// IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
|
|
|
+
|
|
|
+// printf("sid value is >>>>>1>>>>>>>>: %d<<<<<<<\n", wp->sid);
|
|
|
+
|
|
|
+
|
|
|
+// char *pStr;
|
|
|
+
|
|
|
+// char *testStr;
|
|
|
+// testStr = malloc(500);
|
|
|
+// //sprintf(testStr, "{data: {\"Version\": \"%s\", \"MAC\": \"%s\", \"IP\": \"%s\"}, \"msg\":\"\"}", FwVersion, MacAddr, IpAddr);
|
|
|
+
|
|
|
+// sprintf(testStr, "{\"data\": {\"buildTime\":\"%s\",\"fwVersion\":\"%s\",\"macAddr\":\"%s\",\"ipAddr\":\"%s\"},\"msg\":\"\",\"code\": %d}", \
|
|
|
+// BuildTime, FwVersion, MacAddr, IpAddr, 200);
|
|
|
+
|
|
|
+
|
|
|
+// //sprintf(testStr, "jimbo and lusa are very confused, please git me some tips, my god!");
|
|
|
+
|
|
|
+// pStr = testStr;
|
|
|
+
|
|
|
+
|
|
|
+// char name[] = "jimbo";
|
|
|
+// char address[] = "shanghai";
|
|
|
+// printf("name: %s, address: %s\n", name, address);
|
|
|
+// websSetStatus(wp, 200);
|
|
|
+// websWriteHeaders(wp, -1, 0);
|
|
|
+// websWriteEndHeaders(wp);
|
|
|
+// websWrite(wp, testStr);
|
|
|
+// websFlush(wp, 0);
|
|
|
+// websDone(wp);
|
|
|
+// // LIBIPMI_CloseSession(&UDSSession );
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
void actionTest(Webs *wp)
|
|
|
{
|
|
|
IPMI20_UDS_SESSION_T UDSSession;
|
|
@@ -413,10 +488,11 @@ void actionTest(Webs *wp)
|
|
|
char IpAddr[16] = "192.168.255.255";
|
|
|
|
|
|
//Create session
|
|
|
- printf("actionTest!\n");
|
|
|
- LIBIPMI_CreateSession(&UDSSession, 10);
|
|
|
- IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
|
|
|
- LIBIPMI_CloseSession(&UDSSession );
|
|
|
+
|
|
|
+ // LIBIPMI_CreateSession(&UDSSession, 10);
|
|
|
+ // IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
|
|
|
+ // LIBIPMI_CloseSession(&UDSSession );
|
|
|
+
|
|
|
|
|
|
char *pStr;
|
|
|
|
|
@@ -426,31 +502,29 @@ void actionTest(Webs *wp)
|
|
|
|
|
|
sprintf(testStr, "{\n\t\"data\": {\n\t\t\"buildTime\":\"%s\",\n\t\t\"fwVersion\":\"%s\",\n\t\t\"macAddr\":\"%s\",\n\t\t\"ipAddr\":\"%s\"\n\t},\n\t\"msg\":\"\",\n\t\"code\": %d\n}", \
|
|
|
BuildTime, FwVersion, MacAddr, IpAddr, 200);
|
|
|
+ pStr = testStr;
|
|
|
|
|
|
-
|
|
|
- //sprintf(testStr, "jimbo and lusa are very confused, please git me some tips, my god!");
|
|
|
-
|
|
|
- pStr = testStr;
|
|
|
-
|
|
|
- cJSON * root = cJSON_CreateObject();
|
|
|
- cJSON * data = cJSON_CreateObject();
|
|
|
+ // cJSON * root = cJSON_CreateObject();
|
|
|
+ // cJSON * data = cJSON_CreateObject();
|
|
|
printf("log1\n");
|
|
|
- //cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
- cJSON_AddStringToObject(root, "msg", NULL);
|
|
|
- cJSON_AddNumberToObject(root, "code", 200);
|
|
|
- cJSON_AddStringToObject(data, "buildTime", BuildTime);
|
|
|
- cJSON_AddStringToObject(data, "fwVersion", FwVersion);
|
|
|
- cJSON_AddStringToObject(data, "macAddr", MacAddr);
|
|
|
- cJSON_AddStringToObject(data, "ipAddr", IpAddr);
|
|
|
- // /*pStr = */cJSON_Print(root); //include malloc
|
|
|
+ // 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);
|
|
|
+ // cJSON_AddStringToObject(data, "macAddr", MacAddr);
|
|
|
+ // cJSON_AddStringToObject(data, "ipAddr", IpAddr);
|
|
|
+ // pStr = cJSON_Print(root); //include malloc
|
|
|
+ // cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
+ // cJSON_AddStringToObject(root, "msg", NULL);
|
|
|
+ // cJSON_AddNumberToObject(root, "code", 200);
|
|
|
+ // // cJSON_AddStringToObject(data, "buildTime", BuildTime);
|
|
|
+ // // cJSON_AddStringToObject(data, "fwVersion", FwVersion);
|
|
|
+ // // cJSON_AddStringToObject(data, "macAddr", MacAddr);
|
|
|
+ // // cJSON_AddStringToObject(data, "ipAddr", IpAddr);
|
|
|
+ // pStr = cJSON_Print(root); //include malloc
|
|
|
|
|
|
printf("%s\n", pStr);
|
|
|
- int i=0;
|
|
|
- while(pStr[i])
|
|
|
- {
|
|
|
- printf("%#x ", pStr[i++]);
|
|
|
- }
|
|
|
- printf("\n");
|
|
|
websSetStatus(wp, 200);
|
|
|
websWriteHeaders(wp, -1, 0);
|
|
|
websWriteEndHeaders(wp);
|
|
@@ -461,10 +535,8 @@ void actionTest(Webs *wp)
|
|
|
if(pStr)
|
|
|
free(pStr);
|
|
|
|
|
|
- cJSON_Delete(root);
|
|
|
- cJSON_Delete(data);
|
|
|
+ // cJSON_Delete(root);
|
|
|
+ // cJSON_Delete(data);
|
|
|
|
|
|
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
+}
|