mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-09 04:56:53 +03:00
Merge branch 'rolling' (#1559)
* Fix for securing wlan.ini (#1509) * Fix for securing wlan.ini * Fixing error with ' instead of " * Changing to errorcode 403 * maybe strcmp instead of regular == Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> * Update Web-Installer * solves #1530 (#1531) * Refactor JSON (#1518) * use correct log level * corrected logging * typo * refactored JSON generagion: removed unused parameters, consolidated into singel function, added "pre" * Wrapped 'rate' into double quotes, like all other JSON values Co-authored-by: CaCO3 <caco@ruinelli.ch> * Various corrections (#1519) * use correct log level * corrected logging * typo * add release to webinstaller * changed logs, added INFO log of raw, value, error * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * Prevent auto restart on cam framebuffer init error (#1522) * use correct log level * revert autorestart on camera framebuffer init error * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * #1524 - ensure the recognized digit is less than 10 (#1525) * fix kernel panic (vector out of range) in getReadoutRawString * fix key of caches * fix key of caches * fix key caches * fix cache keys * fix cache keys * move set variables to top * debug * fix key * testing * try fix changelog * test * Update Changelog.md for release * Revert "Update Changelog.md for release" This reverts commit4f51ec7962. * remove testing * fix release creation * testing * Update Changelog.md for release * test * Revert "Merge branch 'master' of https://github.com/haverland/AI-on-the-edge-device" This reverts commitf68695a4c0, reversing changes made toa096cf7182. * Revert "test" This reverts commita096cf7182. * revert testing * #1524 - ensure the result of ZeigerEvalHybridNeu is <10 * Fix late digit transition #1503 Co-authored-by: github-actions <github-actions@github.com> * fix frozen time in datafile on error (#1534) Co-authored-by: CaCO3 <caco@ruinelli.ch> * log NTP server name (#1497) * log NTP server name * . * . * replace calls to /wasserzaehler.html with calls to /value (#1469) Co-authored-by: CaCO3 <caco@ruinelli.ch> * Fix cookie usage, use correct http response codes, add 404 page (#1495) * replaced some HTTP response code with better matching codes * add custom 404 page, add log entry for debugging * fix cookie * replace non-necessary whitespace * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * Don't autofail if NTP server can't be reached during initalization (#1498) This fixes an issue with a restricted network without internet access, where the hardcoded ntp server can't be reached and thus the esp resets, as it's not able to finish initalization. * Update Changelog.md * Update Changelog.md for release * Fix for securing wlan.ini (#1509) * Fix for securing wlan.ini * Fixing error with ' instead of " * Changing to errorcode 403 * maybe strcmp instead of regular == Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> * Update Web-Installer * solves #1530 (#1531) * Refactor JSON (#1518) * use correct log level * corrected logging * typo * refactored JSON generagion: removed unused parameters, consolidated into singel function, added "pre" * Wrapped 'rate' into double quotes, like all other JSON values Co-authored-by: CaCO3 <caco@ruinelli.ch> * Various corrections (#1519) * use correct log level * corrected logging * typo * add release to webinstaller * changed logs, added INFO log of raw, value, error * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * Prevent auto restart on cam framebuffer init error (#1522) * use correct log level * revert autorestart on camera framebuffer init error * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * #1524 - ensure the recognized digit is less than 10 (#1525) * fix kernel panic (vector out of range) in getReadoutRawString * fix key of caches * fix key of caches * fix key caches * fix cache keys * fix cache keys * move set variables to top * debug * fix key * testing * try fix changelog * test * Update Changelog.md for release * Revert "Update Changelog.md for release" This reverts commit4f51ec7962. * remove testing * fix release creation * testing * Update Changelog.md for release * test * Revert "Merge branch 'master' of https://github.com/haverland/AI-on-the-edge-device" This reverts commitf68695a4c0, reversing changes made toa096cf7182. * Revert "test" This reverts commita096cf7182. * revert testing * #1524 - ensure the result of ZeigerEvalHybridNeu is <10 * Fix late digit transition #1503 Co-authored-by: github-actions <github-actions@github.com> * only use sntp_getservername() after init sntp * set default NTP server on dnew installations Co-authored-by: CaCO3 <caco@ruinelli.ch> Co-authored-by: Ralf Rachinger <git@ralfrachinger.de> Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: parhedberg <par.hedberg@gmail.com> Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> Co-authored-by: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Co-authored-by: Frank Haverland <fspapaping@googlemail.com> * Renamed variables and added debug log (#1537) * add debug logs * renamed variables * renamed TAGs, added flow status logging * . * . Co-authored-by: CaCO3 <caco@ruinelli.ch> * replaced printf usage in LogFile.WriteToFile() * ENABLE_MQTT c++ macro definition (#1546) * macro * 2 * 2 * delete jomjol_mqtt from CMakeLists * mqtt macro * final * ENABLE_INFLUXDB c++ macro definition (#1547) * macro * 2 * 2 * delete jomjol_mqtt from CMakeLists * mqtt macro * final * ENABLE_INFLUXDB c++ macro definition * Update Changelog.md Co-authored-by: parhedberg <par.hedberg@gmail.com> Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se> Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com> Co-authored-by: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Co-authored-by: CaCO3 <caco@ruinelli.ch> Co-authored-by: Frank Haverland <fspapaping@googlemail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Ralf Rachinger <git@ralfrachinger.de> Co-authored-by: Nicolas Liaudat <nliaudat@users.noreply.github.com>
This commit is contained in:
15
Changelog.md
15
Changelog.md
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [13.0.5] - 2022-12-06
|
|
||||||
|
|
||||||
**Home Assistant MQTT Discovery Support**
|
**Home Assistant MQTT Discovery Support**
|
||||||
|
|
||||||
### Update Procedure
|
### Update Procedure
|
||||||
@@ -65,6 +63,10 @@ If anything breaks you can try to enforce manual update as following:
|
|||||||
- NEW v13.0.2: Update Tool "Logfile downloader and combiner" to handle the new csv file format.
|
- NEW v13.0.2: Update Tool "Logfile downloader and combiner" to handle the new csv file format.
|
||||||
- NEW v13.0.2: MQTT: Added MQTT topic `status` (Digitalization Status), Timezone to MQTT topic `timestamp`.#
|
- NEW v13.0.2: MQTT: Added MQTT topic `status` (Digitalization Status), Timezone to MQTT topic `timestamp`.#
|
||||||
- NEW v13.0.2: Logging: Disable heap logs by default, cleanup
|
- NEW v13.0.2: Logging: Disable heap logs by default, cleanup
|
||||||
|
- **NEW v13.0.5**:
|
||||||
|
- log NTP server name
|
||||||
|
- Improved log messages
|
||||||
|
- Various preparations for next release
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
@@ -79,7 +81,14 @@ If anything breaks you can try to enforce manual update as following:
|
|||||||
- NEW v13.0.2: Corrected Version comparison between firmware and Web UI.
|
- NEW v13.0.2: Corrected Version comparison between firmware and Web UI.
|
||||||
- NEW v13.0.3: Re-updated build environment to v5.2.0 (from accidental downgrad to v4.4.0)
|
- NEW v13.0.3: Re-updated build environment to v5.2.0 (from accidental downgrad to v4.4.0)
|
||||||
- NEW v13.0.4: Fix for reboot in case of MQTT not used
|
- NEW v13.0.4: Fix for reboot in case of MQTT not used
|
||||||
- **NEW v13.0.5**: No reboot in case of missing NTP-connection
|
- NEW v13.0.5: No reboot in case of missing NTP-connection
|
||||||
|
- **NEW v13.0.5**:
|
||||||
|
- Prevent autoreboot on cam framebuffer init error
|
||||||
|
- Properly protect `wlan.ini` against deletion
|
||||||
|
- Fixed various MQTT topic content issues
|
||||||
|
- Fix Digit detected as 10 (https://github.com/jomjol/AI-on-the-edge-device/pull/1525)
|
||||||
|
- Fix frozen time in datafile on error
|
||||||
|
- Various minor fixes
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
#include "configFile.h"
|
#include "configFile.h"
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
#include "interface_mqtt.h"
|
#ifdef ENABLE_MQTT
|
||||||
|
#include "interface_mqtt.h"
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
static const char *TAG = "GPIO";
|
static const char *TAG = "GPIO";
|
||||||
QueueHandle_t gpio_queue_handle = NULL;
|
QueueHandle_t gpio_queue_handle = NULL;
|
||||||
@@ -83,12 +85,14 @@ static void gpioHandlerTask(void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GpioPin::gpioInterrupt(int value) {
|
void GpioPin::gpioInterrupt(int value) {
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
if (_mqttTopic != "") {
|
if (_mqttTopic != "") {
|
||||||
ESP_LOGD(TAG, "gpioInterrupt %s %d", _mqttTopic.c_str(), value);
|
ESP_LOGD(TAG, "gpioInterrupt %s %d", _mqttTopic.c_str(), value);
|
||||||
|
|
||||||
MQTTPublish(_mqttTopic, value ? "true" : "false");
|
MQTTPublish(_mqttTopic, value ? "true" : "false");
|
||||||
currentState = value;
|
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
currentState = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GpioPin::init()
|
void GpioPin::init()
|
||||||
@@ -114,10 +118,12 @@ void GpioPin::init()
|
|||||||
gpio_isr_handler_add(_gpio, gpio_isr_handler, (void*)&_gpio);
|
gpio_isr_handler_add(_gpio, gpio_isr_handler, (void*)&_gpio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
if ((_mqttTopic != "") && ((_mode == GPIO_PIN_MODE_OUTPUT) || (_mode == GPIO_PIN_MODE_OUTPUT_PWM) || (_mode == GPIO_PIN_MODE_BUILT_IN_FLASH_LED))) {
|
if ((_mqttTopic != "") && ((_mode == GPIO_PIN_MODE_OUTPUT) || (_mode == GPIO_PIN_MODE_OUTPUT_PWM) || (_mode == GPIO_PIN_MODE_BUILT_IN_FLASH_LED))) {
|
||||||
std::function<bool(std::string, char*, int)> f = std::bind(&GpioPin::handleMQTT, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
std::function<bool(std::string, char*, int)> f = std::bind(&GpioPin::handleMQTT, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||||
MQTTregisterSubscribeFunction(_mqttTopic, f);
|
MQTTregisterSubscribeFunction(_mqttTopic, f);
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GpioPin::getValue(std::string* errorText)
|
bool GpioPin::getValue(std::string* errorText)
|
||||||
@@ -138,9 +144,11 @@ void GpioPin::setValue(bool value, gpio_set_source setSource, std::string* error
|
|||||||
} else {
|
} else {
|
||||||
gpio_set_level(_gpio, value);
|
gpio_set_level(_gpio, value);
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
if ((_mqttTopic != "") && (setSource != GPIO_SET_SOURCE_MQTT)) {
|
if ((_mqttTopic != "") && (setSource != GPIO_SET_SOURCE_MQTT)) {
|
||||||
MQTTPublish(_mqttTopic, value ? "true" : "false");
|
MQTTPublish(_mqttTopic, value ? "true" : "false");
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,11 +156,14 @@ void GpioPin::publishState() {
|
|||||||
int newState = gpio_get_level(_gpio);
|
int newState = gpio_get_level(_gpio);
|
||||||
if (newState != currentState) {
|
if (newState != currentState) {
|
||||||
ESP_LOGD(TAG,"publish state of GPIO %d new state %d", _gpio, newState);
|
ESP_LOGD(TAG,"publish state of GPIO %d new state %d", _gpio, newState);
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
MQTTPublish(_mqttTopic, newState ? "true" : "false");
|
MQTTPublish(_mqttTopic, newState ? "true" : "false");
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
currentState = newState;
|
currentState = newState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
bool GpioPin::handleMQTT(std::string, char* data, int data_len) {
|
bool GpioPin::handleMQTT(std::string, char* data, int data_len) {
|
||||||
ESP_LOGD(TAG, "GpioPin::handleMQTT data %.*s", data_len, data);
|
ESP_LOGD(TAG, "GpioPin::handleMQTT data %.*s", data_len, data);
|
||||||
|
|
||||||
@@ -174,7 +185,7 @@ bool GpioPin::handleMQTT(std::string, char* data, int data_len) {
|
|||||||
|
|
||||||
return (errorText == "");
|
return (errorText == "");
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
esp_err_t callHandleHttpRequest(httpd_req_t *req)
|
esp_err_t callHandleHttpRequest(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
@@ -236,8 +247,10 @@ void GpioHandler::init()
|
|||||||
it->second->init();
|
it->second->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
std::function<void()> f = std::bind(&GpioHandler::handleMQTTconnect, this);
|
std::function<void()> f = std::bind(&GpioHandler::handleMQTTconnect, this);
|
||||||
MQTTregisterConnectFunction("gpio-handler", f);
|
MQTTregisterConnectFunction("gpio-handler", f);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
if (xHandleTaskGpio == NULL) {
|
if (xHandleTaskGpio == NULL) {
|
||||||
gpio_queue_handle = xQueueCreate(10,sizeof(GpioResult));
|
gpio_queue_handle = xQueueCreate(10,sizeof(GpioResult));
|
||||||
@@ -261,7 +274,7 @@ void GpioHandler::taskHandler() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
void GpioHandler::handleMQTTconnect()
|
void GpioHandler::handleMQTTconnect()
|
||||||
{
|
{
|
||||||
if (gpioMap != NULL) {
|
if (gpioMap != NULL) {
|
||||||
@@ -271,9 +284,12 @@ void GpioHandler::handleMQTTconnect()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
void GpioHandler::deinit() {
|
void GpioHandler::deinit() {
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
MQTTunregisterConnectFunction("gpio-handler");
|
MQTTunregisterConnectFunction("gpio-handler");
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
clear();
|
clear();
|
||||||
if (xHandleTaskGpio != NULL) {
|
if (xHandleTaskGpio != NULL) {
|
||||||
vTaskDelete(xHandleTaskGpio);
|
vTaskDelete(xHandleTaskGpio);
|
||||||
@@ -316,6 +332,7 @@ bool GpioHandler::readConfig()
|
|||||||
|
|
||||||
// ESP_LOGD(TAG, "readConfig - Start 3");
|
// ESP_LOGD(TAG, "readConfig - Start 3");
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
// std::string mainTopicMQTT = "";
|
// std::string mainTopicMQTT = "";
|
||||||
std::string mainTopicMQTT = GetMQTTMainTopic();
|
std::string mainTopicMQTT = GetMQTTMainTopic();
|
||||||
if (mainTopicMQTT.length() > 0)
|
if (mainTopicMQTT.length() > 0)
|
||||||
@@ -323,7 +340,7 @@ bool GpioHandler::readConfig()
|
|||||||
mainTopicMQTT = mainTopicMQTT + "/GPIO";
|
mainTopicMQTT = mainTopicMQTT + "/GPIO";
|
||||||
ESP_LOGD(TAG, "MAINTOPICMQTT found");
|
ESP_LOGD(TAG, "MAINTOPICMQTT found");
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MQTT
|
||||||
bool registerISR = false;
|
bool registerISR = false;
|
||||||
while (configFile.getNextLine(&line, disabledLine, eof) && !configFile.isNewParagraph(line))
|
while (configFile.getNextLine(&line, disabledLine, eof) && !configFile.isNewParagraph(line))
|
||||||
{
|
{
|
||||||
@@ -345,7 +362,9 @@ bool GpioHandler::readConfig()
|
|||||||
gpio_pin_mode_t pinMode = resolvePinMode(toLower(zerlegt[1]));
|
gpio_pin_mode_t pinMode = resolvePinMode(toLower(zerlegt[1]));
|
||||||
gpio_int_type_t intType = resolveIntType(toLower(zerlegt[2]));
|
gpio_int_type_t intType = resolveIntType(toLower(zerlegt[2]));
|
||||||
uint16_t dutyResolution = (uint8_t)atoi(zerlegt[3].c_str());
|
uint16_t dutyResolution = (uint8_t)atoi(zerlegt[3].c_str());
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
bool mqttEnabled = toLower(zerlegt[4]) == "true";
|
bool mqttEnabled = toLower(zerlegt[4]) == "true";
|
||||||
|
#endif // ENABLE_MQTT
|
||||||
bool httpEnabled = toLower(zerlegt[5]) == "true";
|
bool httpEnabled = toLower(zerlegt[5]) == "true";
|
||||||
char gpioName[100];
|
char gpioName[100];
|
||||||
if (zerlegt.size() >= 7) {
|
if (zerlegt.size() >= 7) {
|
||||||
@@ -353,7 +372,11 @@ bool GpioHandler::readConfig()
|
|||||||
} else {
|
} else {
|
||||||
sprintf(gpioName, "GPIO%d", gpioNr);
|
sprintf(gpioName, "GPIO%d", gpioNr);
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
std::string mqttTopic = mqttEnabled ? (mainTopicMQTT + "/" + gpioName) : "";
|
std::string mqttTopic = mqttEnabled ? (mainTopicMQTT + "/" + gpioName) : "";
|
||||||
|
#else // ENABLE_MQTT
|
||||||
|
std::string mqttTopic = "";
|
||||||
|
#endif // ENABLE_MQTT
|
||||||
GpioPin* gpioPin = new GpioPin(gpioNr, gpioName, pinMode, intType,dutyResolution, mqttTopic, httpEnabled);
|
GpioPin* gpioPin = new GpioPin(gpioNr, gpioName, pinMode, intType,dutyResolution, mqttTopic, httpEnabled);
|
||||||
(*gpioMap)[gpioNr] = gpioPin;
|
(*gpioMap)[gpioNr] = gpioPin;
|
||||||
|
|
||||||
@@ -682,3 +705,4 @@ GpioHandler* gpio_handler_get()
|
|||||||
{
|
{
|
||||||
return gpioHandler;
|
return gpioHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
bool getValue(std::string* errorText);
|
bool getValue(std::string* errorText);
|
||||||
void setValue(bool value, gpio_set_source setSource, std::string* errorText);
|
void setValue(bool value, gpio_set_source setSource, std::string* errorText);
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
bool handleMQTT(std::string, char* data, int data_len);
|
bool handleMQTT(std::string, char* data, int data_len);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
void publishState();
|
void publishState();
|
||||||
void gpioInterrupt(int value);
|
void gpioInterrupt(int value);
|
||||||
gpio_int_type_t getInterruptType() { return _interruptType; }
|
gpio_int_type_t getInterruptType() { return _interruptType; }
|
||||||
@@ -77,7 +79,9 @@ public:
|
|||||||
void gpioInterrupt(GpioResult* gpioResult);
|
void gpioInterrupt(GpioResult* gpioResult);
|
||||||
void flashLightEnable(bool value);
|
void flashLightEnable(bool value);
|
||||||
bool isEnabled() { return _isEnabled; }
|
bool isEnabled() { return _isEnabled; }
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
void handleMQTTconnect();
|
void handleMQTTconnect();
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _configFile;
|
std::string _configFile;
|
||||||
@@ -109,4 +113,5 @@ GpioHandler* gpio_handler_get();
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //SERVER_GPIO_H
|
#endif //SERVER_GPIO_H
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ extern "C" {
|
|||||||
#include "server_tflite.h"
|
#include "server_tflite.h"
|
||||||
|
|
||||||
#include "server_help.h"
|
#include "server_help.h"
|
||||||
#include "interface_mqtt.h"
|
#ifdef ENABLE_MQTT
|
||||||
|
#include "interface_mqtt.h"
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
#include "server_GPIO.h"
|
#include "server_GPIO.h"
|
||||||
|
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
@@ -219,7 +221,7 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath, const
|
|||||||
ESP_LOGD(TAG, "entrypath: <%s>", entrypath);
|
ESP_LOGD(TAG, "entrypath: <%s>", entrypath);
|
||||||
|
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to stat dir: %s", dirpath);
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to stat dir: " + std::string(dirpath) + "!");
|
||||||
/* Respond with 404 Not Found */
|
/* Respond with 404 Not Found */
|
||||||
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
|
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
@@ -361,7 +363,7 @@ static esp_err_t send_datafile(httpd_req_t *req, bool send_full_file)
|
|||||||
|
|
||||||
fd = OpenFileAndWait(currentfilename.c_str(), "r");
|
fd = OpenFileAndWait(currentfilename.c_str(), "r");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to read existing file: %s", filepath);
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to read existing file: " + std::string(filepath) +"!");
|
||||||
/* Respond with 404 Error */
|
/* Respond with 404 Error */
|
||||||
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
|
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
@@ -446,7 +448,7 @@ static esp_err_t send_logfile(httpd_req_t *req, bool send_full_file)
|
|||||||
|
|
||||||
fd = OpenFileAndWait(currentfilename.c_str(), "r");
|
fd = OpenFileAndWait(currentfilename.c_str(), "r");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to read existing file: %s", filepath);
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to read existing file: " + std::string(filepath) +"!");
|
||||||
/* Respond with 404 Error */
|
/* Respond with 404 Error */
|
||||||
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
|
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
@@ -566,7 +568,7 @@ static esp_err_t download_get_handler(httpd_req_t *req)
|
|||||||
|
|
||||||
/* If file not present on SPIFFS check if URI
|
/* If file not present on SPIFFS check if URI
|
||||||
* corresponds to one of the hardcoded paths */
|
* corresponds to one of the hardcoded paths */
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to stat file: %s!", filepath);
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to stat file: " + std::string(filepath) + "!");
|
||||||
/* Respond with 404 Not Found */
|
/* Respond with 404 Not Found */
|
||||||
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
|
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
@@ -574,7 +576,7 @@ static esp_err_t download_get_handler(httpd_req_t *req)
|
|||||||
|
|
||||||
fd = OpenFileAndWait(filepath, "r");
|
fd = OpenFileAndWait(filepath, "r");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to read existing file: %s!", filepath);
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to read existing file: " + std::string(filepath) +"!");
|
||||||
/* Respond with 404 Error */
|
/* Respond with 404 Error */
|
||||||
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
|
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
@@ -831,6 +833,12 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
|
|||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(filename, "wlan.ini") == 0) {
|
||||||
|
ESP_LOGE(TAG, "Trying to delete protected file : %s", filename);
|
||||||
|
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Not allowed to delete wlan.ini");
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
if (stat(filepath, &file_stat) == -1) {
|
if (stat(filepath, &file_stat) == -1) {
|
||||||
ESP_LOGE(TAG, "File does not exist: %s", filename);
|
ESP_LOGE(TAG, "File does not exist: %s", filename);
|
||||||
/* Respond with 400 Bad Request */
|
/* Respond with 400 Bad Request */
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
static const char *TAG = "FLOW CLASS";
|
static const char *TAG = "CLASS";
|
||||||
|
|
||||||
|
|
||||||
void ClassFlow::SetInitialParameter(void)
|
void ClassFlow::SetInitialParameter(void)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
|
|
||||||
static const char *TAG = "FLOW ALIGN";
|
static const char *TAG = "ALIGN";
|
||||||
|
|
||||||
bool AlignmentExtendedDebugging = true;
|
bool AlignmentExtendedDebugging = true;
|
||||||
|
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ int ClassFlowCNNGeneral::ZeigerEvalHybridNeu(float zahl, float zahl_vorgaenger,
|
|||||||
result = (ergebnis_vorkomma + 1) % 10;
|
result = (ergebnis_vorkomma + 1) % 10;
|
||||||
else
|
else
|
||||||
// Akt. digit und Vorgänger haben Nulldurchgang
|
// Akt. digit und Vorgänger haben Nulldurchgang
|
||||||
result = ergebnis_vorkomma;
|
result = ergebnis_vorkomma % 10;
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "ZeigerEvalHybridNeu - KEIN Analoger Vorgänger, Nulldurchgang hat stattgefunden = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "ZeigerEvalHybridNeu - KEIN Analoger Vorgänger, Nulldurchgang hat stattgefunden = " + std::to_string(result) +
|
||||||
" zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe));
|
" zahl: " + std::to_string(zahl) + " zahl_vorgaenger = " + std::to_string(zahl_vorgaenger)+ " eval_vorgaenger = " + std::to_string(eval_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe));
|
||||||
return result;
|
return result;
|
||||||
@@ -191,7 +191,7 @@ int ClassFlowCNNGeneral::ZeigerEvalHybridNeu(float zahl, float zahl_vorgaenger,
|
|||||||
// Vorlauf (else - Zweig) passiert nicht bereits ab 9.
|
// Vorlauf (else - Zweig) passiert nicht bereits ab 9.
|
||||||
if (DigitalUebergangsbereichVorlauf>=zahl_vorgaenger || ergebnis_nachkomma >= 4)
|
if (DigitalUebergangsbereichVorlauf>=zahl_vorgaenger || ergebnis_nachkomma >= 4)
|
||||||
// aktuelles digit hat genauso wie das Vorgängerdigit noch keinen Nulldurchgang.
|
// aktuelles digit hat genauso wie das Vorgängerdigit noch keinen Nulldurchgang.
|
||||||
result = ergebnis_vorkomma;
|
result = ergebnis_vorkomma % 10;
|
||||||
else
|
else
|
||||||
// aktuelles digit läuft dem kleineren digit (9.x) vor. Also schon >=x.0 während das vorherige Digit noch
|
// aktuelles digit läuft dem kleineren digit (9.x) vor. Also schon >=x.0 während das vorherige Digit noch
|
||||||
// keinen Nulldurchgang hat. Daher wird um 1 reduziert.
|
// keinen Nulldurchgang hat. Daher wird um 1 reduziert.
|
||||||
@@ -211,7 +211,8 @@ int ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu(float zahl, float ziffer_vor
|
|||||||
bool roundedUp = false;
|
bool roundedUp = false;
|
||||||
|
|
||||||
// Innerhalb der digitalen Unschaefe
|
// Innerhalb der digitalen Unschaefe
|
||||||
if (ergebnis_nachkomma >= (10-DigitalUnschaerfe * 10)) { // Band um die Ziffer --> Runden, da Ziffer im Rahmen Ungenauigkeit erreicht
|
if ((ergebnis_nachkomma >= (10-DigitalUnschaerfe * 10)) // Band um die Ziffer --> Runden, da Ziffer im Rahmen Ungenauigkeit erreicht
|
||||||
|
|| (eval_vorgaenger <= 4 && ergebnis_nachkomma>=6)) { // oder digit läuft nach (analog =0..4, digit >=6)
|
||||||
result = (int) (round(zahl) + 10) % 10;
|
result = (int) (round(zahl) + 10) % 10;
|
||||||
roundedUp = true;
|
roundedUp = true;
|
||||||
// vor/nachkomma neu berechnen, da wir anhand der Unschaefe die Zahl anpassen.
|
// vor/nachkomma neu berechnen, da wir anhand der Unschaefe die Zahl anpassen.
|
||||||
@@ -230,11 +231,7 @@ int ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu(float zahl, float ziffer_vor
|
|||||||
// Kein Nulldurchgang hat stattgefunden.
|
// Kein Nulldurchgang hat stattgefunden.
|
||||||
// Nur eval_vorgaenger verwendet, da ziffer_vorgaenger hier falsch sein könnte.
|
// Nur eval_vorgaenger verwendet, da ziffer_vorgaenger hier falsch sein könnte.
|
||||||
// ziffer_vorgaenger<=0.1 & eval_vorgaenger=9 entspricht analog wurde zurückgesetzt wegen vorhergehender analog, die noch nicht auf 0 sind.
|
// ziffer_vorgaenger<=0.1 & eval_vorgaenger=9 entspricht analog wurde zurückgesetzt wegen vorhergehender analog, die noch nicht auf 0 sind.
|
||||||
if ((eval_vorgaenger>=6 && (ziffer_vorgaenger>analogDigitalTransitionStart || ziffer_vorgaenger<=0.2) && roundedUp)
|
if ((eval_vorgaenger>=6 && (ziffer_vorgaenger>analogDigitalTransitionStart || ziffer_vorgaenger<=0.2) && roundedUp))
|
||||||
// digit läuft dem Analog vor. Darf aber erst passieren, wenn
|
|
||||||
// digit wirklich schnon los läuft, deshalb 9
|
|
||||||
|| (eval_vorgaenger>9 && ziffer_vorgaenger>analogDigitalTransitionStart && ergebnis_nachkomma<=1))
|
|
||||||
|
|
||||||
{
|
{
|
||||||
result = ((ergebnis_vorkomma+10) - 1) % 10;
|
result = ((ergebnis_vorkomma+10) - 1) % 10;
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "ZeigerEvalAnalogToDigitNeu - Nulldurchgang noch nicht stattgefunden = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "ZeigerEvalAnalogToDigitNeu - Nulldurchgang noch nicht stattgefunden = " + std::to_string(result) +
|
||||||
@@ -623,19 +620,22 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
}
|
}
|
||||||
tflite->MakeAllocate();
|
tflite->MakeAllocate();
|
||||||
|
|
||||||
for (int _ana = 0; _ana < GENERAL.size(); ++_ana)
|
for (int n = 0; n < GENERAL.size(); ++n) // For each NUMBER
|
||||||
{
|
{
|
||||||
for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i)
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Processing Number '" + GENERAL[n]->name + "'");
|
||||||
|
for (int roi = 0; roi < GENERAL[n]->ROI.size(); ++roi) // For each ROI
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG, "General %d - TfLite", i);
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "ROI #" + std::to_string(roi) + " - TfLite");
|
||||||
|
//ESP_LOGD(TAG, "General %d - TfLite", i);
|
||||||
|
|
||||||
switch (CNNType) {
|
switch (CNNType) {
|
||||||
case Analogue:
|
case Analogue:
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Analogue");
|
||||||
{
|
{
|
||||||
float f1, f2;
|
float f1, f2;
|
||||||
f1 = 0; f2 = 0;
|
f1 = 0; f2 = 0;
|
||||||
|
|
||||||
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
tflite->LoadInputImageBasis(GENERAL[n]->ROI[roi]->image);
|
||||||
tflite->Invoke();
|
tflite->Invoke();
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Nach Invoke");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Nach Invoke");
|
||||||
|
|
||||||
@@ -643,39 +643,41 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
f2 = tflite->GetOutputValue(1);
|
f2 = tflite->GetOutputValue(1);
|
||||||
float result = fmod(atan2(f1, f2) / (M_PI * 2) + 2, 1);
|
float result = fmod(atan2(f1, f2) / (M_PI * 2) + 2, 1);
|
||||||
|
|
||||||
if(GENERAL[_ana]->ROI[i]->CCW)
|
if(GENERAL[n]->ROI[roi]->CCW)
|
||||||
GENERAL[_ana]->ROI[i]->result_float = 10 - (result * 10);
|
GENERAL[n]->ROI[roi]->result_float = 10 - (result * 10);
|
||||||
else
|
else
|
||||||
GENERAL[_ana]->ROI[i]->result_float = result * 10;
|
GENERAL[n]->ROI[roi]->result_float = result * 10;
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Result General(Analog)%i - CCW: %d - %f", i, GENERAL[_ana]->ROI[i]->CCW, GENERAL[_ana]->ROI[i]->result_float);
|
ESP_LOGD(TAG, "Result General(Analog)%i - CCW: %d - %f", roi, GENERAL[n]->ROI[roi]->CCW, GENERAL[n]->ROI[roi]->result_float);
|
||||||
if (isLogImage)
|
if (isLogImage)
|
||||||
LogImage(logPath, GENERAL[_ana]->ROI[i]->name, &GENERAL[_ana]->ROI[i]->result_float, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
|
LogImage(logPath, GENERAL[n]->ROI[roi]->name, &GENERAL[n]->ROI[roi]->result_float, NULL, time, GENERAL[n]->ROI[roi]->image_org);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Digital:
|
case Digital:
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Digital");
|
||||||
{
|
{
|
||||||
GENERAL[_ana]->ROI[i]->result_klasse = 0;
|
GENERAL[n]->ROI[roi]->result_klasse = 0;
|
||||||
GENERAL[_ana]->ROI[i]->result_klasse = tflite->GetClassFromImageBasis(GENERAL[_ana]->ROI[i]->image);
|
GENERAL[n]->ROI[roi]->result_klasse = tflite->GetClassFromImageBasis(GENERAL[n]->ROI[roi]->image);
|
||||||
ESP_LOGD(TAG, "Result General(Digit)%i: %d", i, GENERAL[_ana]->ROI[i]->result_klasse);
|
ESP_LOGD(TAG, "Result General(Digit)%i: %d", roi, GENERAL[n]->ROI[roi]->result_klasse);
|
||||||
|
|
||||||
if (isLogImage)
|
if (isLogImage)
|
||||||
{
|
{
|
||||||
string _imagename = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name;
|
string _imagename = GENERAL[n]->name + "_" + GENERAL[n]->ROI[roi]->name;
|
||||||
if (isLogImageSelect)
|
if (isLogImageSelect)
|
||||||
{
|
{
|
||||||
if (LogImageSelect.find(GENERAL[_ana]->ROI[i]->name) != std::string::npos)
|
if (LogImageSelect.find(GENERAL[n]->ROI[roi]->name) != std::string::npos)
|
||||||
LogImage(logPath, _imagename, NULL, &GENERAL[_ana]->ROI[i]->result_klasse, time, GENERAL[_ana]->ROI[i]->image_org);
|
LogImage(logPath, _imagename, NULL, &GENERAL[n]->ROI[roi]->result_klasse, time, GENERAL[n]->ROI[roi]->image_org);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogImage(logPath, _imagename, NULL, &GENERAL[_ana]->ROI[i]->result_klasse, time, GENERAL[_ana]->ROI[i]->image_org);
|
LogImage(logPath, _imagename, NULL, &GENERAL[n]->ROI[roi]->result_klasse, time, GENERAL[n]->ROI[roi]->image_org);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
/*
|
/*
|
||||||
case DigitalHyprid:
|
case DigitalHyprid:
|
||||||
{
|
{
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: DigitalHyprid");
|
||||||
int _num, _nachkomma;
|
int _num, _nachkomma;
|
||||||
|
|
||||||
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
||||||
@@ -716,6 +718,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
/*
|
/*
|
||||||
case DigitalHyprid10:
|
case DigitalHyprid10:
|
||||||
{
|
{
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: DigitalHyprid10");
|
||||||
int _num, _nachkomma;
|
int _num, _nachkomma;
|
||||||
|
|
||||||
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
||||||
@@ -753,12 +756,13 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
|
|
||||||
case DoubleHyprid10:
|
case DoubleHyprid10:
|
||||||
{
|
{
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: DoubleHyprid10");
|
||||||
int _num, _numplus, _numminus;
|
int _num, _numplus, _numminus;
|
||||||
float _val, _valplus, _valminus;
|
float _val, _valplus, _valminus;
|
||||||
float _fit;
|
float _fit;
|
||||||
float _result_save_file;
|
float _result_save_file;
|
||||||
|
|
||||||
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
tflite->LoadInputImageBasis(GENERAL[n]->ROI[roi]->image);
|
||||||
tflite->Invoke();
|
tflite->Invoke();
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Nach Invoke");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Nach Invoke");
|
||||||
|
|
||||||
@@ -798,7 +802,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
|
|
||||||
if (_fit < CNNGoodThreshold)
|
if (_fit < CNNGoodThreshold)
|
||||||
{
|
{
|
||||||
GENERAL[_ana]->ROI[i]->isReject = true;
|
GENERAL[n]->ROI[roi]->isReject = true;
|
||||||
result = -1;
|
result = -1;
|
||||||
_result_save_file+= 100; // Für den Fall, dass fit nicht ausreichend, soll trotzdem das Ergebnis mit "-10x.y" abgespeichert werden.
|
_result_save_file+= 100; // Für den Fall, dass fit nicht ausreichend, soll trotzdem das Ergebnis mit "-10x.y" abgespeichert werden.
|
||||||
string zw = "Value Rejected due to Threshold (Fit: " + to_string(_fit) + "Threshold: " + to_string(CNNGoodThreshold) + ")";
|
string zw = "Value Rejected due to Threshold (Fit: " + to_string(_fit) + "Threshold: " + to_string(CNNGoodThreshold) + ")";
|
||||||
@@ -806,24 +810,24 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GENERAL[_ana]->ROI[i]->isReject = false;
|
GENERAL[n]->ROI[roi]->isReject = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GENERAL[_ana]->ROI[i]->result_float = result;
|
GENERAL[n]->ROI[roi]->result_float = result;
|
||||||
ESP_LOGD(TAG, "Result General(Analog)%i: %f", i, GENERAL[_ana]->ROI[i]->result_float);
|
ESP_LOGD(TAG, "Result General(Analog)%i: %f", roi, GENERAL[n]->ROI[roi]->result_float);
|
||||||
|
|
||||||
if (isLogImage)
|
if (isLogImage)
|
||||||
{
|
{
|
||||||
string _imagename = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name;
|
string _imagename = GENERAL[n]->name + "_" + GENERAL[n]->ROI[roi]->name;
|
||||||
if (isLogImageSelect)
|
if (isLogImageSelect)
|
||||||
{
|
{
|
||||||
if (LogImageSelect.find(GENERAL[_ana]->ROI[i]->name) != std::string::npos)
|
if (LogImageSelect.find(GENERAL[n]->ROI[roi]->name) != std::string::npos)
|
||||||
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
|
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[n]->ROI[roi]->image_org);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
|
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[n]->ROI[roi]->image_org);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -831,37 +835,38 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
case Digital100:
|
case Digital100:
|
||||||
case Analogue100:
|
case Analogue100:
|
||||||
{
|
{
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Digital100 or Analogue100");
|
||||||
int _num;
|
int _num;
|
||||||
float _result_save_file;
|
float _result_save_file;
|
||||||
|
|
||||||
tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);
|
tflite->LoadInputImageBasis(GENERAL[n]->ROI[roi]->image);
|
||||||
tflite->Invoke();
|
tflite->Invoke();
|
||||||
|
|
||||||
_num = tflite->GetOutClassification();
|
_num = tflite->GetOutClassification();
|
||||||
|
|
||||||
if(GENERAL[_ana]->ROI[i]->CCW)
|
if(GENERAL[n]->ROI[roi]->CCW)
|
||||||
GENERAL[_ana]->ROI[i]->result_float = 10 - ((float)_num / 10.0);
|
GENERAL[n]->ROI[roi]->result_float = 10 - ((float)_num / 10.0);
|
||||||
else
|
else
|
||||||
GENERAL[_ana]->ROI[i]->result_float = (float)_num / 10.0;
|
GENERAL[n]->ROI[roi]->result_float = (float)_num / 10.0;
|
||||||
|
|
||||||
_result_save_file = GENERAL[_ana]->ROI[i]->result_float;
|
_result_save_file = GENERAL[n]->ROI[roi]->result_float;
|
||||||
|
|
||||||
|
|
||||||
GENERAL[_ana]->ROI[i]->isReject = false;
|
GENERAL[n]->ROI[roi]->isReject = false;
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Result General(Analog)%i - CCW: %d - %f", i, GENERAL[_ana]->ROI[i]->CCW, GENERAL[_ana]->ROI[i]->result_float);
|
ESP_LOGD(TAG, "Result General(Analog)%i - CCW: %d - %f", roi, GENERAL[n]->ROI[roi]->CCW, GENERAL[n]->ROI[roi]->result_float);
|
||||||
|
|
||||||
if (isLogImage)
|
if (isLogImage)
|
||||||
{
|
{
|
||||||
string _imagename = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name;
|
string _imagename = GENERAL[n]->name + "_" + GENERAL[n]->ROI[roi]->name;
|
||||||
if (isLogImageSelect)
|
if (isLogImageSelect)
|
||||||
{
|
{
|
||||||
if (LogImageSelect.find(GENERAL[_ana]->ROI[i]->name) != std::string::npos)
|
if (LogImageSelect.find(GENERAL[n]->ROI[roi]->name) != std::string::npos)
|
||||||
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
|
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[n]->ROI[roi]->image_org);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
|
LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[n]->ROI[roi]->image_org);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,10 @@ extern "C" {
|
|||||||
#include "time_sntp.h"
|
#include "time_sntp.h"
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
#include "server_ota.h"
|
#include "server_ota.h"
|
||||||
#include "interface_mqtt.h"
|
#ifdef ENABLE_MQTT
|
||||||
#include "server_mqtt.h"
|
#include "interface_mqtt.h"
|
||||||
|
#include "server_mqtt.h"
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
//#include "CImg.h"
|
//#include "CImg.h"
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ extern "C" {
|
|||||||
|
|
||||||
//#define DEBUG_DETAIL_ON
|
//#define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
static const char* TAG = "FLOW CTRL";
|
static const char* TAG = "CTRL";
|
||||||
|
|
||||||
|
|
||||||
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
||||||
@@ -50,12 +51,17 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _
|
|||||||
if ((_stepname.compare("[Analog]") == 0) || (_stepname.compare(";[Analog]") == 0)){
|
if ((_stepname.compare("[Analog]") == 0) || (_stepname.compare(";[Analog]") == 0)){
|
||||||
_classname = "ClassFlowCNNGeneral";
|
_classname = "ClassFlowCNNGeneral";
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
if ((_stepname.compare("[MQTT]") == 0) || (_stepname.compare(";[MQTT]") == 0)){
|
if ((_stepname.compare("[MQTT]") == 0) || (_stepname.compare(";[MQTT]") == 0)){
|
||||||
_classname = "ClassFlowMQTT";
|
_classname = "ClassFlowMQTT";
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
|
#ifdef ENABLE_INFLUXDB
|
||||||
if ((_stepname.compare("[InfluxDB]") == 0) || (_stepname.compare(";[InfluxDB]") == 0)){
|
if ((_stepname.compare("[InfluxDB]") == 0) || (_stepname.compare(";[InfluxDB]") == 0)){
|
||||||
_classname = "ClassFlowInfluxDB";
|
_classname = "ClassFlowInfluxDB";
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_INFLUXDB
|
||||||
|
|
||||||
for (int i = 0; i < FlowControll.size(); ++i)
|
for (int i = 0; i < FlowControll.size(); ++i)
|
||||||
if (FlowControll[i]->name().compare(_classname) == 0){
|
if (FlowControll[i]->name().compare(_classname) == 0){
|
||||||
@@ -78,14 +84,18 @@ std::string ClassFlowControll::TranslateAktstatus(std::string _input)
|
|||||||
return ("Aligning");
|
return ("Aligning");
|
||||||
if (_input.compare("ClassFlowCNNGeneral") == 0)
|
if (_input.compare("ClassFlowCNNGeneral") == 0)
|
||||||
return ("Digitalization of ROIs");
|
return ("Digitalization of ROIs");
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
if (_input.compare("ClassFlowMQTT") == 0)
|
if (_input.compare("ClassFlowMQTT") == 0)
|
||||||
return ("Sending MQTT");
|
return ("Sending MQTT");
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
#ifdef ENABLE_INFLUXDB
|
||||||
if (_input.compare("ClassFlowInfluxDB") == 0)
|
if (_input.compare("ClassFlowInfluxDB") == 0)
|
||||||
return ("Sending InfluxDB");
|
return ("Sending InfluxDB");
|
||||||
|
#endif //ENABLE_INFLUXDB
|
||||||
if (_input.compare("ClassFlowPostProcessing") == 0)
|
if (_input.compare("ClassFlowPostProcessing") == 0)
|
||||||
return ("Processing");
|
return ("Post-Processing");
|
||||||
if (_input.compare("ClassFlowWriteList") == 0)
|
if (_input.compare("ClassFlowWriteList") == 0)
|
||||||
return ("Processing");
|
return ("Writing List");
|
||||||
|
|
||||||
return "Unkown Status";
|
return "Unkown Status";
|
||||||
}
|
}
|
||||||
@@ -130,7 +140,7 @@ t_CNNType ClassFlowControll::GetTypeAnalog()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
string ClassFlowControll::GetMQTTMainTopic()
|
string ClassFlowControll::GetMQTTMainTopic()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < FlowControll.size(); ++i)
|
for (int i = 0; i < FlowControll.size(); ++i)
|
||||||
@@ -149,7 +159,7 @@ bool ClassFlowControll::StartMQTTService() {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
void ClassFlowControll::SetInitialParameter(void)
|
void ClassFlowControll::SetInitialParameter(void)
|
||||||
{
|
{
|
||||||
@@ -196,12 +206,14 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
|
|||||||
cfc = new ClassFlowCNNGeneral(flowalignment);
|
cfc = new ClassFlowCNNGeneral(flowalignment);
|
||||||
flowdigit = (ClassFlowCNNGeneral*) cfc;
|
flowdigit = (ClassFlowCNNGeneral*) cfc;
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
if (toUpper(_type).compare("[MQTT]") == 0)
|
if (toUpper(_type).compare("[MQTT]") == 0)
|
||||||
cfc = new ClassFlowMQTT(&FlowControll);
|
cfc = new ClassFlowMQTT(&FlowControll);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
#ifdef ENABLE_INFLUXDB
|
||||||
if (toUpper(_type).compare("[INFLUXDB]") == 0)
|
if (toUpper(_type).compare("[INFLUXDB]") == 0)
|
||||||
cfc = new ClassFlowInfluxDB(&FlowControll);
|
cfc = new ClassFlowInfluxDB(&FlowControll);
|
||||||
|
#endif //ENABLE_INFLUXDB
|
||||||
if (toUpper(_type).compare("[WRITELIST]") == 0)
|
if (toUpper(_type).compare("[WRITELIST]") == 0)
|
||||||
cfc = new ClassFlowWriteList(&FlowControll);
|
cfc = new ClassFlowWriteList(&FlowControll);
|
||||||
|
|
||||||
@@ -287,7 +299,9 @@ void ClassFlowControll::doFlowMakeImageOnly(string time){
|
|||||||
zw_time = gettimestring("%H:%M:%S");
|
zw_time = gettimestring("%H:%M:%S");
|
||||||
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
|
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
|
||||||
aktstatus = flowStatus + " (" + zw_time + ")";
|
aktstatus = flowStatus + " (" + zw_time + ")";
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
FlowControll[i]->doFlow(time);
|
FlowControll[i]->doFlow(time);
|
||||||
}
|
}
|
||||||
@@ -317,7 +331,9 @@ bool ClassFlowControll::doFlow(string time)
|
|||||||
zw_time = gettimestring("%H:%M:%S");
|
zw_time = gettimestring("%H:%M:%S");
|
||||||
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
|
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
|
||||||
aktstatus = flowStatus + " (" + zw_time + ")";
|
aktstatus = flowStatus + " (" + zw_time + ")";
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
|
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
@@ -348,7 +364,9 @@ bool ClassFlowControll::doFlow(string time)
|
|||||||
zw_time = gettimestring("%H:%M:%S");
|
zw_time = gettimestring("%H:%M:%S");
|
||||||
std::string flowStatus = "Flow finished";
|
std::string flowStatus = "Flow finished";
|
||||||
aktstatus = flowStatus + " (" + zw_time + ")";
|
aktstatus = flowStatus + " (" + zw_time + ")";
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,7 +719,7 @@ string ClassFlowControll::getNumbersName()
|
|||||||
return flowpostprocessing->getNumbersName();
|
return flowpostprocessing->getNumbersName();
|
||||||
}
|
}
|
||||||
|
|
||||||
string ClassFlowControll::getJSON(std::string _id, std::string _mac)
|
string ClassFlowControll::getJSON()
|
||||||
{
|
{
|
||||||
return flowpostprocessing->GetJSON(_id, _mac);
|
return flowpostprocessing->GetJSON();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __FLOWCONTROLL__
|
#ifndef __FLOWCONTROLL__
|
||||||
#define __FLOWCONTROLL__
|
#define __FLOWCONTROLL__
|
||||||
|
|
||||||
@@ -8,8 +10,12 @@
|
|||||||
#include "ClassFlowAlignment.h"
|
#include "ClassFlowAlignment.h"
|
||||||
#include "ClassFlowCNNGeneral.h"
|
#include "ClassFlowCNNGeneral.h"
|
||||||
#include "ClassFlowPostProcessing.h"
|
#include "ClassFlowPostProcessing.h"
|
||||||
#include "ClassFlowMQTT.h"
|
#ifdef ENABLE_MQTT
|
||||||
#include "ClassFlowInfluxDB.h"
|
#include "ClassFlowMQTT.h"
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
#ifdef ENABLE_INFLUXDB
|
||||||
|
#include "ClassFlowInfluxDB.h"
|
||||||
|
#endif //ENABLE_INFLUXDB
|
||||||
#include "ClassFlowCNNGeneral.h"
|
#include "ClassFlowCNNGeneral.h"
|
||||||
#include "ClassFlowWriteList.h"
|
#include "ClassFlowWriteList.h"
|
||||||
|
|
||||||
@@ -50,12 +56,13 @@ public:
|
|||||||
string UpdatePrevalue(std::string _newvalue, std::string _numbers, bool _extern);
|
string UpdatePrevalue(std::string _newvalue, std::string _numbers, bool _extern);
|
||||||
string GetPrevalue(std::string _number = "");
|
string GetPrevalue(std::string _number = "");
|
||||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||||
string getJSON(std::string _id = "", std::string _mac = "");
|
string getJSON();
|
||||||
string getNumbersName();
|
string getNumbersName();
|
||||||
|
|
||||||
string TranslateAktstatus(std::string _input);
|
string TranslateAktstatus(std::string _input);
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
string GetMQTTMainTopic();
|
string GetMQTTMainTopic();
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
esp_err_t GetJPGStream(std::string _fn, httpd_req_t *req);
|
esp_err_t GetJPGStream(std::string _fn, httpd_req_t *req);
|
||||||
esp_err_t SendRawJPG(httpd_req_t *req);
|
esp_err_t SendRawJPG(httpd_req_t *req);
|
||||||
@@ -71,7 +78,9 @@ public:
|
|||||||
|
|
||||||
t_CNNType GetTypeDigital();
|
t_CNNType GetTypeDigital();
|
||||||
t_CNNType GetTypeAnalog();
|
t_CNNType GetTypeAnalog();
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
bool StartMQTTService();
|
bool StartMQTTService();
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
int CleanTempFolder();
|
int CleanTempFolder();
|
||||||
|
|
||||||
@@ -81,3 +90,4 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ extern "C" {
|
|||||||
#include "CImageBasis.h"
|
#include "CImageBasis.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
static const char* TAG = "FLOW IMG";
|
static const char* TAG = "IMG";
|
||||||
|
|
||||||
ClassFlowImage::ClassFlowImage(const char* logTag)
|
ClassFlowImage::ClassFlowImage(const char* logTag)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifdef ENABLE_INFLUXDB
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "ClassFlowInfluxDB.h"
|
#include "ClassFlowInfluxDB.h"
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
@@ -5,6 +6,7 @@
|
|||||||
|
|
||||||
#include "time_sntp.h"
|
#include "time_sntp.h"
|
||||||
#include "interface_influxdb.h"
|
#include "interface_influxdb.h"
|
||||||
|
|
||||||
#include "ClassFlowPostProcessing.h"
|
#include "ClassFlowPostProcessing.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
@@ -162,3 +164,5 @@ bool ClassFlowInfluxDB::doFlow(string zwtime)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //ENABLE_INFLUXDB
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifdef ENABLE_INFLUXDB
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "ClassFlow.h"
|
#include "ClassFlow.h"
|
||||||
|
|
||||||
@@ -29,3 +30,4 @@ public:
|
|||||||
string name(){return "ClassFlowInfluxDB";};
|
string name(){return "ClassFlowInfluxDB";};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif //ENABLE_INFLUXDB
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include "ClassFlowMQTT.h"
|
#include "ClassFlowMQTT.h"
|
||||||
@@ -17,7 +19,7 @@
|
|||||||
|
|
||||||
#define __HIDE_PASSWORD
|
#define __HIDE_PASSWORD
|
||||||
|
|
||||||
static const char *TAG = "FLOW MQTT";
|
static const char *TAG = "MQTT";
|
||||||
#define LWT_TOPIC "connection"
|
#define LWT_TOPIC "connection"
|
||||||
#define LWT_CONNECTED "connected"
|
#define LWT_CONNECTED "connected"
|
||||||
#define LWT_DISCONNECTED "connection lost"
|
#define LWT_DISCONNECTED "connection lost"
|
||||||
@@ -239,7 +241,7 @@ bool ClassFlowMQTT::doFlow(string zwtime)
|
|||||||
{
|
{
|
||||||
std::vector<NumberPost*>* NUMBERS = flowpostprocessing->GetNumbers();
|
std::vector<NumberPost*>* NUMBERS = flowpostprocessing->GetNumbers();
|
||||||
|
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Publishing MQTT topics...");
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Publishing MQTT topics...");
|
||||||
|
|
||||||
for (int i = 0; i < (*NUMBERS).size(); ++i)
|
for (int i = 0; i < (*NUMBERS).size(); ++i)
|
||||||
{
|
{
|
||||||
@@ -288,26 +290,7 @@ bool ClassFlowMQTT::doFlow(string zwtime)
|
|||||||
if (resulttimestamp.length() > 0)
|
if (resulttimestamp.length() > 0)
|
||||||
MQTTPublish(namenumber + "timestamp", resulttimestamp, SetRetainFlag);
|
MQTTPublish(namenumber + "timestamp", resulttimestamp, SetRetainFlag);
|
||||||
|
|
||||||
std::string json = "";
|
std::string json = flowpostprocessing->getJsonFromNumber(i, "\n");
|
||||||
|
|
||||||
if (result.length() > 0)
|
|
||||||
json += "{\"value\": "+result;
|
|
||||||
else
|
|
||||||
json += "{\"value\": \"\"";
|
|
||||||
|
|
||||||
json += ", \"raw\": \""+resultraw;
|
|
||||||
|
|
||||||
json += ", \"pre\": \"" + resultpre;
|
|
||||||
|
|
||||||
json += "\", \"error\": \""+resulterror;
|
|
||||||
|
|
||||||
if (resultrate.length() > 0)
|
|
||||||
json += "\", \"rate\": "+resultrate;
|
|
||||||
else
|
|
||||||
json += "\", \"rate\": \"\"";
|
|
||||||
|
|
||||||
json += ", \"timestamp\": \""+resulttimestamp+"\"}";
|
|
||||||
|
|
||||||
MQTTPublish(namenumber + "json", json, SetRetainFlag);
|
MQTTPublish(namenumber + "json", json, SetRetainFlag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,3 +316,6 @@ bool ClassFlowMQTT::doFlow(string zwtime)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifdef ENABLE_MQTT
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "ClassFlow.h"
|
#include "ClassFlow.h"
|
||||||
|
|
||||||
@@ -33,3 +34,4 @@ public:
|
|||||||
string name(){return "ClassFlowMQTT";};
|
string name(){return "ClassFlowMQTT";};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
static const char* TAG = "FLOW POSTPROC";
|
static const char* TAG = "POSTPROC";
|
||||||
|
|
||||||
//#define SERIAL_DEBUG // testing debug on serial enabled
|
//#define SERIAL_DEBUG // testing debug on serial enabled
|
||||||
|
|
||||||
@@ -37,42 +37,51 @@ std::string ClassFlowPostProcessing::getNumbersName()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ClassFlowPostProcessing::GetJSON(std::string _id, std::string _mac, std::string _lineend)
|
std::string ClassFlowPostProcessing::GetJSON(std::string _lineend)
|
||||||
{
|
{
|
||||||
std::string json="{" + _lineend;
|
std::string json="{" + _lineend;
|
||||||
|
|
||||||
for (int i = 0; i < NUMBERS.size(); ++i)
|
for (int i = 0; i < NUMBERS.size(); ++i)
|
||||||
{
|
{
|
||||||
json += "\"" + NUMBERS[i]->name + "\":" + _lineend;
|
json += "\"" + NUMBERS[i]->name + "\":" + _lineend;
|
||||||
json += " {" + _lineend;
|
|
||||||
|
|
||||||
if (_id.length() > 0)
|
json += getJsonFromNumber(i, _lineend) + _lineend;
|
||||||
json += " \"ID\": \"" + _id + "\"," + _lineend;
|
|
||||||
if (_mac.length() > 0)
|
|
||||||
json += " \"MAC\": \"" + _mac + "\"," + _lineend;
|
|
||||||
|
|
||||||
if (NUMBERS[i]->ReturnValue.length() > 0)
|
|
||||||
json += " \"value\": \"" + NUMBERS[i]->ReturnValue + "\"," + _lineend;
|
|
||||||
else
|
|
||||||
json += " \"value\": \"\"," + _lineend;
|
|
||||||
json += " \"raw\": \"" + NUMBERS[i]->ReturnRawValue + "\"," + _lineend;
|
|
||||||
json += " \"error\": \"" + NUMBERS[i]->ErrorMessageText + "\"," + _lineend;
|
|
||||||
if (NUMBERS[i]->ReturnRateValue.length() > 0)
|
|
||||||
json += " \"rate\": " + NUMBERS[i]->ReturnRateValue + "," + _lineend;
|
|
||||||
else
|
|
||||||
json += " \"rate\": \"\"," + _lineend;
|
|
||||||
|
|
||||||
json += " \"timestamp\": \"" + NUMBERS[i]->timeStamp + "\"" + _lineend;
|
|
||||||
if ((i+1) < NUMBERS.size())
|
if ((i+1) < NUMBERS.size())
|
||||||
json += " }," + _lineend;
|
json += "," + _lineend;
|
||||||
else
|
|
||||||
json += " }" + _lineend;
|
|
||||||
}
|
}
|
||||||
json += "}";
|
json += "}";
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string ClassFlowPostProcessing::getJsonFromNumber(int i, std::string _lineend) {
|
||||||
|
std::string json = "";
|
||||||
|
|
||||||
|
json += " {" + _lineend;
|
||||||
|
|
||||||
|
if (NUMBERS[i]->ReturnValue.length() > 0)
|
||||||
|
json += " \"value\": \"" + NUMBERS[i]->ReturnValue + "\"," + _lineend;
|
||||||
|
else
|
||||||
|
json += " \"value\": \"\"," + _lineend;
|
||||||
|
|
||||||
|
json += " \"raw\": \"" + NUMBERS[i]->ReturnRawValue + "\"," + _lineend;
|
||||||
|
json += " \"pre\": \"" + NUMBERS[i]->ReturnPreValue + "\"," + _lineend;
|
||||||
|
json += " \"error\": \"" + NUMBERS[i]->ErrorMessageText + "\"," + _lineend;
|
||||||
|
|
||||||
|
if (NUMBERS[i]->ReturnRateValue.length() > 0)
|
||||||
|
json += " \"rate\": \"" + NUMBERS[i]->ReturnRateValue + "\"," + _lineend;
|
||||||
|
else
|
||||||
|
json += " \"rate\": \"\"," + _lineend;
|
||||||
|
|
||||||
|
json += " \"timestamp\": \"" + NUMBERS[i]->timeStamp + "\"" + _lineend;
|
||||||
|
json += " }" + _lineend;
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string ClassFlowPostProcessing::GetPreValue(std::string _number)
|
string ClassFlowPostProcessing::GetPreValue(std::string _number)
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
@@ -698,6 +707,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
NUMBERS[j]->ReturnValue = "";
|
NUMBERS[j]->ReturnValue = "";
|
||||||
NUMBERS[j]->ErrorMessageText = "";
|
NUMBERS[j]->ErrorMessageText = "";
|
||||||
NUMBERS[j]->Value = -1;
|
NUMBERS[j]->Value = -1;
|
||||||
|
NUMBERS[j]->lastvalue = imagetime;
|
||||||
|
|
||||||
UpdateNachkommaDecimalShift();
|
UpdateNachkommaDecimalShift();
|
||||||
|
|
||||||
@@ -752,6 +762,8 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
|
||||||
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, _zw);
|
||||||
WriteDataLog(j);
|
WriteDataLog(j);
|
||||||
continue; // es gibt keinen Zahl, da noch ein N vorhanden ist.
|
continue; // es gibt keinen Zahl, da noch ein N vorhanden ist.
|
||||||
}
|
}
|
||||||
@@ -809,6 +821,9 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Neg. Rate - Read: " + zwvalue + " - Raw: " + NUMBERS[j]->ReturnRawValue + " - Pre: " + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + " ";
|
NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Neg. Rate - Read: " + zwvalue + " - Raw: " + NUMBERS[j]->ReturnRawValue + " - Pre: " + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + " ";
|
||||||
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
|
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
|
||||||
NUMBERS[j]->ReturnValue = "";
|
NUMBERS[j]->ReturnValue = "";
|
||||||
|
|
||||||
|
string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
|
||||||
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, _zw);
|
||||||
WriteDataLog(j);
|
WriteDataLog(j);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -837,6 +852,9 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
|
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
|
||||||
NUMBERS[j]->ReturnValue = "";
|
NUMBERS[j]->ReturnValue = "";
|
||||||
NUMBERS[j]->ReturnRateValue = "";
|
NUMBERS[j]->ReturnRateValue = "";
|
||||||
|
|
||||||
|
string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
|
||||||
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, _zw);
|
||||||
WriteDataLog(j);
|
WriteDataLog(j);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -844,8 +862,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
ESP_LOGD(TAG, "After MaxRateCheck: Value %f", NUMBERS[j]->Value);
|
ESP_LOGD(TAG, "After MaxRateCheck: Value %f", NUMBERS[j]->Value);
|
||||||
#endif
|
#endif
|
||||||
NUMBERS[j]->ReturnChangeAbsolute = RundeOutput(NUMBERS[j]->Value - NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
|
NUMBERS[j]->ReturnChangeAbsolute = RundeOutput(NUMBERS[j]->Value - NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
|
||||||
NUMBERS[j]->lastvalue = imagetime;
|
|
||||||
NUMBERS[j]->PreValue = NUMBERS[j]->Value;
|
NUMBERS[j]->PreValue = NUMBERS[j]->Value;
|
||||||
NUMBERS[j]->PreValueOkay = true;
|
NUMBERS[j]->PreValueOkay = true;
|
||||||
|
|
||||||
@@ -856,9 +873,9 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
NUMBERS[j]->ErrorMessageText = "no error";
|
NUMBERS[j]->ErrorMessageText = "no error";
|
||||||
UpdatePreValueINI = true;
|
UpdatePreValueINI = true;
|
||||||
|
|
||||||
string _zw = "PostProcessing - Raw: " + NUMBERS[j]->ReturnRawValue + " Value: " + NUMBERS[j]->ReturnValue + " Error: " + NUMBERS[j]->ErrorMessageText;
|
string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
|
||||||
ESP_LOGD(TAG, "%s", zw.c_str());
|
ESP_LOGD(TAG, "%s", zw.c_str());
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, _zw);
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, _zw);
|
||||||
WriteDataLog(j);
|
WriteDataLog(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,10 +61,11 @@ public:
|
|||||||
string getReadoutRate(int _number = 0);
|
string getReadoutRate(int _number = 0);
|
||||||
string getReadoutTimeStamp(int _number = 0);
|
string getReadoutTimeStamp(int _number = 0);
|
||||||
void SavePreValue();
|
void SavePreValue();
|
||||||
|
string getJsonFromNumber(int i, std::string _lineend);
|
||||||
string GetPreValue(std::string _number = "");
|
string GetPreValue(std::string _number = "");
|
||||||
void SetPreValue(double zw, string _numbers, bool _extern = false);
|
void SetPreValue(double zw, string _numbers, bool _extern = false);
|
||||||
|
|
||||||
std::string GetJSON(std::string _id = "", std::string _mac = "", std::string _lineend = "\n");
|
std::string GetJSON(std::string _lineend = "\n");
|
||||||
std::string getNumbersName();
|
std::string getNumbersName();
|
||||||
|
|
||||||
void UpdateNachkommaDecimalShift();
|
void UpdateNachkommaDecimalShift();
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifdef ENABLE_INFLUXDB
|
||||||
#include "interface_influxdb.h"
|
#include "interface_influxdb.h"
|
||||||
|
|
||||||
//#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
//#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
||||||
@@ -111,4 +112,4 @@ void InfluxDBInit(std::string _uri, std::string _database, std::string _measurem
|
|||||||
void InfluxDBdestroy() {
|
void InfluxDBdestroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //ENABLE_INFLUXDB
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifdef ENABLE_INFLUXDB
|
||||||
#ifndef INTERFACE_INFLUXDB_H
|
#ifndef INTERFACE_INFLUXDB_H
|
||||||
#define INTERFACE_INFLUXDB_H
|
#define INTERFACE_INFLUXDB_H
|
||||||
|
|
||||||
@@ -11,3 +12,4 @@ void InfluxDBdestroy();
|
|||||||
void InfluxDBPublish(std::string _key, std::string _content, std::string _timestamp);
|
void InfluxDBPublish(std::string _key, std::string _content, std::string _timestamp);
|
||||||
|
|
||||||
#endif //INTERFACE_INFLUXDB_H
|
#endif //INTERFACE_INFLUXDB_H
|
||||||
|
#endif //ENABLE_INFLUXDB
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifdef ENABLE_MQTT
|
||||||
#include "interface_mqtt.h"
|
#include "interface_mqtt.h"
|
||||||
|
|
||||||
//#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
//#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
||||||
@@ -346,3 +347,4 @@ void MQTTdestroySubscribeFunction(){
|
|||||||
subscribeFunktionMap = NULL;
|
subscribeFunktionMap = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifdef ENABLE_MQTT
|
||||||
#ifndef INTERFACE_MQTT_H
|
#ifndef INTERFACE_MQTT_H
|
||||||
#define INTERFACE_MQTT_H
|
#define INTERFACE_MQTT_H
|
||||||
|
|
||||||
@@ -22,5 +23,5 @@ void MQTTdestroySubscribeFunction();
|
|||||||
void MQTTconnected();
|
void MQTTconnected();
|
||||||
|
|
||||||
void MQTTdisable();
|
void MQTTdisable();
|
||||||
|
#endif //INTERFACE_MQTT_H
|
||||||
#endif //INTERFACE_MQTT_H
|
#endif //#ENABLE_MQTT
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifdef ENABLE_MQTT
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@@ -155,7 +156,7 @@ void MQTThomeassistantDiscovery() {
|
|||||||
sendHomeAssistantDiscoveryTopic(group, "rate_per_digitalization_round", "Change since last digitalization round", "arrow-expand-vertical", valueUnit, "", "measurement", ""); // correctly the Unit is Uint/Interval!
|
sendHomeAssistantDiscoveryTopic(group, "rate_per_digitalization_round", "Change since last digitalization round", "arrow-expand-vertical", valueUnit, "", "measurement", ""); // correctly the Unit is Uint/Interval!
|
||||||
sendHomeAssistantDiscoveryTopic(group, "timestamp", "Timestamp", "clock-time-eight-outline", "", "timestamp", "", "diagnostic");
|
sendHomeAssistantDiscoveryTopic(group, "timestamp", "Timestamp", "clock-time-eight-outline", "", "timestamp", "", "diagnostic");
|
||||||
sendHomeAssistantDiscoveryTopic(group, "json", "JSON", "code-json", "", "", "", "diagnostic");
|
sendHomeAssistantDiscoveryTopic(group, "json", "JSON", "code-json", "", "", "", "diagnostic");
|
||||||
sendHomeAssistantDiscoveryTopic(group, "problem", "Problem", "alert-outline", "", "", "", ""); // Special binary sensor which is based on error topic
|
sendHomeAssistantDiscoveryTopic(group, "problem", "Problem", "alert-outline", "", "problem", "", ""); // Special binary sensor which is based on error topic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,3 +244,5 @@ void mqttServer_setMainTopic( std::string _maintopic) {
|
|||||||
std::string mqttServer_getMainTopic() {
|
std::string mqttServer_getMainTopic() {
|
||||||
return maintopic;
|
return maintopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
|
||||||
#include "ClassFlowDefineTypes.h"
|
#include "ClassFlowDefineTypes.h"
|
||||||
|
|
||||||
#define LWT_TOPIC "connection"
|
#define LWT_TOPIC "connection"
|
||||||
@@ -17,4 +19,6 @@ void register_server_mqtt_uri(httpd_handle_t server);
|
|||||||
void publishSystemData();
|
void publishSystemData();
|
||||||
|
|
||||||
std::string getTimeUnit(void);
|
std::string getTimeUnit(void);
|
||||||
void GotConnected(std::string maintopic, int SetRetainFlag);
|
void GotConnected(std::string maintopic, int SetRetainFlag);
|
||||||
|
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
// #define DEBUG_DETAIL_ON
|
// #define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
|
|
||||||
static const char *TAG = "C TFLITE";
|
static const char *TAG = "TFLITE";
|
||||||
|
|
||||||
float CTfLiteClass::GetOutputValue(int nr)
|
float CTfLiteClass::GetOutputValue(int nr)
|
||||||
{
|
{
|
||||||
@@ -179,6 +179,8 @@ void CTfLiteClass::MakeAllocate()
|
|||||||
static tflite::AllOpsResolver resolver;
|
static tflite::AllOpsResolver resolver;
|
||||||
|
|
||||||
// ESP_LOGD(TAG, "%s", LogFile.getESPHeapInfo().c_str());
|
// ESP_LOGD(TAG, "%s", LogFile.getESPHeapInfo().c_str());
|
||||||
|
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Make Allocate");
|
||||||
this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize, this->error_reporter);
|
this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize, this->error_reporter);
|
||||||
// ESP_LOGD(TAG, "%s", LogFile.getESPHeapInfo().c_str());
|
// ESP_LOGD(TAG, "%s", LogFile.getESPHeapInfo().c_str());
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ bool auto_isrunning = false;
|
|||||||
|
|
||||||
int countRounds = 0;
|
int countRounds = 0;
|
||||||
|
|
||||||
static const char *TAG = "TFLITE";
|
static const char *TAG = "TFLITE SERVER";
|
||||||
|
|
||||||
|
|
||||||
int getCountFlowRounds() {
|
int getCountFlowRounds() {
|
||||||
@@ -104,7 +104,9 @@ void doInit(void)
|
|||||||
ESP_LOGD(TAG, "Finished tfliteflow.InitFlow(config);");
|
ESP_LOGD(TAG, "Finished tfliteflow.InitFlow(config);");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
tfliteflow.StartMQTTService();
|
tfliteflow.StartMQTTService();
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -736,7 +738,7 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
while (auto_isrunning)
|
while (auto_isrunning)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "----------------------------------------------------------------"); // Clear separation between runs
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "----------------------------------------------------------------"); // Clear separation between runs
|
||||||
std::string _zw = "task_autodoFlow - Starting Round #" + std::to_string(++countRounds);
|
std::string _zw = "Round #" + std::to_string(++countRounds) + " started";
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, _zw);
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, _zw);
|
||||||
fr_start = esp_timer_get_time();
|
fr_start = esp_timer_get_time();
|
||||||
|
|
||||||
@@ -767,7 +769,7 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
string zwtemp = "CPU Temperature: " + stream.str();
|
string zwtemp = "CPU Temperature: " + stream.str();
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, zwtemp);
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, zwtemp);
|
||||||
|
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "task_autodoFlow - round #" + std::to_string(countRounds) + " completed");
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Round #" + std::to_string(countRounds) + " completed");
|
||||||
|
|
||||||
fr_delta_ms = (esp_timer_get_time() - fr_start) / 1000;
|
fr_delta_ms = (esp_timer_get_time() - fr_start) / 1000;
|
||||||
if (auto_intervall > fr_delta_ms)
|
if (auto_intervall > fr_delta_ms)
|
||||||
@@ -803,11 +805,12 @@ void TFliteDoAutoStart()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
std::string GetMQTTMainTopic()
|
std::string GetMQTTMainTopic()
|
||||||
{
|
{
|
||||||
return tfliteflow.GetMQTTMainTopic();
|
return tfliteflow.GetMQTTMainTopic();
|
||||||
}
|
}
|
||||||
|
#endif//ENABLE_MQTT
|
||||||
|
|
||||||
|
|
||||||
void register_server_tflite_uri(httpd_handle_t server)
|
void register_server_tflite_uri(httpd_handle_t server)
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ void TFliteDoAutoStart();
|
|||||||
|
|
||||||
bool isSetupModusActive();
|
bool isSetupModusActive();
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
std::string GetMQTTMainTopic();
|
std::string GetMQTTMainTopic();
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
int getCountFlowRounds();
|
int getCountFlowRounds();
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ bool setup_time()
|
|||||||
|
|
||||||
// Is time set? If not, tm_year will be (1970 - 1900).
|
// Is time set? If not, tm_year will be (1970 - 1900).
|
||||||
if (!getTimeIsSet()) {
|
if (!getTimeIsSet()) {
|
||||||
ESP_LOGI(TAG, "Time is not set yet. Getting time over NTP.");
|
|
||||||
initialize_sntp();
|
initialize_sntp();
|
||||||
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Time is not set yet. Getting time over NTP server " + std::string(sntp_getservername(0)));
|
||||||
if (!obtain_time()) {
|
if (!obtain_time()) {
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
@@ -103,9 +103,9 @@ static bool obtain_time(void)
|
|||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
localtime_r(&now, &timeinfo);
|
localtime_r(&now, &timeinfo);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Waiting until we get a time from the NTP server...");
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Waiting until we get a time from the NTP server " + std::string(sntp_getservername(0)));
|
||||||
while (true) {
|
while (true) {
|
||||||
retry++;
|
retry++;
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ static bool obtain_time(void)
|
|||||||
sntp_sync_status_t status = sntp_get_sync_status();
|
sntp_sync_status_t status = sntp_get_sync_status();
|
||||||
logNtpStatus(status);
|
logNtpStatus(status);
|
||||||
if (status == SNTP_SYNC_STATUS_COMPLETED) {
|
if (status == SNTP_SYNC_STATUS_COMPLETED) {
|
||||||
ESP_LOGI(TAG, "Time is synced with NTP Server");
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Time is synced with NTP Server " + std::string(sntp_getservername(0)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,23 +133,23 @@ static bool obtain_time(void)
|
|||||||
|
|
||||||
void logNtpStatus(sntp_sync_status_t status) {
|
void logNtpStatus(sntp_sync_status_t status) {
|
||||||
if (status == SNTP_SYNC_STATUS_COMPLETED) {
|
if (status == SNTP_SYNC_STATUS_COMPLETED) {
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "NTP Status OK");
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Status OK");
|
||||||
}
|
}
|
||||||
else if (status == SNTP_SYNC_STATUS_IN_PROGRESS) {
|
else if (status == SNTP_SYNC_STATUS_IN_PROGRESS) {
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "NTP Status: In Progress");
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Status: In Progress");
|
||||||
}
|
}
|
||||||
else { // SNTP_SYNC_STATUS_RESET
|
else { // SNTP_SYNC_STATUS_RESET
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "NTP Status: Reset");
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Status: Reset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void reset_servername(std::string _servername)
|
void reset_servername(std::string _servername)
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG, "Set SNTP-Server: %s", _servername.c_str());
|
|
||||||
sntp_stop();
|
sntp_stop();
|
||||||
sntp_setoperatingmode(SNTP_OPMODE_POLL);
|
sntp_setoperatingmode(SNTP_OPMODE_POLL);
|
||||||
sntp_setservername(0, _servername.c_str());
|
sntp_setservername(0, _servername.c_str());
|
||||||
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Set SNTP-Server to " + std::string(sntp_getservername(0)));
|
||||||
sntp_init();
|
sntp_init();
|
||||||
obtain_time();
|
obtain_time();
|
||||||
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
||||||
|
|||||||
@@ -27,7 +27,9 @@
|
|||||||
#include "ClassControllCamera.h"
|
#include "ClassControllCamera.h"
|
||||||
#include "server_main.h"
|
#include "server_main.h"
|
||||||
#include "server_camera.h"
|
#include "server_camera.h"
|
||||||
#include "server_mqtt.h"
|
#ifdef ENABLE_MQTT
|
||||||
|
#include "server_mqtt.h"
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
|
|
||||||
extern const char* GIT_TAG;
|
extern const char* GIT_TAG;
|
||||||
@@ -195,7 +197,7 @@ extern "C" void app_main(void)
|
|||||||
ESP_LOGD(TAG, "No SSID and PASSWORD set!!!");
|
ESP_LOGD(TAG, "No SSID and PASSWORD set!!!");
|
||||||
|
|
||||||
if (hostname != NULL)
|
if (hostname != NULL)
|
||||||
ESP_LOGD(TAG, "Hostename: %s", hostname);
|
ESP_LOGD(TAG, "Hostname: %s", hostname);
|
||||||
else
|
else
|
||||||
ESP_LOGD(TAG, "Hostname not set");
|
ESP_LOGD(TAG, "Hostname not set");
|
||||||
|
|
||||||
@@ -230,10 +232,10 @@ extern "C" void app_main(void)
|
|||||||
ESP_LOGD(TAG, "time %s", zw.c_str());
|
ESP_LOGD(TAG, "time %s", zw.c_str());
|
||||||
|
|
||||||
size_t _hsize = getESPHeapSize();
|
size_t _hsize = getESPHeapSize();
|
||||||
if (_hsize < 4000000)
|
if (_hsize < 4000000) // Check for a bit less than 4 MB (but clearly over 2 MB)
|
||||||
{
|
{
|
||||||
std::string _zws = "Not enough PSRAM available. Expected 4.194.304 MByte - available: " + std::to_string(_hsize);
|
std::string _zws = "Not enough PSRAM available. Expected around 4 MBytes - available: " + std::to_string((float)_hsize/1024/1024) + " MBytes!";
|
||||||
_zws = _zws + "\nEither not initialized, too small (2MByte only) or not present at all. Firmware cannot start!!";
|
_zws = _zws + "\nEither not initialized, too small (2 MByte only) or not present at all. Firmware cannot start!!";
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, _zws);
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, _zws);
|
||||||
} else { // Bad Camera Status, retry init
|
} else { // Bad Camera Status, retry init
|
||||||
if (camStatus != ESP_OK) {
|
if (camStatus != ESP_OK) {
|
||||||
@@ -255,7 +257,10 @@ extern "C" void app_main(void)
|
|||||||
camera_fb_t * fb = esp_camera_fb_get();
|
camera_fb_t * fb = esp_camera_fb_get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Camera Framebuffer cannot be initialized!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Camera Framebuffer cannot be initialized!");
|
||||||
initSucessful = false;
|
/* Easiest would be to simply restart here and try again,
|
||||||
|
how ever there seem to be systems where it fails at startup but still work corectly later.
|
||||||
|
Therefore we treat it still as successed!
|
||||||
|
//initSucessful = false; */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
esp_camera_fb_return(fb);
|
esp_camera_fb_return(fb);
|
||||||
@@ -277,7 +282,9 @@ extern "C" void app_main(void)
|
|||||||
register_server_tflite_uri(server);
|
register_server_tflite_uri(server);
|
||||||
register_server_file_uri(server, "/sdcard");
|
register_server_file_uri(server, "/sdcard");
|
||||||
register_server_ota_sdcard_uri(server);
|
register_server_ota_sdcard_uri(server);
|
||||||
register_server_mqtt_uri(server);
|
#ifdef ENABLE_MQTT
|
||||||
|
register_server_mqtt_uri(server);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
gpio_handler_create(server);
|
gpio_handler_create(server);
|
||||||
|
|
||||||
|
|||||||
@@ -18,24 +18,28 @@ board = esp32cam
|
|||||||
;board = m5stack-core-esp32
|
;board = m5stack-core-esp32
|
||||||
framework = espidf
|
framework = espidf
|
||||||
|
|
||||||
|
;Add macro definition ENABLE_MQTT, ENABLE_INFLUXDB
|
||||||
|
build_flags = -D ENABLE_MQTT -D ENABLE_INFLUXDB
|
||||||
|
|
||||||
;board_build.partitions = partitions_singleapp.csv
|
;board_build.partitions = partitions_singleapp.csv
|
||||||
board_build.partitions = partitions.csv
|
board_build.partitions = partitions.csv
|
||||||
|
|
||||||
lib_deps =
|
;lib_deps not needed
|
||||||
jomjol_configfile
|
;lib_deps =
|
||||||
jomjol_helper
|
; jomjol_configfile
|
||||||
jomjol_wlan
|
; jomjol_helper
|
||||||
jomjol_image_proc
|
; jomjol_wlan
|
||||||
jomjol_controlcamera
|
; jomjol_image_proc
|
||||||
jomjol_flowcontroll
|
; jomjol_controlcamera
|
||||||
jomjol_tfliteclass
|
; jomjol_flowcontroll
|
||||||
tflite-lib
|
; jomjol_tfliteclass
|
||||||
jomjol_fileserver_ota
|
; tflite-lib
|
||||||
jomjol_time_sntp
|
; jomjol_fileserver_ota
|
||||||
jomjol_logfile
|
; jomjol_time_sntp
|
||||||
jomjol_mqtt
|
; jomjol_logfile
|
||||||
jomjol_influxdb
|
; jomjol_mqtt
|
||||||
jomjol_controlGPIO
|
; jomjol_influxdb
|
||||||
|
; jomjol_controlGPIO
|
||||||
|
|
||||||
|
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "test_flow_postrocess_helper.h"
|
#include "test_flow_postrocess_helper.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
static const char *TAG = "FLOW CTRL POSTPROC TEST";
|
static const char *TAG = "POSTPROC TEST";
|
||||||
|
|
||||||
UnderTestPost* setUpClassFlowPostprocessing(t_CNNType digType, t_CNNType anaType)
|
UnderTestPost* setUpClassFlowPostprocessing(t_CNNType digType, t_CNNType anaType)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -522,4 +522,24 @@ void test_doFlowPP3() {
|
|||||||
delete undertestPost;
|
delete undertestPost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_doFlowPP4() {
|
||||||
|
|
||||||
|
// Fehler V13.0.4
|
||||||
|
// https://github.com/jomjol/AI-on-the-edge-device/issues/1503#issuecomment-1343335855
|
||||||
|
std::vector<float> digits = { 0.0, 0.0, 6.9, 1.0, 6.6}; // 716.0199 als falsches Ergebnis.
|
||||||
|
// Test ist nur erfolgreich mit Veränderung des AnalogdigitTransistionStart
|
||||||
|
std::vector<float> analogs = {9.9, 1.8, 6.6, 5.8};
|
||||||
|
const char* expected = "717.0165";
|
||||||
|
const char* expected_extended= "717.01658";
|
||||||
|
|
||||||
|
// extendResolution=false
|
||||||
|
std::string result = process_doFlow(analogs, digits, Digital100, false, false);
|
||||||
|
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
||||||
|
|
||||||
|
// checkConsistency=false und extendResolution=true
|
||||||
|
result = process_doFlow(analogs, digits, Digital100, false, true);
|
||||||
|
TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ void test_getReadoutRawString() {
|
|||||||
gen_analog->ROI.push_back(anaROI);
|
gen_analog->ROI.push_back(anaROI);
|
||||||
|
|
||||||
result = _undertestPost->flowAnalog->getReadoutRawString(0);
|
result = _undertestPost->flowAnalog->getReadoutRawString(0);
|
||||||
TEST_ASSERT_EQUAL_STRING("\t5.5", result.c_str());
|
TEST_ASSERT_EQUAL_STRING(",5.5", result.c_str());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "sdmmc_cmd.h"
|
#include "sdmmc_cmd.h"
|
||||||
#include "driver/sdmmc_host.h"
|
#include "driver/sdmmc_host.h"
|
||||||
#include "driver/sdmmc_defs.h"
|
#include "driver/sdmmc_defs.h"
|
||||||
static const char *TAG = "MAIN TEST";
|
//static const char *TAG = "MAIN TEST";
|
||||||
#define __SD_USE_ONE_LINE_MODE__
|
#define __SD_USE_ONE_LINE_MODE__
|
||||||
#include "server_GPIO.h"
|
#include "server_GPIO.h"
|
||||||
|
|
||||||
@@ -117,6 +117,7 @@ extern "C" void app_main()
|
|||||||
RUN_TEST(test_doFlowPP1);
|
RUN_TEST(test_doFlowPP1);
|
||||||
RUN_TEST(test_doFlowPP2);
|
RUN_TEST(test_doFlowPP2);
|
||||||
RUN_TEST(test_doFlowPP3);
|
RUN_TEST(test_doFlowPP3);
|
||||||
|
RUN_TEST(test_doFlowPP4);
|
||||||
|
|
||||||
// getReadoutRawString test
|
// getReadoutRawString test
|
||||||
RUN_TEST(test_getReadoutRawString);
|
RUN_TEST(test_getReadoutRawString);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "AI-on-the-edge",
|
"name": "AI-on-the-edge",
|
||||||
"version": "12.0.1",
|
"version": "13.0.5",
|
||||||
"funding_url": "https://www.paypal.com/donate?hosted_button_id=8TRSVYNYKDSWL",
|
"funding_url": "https://www.paypal.com/donate?hosted_button_id=8TRSVYNYKDSWL",
|
||||||
"new_install_prompt_erase": false,
|
"new_install_prompt_erase": false,
|
||||||
"builds": [
|
"builds": [
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
"offset": 32768
|
"offset": 32768
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "releases/download/v12.0.1/firmware.bin",
|
"path": "releases/download/v13.0.5/firmware.bin",
|
||||||
"offset": 65536
|
"offset": 65536
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
BIN
docs/releases/download/v12.0.5/firmware.bin
Normal file
BIN
docs/releases/download/v12.0.5/firmware.bin
Normal file
Binary file not shown.
BIN
docs/releases/download/v13.0.5/firmware.bin
Normal file
BIN
docs/releases/download/v13.0.5/firmware.bin
Normal file
Binary file not shown.
@@ -94,7 +94,7 @@ LogfileRetentionInDays = 3
|
|||||||
|
|
||||||
[System]
|
[System]
|
||||||
TimeZone = CET-1CEST,M3.5.0,M10.5.0/3
|
TimeZone = CET-1CEST,M3.5.0,M10.5.0/3
|
||||||
;TimeServer = undefined
|
;TimeServer = pool.ntp.org
|
||||||
;AutoAdjustSummertime = false
|
;AutoAdjustSummertime = false
|
||||||
;Hostname = undefined
|
;Hostname = undefined
|
||||||
SetupMode = true
|
SetupMode = true
|
||||||
|
|||||||
Reference in New Issue
Block a user