Bladeren bron

Add HTML Version

Philipp Harsch 5 jaren geleden
bovenliggende
commit
ccd1d3f460
11 gewijzigde bestanden met toevoegingen van 58 en 51 verwijderingen
  1. BIN
      .DS_Store
  2. BIN
      code/.DS_Store
  3. 50 2
      code/src/server_main.cpp
  4. 1 45
      code/src/server_tflite.cpp
  5. 2 2
      code/src/version.cpp
  6. 3 0
      code/src/version.h
  7. 2 2
      code/version.cpp
  8. BIN
      firmware/.DS_Store
  9. BIN
      firmware/html.zip
  10. BIN
      sd-card/.DS_Store
  11. BIN
      sd-card/html/.DS_Store

BIN
.DS_Store


BIN
code/.DS_Store


+ 50 - 2
code/src/server_main.cpp

@@ -9,6 +9,8 @@
 
 #include "version.h"
 
+#include "esp_wifi.h"
+
 
 httpd_handle_t server = NULL;   
 
@@ -163,8 +165,6 @@ esp_err_t hello_main_handler(httpd_req_t *req)
     return ESP_OK;
 }
 
-
-
 esp_err_t img_tmp_handler(httpd_req_t *req)
 {
     char filepath[50];
@@ -205,7 +205,47 @@ esp_err_t img_tmp_handler(httpd_req_t *req)
     return ESP_OK;
 }
 
+esp_err_t sysinfo_handler(httpd_req_t *req)
+{
+    const char* resp_str; 
+    std::string zw;
+    std::string cputemp = std::to_string(temperatureRead());
+    std::string gitversion = libfive_git_version();
+    std::string buildtime = build_time();
+    std::string gitbranch = libfive_git_branch();
+    std::string gitbasebranch = git_base_branch();
+    std::string htmlversion = getHTMLversion();
+
+    tcpip_adapter_ip_info_t ip_info;
+    ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
+    ip6_addr_t if_ip6;
+    ESP_ERROR_CHECK(tcpip_adapter_get_ip6_global(TCPIP_ADAPTER_IF_STA, &if_ip6));
+    const char *hostname;
+    ESP_ERROR_CHECK(tcpip_adapter_get_hostname(TCPIP_ADAPTER_IF_STA, &hostname));
+        
+    zw = "[\
+            {\
+                \"firmware\" : \"" + gitversion + "\",\
+                \"buildtime\" : \"" + buildtime + "\",\
+                \"gitbranch\" : \"" + gitbranch + "\",\
+                \"gitbasebranch\" : \"" + gitbasebranch + "\",\
+                \"html\" : \"" + htmlversion + "\",\
+                \"cputemp\" : \"" + cputemp + "\",\
+                \"hostname\" : \"" + hostname + "\",\
+                \"IPv4\" : \"" + ip4addr_ntoa(&ip_info.ip) + "\"\
+            }\
+        ]";
+
+
+    resp_str = zw.c_str();
+
+    httpd_resp_set_type(req, "application/json");
+    httpd_resp_send(req, resp_str, strlen(resp_str));   
+    /* Respond with an empty chunk to signal HTTP response completion */
+    httpd_resp_send_chunk(req, NULL, 0);      
 
+    return ESP_OK;
+}
 
 void register_server_main_uri(httpd_handle_t server, const char *base_path)
 {
@@ -217,6 +257,13 @@ void register_server_main_uri(httpd_handle_t server, const char *base_path)
     };
     httpd_register_uri_handler(server, &info_get_handle);
 
+    httpd_uri_t sysinfo_handle = {
+        .uri       = "/sysinfo",  // Match all URIs of type /path/to/file
+        .method    = HTTP_GET,
+        .handler   = sysinfo_handler,
+        .user_ctx  = (void*) base_path    // Pass server data as context
+    };
+    httpd_register_uri_handler(server, &sysinfo_handle);
 
     httpd_uri_t starttime_tmp_handle = {
         .uri       = "/starttime",  // Match all URIs of type /path/to/file
@@ -243,6 +290,7 @@ void register_server_main_uri(httpd_handle_t server, const char *base_path)
         .user_ctx  = (void*) base_path    // Pass server data as context
     };
     httpd_register_uri_handler(server, &main_rest_handle);
+
 }
 
 

+ 1 - 45
code/src/server_tflite.cpp

@@ -18,8 +18,6 @@
 
 #include "ClassLogFile.h"
 
-#include "version.h"
-
 ClassFlowControll tfliteflow;
 
 TaskHandle_t xHandleblink_task_doFlow = NULL;
@@ -412,44 +410,6 @@ esp_err_t handler_prevalue(httpd_req_t *req)
     return ESP_OK;
 };
 
-
-esp_err_t handler_sysinfo(httpd_req_t *req)
-{
-    LogFile.WriteToFile("handler_sysinfo"); 
-    const char* resp_str;
-    string zw;
-    string cputemp = std::to_string(temperatureRead());
-    string gitversion = libfive_git_version();
-    string buildtime = build_time();
-    string gitbranch = libfive_git_branch();
-    string gitbasebranch = git_base_branch();
-    string htmlversion = getHTMLversion();
-
-    zw = "[\
-            {\
-                \"firmware\" : \"" + gitversion + "\",\
-                \"buildtime\" : \"" + buildtime + "\",\
-                \"gitbranch\" : \"" + gitbranch + "\",\
-                \"gitbasebranch\" : \"" + gitbasebranch + "\",\
-                \"html\" : \"" + htmlversion + "\",\
-                \"cputemp\" : \"" + cputemp + "\",\
-                \"hostname\" : \"host\",\
-                \"IPv4\" : \"IP\"\
-            }\
-        ]";
-
-
-    resp_str = zw.c_str();
-
-    httpd_resp_set_type(req, "application/json");
-    httpd_resp_send(req, resp_str, strlen(resp_str));   
-    /* Respond with an empty chunk to signal HTTP response completion */
-    httpd_resp_send_chunk(req, NULL, 0);      
-
-    return ESP_OK;
-};
-
-
 void task_autodoFlow(void *pvParameter)
 {
     int64_t fr_start, fr_delta_ms;
@@ -528,9 +488,5 @@ void register_server_tflite_uri(httpd_handle_t server)
     camuri.handler   = handler_wasserzaehler;
     camuri.user_ctx  = (void*) "Wasserzaehler"; 
     httpd_register_uri_handler(server, &camuri);  
-    
-    camuri.uri       = "/sysinfo";
-    camuri.handler   = handler_sysinfo;
-    camuri.user_ctx  = (void*) "Sysinfo"; 
-    httpd_register_uri_handler(server, &camuri);
+
 }

+ 2 - 2
code/src/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="9080f1d+";
+const char* GIT_REV="964486a+";
 const char* GIT_TAG="";
 const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2020-09-28 23:50";
+const char* BUILD_TIME="2020-09-29 01:57";

+ 3 - 0
code/src/version.h

@@ -9,6 +9,9 @@ extern "C"
 }
 
 #include <string>
+#include <string.h>
+#include "Helper.h"
+#include <fstream>
 
 const char* GIT_BASE_BRANCH = "master - v2.1.1 - 2020-09-28";
 

+ 2 - 2
code/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="9080f1d+";
+const char* GIT_REV="964486a+";
 const char* GIT_TAG="";
 const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2020-09-28 23:50";
+const char* BUILD_TIME="2020-09-29 01:57";

BIN
firmware/.DS_Store


BIN
firmware/html.zip


BIN
sd-card/.DS_Store


BIN
sd-card/html/.DS_Store