|
@@ -10,7 +10,10 @@
|
|
|
#include <sys/socket.h>
|
|
|
#include <sys/un.h>
|
|
|
#include <unistd.h>
|
|
|
-
|
|
|
+/*
|
|
|
+ 废弃机箱管理是能按钮。由BMC程序里的g_BMCInfo.isChMC代替。ChMC默认就支持机箱管理,IPMC默认不支持。
|
|
|
+ gChassisManageEn、setBladeManage、getBladeManage保留但是用不到。
|
|
|
+*/
|
|
|
uint8_t gIPMBAddr[BLADE_NUMBERS] = {0x20, 0x84, 0x86, 0x88, 0x8A, 0x8C, 0x8E, 0x90, 0x92, 0x94};
|
|
|
uint8_t gChassisManageEn = 0;
|
|
|
/*获取设备信息*/
|
|
@@ -21,67 +24,80 @@ void getDeviceInfo(Webs *wp){
|
|
|
int sock;
|
|
|
struct sockaddr_in *myaddr;
|
|
|
IPMI20_UDS_SESSION_T UDSSession;
|
|
|
+ uint8_t target_addr;
|
|
|
|
|
|
char BuildTime[30] = {0};
|
|
|
char FwVersion[10] = {0};
|
|
|
char MacAddr[18] = {0};
|
|
|
char IpAddr[16] = {0};
|
|
|
|
|
|
- printf("---> getSensorInfo, wp.index = %d\n", wp->index);
|
|
|
-
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
|
|
|
- //get build time
|
|
|
- sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
|
|
|
-
|
|
|
- //get firmware version
|
|
|
- wRet = IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
|
|
|
- if (wRet == LIBIPMI_E_SUCCESS)
|
|
|
- {
|
|
|
- sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
|
|
|
- }
|
|
|
-
|
|
|
- //Close session
|
|
|
- LIBIPMI_CloseSession(&UDSSession );
|
|
|
-
|
|
|
- //get mac adn ip address
|
|
|
- if((sock=socket(AF_INET,SOCK_STREAM,0))<0)
|
|
|
- {
|
|
|
- printf("Get mac address socket fail!\n");
|
|
|
- }
|
|
|
- else
|
|
|
+ wp->index = TEST_INDEX;
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
{
|
|
|
- strcpy(ifreq.ifr_name,"eth0");
|
|
|
-
|
|
|
- //MAC
|
|
|
- if(ioctl(sock,SIOCGIFHWADDR,&ifreq)<0)
|
|
|
+ //get build time
|
|
|
+ sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
|
|
|
+ //get firmware version
|
|
|
+ wRet = IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
|
|
|
+ if (wRet == LIBIPMI_E_SUCCESS)
|
|
|
{
|
|
|
- printf("Get mac address ioctl fail!\n");
|
|
|
+ sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
|
|
|
}
|
|
|
- else
|
|
|
+ //get mac adn ip address
|
|
|
+ if((sock=socket(AF_INET,SOCK_STREAM,0))<0)
|
|
|
{
|
|
|
- sprintf(MacAddr, "%02x:%02x:%02x:%02x:%02x:%02x",
|
|
|
- (unsigned char)ifreq.ifr_hwaddr.sa_data[0],
|
|
|
- (unsigned char)ifreq.ifr_hwaddr.sa_data[1],
|
|
|
- (unsigned char)ifreq.ifr_hwaddr.sa_data[2],
|
|
|
- (unsigned char)ifreq.ifr_hwaddr.sa_data[3],
|
|
|
- (unsigned char)ifreq.ifr_hwaddr.sa_data[4],
|
|
|
- (unsigned char)ifreq.ifr_hwaddr.sa_data[5]);
|
|
|
+ printf("Get mac address socket fail!\n");
|
|
|
}
|
|
|
-
|
|
|
- //IP
|
|
|
- if(ioctl(sock, SIOCGIFADDR, &ifreq) < 0)
|
|
|
+ else
|
|
|
{
|
|
|
- printf("Get ip address ioctl fail!\n");
|
|
|
+ strcpy(ifreq.ifr_name,"eth0");
|
|
|
+ //MAC
|
|
|
+ if(ioctl(sock,SIOCGIFHWADDR,&ifreq)<0)
|
|
|
+ {
|
|
|
+ printf("Get mac address ioctl fail!\n");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sprintf(MacAddr, "%02x:%02x:%02x:%02x:%02x:%02x",
|
|
|
+ (unsigned char)ifreq.ifr_hwaddr.sa_data[0],
|
|
|
+ (unsigned char)ifreq.ifr_hwaddr.sa_data[1],
|
|
|
+ (unsigned char)ifreq.ifr_hwaddr.sa_data[2],
|
|
|
+ (unsigned char)ifreq.ifr_hwaddr.sa_data[3],
|
|
|
+ (unsigned char)ifreq.ifr_hwaddr.sa_data[4],
|
|
|
+ (unsigned char)ifreq.ifr_hwaddr.sa_data[5]);
|
|
|
+ }
|
|
|
+ //IP
|
|
|
+ if(ioctl(sock, SIOCGIFADDR, &ifreq) < 0)
|
|
|
+ {
|
|
|
+ printf("Get ip address ioctl fail!\n");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ myaddr = (struct sockaddr_in *)&(ifreq.ifr_addr);
|
|
|
+ strcpy(IpAddr, inet_ntoa(myaddr->sin_addr));
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
+ close(sock);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //get build time
|
|
|
+ sprintf(BuildTime, "--");
|
|
|
+ sprintf(MacAddr, "--");
|
|
|
+ sprintf(IpAddr, "--");
|
|
|
+ //get firmware version
|
|
|
+ wRet = IPMC_GetDeviceID( &UDSSession, target_addr, &DeviceID, DEFAULT_TIMEOUT);
|
|
|
+ if (wRet == LIBIPMI_E_SUCCESS)
|
|
|
{
|
|
|
- myaddr = (struct sockaddr_in *)&(ifreq.ifr_addr);
|
|
|
- strcpy(IpAddr, inet_ntoa(myaddr->sin_addr));
|
|
|
+ sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
|
|
|
}
|
|
|
}
|
|
|
- close(sock);
|
|
|
+
|
|
|
+ //Close session
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
|
|
|
char *pStr;
|
|
|
cJSON * root = cJSON_CreateObject();
|
|
@@ -96,8 +112,6 @@ void getDeviceInfo(Webs *wp){
|
|
|
cJSON_AddStringToObject(data, "netMode", "static");
|
|
|
|
|
|
pStr = cJSON_PrintUnformatted(root);
|
|
|
-
|
|
|
-// printf("---> cJSON Str:\n%s\n", pStr);
|
|
|
websSetStatus(wp, 200);
|
|
|
websWriteHeaders(wp, -1, 0);
|
|
|
websWriteEndHeaders(wp);
|
|
@@ -105,6 +119,7 @@ void getDeviceInfo(Webs *wp){
|
|
|
websFlush(wp, 0);
|
|
|
websDone(wp);
|
|
|
|
|
|
+ printf("---> cJSON Str:\n%s\n", pStr);
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|
|
|
if(root)
|
|
@@ -118,9 +133,8 @@ void getSysInfo(Webs *wp){
|
|
|
int wRet;
|
|
|
SysInfo_T sysInfo;
|
|
|
IPMI20_UDS_SESSION_T UDSSession;
|
|
|
+ uint8_t target_addr;
|
|
|
|
|
|
-
|
|
|
- printf("---> getSysInfo, wp.index = %d\n", wp->index);
|
|
|
sysInfo.title = walloc(MAX_TITLE_LEN);
|
|
|
if(sysInfo.title == NULL)
|
|
|
{
|
|
@@ -128,7 +142,9 @@ void getSysInfo(Webs *wp){
|
|
|
goto sys_info_end;
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
memset(sysInfo.title, 0, MAX_TITLE_LEN);
|
|
|
+ }
|
|
|
|
|
|
sysInfo.text = walloc(MAX_TEXT_LEN);
|
|
|
if(sysInfo.text == NULL)
|
|
@@ -137,12 +153,23 @@ void getSysInfo(Webs *wp){
|
|
|
goto sys_info_end;
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
memset(sysInfo.text, 0, MAX_TEXT_LEN);
|
|
|
+ }
|
|
|
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
|
|
|
- LIBIPMI_HL_GetSysInfo(&UDSSession, &sysInfo, DEFAULT_TIMEOUT);
|
|
|
+ wp->index = TEST_INDEX;
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
+ {
|
|
|
+ LIBIPMI_HL_GetSysInfo(&UDSSession, &sysInfo, DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IPMC_GetSysInfo(&UDSSession, target_addr, &sysInfo, DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
|
|
|
//Close session
|
|
|
LIBIPMI_CloseSession(&UDSSession );
|
|
@@ -157,14 +184,13 @@ void getSysInfo(Webs *wp){
|
|
|
cJSON_AddStringToObject(data, "text", sysInfo.text);
|
|
|
|
|
|
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 Str:\n%s\n", pStr);
|
|
|
|
|
|
sys_info_end:
|
|
|
if(sysInfo.title)
|
|
@@ -210,139 +236,171 @@ void getSensorInfo(Webs *wp){
|
|
|
char maxReading[10], minReading[10];
|
|
|
unsigned char *pStartBuff = NULL;
|
|
|
IPMI20_UDS_SESSION_T UDSSession;
|
|
|
+ uint8_t target_addr;
|
|
|
|
|
|
- printf("---> getSensorInfo, wp.index = %d\n", wp->index);
|
|
|
//Create session
|
|
|
LIBIPMI_CreateSession(&UDSSession, 10000);
|
|
|
-
|
|
|
- /* Get number of SEL records in the system at this time */
|
|
|
- wRet = LIBIPMI_HL_GetSensorCount(&UDSSession,&nSensors,DEFAULT_TIMEOUT);
|
|
|
- if( wRet != 0 )
|
|
|
- {
|
|
|
- printf("Error getting num of sensors\n");
|
|
|
- goto error_out;
|
|
|
- }
|
|
|
- else
|
|
|
+
|
|
|
+ wp->index = TEST_INDEX;
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
{
|
|
|
- //printf("success getting num of sensors: %d\n",nSensors); //this is all sensor count
|
|
|
- /* Now get all sensors records */
|
|
|
- if(!nSensors)
|
|
|
+ /* Get number of SEL records in the system at this time */
|
|
|
+ wRet = LIBIPMI_HL_GetSensorCount(&UDSSession,&nSensors,DEFAULT_TIMEOUT);
|
|
|
+ if( wRet != 0 )
|
|
|
{
|
|
|
- /* There are no sensors present at this time */
|
|
|
+ printf("Error getting num of sensors\n");
|
|
|
goto error_out;
|
|
|
}
|
|
|
-
|
|
|
- /* Allocate the buffer to hold sensors records */
|
|
|
- pSensorBuff = (struct sensor_data *) walloc(nSensors * sizeof(struct sensor_data));
|
|
|
- if(pSensorBuff == NULL)
|
|
|
+ else
|
|
|
{
|
|
|
- printf("Error alloc memory!\n");
|
|
|
- goto error_out;
|
|
|
- }
|
|
|
- memset(pSensorBuff, 0, nSensors * sizeof(struct sensor_data));
|
|
|
- pStartBuff = (unsigned char *)pSensorBuff;
|
|
|
-
|
|
|
- //printf("sensorcount = %d\n", nSensors);
|
|
|
- nSensors -= 1; //remove first sdr
|
|
|
- wRet = LIBIPMI_HL_GetAllSensorReadings(&UDSSession,pSensorBuff, nSensors,DEFAULT_TIMEOUT);
|
|
|
-
|
|
|
- //Close session
|
|
|
- LIBIPMI_CloseSession(&UDSSession );
|
|
|
+ //printf("success getting num of sensors: %d\n",nSensors); //this is all sensor count
|
|
|
+ /* Now get all sensors records */
|
|
|
+ if(!nSensors)
|
|
|
+ {
|
|
|
+ /* There are no sensors present at this time */
|
|
|
+ goto error_out;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Allocate the buffer to hold sensors records */
|
|
|
+ pSensorBuff = (struct sensor_data *) walloc(nSensors * sizeof(struct sensor_data));
|
|
|
+ if(pSensorBuff == NULL)
|
|
|
+ {
|
|
|
+ printf("Error alloc memory!\n");
|
|
|
+ goto error_out;
|
|
|
+ }
|
|
|
+ memset(pSensorBuff, 0, nSensors * sizeof(struct sensor_data));
|
|
|
+ pStartBuff = (unsigned char *)pSensorBuff;
|
|
|
|
|
|
- if(wRet != 0)
|
|
|
+ //printf("sensorcount = %d\n", nSensors);
|
|
|
+ nSensors -= 1; //remove first sdr
|
|
|
+ wRet = LIBIPMI_HL_GetAllSensorReadings(&UDSSession,pSensorBuff, nSensors,DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* Get number of SEL records in the system at this time */
|
|
|
+ wRet = IPMC_GetSensorCount(&UDSSession, target_addr, &nSensors,DEFAULT_TIMEOUT);
|
|
|
+ if( wRet != 0 )
|
|
|
{
|
|
|
- printf("Error reading All Sensors\n");
|
|
|
+ printf("Error getting num of sensors\n");
|
|
|
goto error_out;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ //printf("success getting num of sensors: %d\n",nSensors); //this is all sensor count
|
|
|
+ /* Now get all sensors records */
|
|
|
+ if(!nSensors)
|
|
|
+ {
|
|
|
+ /* There are no sensors present at this time */
|
|
|
+ goto error_out;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Allocate the buffer to hold sensors records */
|
|
|
+ pSensorBuff = (struct sensor_data *) walloc(nSensors * sizeof(struct sensor_data));
|
|
|
+ if(pSensorBuff == NULL)
|
|
|
+ {
|
|
|
+ printf("Error alloc memory!\n");
|
|
|
+ goto error_out;
|
|
|
+ }
|
|
|
+ memset(pSensorBuff, 0, nSensors * sizeof(struct sensor_data));
|
|
|
+ pStartBuff = (unsigned char *)pSensorBuff;
|
|
|
+
|
|
|
+ nSensors -= 1; //remove first sdr
|
|
|
+ //printf("sensorcount = %d\n", nSensors);
|
|
|
+ wRet = IPMC_GetAllSensorReadings(&UDSSession,target_addr, pSensorBuff, nSensors,DEFAULT_TIMEOUT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //Close session
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
+
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ printf("Error reading All Sensors\n");
|
|
|
+ goto error_out;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
|
|
|
- char *pStr;
|
|
|
- int code = 200;
|
|
|
- cJSON * root = cJSON_CreateObject();
|
|
|
- cJSON *pJsonArry,*pJsonsub;
|
|
|
- pJsonArry=cJSON_CreateArray(); /*创建数组*/
|
|
|
- while(nSensors)
|
|
|
+ char *pStr;
|
|
|
+ int code = 200;
|
|
|
+ cJSON * root = cJSON_CreateObject();
|
|
|
+ cJSON *pJsonArry,*pJsonsub;
|
|
|
+ pJsonArry=cJSON_CreateArray(); /*创建数组*/
|
|
|
+ while(nSensors)
|
|
|
+ {
|
|
|
+ sprintf(reading, "%.3f", pSensorBuff->sensor_reading);
|
|
|
+ sprintf(lownr, "%.3f", pSensorBuff->low_non_recov_thresh);
|
|
|
+ sprintf(lowct, "%.3f", pSensorBuff->low_crit_thresh);
|
|
|
+ sprintf(lownc, "%.3f", pSensorBuff->low_non_crit_thresh);
|
|
|
+ sprintf(highnc, "%.3f", pSensorBuff->high_non_crit_thresh);
|
|
|
+ sprintf(highct, "%.3f", pSensorBuff->high_crit_thresh);
|
|
|
+ sprintf(highnr, "%.3f", pSensorBuff->high_non_recov_thresh);
|
|
|
+ sprintf(maxReading, "%.3f", pSensorBuff->max_reading);
|
|
|
+ sprintf(minReading, "%.3f", pSensorBuff->min_reading);
|
|
|
+
|
|
|
+ cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
|
|
|
+ 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);
|
|
|
+ cJSON_AddStringToObject(pJsonsub, "lownc", lownc);
|
|
|
+ cJSON_AddStringToObject(pJsonsub, "highnc", highnc);
|
|
|
+ cJSON_AddStringToObject(pJsonsub, "highct", highct);
|
|
|
+ cJSON_AddStringToObject(pJsonsub, "highnr", highnr);
|
|
|
+ cJSON_AddStringToObject(pJsonsub, "maxReading", maxReading);
|
|
|
+ cJSON_AddStringToObject(pJsonsub, "minReading", minReading);
|
|
|
+
|
|
|
+ switch(pSensorBuff->sensor_units[1]) //sensorUinits2
|
|
|
{
|
|
|
- sprintf(reading, "%.3f", pSensorBuff->sensor_reading);
|
|
|
- sprintf(lownr, "%.3f", pSensorBuff->low_non_recov_thresh);
|
|
|
- sprintf(lowct, "%.3f", pSensorBuff->low_crit_thresh);
|
|
|
- sprintf(lownc, "%.3f", pSensorBuff->low_non_crit_thresh);
|
|
|
- sprintf(highnc, "%.3f", pSensorBuff->high_non_crit_thresh);
|
|
|
- sprintf(highct, "%.3f", pSensorBuff->high_crit_thresh);
|
|
|
- sprintf(highnr, "%.3f", pSensorBuff->high_non_recov_thresh);
|
|
|
- sprintf(maxReading, "%.3f", pSensorBuff->max_reading);
|
|
|
- sprintf(minReading, "%.3f", pSensorBuff->min_reading);
|
|
|
-
|
|
|
- cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
|
|
|
- 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);
|
|
|
- cJSON_AddStringToObject(pJsonsub, "lownc", lownc);
|
|
|
- cJSON_AddStringToObject(pJsonsub, "highnc", highnc);
|
|
|
- cJSON_AddStringToObject(pJsonsub, "highct", highct);
|
|
|
- cJSON_AddStringToObject(pJsonsub, "highnr", highnr);
|
|
|
- cJSON_AddStringToObject(pJsonsub, "maxReading", maxReading);
|
|
|
- cJSON_AddStringToObject(pJsonsub, "minReading", minReading);
|
|
|
-
|
|
|
- switch(pSensorBuff->sensor_units[1]) //sensorUinits2
|
|
|
- {
|
|
|
- case 0: cJSON_AddStringToObject(pJsonsub, "unit", "unspecified"); break;
|
|
|
- case 1: cJSON_AddStringToObject(pJsonsub, "unit", "degree C"); break;
|
|
|
- case 2: cJSON_AddStringToObject(pJsonsub, "unit", "degree F"); break;
|
|
|
- case 3: cJSON_AddStringToObject(pJsonsub, "unit", "degree K"); break;
|
|
|
- case 4: cJSON_AddStringToObject(pJsonsub, "unit", "Volts"); break;
|
|
|
- case 5: cJSON_AddStringToObject(pJsonsub, "unit", "Amps"); break;
|
|
|
- case 6: cJSON_AddStringToObject(pJsonsub, "unit", "Watts"); break;
|
|
|
- case 18: cJSON_AddStringToObject(pJsonsub, "unit", "RPM"); break;
|
|
|
- default: cJSON_AddStringToObject(pJsonsub, "unit", "unknown"); break;
|
|
|
- }
|
|
|
-
|
|
|
- switch(pSensorBuff->sensor_state)
|
|
|
- {
|
|
|
- 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;
|
|
|
- case 0x4: cJSON_AddStringToObject(pJsonsub, "state", "Upper Critical Threshold");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;
|
|
|
- case 0x8: cJSON_AddStringToObject(pJsonsub, "state", "Lower Non-Critical");cJSON_AddStringToObject(pJsonsub, "status", "2"); break;
|
|
|
- case 0x10: cJSON_AddStringToObject(pJsonsub, "state", "Lower Critical");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;
|
|
|
- case 0x20: cJSON_AddStringToObject(pJsonsub, "state", "Access failed");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;
|
|
|
- case 0x40: cJSON_AddStringToObject(pJsonsub, "state", "Upper Non-Recoverable");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;
|
|
|
- case 0x80: cJSON_AddStringToObject(pJsonsub, "state", "Lower Non-Recoverable");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;
|
|
|
- default: cJSON_AddNumberToObject(pJsonsub, "state", pSensorBuff->sensor_state);cJSON_AddStringToObject(pJsonsub, "status", "3"); break;
|
|
|
- }
|
|
|
-
|
|
|
- pSensorBuff++;
|
|
|
- nSensors--;
|
|
|
+ case 0: cJSON_AddStringToObject(pJsonsub, "unit", "unspecified"); break;
|
|
|
+ case 1: cJSON_AddStringToObject(pJsonsub, "unit", "degree C"); break;
|
|
|
+ case 2: cJSON_AddStringToObject(pJsonsub, "unit", "degree F"); break;
|
|
|
+ case 3: cJSON_AddStringToObject(pJsonsub, "unit", "degree K"); break;
|
|
|
+ case 4: cJSON_AddStringToObject(pJsonsub, "unit", "Volts"); break;
|
|
|
+ case 5: cJSON_AddStringToObject(pJsonsub, "unit", "Amps"); break;
|
|
|
+ case 6: cJSON_AddStringToObject(pJsonsub, "unit", "Watts"); break;
|
|
|
+ case 18: cJSON_AddStringToObject(pJsonsub, "unit", "RPM"); break;
|
|
|
+ default: cJSON_AddStringToObject(pJsonsub, "unit", "unknown"); break;
|
|
|
}
|
|
|
|
|
|
- // cJSON_AddItemToObject(root, "data", pJsonArry);//根节点下添加
|
|
|
- // cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
|
|
|
- // cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
|
|
|
- // pStr = cJSON_Print(pJsonArry);
|
|
|
- cJSON_AddItemToObject(root, "data", pJsonArry);
|
|
|
- pStr = cJSON_PrintUnformatted(root);
|
|
|
- // printf("---> pStr %d: %s\n", strlen(pStr), pStr);
|
|
|
-
|
|
|
- websSetStatus(wp, 200);
|
|
|
- websWriteHeaders(wp, -1, 0);
|
|
|
- websWriteEndHeaders(wp);
|
|
|
- //websWrite(wp, "[");
|
|
|
- websWrite(wp, pStr);
|
|
|
- //websWrite(wp, "]");
|
|
|
- //websFlush(wp, 0);
|
|
|
- websDone(wp);
|
|
|
-
|
|
|
- if(root)
|
|
|
- cJSON_Delete(root);
|
|
|
- if(pStr)
|
|
|
- wfree(pStr);
|
|
|
+ switch(pSensorBuff->sensor_state)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ case 0x4: cJSON_AddStringToObject(pJsonsub, "state", "Upper Critical Threshold");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;
|
|
|
+ case 0x8: cJSON_AddStringToObject(pJsonsub, "state", "Lower Non-Critical");cJSON_AddStringToObject(pJsonsub, "status", "2"); break;
|
|
|
+ case 0x10: cJSON_AddStringToObject(pJsonsub, "state", "Lower Critical");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;
|
|
|
+ case 0x20: cJSON_AddStringToObject(pJsonsub, "state", "Access failed");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;
|
|
|
+ case 0x40: cJSON_AddStringToObject(pJsonsub, "state", "Upper Non-Recoverable");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;
|
|
|
+ case 0x80: cJSON_AddStringToObject(pJsonsub, "state", "Lower Non-Recoverable");cJSON_AddStringToObject(pJsonsub, "status", "3"); break;
|
|
|
+ default: cJSON_AddNumberToObject(pJsonsub, "state", pSensorBuff->sensor_state);cJSON_AddStringToObject(pJsonsub, "status", "3"); break;
|
|
|
+ }
|
|
|
+
|
|
|
+ pSensorBuff++;
|
|
|
+ nSensors--;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ cJSON_AddItemToObject(root, "data", pJsonArry);
|
|
|
+ pStr = cJSON_PrintUnformatted(root);
|
|
|
+
|
|
|
+ websSetStatus(wp, 200);
|
|
|
+ websWriteHeaders(wp, -1, 0);
|
|
|
+ websWriteEndHeaders(wp);
|
|
|
+ websWrite(wp, pStr);
|
|
|
+ websFlush(wp, 0);
|
|
|
+ websDone(wp);
|
|
|
+ printf("---> cJSON Str:\n%s\n", pStr);
|
|
|
+
|
|
|
+ if(root)
|
|
|
+ cJSON_Delete(root);
|
|
|
+ if(pStr)
|
|
|
+ wfree(pStr);
|
|
|
}
|
|
|
- //TODO: lusa
|
|
|
error_out:
|
|
|
if(pStartBuff)
|
|
|
free(pStartBuff);
|
|
@@ -437,13 +495,13 @@ void getAllBladeInfo(Webs *wp){
|
|
|
|
|
|
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 Str:\n%s\n", pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|
|
@@ -454,6 +512,7 @@ void getAllBladeInfo(Webs *wp){
|
|
|
|
|
|
}
|
|
|
|
|
|
+//废弃
|
|
|
void setBladeManage(Webs *wp){
|
|
|
char *strEnable = websGetVar(wp, "enable", NULL);
|
|
|
|
|
@@ -467,14 +526,14 @@ void setBladeManage(Webs *wp){
|
|
|
cJSON_AddNumberToObject(root, "code", 200);
|
|
|
|
|
|
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 Str:\n%s\n", pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|
|
@@ -483,45 +542,25 @@ void setBladeManage(Webs *wp){
|
|
|
|
|
|
}
|
|
|
|
|
|
+//废弃
|
|
|
void getBladeManage(Webs *wp){
|
|
|
- // uint16_t wRet = LIBIPMI_E_SUCCESS;
|
|
|
- // IPMI20_UDS_SESSION_T UDSSession;
|
|
|
- // uint8_t enable = 0;
|
|
|
-
|
|
|
- // //Create session
|
|
|
- // LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
-
|
|
|
- // wRet = LIBIPMI_HL_GetBladeManageFn(&UDSSession, &enable, DEFAULT_TIMEOUT);
|
|
|
- // if(wRet != 0)
|
|
|
- // {
|
|
|
- // printf("Set Blade Manage error!\n");
|
|
|
- // websError(wp, 404, "Set Blade Manage Error!");
|
|
|
- // LIBIPMI_CloseSession(&UDSSession );
|
|
|
- // return;
|
|
|
- // }
|
|
|
-
|
|
|
- // //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, "isEnable", gChassisManageEn); //机箱管理功能是否已经打开
|
|
|
|
|
|
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 Str:\n%s\n", pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|
|
@@ -550,7 +589,7 @@ void getChassisInfo(Webs *wp){
|
|
|
//Close session
|
|
|
LIBIPMI_CloseSession(&UDSSession );
|
|
|
|
|
|
- if(ChassisInfo.supportChassisManageFn)
|
|
|
+ if(ChassisInfo.isChMC)
|
|
|
{
|
|
|
if(ChassisInfo.curIndex < BLADE_NUMBERS)
|
|
|
{
|
|
@@ -566,13 +605,6 @@ void getChassisInfo(Webs *wp){
|
|
|
gChassisManageEn = 0;
|
|
|
}
|
|
|
|
|
|
- // int i;
|
|
|
- // printf("IPMBAddr ");
|
|
|
- // for(i=0;i<BLADE_NUMBERS;i++)
|
|
|
- // {
|
|
|
- // printf("%#X ", gIPMBAddr[i]);
|
|
|
- // }
|
|
|
- // printf("\n");
|
|
|
|
|
|
char *pStr;
|
|
|
cJSON * root = cJSON_CreateObject();
|
|
@@ -582,19 +614,18 @@ void getChassisInfo(Webs *wp){
|
|
|
cJSON_AddNumberToObject(root, "code", 200);
|
|
|
|
|
|
cJSON_AddNumberToObject(data, "slotNum", ChassisInfo.slotNum); //机箱内一共有多少个槽位
|
|
|
- cJSON_AddNumberToObject(data, "supportManage", ChassisInfo.supportChassisManageFn); //是否支持机箱管理功能。 0:不支持, 1:支持
|
|
|
+ cJSON_AddNumberToObject(data, "supportManage", ChassisInfo.isChMC); //是否支持机箱管理功能。 0:不支持, 1:支持
|
|
|
cJSON_AddNumberToObject(data, "ManageEn", gChassisManageEn); //是否打开机箱管理功能。0:关闭, 1:打开
|
|
|
cJSON_AddNumberToObject(data, "curIndex", ChassisInfo.curIndex); //当前刀片插在第几个槽位。
|
|
|
|
|
|
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 Str:\n%s\n", pStr);
|
|
|
|
|
|
if(pStr)
|
|
|
wfree(pStr);
|