Răsfoiți Sursa

Rolling 20211124

jomjol 4 ani în urmă
părinte
comite
cc0bd1473f

+ 2 - 1
README.md

@@ -47,8 +47,9 @@ In other cases you can contact the developer via email: <img src="https://raw.gi
 
 **General remark:** Beside the `firmware.bin`, typically also the content of `/html` needs to be updated!
 
-##### Rolling (2021-11-23)
+##### Rolling (2021-11-24)
 
+- Direct JSON access: ``http://IP-ADRESS/json`` 
 - Error message in log file in case camera error during startup
 - Upgrade digital CNN to v13.3.0 (added new images)
 - html: support of different port

+ 27 - 1
code/components/jomjol_flowcontroll/ClassFlowControll.cpp

@@ -624,4 +624,30 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
     }
 
     return result;
-}
+}
+
+
+string ClassFlowControll::getJSON()
+{
+    std::vector<NumberPost*>* NUMBERS = flowpostprocessing->GetNumbers();
+
+    std::string json="{\n";
+
+    for (int i = 0; i < (*NUMBERS).size(); ++i)
+    {
+        json += "\"" + (*NUMBERS)[i]->name + "\":\n";
+        json += "  {\n";
+        json += "    \"value\": \""      + (*NUMBERS)[i]->ReturnValueNoError          + "\",\n";
+        json += "    \"raw\": \""        + (*NUMBERS)[i]->ReturnRawValue              + "\",\n";
+        json += "    \"error\": \""     + (*NUMBERS)[i]->ErrorMessageText             + "\",\n";
+        json += "    \"rate\": \""      + std::to_string((*NUMBERS)[i]->FlowRateAct)  + "\",\n";
+        json += "    \"timestamp\": \"" + (*NUMBERS)[i]->timeStamp                    + "\"\n";
+        if ((i+1) < (*NUMBERS).size())
+            json += "  },\n";
+        else
+            json += "  }\n";
+    }
+    json += "}";
+
+    return json;
+}

+ 1 - 0
code/components/jomjol_flowcontroll/ClassFlowControll.h

@@ -48,6 +48,7 @@ public:
 	string UpdatePrevalue(std::string _newvalue, std::string _numbers, bool _extern);
 	string GetPrevalue(std::string _number = "");	
 	bool ReadParameter(FILE* pfile, string& aktparamgraph);	
+	string getJSON();
 
 	string TranslateAktstatus(std::string _input);
 

+ 36 - 0
code/components/jomjol_tfliteclass/server_tflite.cpp

@@ -189,6 +189,36 @@ esp_err_t handler_doflow(httpd_req_t *req)
 };
 
 
+esp_err_t handler_json(httpd_req_t *req)
+{
+#ifdef DEBUG_DETAIL_ON       
+    LogFile.WriteHeapInfo("handler_json - Start");    
+#endif
+
+
+    printf("handler_JSON uri:\n"); printf(req->uri); printf("\n");
+
+    char _query[100];
+    char _size[10];
+
+    httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
+    httpd_resp_set_type(req, "application/json");
+
+    std::string zw = tfliteflow.getJSON();
+    if (zw.length() > 0)
+        httpd_resp_sendstr_chunk(req, zw.c_str()); 
+
+    string query = std::string(_query);
+
+    /* Respond with an empty chunk to signal HTTP response completion */
+    httpd_resp_sendstr_chunk(req, NULL);   
+
+#ifdef DEBUG_DETAIL_ON       
+    LogFile.WriteHeapInfo("handler_JSON - Done");   
+#endif
+    return ESP_OK;
+};
+
 
 
 esp_err_t handler_wasserzaehler(httpd_req_t *req)
@@ -710,4 +740,10 @@ 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       = "/json";
+    camuri.handler   = handler_json;
+    camuri.user_ctx  = (void*) "JSON"; 
+    httpd_register_uri_handler(server, &camuri);     
+
 }

+ 2 - 2
code/main/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="9ad1188";
+const char* GIT_REV="58124d2";
 const char* GIT_TAG="";
 const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2021-11-23 17:39";
+const char* BUILD_TIME="2021-11-24 07:21";

+ 2 - 2
code/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="9ad1188";
+const char* GIT_REV="58124d2";
 const char* GIT_TAG="";
 const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2021-11-23 17:39";
+const char* BUILD_TIME="2021-11-24 07:21";

BIN
firmware/bootloader.bin


BIN
firmware/firmware.bin