Pārlūkot izejas kodu

1、误把mongoose调试打开,关闭
2、导出文件时,不可以调用http_reply(), 去掉

guohui 2 gadi atpakaļ
vecāks
revīzija
e0d322e6b9
1 mainītis faili ar 9 papildinājumiem un 24 dzēšanām
  1. 9 24
      pro/src/appweb_handle.c

+ 9 - 24
pro/src/appweb_handle.c

@@ -103,7 +103,7 @@ static int save_to_csv(char *path, status_data_t *data, int flag)
     for(i=0; i<TOTAL_COUNT; i++) {
         if(i==0) fprintf(fp, "total voltage value,");
         fprintf(fp, "%.8f,", info->_total_voltage.ydata[i]);
-    } fprintf(fp, "\n");
+    } fprintf(fp, "\n\n");
 
     for(i=0; i<TOTAL_COUNT; i++) {
         if(i==0) fprintf(fp, "total current time,");
@@ -112,16 +112,16 @@ static int save_to_csv(char *path, status_data_t *data, int flag)
     for(i=0; i<TOTAL_COUNT; i++) {
         if(i==0) fprintf(fp, "total current value,");
         fprintf(fp, "%.8f,", info->_total_current.ydata[i]);
-    } fprintf(fp, "\n");
+    } fprintf(fp, "\n\n");
 
     for(i=0; i<TOTAL_COUNT; i++) {
-        if(i==0) fprintf(fp, "total power, time");
+        if(i==0) fprintf(fp, "total power time,");
         fprintf(fp, "%s,", info->_total_power.xAxis[i]);
     } fprintf(fp, "\n");
     for(i=0; i<TOTAL_COUNT; i++) {
         if(i==0) fprintf(fp, "total power value,");
         fprintf(fp, "%.8f,", info->_total_power.ydata[i]);
-    } fprintf(fp, "\n");
+    } fprintf(fp, "\n\n");
 
     for(i=0; i<TOTAL_COUNT; i++) {
         if(i==0) fprintf(fp, "total consum time,");
@@ -130,7 +130,7 @@ static int save_to_csv(char *path, status_data_t *data, int flag)
     for(i=0; i<TOTAL_COUNT; i++) {
         if(i==0) fprintf(fp, "total consum value,");
         fprintf(fp, "%.8f,", info->_total_consumption.ydata[i]);
-    } fprintf(fp, "\n");
+    } fprintf(fp, "\n\n");
 
     fclose(fp);
     return 0;
@@ -143,7 +143,7 @@ static int export_handle(void *conn, int flag)
     mg_stream_t *s=(mg_stream_t*)conn;
     struct mg_http_message *hm = (struct mg_http_message *)s->ev_data;
 
-    sprintf(path, "%s_history.csv", (flag==0)?"overall":"channel");
+    sprintf(path, "%s.csv", (flag==0)?"overall":"channel");
     r = save_to_csv(path, &wh->stt, flag);
     if(r==0) {
         struct mg_http_serve_opts opts = {.root_dir = NULL};
@@ -163,7 +163,6 @@ static int upload_handle(void *conn, char *path)
     size_t pos = 0, total_bytes = 0;
     struct mg_http_message *hm = (struct mg_http_message *)s->ev_data;
     
-    printf("___ upload file to %s 000\n", path);
     memset(name, 0, sizeof(name));
     while ((pos = mg_http_next_multipart(hm->body, pos, &part)) > 0) {
         memcpy(name, part.filename.buf, part.filename.len);
@@ -174,7 +173,7 @@ static int upload_handle(void *conn, char *path)
             total_bytes += part.body.len;
         }
     }
-    printf("___ upload file to %s %d\n", path, total_bytes);
+    //printf("___ upload file to %s %d\n", path, total_bytes);
 
     return r;
 }
@@ -207,7 +206,7 @@ static void *web_thread(void *arg)
     thread_handle_t *h=(thread_handle_t*)arg;
     const char *listen_addr="http://0.0.0.0:80";
 
-    mg_log_set(MG_LL_DEBUG);
+    //mg_log_set(MG_LL_DEBUG);
     mg_mgr_init(&mgr);
 
     //sys_get_path(h->rootDir, WEB_ROOT);
@@ -430,14 +429,6 @@ static void getUserRouters(void* conn)
 }
 
 
-
-static void log_message(const char *filename, const char *message) {
-  FILE *fp = fopen(filename, "a");
-  if (fp != NULL) {
-    fprintf(fp, "%s", message);
-    fclose(fp);
-  }
-}
 /// @brief 设备总体信息
 /// @param stream 
 static void overallStatusMonitoring(void* conn)
@@ -461,7 +452,6 @@ static void overallStatusMonitoring(void* conn)
         if (strstr(hm->uri.buf,"type=export")) {
             export_handle(conn, 0);
 
-            http_reply(conn, 200, ack_str);
         }
         else {
             http_reply(conn, 400, NULL);
@@ -899,11 +889,6 @@ static void channelStatusMonitoring(void* conn)
     {
         if (strstr(hm->uri.buf,"type=export")) {
             export_handle(conn, 1);
-
-            http_reply(conn, 200, ack_str);
-        }
-        else {
-            http_reply(conn, 400, NULL);
         }
         return;     
     }
@@ -3532,7 +3517,7 @@ static void equipmentMintenanceExport(void *conn)
         //export_handle(conn, 0);
     }
 
-    http_reply(conn, 200, "操作成功");
+    //http_reply(conn, 200, "操作成功");
 }
 
 static int webSetCallback(void)