diff --git a/README.md b/README.md index 49ad8c63..d9340137 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,9 @@ In other cases you can contact the developer via email: 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; +} diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.h b/code/components/jomjol_flowcontroll/ClassFlowControll.h index 904259ef..3f568b26 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.h +++ b/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); diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_tfliteclass/server_tflite.cpp index 354f9250..0469522a 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/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); + } diff --git a/code/main/version.cpp b/code/main/version.cpp index f6a14516..4071b717 100644 --- a/code/main/version.cpp +++ b/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"; \ No newline at end of file +const char* BUILD_TIME="2021-11-24 07:21"; \ No newline at end of file diff --git a/code/version.cpp b/code/version.cpp index f6a14516..4071b717 100644 --- a/code/version.cpp +++ b/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"; \ No newline at end of file +const char* BUILD_TIME="2021-11-24 07:21"; \ No newline at end of file diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index 98bc12fd..19e6fcad 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index 165598d2..9b3c6bad 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ