diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..7911e3f44 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md index bfb2c53eb..d81ff467c 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,21 @@ A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571 -##### Rolling - (2020-09-28) +##### Rolling - (2020-10-13) + +* Implementation of user and password for MQTT Authentication (see `config.ini`) + +2020-10-04 + +* First simple MQTT Client - to be configured in `config.ini` (see example) + + + +2020-09-29 + +* Implementation of HTML-Version (thanks to phlupp) + +* ESP32 Temperature is now written correctly to log file * based on v2.2.1 (2020-09-28) diff --git a/code/.DS_Store b/code/.DS_Store new file mode 100644 index 000000000..017ffc682 Binary files /dev/null and b/code/.DS_Store differ diff --git a/code/lib/jomjol_flowcontroll/ClassFlowAnalog.cpp b/code/lib/jomjol_flowcontroll/ClassFlowAnalog.cpp index c1656f5e5..fa6085e79 100644 --- a/code/lib/jomjol_flowcontroll/ClassFlowAnalog.cpp +++ b/code/lib/jomjol_flowcontroll/ClassFlowAnalog.cpp @@ -12,6 +12,8 @@ #include "ClassLogFile.h" +bool debugdetailanalog = false; + ClassFlowAnalog::ClassFlowAnalog() { isLogImage = false; @@ -147,6 +149,8 @@ bool ClassFlowAnalog::doFlow(string time) return false; }; + if (debugdetailanalog) LogFile.WriteToFile("ClassFlowAnalog::doFlow nach Alignment"); + doNeuralNetwork(time); return true; @@ -167,7 +171,7 @@ bool ClassFlowAnalog::doAlignAndCut(string time) CAlignAndCutImage *caic = new CAlignAndCutImage(input); if (!caic->ImageOkay()){ - LogFile.WriteToFile("ClassFlowAnalog::doAlignAndCut not okay!"); + if (debugdetailanalog) LogFile.WriteToFile("ClassFlowAnalog::doAlignAndCut not okay!"); delete caic; return false; } @@ -175,7 +179,7 @@ bool ClassFlowAnalog::doAlignAndCut(string time) if (input_roi.length() > 0){ img_roi = new CImageBasis(input_roi); if (!img_roi->ImageOkay()){ - LogFile.WriteToFile("ClassFlowAnalog::doAlignAndCut ImageRoi not okay!"); + if (debugdetailanalog) LogFile.WriteToFile("ClassFlowAnalog::doAlignAndCut ImageRoi not okay!"); delete caic; delete img_roi; return false; @@ -190,6 +194,13 @@ bool ClassFlowAnalog::doAlignAndCut(string time) caic->CutAndSave(output, ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay); rs = new CResizeImage(output); + if (!rs->ImageOkay()){ + if (debugdetailanalog) LogFile.WriteToFile("ClassFlowAnalog::doAlignAndCut CResizeImage(output);!"); + delete caic; + delete rs; + return false; + } + rs->Resize(modelxsize, modelysize); ioresize = "/sdcard/img_tmp/ra" + std::to_string(i) + ".bmp"; ioresize = FormatFileName(ioresize); @@ -248,8 +259,11 @@ bool ClassFlowAnalog::doNeuralNetwork(string time) f1 = 0; f2 = 0; #ifndef OHNETFLITE +// LogFile.WriteToFile("ClassFlowAnalog::doNeuralNetwork vor CNN tflite->LoadInputImage(ioresize)"); tflite->LoadInputImage(ioresize); tflite->Invoke(); + if (debugdetailanalog) LogFile.WriteToFile("Nach Invoke"); + f1 = tflite->GetOutputValue(0); f2 = tflite->GetOutputValue(1); diff --git a/code/lib/jomjol_flowcontroll/ClassFlowControll.cpp b/code/lib/jomjol_flowcontroll/ClassFlowControll.cpp index cda40f2c7..50ea08c71 100644 --- a/code/lib/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/lib/jomjol_flowcontroll/ClassFlowControll.cpp @@ -20,6 +20,9 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _ if (_stepname.compare("[Analog]") == 0){ _classname = "ClassFlowAnalog"; } + if (_stepname.compare("[MQTT]") == 0){ + _classname = "ClassFlowMQTT"; + } // std::string zw = "Classname: " + _classname + "\n"; // printf(zw.c_str()); @@ -80,6 +83,8 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type) cfc = new ClassFlowAnalog(&FlowControll); if (toUpper(_type).compare("[DIGITS]") == 0) cfc = new ClassFlowDigit(&FlowControll); + if (toUpper(_type).compare("[MQTT]") == 0) + cfc = new ClassFlowMQTT(&FlowControll); if (toUpper(_type).compare("[POSTPROCESSING]") == 0) { cfc = new ClassFlowPostProcessing(&FlowControll); diff --git a/code/lib/jomjol_flowcontroll/ClassFlowControll.h b/code/lib/jomjol_flowcontroll/ClassFlowControll.h index b63748b53..d3d9de9a1 100644 --- a/code/lib/jomjol_flowcontroll/ClassFlowControll.h +++ b/code/lib/jomjol_flowcontroll/ClassFlowControll.h @@ -8,6 +8,7 @@ #include "ClassFlowDigit.h" #include "ClassFlowAnalog.h" #include "ClassFlowPostProcessing.h" +#include "ClassFlowMQTT.h" class ClassFlowControll : diff --git a/code/lib/jomjol_flowcontroll/ClassFlowMQTT.cpp b/code/lib/jomjol_flowcontroll/ClassFlowMQTT.cpp new file mode 100644 index 000000000..c1d66426a --- /dev/null +++ b/code/lib/jomjol_flowcontroll/ClassFlowMQTT.cpp @@ -0,0 +1,122 @@ +#include "ClassFlowMQTT.h" +#include "Helper.h" + +#include "interface_mqtt.h" +#include "ClassFlowPostProcessing.h" + +#include + +static const char* TAG2 = "example"; + +ClassFlowMQTT::ClassFlowMQTT() +{ + uri = ""; + topic = ""; + clientname = "watermeter"; + OldValue = ""; + flowpostprocessing = NULL; + user = ""; + password = ""; +} + +ClassFlowMQTT::ClassFlowMQTT(std::vector* lfc) +{ + uri = ""; + topic = ""; + clientname = "watermeter"; + OldValue = ""; + flowpostprocessing = NULL; + user = ""; + password = ""; + + ListFlowControll = lfc; + + for (int i = 0; i < ListFlowControll->size(); ++i) + { + if (((*ListFlowControll)[i])->name().compare("ClassFlowPostProcessing") == 0) + { + flowpostprocessing = (ClassFlowPostProcessing*) (*ListFlowControll)[i]; + } + } + +} + +bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph) +{ + std::vector zerlegt; + + aktparamgraph = trim(aktparamgraph); + + if (aktparamgraph.size() == 0) + if (!this->GetNextParagraph(pfile, aktparamgraph)) + return false; + + if (toUpper(aktparamgraph).compare("[MQTT]") != 0) // Paragraph passt nich zu MakeImage + return false; + + while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) + { + zerlegt = this->ZerlegeZeile(aktparamgraph); + if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1)) + { + this->user = zerlegt[1]; + } + if ((toUpper(zerlegt[0]) == "PASSWORD") && (zerlegt.size() > 1)) + { + this->password = zerlegt[1]; + } + if ((toUpper(zerlegt[0]) == "URI") && (zerlegt.size() > 1)) + { + this->uri = zerlegt[1]; + } + if ((toUpper(zerlegt[0]) == "TOPIC") && (zerlegt.size() > 1)) + { + this->topic = zerlegt[1]; + } + if ((toUpper(zerlegt[0]) == "CLIENTID") && (zerlegt.size() > 1)) + { + this->clientname = zerlegt[1]; + } + + } + + if ((uri.length() > 0) && (topic.length() > 0)) + { + MQTTInit(uri, clientname, user, password); + } + + return true; +} + + +bool ClassFlowMQTT::doFlow(string zwtime) +{ + std::string result; + string zw = ""; + + if (flowpostprocessing) + { + result = flowpostprocessing->getReadoutParam(false, true); + } + else + { + for (int i = 0; i < ListFlowControll->size(); ++i) + { + zw = (*ListFlowControll)[i]->getReadout(); + if (zw.length() > 0) + { + if (result.length() == 0) + result = zw; + else + result = result + "\t" + zw; + } + } + } + + MQTTPublish(topic, result); + + OldValue = result; + + + return true; +} diff --git a/code/lib/jomjol_flowcontroll/ClassFlowMQTT.h b/code/lib/jomjol_flowcontroll/ClassFlowMQTT.h new file mode 100644 index 000000000..a22173ef1 --- /dev/null +++ b/code/lib/jomjol_flowcontroll/ClassFlowMQTT.h @@ -0,0 +1,25 @@ +#pragma once +#include "ClassFlow.h" + +#include "ClassFlowPostProcessing.h" + +#include + +class ClassFlowMQTT : + public ClassFlow +{ +protected: + std::string uri, topic, clientname; + std::string OldValue; + ClassFlowPostProcessing* flowpostprocessing; + std::string user, password; + + +public: + ClassFlowMQTT(); + ClassFlowMQTT(std::vector* lfc); + bool ReadParameter(FILE* pfile, string& aktparamgraph); + bool doFlow(string time); + string name(){return "ClassFlowMQTT";}; +}; + diff --git a/code/lib/jomjol_image_proc/CFindTemplate.cpp b/code/lib/jomjol_image_proc/CFindTemplate.cpp index cb3dd4eea..69397e81e 100644 --- a/code/lib/jomjol_image_proc/CFindTemplate.cpp +++ b/code/lib/jomjol_image_proc/CFindTemplate.cpp @@ -391,11 +391,11 @@ CImageBasis::CImageBasis(std::string _image) channels = 3; externalImage = false; filename = _image; - long freebefore = esp_get_free_heap_size(); +// long freebefore = esp_get_free_heap_size(); rgb_image = stbi_load(_image.c_str(), &width, &height, &bpp, channels); - if (rgb_image == NULL) - LogFile.WriteToFile("Image Load failed:" + _image + " FreeHeapSize before: " + to_string(freebefore) + " after: " + to_string(esp_get_free_heap_size())); +// if (rgb_image == NULL) +// LogFile.WriteToFile("Image Load failed:" + _image + " FreeHeapSize before: " + to_string(freebefore) + " after: " + to_string(esp_get_free_heap_size())); // printf("CImageBasis after load\n"); // printf("w %d, h %d, b %d, c %d", this->width, this->height, this->bpp, this->channels); } diff --git a/code/lib/jomjol_mqtt/interface_mqtt.cpp b/code/lib/jomjol_mqtt/interface_mqtt.cpp new file mode 100644 index 000000000..dfa30408b --- /dev/null +++ b/code/lib/jomjol_mqtt/interface_mqtt.cpp @@ -0,0 +1,82 @@ +#include "interface_mqtt.h" + + +#include "esp_log.h" +#include "mqtt_client.h" +#include "ClassLogFile.h" + +static const char *TAG = "interface_mqtt"; + +bool debugdetail = true; + +// #define CONFIG_BROKER_URL "mqtt://192.168.178.43:1883" + +esp_mqtt_event_id_t esp_mmqtt_ID = MQTT_EVENT_ANY; + +bool mqtt_connected = false; +esp_mqtt_client_handle_t client = NULL; + +void MQTTPublish(std::string _key, std::string _content){ + if (client && mqtt_connected) { + int msg_id; + std::string zw; + msg_id = esp_mqtt_client_publish(client, _key.c_str(), _content.c_str(), 0, 1, 0); + zw = "sent publish successful in MQTTPublish, msg_id=" + std::to_string(msg_id) + ", " + _key + ", " + _content; + if (debugdetail) LogFile.WriteToFile(zw); + ESP_LOGI(TAG, "sent publish successful in MQTTPublish, msg_id=%d, %s, %s", msg_id, _key.c_str(), _content.c_str()); + } + else { + ESP_LOGI(TAG, "Problem with Publish, client=%d, mqtt_connected %d", (int) client, (int) mqtt_connected); + } +} + + +static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event) +{ + switch (event->event_id) { + case MQTT_EVENT_CONNECTED: + ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED"); + mqtt_connected = true; + break; + case MQTT_EVENT_DISCONNECTED: + ESP_LOGI(TAG, "MQTT_EVENT_DISCONNECTED"); + break; + case MQTT_EVENT_PUBLISHED: + ESP_LOGI(TAG, "MQTT_EVENT_PUBLISHED, msg_id=%d", event->msg_id); + break; + case MQTT_EVENT_DATA: + ESP_LOGI(TAG, "MQTT_EVENT_DATA"); + printf("TOPIC=%.*s\r\n", event->topic_len, event->topic); + printf("DATA=%.*s\r\n", event->data_len, event->data); + break; + case MQTT_EVENT_ERROR: + ESP_LOGI(TAG, "MQTT_EVENT_ERROR"); + break; + default: + ESP_LOGI(TAG, "Other event id:%d", event->event_id); + break; + } + return ESP_OK; +} + +static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) { + ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id); + mqtt_event_handler_cb((esp_mqtt_event_handle_t) event_data); +} + +void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, std::string _password){ + esp_mqtt_client_config_t mqtt_cfg = { + .uri = _mqttURI.c_str(), + .client_id = _clientid.c_str(), + }; + + if (_user.length() && _password.length()){ + mqtt_cfg.username = _user.c_str(); + mqtt_cfg.password = _password.c_str(); + printf("Connect to MQTT: %s, %s", mqtt_cfg.username, mqtt_cfg.password); + }; + + client = esp_mqtt_client_init(&mqtt_cfg); + esp_mqtt_client_register_event(client, esp_mmqtt_ID, mqtt_event_handler, client); + esp_mqtt_client_start(client); +} diff --git a/code/lib/jomjol_mqtt/interface_mqtt.h b/code/lib/jomjol_mqtt/interface_mqtt.h new file mode 100644 index 000000000..c34c93a61 --- /dev/null +++ b/code/lib/jomjol_mqtt/interface_mqtt.h @@ -0,0 +1,4 @@ +#include + +void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user = "", std::string _password = ""); +void MQTTPublish(std::string _key, std::string _content); \ No newline at end of file diff --git a/code/lib/jomjol_tfliteclass/CTfLiteClass.cpp b/code/lib/jomjol_tfliteclass/CTfLiteClass.cpp index 5887436f7..382f0e663 100644 --- a/code/lib/jomjol_tfliteclass/CTfLiteClass.cpp +++ b/code/lib/jomjol_tfliteclass/CTfLiteClass.cpp @@ -2,8 +2,12 @@ #include "bitmap_image.hpp" +#include "ClassLogFile.h" + #include +bool debugdetailtflite = false; + float CTfLiteClass::GetOutputValue(int nr) { TfLiteTensor* output2 = this->interpreter->output(0); @@ -109,7 +113,11 @@ void CTfLiteClass::Invoke() bool CTfLiteClass::LoadInputImage(std::string _fn) { + std::string zw = "ClassFlowAnalog::doNeuralNetwork nach Load Image: " + _fn; +// LogFile.WriteToFile(zw); bitmap_image image(_fn); + if (debugdetailtflite) LogFile.WriteToFile(zw); + unsigned int w = image.width(); unsigned int h = image.height(); unsigned char red, green, blue; @@ -135,6 +143,9 @@ bool CTfLiteClass::LoadInputImage(std::string _fn) // printf("BMP: %f %f %f\n", (float) red, (float) green, (float) blue); } + + if (debugdetailtflite) LogFile.WriteToFile("Nach dem Laden in input"); + return true; } diff --git a/code/platformio.ini b/code/platformio.ini index a95abebc1..e12489c36 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -23,7 +23,7 @@ board_build.embed_files = ;board_build.partitions = partitions_singleapp.csv board_build.partitions = partition.csv -lib_deps = jomjol_helper, connect_wlan, conversions, driver, sensors, jomjol_image_proc, jomjol_controlcamera, jomjol_flowcontroll, jomjol_tfliteclass, tfmicro, jomjol_fileserver_ota, jomjol_time_sntp, jomjol_logfile +lib_deps = jomjol_helper, connect_wlan, conversions, driver, sensors, jomjol_image_proc, jomjol_controlcamera, jomjol_flowcontroll, jomjol_tfliteclass, tfmicro, jomjol_fileserver_ota, jomjol_time_sntp, jomjol_logfile, jomjol_mqtt monitor_speed = 115200 debug_tool = esp-prog diff --git a/code/src/main.cpp b/code/src/main.cpp index f57cbb7f4..63d9182ef 100644 --- a/code/src/main.cpp +++ b/code/src/main.cpp @@ -5,63 +5,26 @@ #include "driver/gpio.h" #include "sdkconfig.h" -//#include "version.h" -#include "ClassLogFile.h" - - -//#include "esp_wifi.h" -//#include "protocol_examples_common.h" - -#include "connect_wlan.h" - -#include - -#include "lwip/err.h" -#include "lwip/sockets.h" -#include "lwip/sys.h" -#include "lwip/netdb.h" -#include "lwip/dns.h" - - -#include -#include -#include "esp_log.h" -#include "esp_system.h" -#include "esp_event.h" -#include "esp_event_loop.h" +// SD-Card //////////////////// #include "nvs_flash.h" -#include "esp_err.h" #include "esp_vfs_fat.h" +#include "sdmmc_cmd.h" #include "driver/sdmmc_host.h" #include "driver/sdmmc_defs.h" -#include "sdmmc_cmd.h" +/////////////////////////////// + +#include "ClassLogFile.h" + +#include "connect_wlan.h" -#include "server_main.h" -#include "server_camera.h" #include "server_tflite.h" #include "server_file.h" #include "server_ota.h" #include "time_sntp.h" #include "ClassControllCamera.h" - - -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/event_groups.h" - -#include "freertos/FreeRTOS.h" - -// SD-Card -#include "nvs_flash.h" -#include "esp_vfs_fat.h" -#include "sdmmc_cmd.h" - #include "server_main.h" #include "server_camera.h" -#include "ClassControllCamera.h" -#include "connect_wlan.h" -#include "time_sntp.h" static const char *TAGMAIN = "connect_wlan_main"; @@ -130,7 +93,7 @@ extern "C" void app_main() vTaskDelay( xDelay ); // LogFile.WriteToFile("Startsequence 07"); setup_time(); - LogFile.WriteToFile("======================== Main Started ================================"); + LogFile.WriteToFile("============================== Main Started ======================================="); LogFile.SwitchOnOff(false); std::string zw = gettimestring("%Y%m%d-%H%M%S"); diff --git a/code/src/server_main.cpp b/code/src/server_main.cpp index 81eadf390..b84d782c2 100644 --- a/code/src/server_main.cpp +++ b/code/src/server_main.cpp @@ -9,6 +9,8 @@ #include "version.h" +#include "esp_wifi.h" + httpd_handle_t server = NULL; @@ -83,6 +85,14 @@ esp_err_t info_get_handler(httpd_req_t *req) return ESP_OK; } + if (_task.compare("HTMLVersion") == 0) + { + std::string zw; + zw = std::string(getHTMLversion()); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } return ESP_OK; } @@ -155,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]; @@ -197,7 +205,45 @@ 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)); + 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) { @@ -209,6 +255,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 @@ -235,6 +288,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); + } diff --git a/code/src/server_tflite.cpp b/code/src/server_tflite.cpp index e2f0985e3..f5e2d5e06 100644 --- a/code/src/server_tflite.cpp +++ b/code/src/server_tflite.cpp @@ -410,36 +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()); - - zw = "[\ - {\ - \"firmware\" : \"2.0.0\",\ - \"html\" : \"1.0.1\",\ - \"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; @@ -468,7 +438,10 @@ void task_autodoFlow(void *pvParameter) LogFile.WriteToFile("task_autodoFlow - round done"); //CPU Temp float cputmp = temperatureRead(); -// LogFile.WriteToFile("CPU Temperature: %.2f", cputmp); + std::stringstream stream; + stream << std::fixed << std::setprecision(1) << cputmp; + string zwtemp = "CPU Temperature: " + stream.str(); + LogFile.WriteToFile(zwtemp); printf("CPU Temperature: %.2f\n", cputmp); fr_delta_ms = (esp_timer_get_time() - fr_start) / 1000; const TickType_t xDelay = (auto_intervall - fr_delta_ms) / portTICK_PERIOD_MS; @@ -518,9 +491,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); + } diff --git a/code/src/version.cpp b/code/src/version.cpp index 7b7c01e5e..3fb591995 100644 --- a/code/src/version.cpp +++ b/code/src/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="bafd67b"; +const char* GIT_REV="04f69f0"; const char* GIT_TAG=""; -const char* GIT_BRANCH="master"; -const char* BUILD_TIME="2020-09-28 19:57"; \ No newline at end of file +const char* GIT_BRANCH="rolling"; +const char* BUILD_TIME="2020-10-13 20:10"; \ No newline at end of file diff --git a/code/src/version.h b/code/src/version.h index 2f571e919..4c2c3d075 100644 --- a/code/src/version.h +++ b/code/src/version.h @@ -8,6 +8,11 @@ extern "C" extern const char* BUILD_TIME; } +#include +#include +#include "Helper.h" +#include + const char* GIT_BASE_BRANCH = "master - v2.1.1 - 2020-09-28"; @@ -35,4 +40,23 @@ const char* libfive_git_revision(void) const char* libfive_git_branch(void) { return GIT_BRANCH; +} + +std::string getHTMLversion(void){ + + string line = ""; + + FILE* pFile; + string fn = FormatFileName("/sdcard/html/version.txt"); + pFile = fopen(fn.c_str(), "r"); + + if (pFile == NULL) + return std::string("NAN"); + + char zw[1024]; + fgets(zw, 1024, pFile); + line = std::string(trim(zw)); + fclose(pFile); + + return line; } \ No newline at end of file diff --git a/code/version.cpp b/code/version.cpp index 7b7c01e5e..3fb591995 100644 --- a/code/version.cpp +++ b/code/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="bafd67b"; +const char* GIT_REV="04f69f0"; const char* GIT_TAG=""; -const char* GIT_BRANCH="master"; -const char* BUILD_TIME="2020-09-28 19:57"; \ No newline at end of file +const char* GIT_BRANCH="rolling"; +const char* BUILD_TIME="2020-10-13 20:10"; \ No newline at end of file diff --git a/firmware/.DS_Store b/firmware/.DS_Store new file mode 100644 index 000000000..9ace466e6 Binary files /dev/null and b/firmware/.DS_Store differ diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index c8d06c6c8..eb151bca3 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index 01729233b..b1558c8b9 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ diff --git a/firmware/html.zip b/firmware/html.zip index a65b49000..47bd7ab7b 100644 Binary files a/firmware/html.zip and b/firmware/html.zip differ diff --git a/sd-card/.DS_Store b/sd-card/.DS_Store new file mode 100644 index 000000000..bb7022449 Binary files /dev/null and b/sd-card/.DS_Store differ diff --git a/sd-card/config/config.ini b/sd-card/config/config.ini index ccd1cdb53..17fc2e0e6 100644 --- a/sd-card/config/config.ini +++ b/sd-card/config/config.ini @@ -38,6 +38,12 @@ MaxRateValue = 0.1 ErrorMessage = True CheckDigitIncreaseConsistency = False +;[MQTT] +;Uri = mqtt://IP-MQTT-SERVER:1883 +;Topic = watermeter/readout +;ClientID = wasser +;user = USERNAME +;password = PASSWORD [AutoTimer] AutoStart= True diff --git a/sd-card/html/info.html b/sd-card/html/info.html index c898d55e9..8729c71fd 100644 --- a/sd-card/html/info.html +++ b/sd-card/html/info.html @@ -3,7 +3,7 @@ Set PreValue - + - + + @@ -38,7 +38,7 @@

Version Info

- + @@ -49,7 +49,7 @@

Version Info

- + @@ -60,7 +60,7 @@

Version Info

- + @@ -71,9 +71,20 @@

Version Info

+ + + + + HTML Version: + + +
+ +
+ - \ No newline at end of file + diff --git a/sd-card/html/version.txt b/sd-card/html/version.txt new file mode 100644 index 000000000..3eefcb9dd --- /dev/null +++ b/sd-card/html/version.txt @@ -0,0 +1 @@ +1.0.0