Rolling 20220928

This commit is contained in:
jomjol
2022-09-28 07:16:56 +02:00
parent 8c5f956dfe
commit 88a074dfa9
6 changed files with 39 additions and 51 deletions

View File

@@ -34,6 +34,7 @@ If anything bricks you can try to
- Update used libraries (`tflite`, `esp32-cam`, `esp-nn`, as of 20220924) - Update used libraries (`tflite`, `esp32-cam`, `esp-nn`, as of 20220924)
### Fixed ### Fixed
- [\#1092](https://github.com/jomjol/AI-on-the-edge-device/issues/1092) censor passwords in log outputs
- [\#1029](https://github.com/jomjol/AI-on-the-edge-device/issues/1029) wrong change of `checkDigitConsistency` now working like releases before `11.3.1` - [\#1029](https://github.com/jomjol/AI-on-the-edge-device/issues/1029) wrong change of `checkDigitConsistency` now working like releases before `11.3.1`
- Spelling corrections (**[cristianmitran](https://github.com/cristianmitran)**) - Spelling corrections (**[cristianmitran](https://github.com/cristianmitran)**)

View File

@@ -10,6 +10,8 @@
#include <time.h> #include <time.h>
#define __HIDE_PASSWORD
void ClassFlowMQTT::SetInitialParameter(void) void ClassFlowMQTT::SetInitialParameter(void)
{ {
uri = ""; uri = "";
@@ -117,12 +119,21 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
} }
} }
#ifdef __HIDE_PASSWORD
printf("Init Read with uri: %s, clientname: %s, user: %s, password: XXXXXX, maintopic: %s\n", uri.c_str(), clientname.c_str(), user.c_str(), mainerrortopic.c_str());
#else
printf("Init Read with uri: %s, clientname: %s, user: %s, password: %s, maintopic: %s\n", uri.c_str(), clientname.c_str(), user.c_str(), password.c_str(), mainerrortopic.c_str()); printf("Init Read with uri: %s, clientname: %s, user: %s, password: %s, maintopic: %s\n", uri.c_str(), clientname.c_str(), user.c_str(), password.c_str(), mainerrortopic.c_str());
#endif
if (!MQTTisConnected() && (uri.length() > 0) && (maintopic.length() > 0)) if (!MQTTisConnected() && (uri.length() > 0) && (maintopic.length() > 0))
{ {
printf("InitMQTTInit\n"); printf("InitMQTTInit\n");
mainerrortopic = maintopic + "/connection"; mainerrortopic = maintopic + "/connection";
#ifdef __HIDE_PASSWORD
printf("Init MQTT with uri: %s, clientname: %s, user: %s, password: XXXXXXXX, maintopic: %s\n", uri.c_str(), clientname.c_str(), user.c_str(), mainerrortopic.c_str());
#else
printf("Init MQTT with uri: %s, clientname: %s, user: %s, password: %s, maintopic: %s\n", uri.c_str(), clientname.c_str(), user.c_str(), password.c_str(), mainerrortopic.c_str()); printf("Init MQTT with uri: %s, clientname: %s, user: %s, password: %s, maintopic: %s\n", uri.c_str(), clientname.c_str(), user.c_str(), password.c_str(), mainerrortopic.c_str());
#endif
if (!MQTTInit(uri, clientname, user, password, mainerrortopic, keepAlive)) if (!MQTTInit(uri, clientname, user, password, mainerrortopic, keepAlive))
{ // Failed { // Failed
MQTTenable = false; MQTTenable = false;
@@ -179,27 +190,6 @@ string ClassFlowMQTT::GetMQTTMainTopic()
bool ClassFlowMQTT::doFlow(string zwtime) bool ClassFlowMQTT::doFlow(string zwtime)
{ {
// if (!MQTTenable) {
// LogFile.WriteToFile("MQTT not enabled!");
//
// // Try again to init it
// if (!MQTTInit(this->uri, this->clientname, this->user, this->password, this->mainerrortopic, keepAlive))
// { // Failed
// MQTTenable = false;
// return true; // We need to return true despite we failed, else it will retry 5x and then reboot!
// }
//
// if (!MQTTPublish(mainerrortopic, "connected", SetRetainFlag))
// { // Failed
// MQTTenable = false;
// return true; // We need to return true despite we failed, else it will retry 5x and then reboot!
// }
//
// LogFile.WriteToFile("MQTT is now enabled");
// MQTTenable = true;
// }
// Try sending mainerrortopic. If it fails, re-run init // Try sending mainerrortopic. If it fails, re-run init
if (!MQTTPublish(mainerrortopic, "connected", SetRetainFlag)) if (!MQTTPublish(mainerrortopic, "connected", SetRetainFlag))
{ // Failed { // Failed

View File

@@ -5,6 +5,8 @@
#include "mqtt_client.h" #include "mqtt_client.h"
#include "ClassLogFile.h" #include "ClassLogFile.h"
#define __HIDE_PASSWORD
static const char *TAG_INTERFACEMQTT = "interface_mqtt"; static const char *TAG_INTERFACEMQTT = "interface_mqtt";
std::map<std::string, std::function<void()>>* connectFunktionMap = NULL; std::map<std::string, std::function<void()>>* connectFunktionMap = NULL;
@@ -21,30 +23,6 @@ esp_mqtt_client_handle_t client = NULL;
bool MQTTPublish(std::string _key, std::string _content, int retained_flag){ bool MQTTPublish(std::string _key, std::string _content, int retained_flag){
// if (!client) {
// LogFile.WriteToFile("MQTT - client not initialized!");
// return false;
// }
// LogFile.WriteToFile("MQTT - client initialized!"); // Debug
//
// if (!mqtt_connected) {
// LogFile.WriteToFile("MQTT - Can not publish, not connected!");
// ESP_LOGW(TAG_INTERFACEMQTT, "Problem with Publish, client=%d, mqtt_connected %d", (int) client, (int) mqtt_connected);
// return false;
// }
// LogFile.WriteToFile("MQTT - connected!"); // Debug
/* if (client && mqtt_connected) {
LogFile.WriteToFile("MQTT - connected!"); // Debug
}
else { // init needed
if (!MQTTInit(this->uri, this->clientname, this->user, password, mainerrortopic, keepAlive)) // validate{
{ // Failed
return false;
}
}*/
int msg_id; int msg_id;
std::string zw; std::string zw;
msg_id = esp_mqtt_client_publish(client, _key.c_str(), _content.c_str(), 0, 1, retained_flag); msg_id = esp_mqtt_client_publish(client, _key.c_str(), _content.c_str(), 0, 1, retained_flag);
@@ -147,7 +125,12 @@ bool MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, st
if (_user.length() && _password.length()){ if (_user.length() && _password.length()){
mqtt_cfg.username = _user.c_str(); mqtt_cfg.username = _user.c_str();
mqtt_cfg.password = _password.c_str(); mqtt_cfg.password = _password.c_str();
#ifdef __HIDE_PASSWORD
ESP_LOGI(TAG_INTERFACEMQTT, "Connect to MQTT: %s, XXXXXXXX", mqtt_cfg.username);
#else
ESP_LOGI(TAG_INTERFACEMQTT, "Connect to MQTT: %s, %s", mqtt_cfg.username, mqtt_cfg.password); ESP_LOGI(TAG_INTERFACEMQTT, "Connect to MQTT: %s, %s", mqtt_cfg.username, mqtt_cfg.password);
#endif
}; };
MQTTdestroy(); MQTTdestroy();

View File

@@ -8,8 +8,6 @@
bool MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, std::string _password, std::string _LWTContext, int _keepalive); bool MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, std::string _password, std::string _LWTContext, int _keepalive);
void MQTTdestroy(); void MQTTdestroy();
//void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user = "", std::string _password = "");
bool MQTTPublish(std::string _key, std::string _content, int retained_flag = 1); // retained Flag as Standart bool MQTTPublish(std::string _key, std::string _content, int retained_flag = 1); // retained Flag as Standart
bool MQTTisConnected(); bool MQTTisConnected();

View File

@@ -20,6 +20,8 @@
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
#define __HIDE_PASSWORD
#define EXAMPLE_ESP_MAXIMUM_RETRY 1000 #define EXAMPLE_ESP_MAXIMUM_RETRY 1000
@@ -247,11 +249,17 @@ void wifi_init_sta(const char *_ssid, const char *_password, const char *_hostna
/* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually /* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
* happened. */ * happened. */
if (bits & WIFI_CONNECTED_BIT) { if (bits & WIFI_CONNECTED_BIT) {
ESP_LOGI(TAG, "connected to ap SSID: %s, password:%s", #ifdef __HIDE_PASSWORD
_ssid, _password); ESP_LOGI(TAG, "connected to ap SSID: %s, password: XXXXXXX", _ssid);
#else
ESP_LOGI(TAG, "connected to ap SSID: %s, password: %s", _ssid, _password);
#endif
} else if (bits & WIFI_FAIL_BIT) { } else if (bits & WIFI_FAIL_BIT) {
ESP_LOGI(TAG, "Failed to connect to SSID: %s, password:%s", #ifdef __HIDE_PASSWORD
_ssid, _password); ESP_LOGI(TAG, "Failed to connect to SSID: %s, password: XXXXXXXX", _ssid);
#else
ESP_LOGI(TAG, "Failed to connect to SSID: %s, password: %s", _ssid, _password);
#endif
} else { } else {
ESP_LOGE(TAG, "UNEXPECTED EVENT"); ESP_LOGE(TAG, "UNEXPECTED EVENT");
} }

View File

@@ -34,6 +34,9 @@ extern const char* GIT_REV;
extern const char* GIT_BRANCH; extern const char* GIT_BRANCH;
extern const char* BUILD_TIME; extern const char* BUILD_TIME;
#define __HIDE_PASSWORD
// #include "jomjol_WS2812Slow.h" // #include "jomjol_WS2812Slow.h"
#include "SmartLeds.h" #include "SmartLeds.h"
@@ -165,7 +168,12 @@ extern "C" void app_main(void)
LoadWlanFromFile("/sdcard/wlan.ini", ssid, passwd, hostname, ip, gateway, netmask, dns); LoadWlanFromFile("/sdcard/wlan.ini", ssid, passwd, hostname, ip, gateway, netmask, dns);
if (ssid != NULL && passwd != NULL) if (ssid != NULL && passwd != NULL)
#ifdef __HIDE_PASSWORD
printf("\nWLan: %s, XXXXXX\n", ssid);
#else
printf("\nWLan: %s, %s\n", ssid, passwd); printf("\nWLan: %s, %s\n", ssid, passwd);
#endif
else else
printf("No SSID and PASSWORD set!!!"); printf("No SSID and PASSWORD set!!!");