|
|
@@ -1,4 +1,3 @@
|
|
|
-#include "http.h"
|
|
|
#include "cJSON.h"
|
|
|
#include "common.h"
|
|
|
#include "json_handle.h"
|
|
|
@@ -9,22 +8,15 @@
|
|
|
#include "thread.h"
|
|
|
#include "cfg.h"
|
|
|
#include "cascade.h"
|
|
|
-#include "appweb.h"
|
|
|
#include "upg.h"
|
|
|
#include "file.h"
|
|
|
+#include "mongoose.h"
|
|
|
#include "language_common.h"
|
|
|
#include "websocket_handle.h"
|
|
|
|
|
|
|
|
|
-
|
|
|
-typedef void (*http_fn_t)(void *arg);
|
|
|
-
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
-#include "http.h"
|
|
|
-#else
|
|
|
-#include "mongoose.h"
|
|
|
#define FN_MAX 30
|
|
|
+typedef void (*http_fn_t)(void *arg);
|
|
|
|
|
|
typedef struct {
|
|
|
struct mg_connection *c;
|
|
|
@@ -42,29 +34,27 @@ typedef struct {
|
|
|
|
|
|
pthread_t tid;
|
|
|
}mg_handle_t;
|
|
|
-#endif
|
|
|
typedef struct {
|
|
|
-#ifndef USE_WEBAPP
|
|
|
- mg_handle_t mg;
|
|
|
-#endif
|
|
|
+ _OverAllPwrAckInfo all;
|
|
|
+ _OverChnPwrAckInfo chn;
|
|
|
+}status_data_t;
|
|
|
+typedef struct {
|
|
|
+ mg_handle_t mg;
|
|
|
+ pthread_t tid;
|
|
|
|
|
|
- pthread_t tid;
|
|
|
+ status_data_t stt;
|
|
|
}web_handle_t;
|
|
|
-static web_handle_t webHandle;
|
|
|
-
|
|
|
|
|
|
static char* g_product_board_cpu[] = {
|
|
|
"xxx",
|
|
|
"T113"
|
|
|
};
|
|
|
-
|
|
|
static char* g_product_type_str[] = {
|
|
|
"SmartPdu(DC)",
|
|
|
"SmartPdu(AC)",
|
|
|
"SmartPdu(Tree_AC_Tree)",
|
|
|
"SmartPdu(Tree_AC_One)",
|
|
|
};
|
|
|
-
|
|
|
static char* g_product_pwr_type_str[] = {
|
|
|
"xxx",
|
|
|
"直流",
|
|
|
@@ -72,86 +62,64 @@ static char* g_product_pwr_type_str[] = {
|
|
|
"交流三相三出",
|
|
|
"交流三相单出",
|
|
|
};
|
|
|
+static web_handle_t webHandle;
|
|
|
static int webSetCallback(void);
|
|
|
|
|
|
+///////////////////////////////////////////////////
|
|
|
|
|
|
static int http_reply(void *conn, int status, char *ack)
|
|
|
{
|
|
|
int r=0;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- httpSetStatus(s, status);
|
|
|
- if(ack && strlen(ack)>0) {
|
|
|
- httpWrite(s->writeq, ack);
|
|
|
- }
|
|
|
- httpFinalize(s);
|
|
|
-#else
|
|
|
+
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
r = mg_http_reply2(s->c, status, "", ack);
|
|
|
-#endif
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
-
|
|
|
static void httpAddCallback(char *uri, http_fn_t f)
|
|
|
{
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- httpDefineAction(uri, (HttpAction)f);
|
|
|
-#else
|
|
|
mg_handle_t *h=&webHandle.mg;
|
|
|
if(h->cnt<FN_MAX-1) {
|
|
|
h->fn[h->cnt].uri = uri;
|
|
|
h->fn[h->cnt].f = f;
|
|
|
h->cnt++;
|
|
|
}
|
|
|
-
|
|
|
-#endif
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
-static void *web_thread(void *arg)
|
|
|
+static int save_to_csv(char *path, status_data_t *data)
|
|
|
{
|
|
|
- Mpr *mpr;
|
|
|
- int rc;
|
|
|
- char path[MG_PATH_MAX];
|
|
|
- thread_handle_t *h=(thread_handle_t*)arg;
|
|
|
-
|
|
|
- rc = MPR_ERR_CANT_CREATE;
|
|
|
- if ((mpr = mprCreate(0, NULL, MPR_USER_EVENTS_THREAD)) == 0) {
|
|
|
- mprError("Cannot create runtime");
|
|
|
- return NULL;
|
|
|
- }
|
|
|
- if (httpCreate(HTTP_CLIENT_SIDE | HTTP_SERVER_SIDE) == 0) {
|
|
|
- mprError("Cannot create the HTTP services");
|
|
|
- return NULL;
|
|
|
- }
|
|
|
-
|
|
|
- mprStart();
|
|
|
+ int tlen=0;
|
|
|
+ FILE *fp=NULL;
|
|
|
|
|
|
- sys_get_path(path, ME_CONFIG_FILE);
|
|
|
- log_d("____ web root: %s\n", path);
|
|
|
- if (maParseConfig(path) < 0) {
|
|
|
- mprError("Cannot parse the config file %s", ME_CONFIG_FILE);
|
|
|
- return NULL;
|
|
|
+ fp = fopen(path, "wt");
|
|
|
+ if(!fp) {
|
|
|
+ return -1;
|
|
|
}
|
|
|
|
|
|
- webSetCallback();
|
|
|
- //httpAddFileHandler(host);
|
|
|
-
|
|
|
- if (httpStartEndpoints() < 0) {
|
|
|
- mprError("Cannot start the web server");
|
|
|
- return NULL;
|
|
|
+ fprintf(fp, "hello world");
|
|
|
+
|
|
|
+ fclose(fp);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+static int download_handle(void *conn, int flag)
|
|
|
+{
|
|
|
+ int r;
|
|
|
+ char path[100];
|
|
|
+ web_handle_t *wh=&webHandle;
|
|
|
+ mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
+ struct mg_http_message *hm = (struct mg_http_message *)s->ev_data;
|
|
|
+
|
|
|
+ sprintf(path, "/tmp/%s_history.csv", (flag==0)?"overall":"channel");
|
|
|
+ r = save_to_csv(path, &wh->stt);
|
|
|
+ if(r==0) {
|
|
|
+ struct mg_http_serve_opts opts = {.root_dir = NULL};
|
|
|
+ mg_http_serve_file(s->c, hm, path, &opts);
|
|
|
+ file_remove(path);
|
|
|
}
|
|
|
- mprServiceEvents(-1, 0);
|
|
|
- mprDestroy();
|
|
|
-
|
|
|
- pthread_exit(NULL);
|
|
|
+
|
|
|
+ return r;
|
|
|
}
|
|
|
|
|
|
-#else
|
|
|
-static int upload_handle(void *conn, char *upload_path)
|
|
|
+static int upload_handle(void *conn, char *path)
|
|
|
{
|
|
|
int r=-1;
|
|
|
struct mg_http_part part;
|
|
|
@@ -162,8 +130,8 @@ static int upload_handle(void *conn, char *upload_path)
|
|
|
while ((pos = mg_http_next_multipart(hm->body, pos, &part)) > 0) {
|
|
|
printf("filename: %s length: %lu bytes", part.filename.buf, (unsigned long) part.body.len);
|
|
|
|
|
|
- if (mg_path_is_sane(mg_str(upload_path))) {
|
|
|
- mg_file_write(&mg_fs_posix, upload_path, part.body.buf, part.body.len);
|
|
|
+ if (mg_path_is_sane(mg_str(path))) {
|
|
|
+ mg_file_write(&mg_fs_posix, path, part.body.buf, part.body.len);
|
|
|
total_bytes += part.body.len;
|
|
|
}
|
|
|
}
|
|
|
@@ -217,7 +185,7 @@ static void *web_thread(void *arg)
|
|
|
|
|
|
pthread_exit(NULL);
|
|
|
}
|
|
|
-#endif
|
|
|
+
|
|
|
|
|
|
|
|
|
/// @brief 系统信息
|
|
|
@@ -225,18 +193,10 @@ static void *web_thread(void *arg)
|
|
|
static void systemConfiguration(void* conn)
|
|
|
{
|
|
|
char *ack_str = NULL;
|
|
|
- char* rx_Head_buf = NULL;
|
|
|
char *g_token = NULL;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s = (HttpStream *)conn;
|
|
|
- rx_Head_buf = (char *)httpGetHeader(s, "Authorization");
|
|
|
- usleep(500000);
|
|
|
-#else
|
|
|
mg_stream_t *s = (mg_stream_t *)conn;
|
|
|
struct mg_http_message *msg = s->ev_data;
|
|
|
- rx_Head_buf = (char *)msg->head.buf;
|
|
|
-#endif
|
|
|
+ char* rx_Head_buf = (char *)msg->head.buf;
|
|
|
|
|
|
g_token = json_to_Token_info(rx_Head_buf);
|
|
|
// 检查token是否有效
|
|
|
@@ -262,16 +222,10 @@ static void systemConfiguration(void* conn)
|
|
|
static void changeLanguages(void* conn)
|
|
|
{
|
|
|
char* ack_str = NULL;
|
|
|
- char* rx_body_buf = NULL;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_body_buf = (char*)httpGetBodyInput(s);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf = (char*)msg->body.buf;
|
|
|
-#endif
|
|
|
+ char* rx_body_buf = (char*)msg->body.buf;
|
|
|
+
|
|
|
json_to_switch_language(rx_body_buf);
|
|
|
dev_update_device_genera_info(__globalDeviceManage.db,__globalDeviceManage._global_device_info);
|
|
|
ack_str = ctrl_sts_ack_to_json();
|
|
|
@@ -285,15 +239,9 @@ static void loginFunc(void* conn)
|
|
|
{
|
|
|
char* ack_str = NULL ;
|
|
|
char g_token[64] = {0};
|
|
|
- cchar* rx_body_buf = NULL;
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_body_buf = httpGetBodyInput(s);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf = msg->body.buf;
|
|
|
-#endif
|
|
|
+ char *rx_body_buf = msg->body.buf;
|
|
|
|
|
|
//用户信息创建-未析构
|
|
|
_User_Log *_newUserLogin = (_User_Log *)malloc(sizeof(_User_Log));
|
|
|
@@ -302,9 +250,8 @@ static void loginFunc(void* conn)
|
|
|
//转换json参数
|
|
|
if(json_to_User_login_info(rx_body_buf,_newUserLogin)!=0)
|
|
|
{
|
|
|
- httpSetStatus(stream, 400);
|
|
|
- httpFinalize(stream);
|
|
|
- return ;
|
|
|
+ http_reply(conn, 400, NULL);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
bool LoginFlag = false;
|
|
|
@@ -365,17 +312,10 @@ static void loginOutFunc(void* conn)
|
|
|
{
|
|
|
__globalDeviceManage.view_page=-1;
|
|
|
char* ack_str = NULL ;
|
|
|
- char* rx_body_buf = NULL;
|
|
|
char* g_token;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_body_buf = (char*)httpGetBodyInput(s);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf = (char*)msg->body.buf;
|
|
|
-#endif
|
|
|
+ char *rx_body_buf = (char*)msg->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
if(json_to_User_loginOut_info(rx_body_buf,&g_token)!=0)
|
|
|
@@ -411,18 +351,10 @@ static void getUserInfo(void* conn)
|
|
|
static void getUserRouters(void* conn)
|
|
|
{
|
|
|
char* ack_str = NULL ;
|
|
|
- char* rx_Head_buf = NULL;
|
|
|
char* g_token=NULL;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_Head_buf = (char*)httpGetHeader(s,"Authorization");
|
|
|
- usleep(500000);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_Head_buf = (char*)msg->head.buf;
|
|
|
-#endif
|
|
|
+ char *rx_Head_buf = (char*)msg->head.buf;
|
|
|
|
|
|
// 查询用户信息
|
|
|
UserInfo User_list;
|
|
|
@@ -466,25 +398,24 @@ static void overallStatusMonitoring(void* conn)
|
|
|
_Over_All_Sts_Monitor _over_all_sts_monitor={0};
|
|
|
_OverBackStsInfo _over_back_sts_info; //设备总体状态信息
|
|
|
_OverAllPwrAckInfo _over_all_pwr_back_info; //设备电源信息
|
|
|
- char* rx_body_buf = NULL;
|
|
|
char* ack_str=NULL;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_body_buf = (char*)httpGetBodyInput(s);
|
|
|
- usleep(500000);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf = (char*)msg->body.buf;
|
|
|
-#endif
|
|
|
+ char *rx_body_buf = (char*)msg->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
cjson = json_to_overall_status_monitor(rx_body_buf,&_over_all_sts_monitor);
|
|
|
if(cjson==NULL)
|
|
|
{
|
|
|
- http_reply(conn, 400, NULL);
|
|
|
- return ;
|
|
|
+ if (strstr(rx_body_buf,"type=export")) {
|
|
|
+ download_handle(conn, 0);
|
|
|
+
|
|
|
+ http_reply(conn, 200, ack_str);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ http_reply(conn, 400, NULL);
|
|
|
+ }
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
//总电压电流信息
|
|
|
@@ -904,29 +835,27 @@ static void channelStatusMonitoring(void* conn)
|
|
|
cmd_data_t cmd;
|
|
|
_OverChnPwrRequest _over_chn_pwr_request;
|
|
|
_OverAllPwrAckInfo _over_all_pwr_back_info; //设备电源信息
|
|
|
- char* rx_body_buf = NULL;
|
|
|
char* ack_str = NULL ;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_body_buf = (char*)httpGetBodyInput(s);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf=(char*)msg->body.buf;
|
|
|
-#endif
|
|
|
+ char *rx_body_buf=(char*)msg->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
memset(&_over_chn_pwr_request,0,sizeof(_OverChnPwrRequest));
|
|
|
cjson = json_to_chn_pwr_status_monitor(rx_body_buf,&_over_chn_pwr_request);
|
|
|
if(cjson==NULL)
|
|
|
{
|
|
|
- http_reply(conn, 400, NULL);
|
|
|
- return ;
|
|
|
+ if (strstr(rx_body_buf,"type=export")) {
|
|
|
+ download_handle(conn, 1);
|
|
|
+
|
|
|
+ http_reply(conn, 200, ack_str);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ http_reply(conn, 400, NULL);
|
|
|
+ }
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- #if(1)
|
|
|
- //查询
|
|
|
if(strcmp(_over_chn_pwr_request.type,"listQuery")==0||strcmp(_over_chn_pwr_request.type,"resetChannel")==0)
|
|
|
{
|
|
|
//log_i("channel status request:listQuery");
|
|
|
@@ -1399,7 +1328,6 @@ static void channelStatusMonitoring(void* conn)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- #endif
|
|
|
|
|
|
quit:
|
|
|
cJSON_Delete(cjson);
|
|
|
@@ -1419,17 +1347,11 @@ static void sensorStatusMonitoring(void* conn)
|
|
|
_OverSensorBackInfo _over_all_sensor_back_info;
|
|
|
GlobalSensorManger _globalSensorMangerTemp ;
|
|
|
GlobalSensorInfo _globalSensorInfo;
|
|
|
- char* rx_body_buf = NULL;
|
|
|
char* ack_str = NULL ;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_body_buf = (char*)httpGetBodyInput(s);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf=(char*)msg->body.buf;
|
|
|
-#endif
|
|
|
+ char *rx_body_buf=(char*)msg->body.buf;
|
|
|
+
|
|
|
//转换json参数
|
|
|
cjson = json_to_sensor_manage(rx_body_buf,&_over_all_sensor_request);
|
|
|
if(cjson==NULL)
|
|
|
@@ -1921,19 +1843,11 @@ static void alarmProtect(void *conn)
|
|
|
cJSON *cjson;
|
|
|
_AlarmRequestInfo _alarm_request_info;
|
|
|
_AlarmAckInfo _alarm_ack_info; //填充数据
|
|
|
- char* rx_body_buf = NULL;
|
|
|
char* ack_str = NULL ;
|
|
|
int nAlarmNumber=0;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_body_buf = (char*)httpGetBodyInput(s);
|
|
|
- usleep(100000);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf=(char*)msg->body.buf;
|
|
|
-#endif
|
|
|
+ char *rx_body_buf=(char*)msg->body.buf;
|
|
|
|
|
|
memset(&_alarm_request_info, 0, sizeof(_alarm_request_info));
|
|
|
//转换json参数
|
|
|
@@ -2196,21 +2110,14 @@ static void alarmProtect(void *conn)
|
|
|
static void logInformation(void *conn)
|
|
|
{
|
|
|
int ret = -1 ;
|
|
|
- char* rx_body_buf = NULL;
|
|
|
char* ack_str = NULL ;
|
|
|
int nAlarmNum = 0;
|
|
|
cJSON *cjson;
|
|
|
_LogInformationRequestInfo __logInformationRequestInfo;
|
|
|
_AlarmAckInfo _alarm_ack_info; //填充数据
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_body_buf = (char*)httpGetBodyInput(s);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf=(char*)msg->body.buf;
|
|
|
-#endif
|
|
|
+ char *rx_body_buf=(char*)msg->body.buf;
|
|
|
|
|
|
memset(&__logInformationRequestInfo,0,sizeof(_LogInformationRequestInfo));
|
|
|
cjson = json_to_loginformation_manage(rx_body_buf,&__logInformationRequestInfo);
|
|
|
@@ -2390,22 +2297,14 @@ static void logInformation(void *conn)
|
|
|
static void communicationManagement(void *conn)
|
|
|
{
|
|
|
int r = -1 ;
|
|
|
- char* rx_body_buf = NULL;
|
|
|
char* ack_str = NULL ;
|
|
|
cJSON *cjson;
|
|
|
_CommunicationManageRequestInfo _communicationManageRequestInfo;
|
|
|
_CommunicationManageRequestInfo reqInfo;
|
|
|
GlobalDeviceInfo *devInfo=__globalDeviceManage._global_device_info;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- usleep(100000);
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_body_buf = (char*)httpGetBodyInput(s);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf=(char*)msg->body.buf;
|
|
|
-#endif
|
|
|
+ char *rx_body_buf=(char*)msg->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
cjson = json_to_communication_manage(rx_body_buf,&reqInfo);
|
|
|
@@ -2508,19 +2407,12 @@ static void serviceManagement(void *conn)
|
|
|
{
|
|
|
__globalDeviceManage.view_page=-1;
|
|
|
int ret = -1 ;
|
|
|
- char* rx_body_buf = NULL;
|
|
|
cJSON *cjson;
|
|
|
_ServiceManageRequestInfo _serviceManageRequestInfo;
|
|
|
char* ack_str = NULL ;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_body_buf = (char*)httpGetBodyInput(s);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf = (char*)msg->body.buf;
|
|
|
-#endif
|
|
|
+ char *rx_body_buf = (char*)msg->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
memset(&_serviceManageRequestInfo, 0, sizeof(_serviceManageRequestInfo));
|
|
|
@@ -3271,19 +3163,12 @@ static void systemManagent(void *conn)
|
|
|
{
|
|
|
__globalDeviceManage.view_page=-1;
|
|
|
int ret = -1 ;
|
|
|
- char* rx_body_buf = NULL;
|
|
|
cJSON *cjson;
|
|
|
_UserRoleManageInfo _UserRoleManageRequestInfo;
|
|
|
char* ack_str = NULL ;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_body_buf = (char*)httpGetBodyInput(s);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf = (char*)msg->body.buf;
|
|
|
-#endif
|
|
|
+ char *rx_body_buf = (char*)msg->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
cjson = json_to_user_manage(rx_body_buf,&_UserRoleManageRequestInfo);
|
|
|
@@ -3450,21 +3335,13 @@ static void systemManagent(void *conn)
|
|
|
static void equipmentMintenance(void *conn)
|
|
|
{
|
|
|
int ret = -1 ;
|
|
|
- char* rx_body_buf = NULL;
|
|
|
char* ack_str = NULL ;
|
|
|
cJSON *cjson;
|
|
|
_OverBackStsInfo _over_back_sts_info; //设备总体状态信息
|
|
|
_Equipment_Mintenance _Over_equipment_mintenance;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- rx_body_buf = (char*)httpGetBodyInput(s);
|
|
|
- usleep(500000);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf = (char*)msg->body.buf;
|
|
|
-#endif
|
|
|
+ char *rx_body_buf = (char*)msg->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
cjson = json_to_over_equipment_mintenance(rx_body_buf,&_Over_equipment_mintenance);
|
|
|
@@ -3570,17 +3447,10 @@ static void equipmentMintenance(void *conn)
|
|
|
static void equipmentMintenanceUpload(void *conn)
|
|
|
{
|
|
|
int r = -1 ;
|
|
|
- char* rx_body_buf = NULL;
|
|
|
char* ack_str = NULL ;
|
|
|
-
|
|
|
-#ifdef USE_WEBAPP
|
|
|
- HttpStream *s=(HttpStream*)conn;
|
|
|
- http_reply(conn, 200, NULL);
|
|
|
-#else
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *msg=s->ev_data;
|
|
|
- rx_body_buf = (char*)msg->body.buf;
|
|
|
-#endif
|
|
|
+ char *rx_body_buf = (char*)msg->body.buf;
|
|
|
char path[200];
|
|
|
|
|
|
if(strstr(msg->uri.buf, "uploadType=gjsj")) { //firmware upload
|
|
|
@@ -3596,7 +3466,7 @@ static void equipmentMintenanceUpload(void *conn)
|
|
|
upload_handle(conn, path);
|
|
|
}
|
|
|
|
|
|
- http_reply(conn, 200, "");
|
|
|
+ http_reply(conn, 200, "操作成功");
|
|
|
}
|
|
|
|
|
|
static int webSetCallback(void)
|