Skip to content

Commit

Permalink
Merge branch 'rolling' (#1559)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* Prevent auto restart on cam framebuffer init error (#1522)

* use correct log level

* revert autorestart on camera framebuffer init error

* .

Co-authored-by: CaCO3 <[email protected]>

* #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 commit 4f51ec7.

* 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 commit f68695a, reversing
changes made to a096cf7.

* Revert "test"

This reverts commit a096cf7.

* revert testing

* #1524 - ensure the result of ZeigerEvalHybridNeu is <10

* Fix late digit transition #1503

Co-authored-by: github-actions <[email protected]>

* fix frozen time in datafile on error (#1534)

Co-authored-by: CaCO3 <[email protected]>

* log NTP server name (#1497)

* log NTP server name

* .

* .

* replace calls to /wasserzaehler.html with calls to /value (#1469)

Co-authored-by: CaCO3 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* Prevent auto restart on cam framebuffer init error (#1522)

* use correct log level

* revert autorestart on camera framebuffer init error

* .

Co-authored-by: CaCO3 <[email protected]>

* #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 commit 4f51ec7.

* 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 commit f68695a, reversing
changes made to a096cf7.

* Revert "test"

This reverts commit a096cf7.

* revert testing

* #1524 - ensure the result of ZeigerEvalHybridNeu is <10

* Fix late digit transition #1503

Co-authored-by: github-actions <[email protected]>

* only use sntp_getservername() after init sntp

* set default NTP server on dnew installations

Co-authored-by: CaCO3 <[email protected]>
Co-authored-by: Ralf Rachinger <[email protected]>
Co-authored-by: jomjol <[email protected]>
Co-authored-by: github-actions <[email protected]>
Co-authored-by: parhedberg <[email protected]>
Co-authored-by: Pär Hedberg <[email protected]>
Co-authored-by: Christopher Fenner <[email protected]>
Co-authored-by: Frank Haverland <[email protected]>

* Renamed variables and added debug log (#1537)

* add debug logs

* renamed variables

* renamed TAGs, added flow status logging

* .

* .

Co-authored-by: CaCO3 <[email protected]>

* 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 <[email protected]>
Co-authored-by: Pär Hedberg <[email protected]>
Co-authored-by: jomjol <[email protected]>
Co-authored-by: Christopher Fenner <[email protected]>
Co-authored-by: CaCO3 <[email protected]>
Co-authored-by: Frank Haverland <[email protected]>
Co-authored-by: github-actions <[email protected]>
Co-authored-by: Ralf Rachinger <[email protected]>
Co-authored-by: Nicolas Liaudat <[email protected]>
  • Loading branch information
10 people authored Dec 11, 2022
1 parent f4d0865 commit 304b9e0
Show file tree
Hide file tree
Showing 36 changed files with 317 additions and 174 deletions.
15 changes: 12 additions & 3 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

## [Unreleased]

## [13.0.5] - 2022-12-06

**Home Assistant MQTT Discovery Support**

### Update Procedure
Expand Down Expand Up @@ -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: 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.5**:
- log NTP server name
- Improved log messages
- Various preparations for next release

### Fixed

Expand All @@ -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.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.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

Expand Down
36 changes: 30 additions & 6 deletions code/components/jomjol_controlGPIO/server_GPIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
#include "ClassLogFile.h"
#include "configFile.h"
#include "Helper.h"
#include "interface_mqtt.h"
#ifdef ENABLE_MQTT
#include "interface_mqtt.h"
#endif //ENABLE_MQTT

static const char *TAG = "GPIO";
QueueHandle_t gpio_queue_handle = NULL;
Expand Down Expand Up @@ -83,12 +85,14 @@ static void gpioHandlerTask(void *arg) {
}

void GpioPin::gpioInterrupt(int value) {
#ifdef ENABLE_MQTT
if (_mqttTopic != "") {
ESP_LOGD(TAG, "gpioInterrupt %s %d", _mqttTopic.c_str(), value);

MQTTPublish(_mqttTopic, value ? "true" : "false");
currentState = value;
MQTTPublish(_mqttTopic, value ? "true" : "false");
}
#endif //ENABLE_MQTT
currentState = value;
}

void GpioPin::init()
Expand All @@ -114,10 +118,12 @@ void GpioPin::init()
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))) {
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);
}
#endif //ENABLE_MQTT
}

bool GpioPin::getValue(std::string* errorText)
Expand All @@ -138,21 +144,26 @@ void GpioPin::setValue(bool value, gpio_set_source setSource, std::string* error
} else {
gpio_set_level(_gpio, value);

#ifdef ENABLE_MQTT
if ((_mqttTopic != "") && (setSource != GPIO_SET_SOURCE_MQTT)) {
MQTTPublish(_mqttTopic, value ? "true" : "false");
}
#endif //ENABLE_MQTT
}
}

void GpioPin::publishState() {
int newState = gpio_get_level(_gpio);
if (newState != currentState) {
ESP_LOGD(TAG,"publish state of GPIO %d new state %d", _gpio, newState);
#ifdef ENABLE_MQTT
MQTTPublish(_mqttTopic, newState ? "true" : "false");
#endif //ENABLE_MQTT
currentState = newState;
}
}

#ifdef ENABLE_MQTT
bool GpioPin::handleMQTT(std::string, char* data, int data_len) {
ESP_LOGD(TAG, "GpioPin::handleMQTT data %.*s", data_len, data);

Expand All @@ -174,7 +185,7 @@ bool GpioPin::handleMQTT(std::string, char* data, int data_len) {

return (errorText == "");
}

#endif //ENABLE_MQTT

esp_err_t callHandleHttpRequest(httpd_req_t *req)
{
Expand Down Expand Up @@ -236,8 +247,10 @@ void GpioHandler::init()
it->second->init();
}

#ifdef ENABLE_MQTT
std::function<void()> f = std::bind(&GpioHandler::handleMQTTconnect, this);
MQTTregisterConnectFunction("gpio-handler", f);
#endif //ENABLE_MQTT

if (xHandleTaskGpio == NULL) {
gpio_queue_handle = xQueueCreate(10,sizeof(GpioResult));
Expand All @@ -261,7 +274,7 @@ void GpioHandler::taskHandler() {
}
}


#ifdef ENABLE_MQTT
void GpioHandler::handleMQTTconnect()
{
if (gpioMap != NULL) {
Expand All @@ -271,9 +284,12 @@ void GpioHandler::handleMQTTconnect()
}
}
}
#endif //ENABLE_MQTT

void GpioHandler::deinit() {
#ifdef ENABLE_MQTT
MQTTunregisterConnectFunction("gpio-handler");
#endif //ENABLE_MQTT
clear();
if (xHandleTaskGpio != NULL) {
vTaskDelete(xHandleTaskGpio);
Expand Down Expand Up @@ -316,14 +332,15 @@ bool GpioHandler::readConfig()

// ESP_LOGD(TAG, "readConfig - Start 3");

#ifdef ENABLE_MQTT
// std::string mainTopicMQTT = "";
std::string mainTopicMQTT = GetMQTTMainTopic();
if (mainTopicMQTT.length() > 0)
{
mainTopicMQTT = mainTopicMQTT + "/GPIO";
ESP_LOGD(TAG, "MAINTOPICMQTT found");
}

#endif // ENABLE_MQTT
bool registerISR = false;
while (configFile.getNextLine(&line, disabledLine, eof) && !configFile.isNewParagraph(line))
{
Expand All @@ -345,15 +362,21 @@ bool GpioHandler::readConfig()
gpio_pin_mode_t pinMode = resolvePinMode(toLower(zerlegt[1]));
gpio_int_type_t intType = resolveIntType(toLower(zerlegt[2]));
uint16_t dutyResolution = (uint8_t)atoi(zerlegt[3].c_str());
#ifdef ENABLE_MQTT
bool mqttEnabled = toLower(zerlegt[4]) == "true";
#endif // ENABLE_MQTT
bool httpEnabled = toLower(zerlegt[5]) == "true";
char gpioName[100];
if (zerlegt.size() >= 7) {
strcpy(gpioName, trim(zerlegt[6]).c_str());
} else {
sprintf(gpioName, "GPIO%d", gpioNr);
}
#ifdef ENABLE_MQTT
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);
(*gpioMap)[gpioNr] = gpioPin;

Expand Down Expand Up @@ -682,3 +705,4 @@ GpioHandler* gpio_handler_get()
{
return gpioHandler;
}

7 changes: 6 additions & 1 deletion code/components/jomjol_controlGPIO/server_GPIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class GpioPin {
void init();
bool getValue(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);
#endif //ENABLE_MQTT
void publishState();
void gpioInterrupt(int value);
gpio_int_type_t getInterruptType() { return _interruptType; }
Expand Down Expand Up @@ -77,7 +79,9 @@ class GpioHandler {
void gpioInterrupt(GpioResult* gpioResult);
void flashLightEnable(bool value);
bool isEnabled() { return _isEnabled; }
#ifdef ENABLE_MQTT
void handleMQTTconnect();
#endif //ENABLE_MQTT

private:
std::string _configFile;
Expand Down Expand Up @@ -109,4 +113,5 @@ GpioHandler* gpio_handler_get();



#endif //SERVER_GPIO_H
#endif //SERVER_GPIO_H

20 changes: 14 additions & 6 deletions code/components/jomjol_fileserver_ota/server_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ extern "C" {
#include "server_tflite.h"

#include "server_help.h"
#include "interface_mqtt.h"
#ifdef ENABLE_MQTT
#include "interface_mqtt.h"
#endif //ENABLE_MQTT
#include "server_GPIO.h"

#include "Helper.h"
Expand Down Expand Up @@ -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);

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 */
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
return ESP_FAIL;
Expand Down Expand Up @@ -361,7 +363,7 @@ static esp_err_t send_datafile(httpd_req_t *req, bool send_full_file)

fd = OpenFileAndWait(currentfilename.c_str(), "r");
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 */
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
return ESP_FAIL;
Expand Down Expand Up @@ -446,7 +448,7 @@ static esp_err_t send_logfile(httpd_req_t *req, bool send_full_file)

fd = OpenFileAndWait(currentfilename.c_str(), "r");
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 */
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
return ESP_FAIL;
Expand Down Expand Up @@ -566,15 +568,15 @@ static esp_err_t download_get_handler(httpd_req_t *req)

/* If file not present on SPIFFS check if URI
* 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 */
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
return ESP_FAIL;
}

fd = OpenFileAndWait(filepath, "r");
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 */
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, get404());
return ESP_FAIL;
Expand Down Expand Up @@ -831,6 +833,12 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
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) {
ESP_LOGE(TAG, "File does not exist: %s", filename);
/* Respond with 400 Bad Request */
Expand Down
2 changes: 1 addition & 1 deletion code/components/jomjol_flowcontroll/ClassFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <string.h>
#include "esp_log.h"

static const char *TAG = "FLOW CLASS";
static const char *TAG = "CLASS";


void ClassFlow::SetInitialParameter(void)
Expand Down
2 changes: 1 addition & 1 deletion code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "ClassLogFile.h"


static const char *TAG = "FLOW ALIGN";
static const char *TAG = "ALIGN";

bool AlignmentExtendedDebugging = true;

Expand Down
Loading

0 comments on commit 304b9e0

Please sign in to comment.