reloxx13 / Sonoff-Tasmota-Modified

Provide ESP8266 based itead Sonoff with Web, MQTT and OTA firmware using Arduino IDE

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ideas

reloxx13 opened this issue · comments

Hi @reloxx13

The issues tab in your Tasmota_Modified is off.

I just want to give you other ideas for your modified Tasmota version that arendst did not add to the main version:

1) Automatic set of MQTT_MAX_PACKET_SIZE (on compiling time) so there is no need of modifying another library.
EDIT: Dont work

From line 42 in original Sonoff.ino v5.12.0b:

// Max message size calculated by PubSubClient is (MQTT_MAX_PACKET_SIZE < 5 + 2 + strlen(topic) + plength)
#if (MQTT_MAX_PACKET_SIZE -TOPSZ -7) < MIN_MESSZ  // If the max message size is too small, throw an error at compile time. See PubSubClient.cpp line 359
  #error "MQTT_MAX_PACKET_SIZE is too small in libraries/PubSubClient/src/PubSubClient.h, increase it to at least 1000"
#endif

change that with:

// Max message size calculated by PubSubClient is (MQTT_MAX_PACKET_SIZE < 5 + 2 + strlen(topic) + plength)
#if (MQTT_MAX_PACKET_SIZE -TOPSZ -7) < MIN_MESSZ  // If the max message size is too small, throw a warning at compile time. See PubSubClient.cpp line 359
  #warning "MQTT_MAX_PACKET_SIZE is too small in libraries/PubSubClient/src/PubSubClient.h, increasing it to 1000"
  #undef MQTT_MAX_PACKET_SIZE
  #define MQTT_MAX_PACKET_SIZE 1000
#endif

2) Automatic order of words for Device Title (on compiling time) depending on the language chosen.

From line 101 in original webserver.ino v5.12.0b:

#ifdef LANGUAGE_MODULE_NAME
  "<div style='text-align:center;'><h3>" D_MODULE " {ha</h3><h2>{h}</h2></div>";
#else
  "<div style='text-align:center;'><h3>{ha " D_MODULE "</h3><h2>{h}</h2></div>";
#endif

change that with:

#if MY_LANGUAGE == es-AR || MY_LANGUAGE == fr-FR || MY_LANGUAGE == it-IT
  "<div style='text-align:center;'><h3>" D_MODULE " {ha</h3><h2>{h}</h2></div>";
#else
  "<div style='text-align:center;'><h3>{ha " D_MODULE "</h3><h2>{h}</h2></div>";
#endif

3) Solve Security issue: MQTT Server Password is being sent to the config web page and can be seen using chrome ShowPassword Extension.

From line 874 in original webserver.ino v5.12.0b:

page.replace(F("{m5"), (Settings.mqtt_pwd[0] == '\0')?"0":Settings.mqtt_pwd);

change that with:

page.replace(F("{m5"), "**********");

AND

From line 1062 in original webserver.ino v5.12.0b:

strlcpy(Settings.mqtt_pwd, (!strlen(tmp)) ? MQTT_PASS : (!strcmp(tmp,"0")) ? "" : tmp, sizeof(Settings.mqtt_pwd));

change that with:

strlcpy(Settings.mqtt_pwd, (!strlen(tmp)) ? "" : (strchr(tmp,'*')) ? Settings.mqtt_pwd : tmp, sizeof(Settings.mqtt_pwd));

4) Add available options for Log Level on comments.

From line 63 in original user_config.h v5.12.0b add comments:

#define SYS_LOG_LEVEL          LOG_LEVEL_NONE    // [SysLog]  LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE
#define SERIAL_LOG_LEVEL       LOG_LEVEL_NONE    // [SerialLog]  LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE
#define WEB_LOG_LEVEL          LOG_LEVEL_INFO    // [WebLog]  LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE

Other ideas I'm working on:

1-If STA_SSID1 and STA_SSID2 are empty, and there is no SSID configuration saved on EEPROM (or coming from a config reset) the WIFI_CONFIG_TOOL change to be WIFI_MANAGER.
So, after a successful wifi setup, WIFI_CONFIG_TOOL change to the one set on user_config.h

The idea behind this is: When you flash a new Sonoff, it will ask for wifi credentials. After it connects, it can change automatically to WIFI_RETRY or WIFI_WAIT for reconnecting when losing connection.

I know that WIFI_MANAGER can be set on user_config.h, and then, with SonWEB, change it to WIFI_RETRY. But the idea is to be automatic.

Beside, if then you change your wifi credentials, you can push 4 times the button1 (at any time) and activate the WIFI_MANAGER

2-Trying to solve the Bug that when the MQTT server is down, Tasmota dont respond to button pressings.
PubSubClient Library is the one with the Lag. The author said that when MQTT is down the lag is on the wificlient library. So, the people from the esp library recommend use martin-ger/esp_mqtt that don't make that lag because it uses callbacks.
So, i'm testing if changing the library can be a solution.
EDIT: NOW SOLVED Tasmota Issue #1992

3-Adding KNX protocol support.
EDIT: NOW WORKING on Sonoff-Tasmota_KNX, when it reaches a working level I can add the driver to this one if you like.

by @ascillato

Hi @reloxx13,

What about doing the following changes?

1) Automatic set of MQTT_MAX_PACKET_SIZE (on compiling time) so there is no need of modifying another library Tasmota Issue #1634.

Changing:

https://github.com/reloxx13/Sonoff-Tasmota-Modified/blob/modified/sonoff/xdrv_00_mqtt.ino#L70-L73

for:

// Max message size calculated by PubSubClient is (MQTT_MAX_PACKET_SIZE < 5 + 2 + strlen(topic) + plength)
#if (MQTT_MAX_PACKET_SIZE -TOPSZ -7) < MIN_MESSZ  // If the max message size is too small, throw a warning at compile time. See PubSubClient.cpp line 359
  #warning "MQTT_MAX_PACKET_SIZE is too small in libraries/PubSubClient/src/PubSubClient.h, increasing it to 1000"
  #undef MQTT_MAX_PACKET_SIZE
  #define MQTT_MAX_PACKET_SIZE 1000
#endif

2) Solving the problem with MQTT and slow response as explained on Tasmota Issue #1992.

Changing:

https://github.com/reloxx13/Sonoff-Tasmota-Modified/blob/modified/sonoff/user_config.h#L79-L83

for:

//#define MQTT_LIBRARY_TYPE      1                 // Use PubSubClient library
// Alternative MQTT driver does not block network when MQTT server is unavailable. No TLS support
#define MQTT_LIBRARY_TYPE      2                 // Use TasmotaMqtt library (+4k4 code, +4k mem) - non-TLS only
// Alternative MQTT driver does not block network when MQTT server is unavailable. No TLS support
//#define MQTT_LIBRARY_TYPE      3                 // Use (patched) esp-mqtt-arduino library (+4k8 code, +4k mem) - non-TLS only

yup, its in, thank you :)

After some tests, I found that the code

// Max message size calculated by PubSubClient is (MQTT_MAX_PACKET_SIZE < 5 + 2 + strlen(topic) + plength)
#if (MQTT_MAX_PACKET_SIZE -TOPSZ -7) < MIN_MESSZ  // If the max message size is too small, throw a warning at compile time. See PubSubClient.cpp line 359
  #warning "MQTT_MAX_PACKET_SIZE is too small in libraries/PubSubClient/src/PubSubClient.h, increasing it to 1000"
  #undef MQTT_MAX_PACKET_SIZE
  #define MQTT_MAX_PACKET_SIZE 1000
#endif

is NOT working. The define variables are not global, so that modification was not reaching the library.

So, the code should be the original:

// Max message size calculated by PubSubClient is (MQTT_MAX_PACKET_SIZE < 5 + 2 + strlen(topic) + plength)
#if (MQTT_MAX_PACKET_SIZE -TOPSZ -7) < MIN_MESSZ  // If the max message size is too small, throw an error at compile time. See PubSubClient.cpp line 359
  #error "MQTT_MAX_PACKET_SIZE is too small in libraries/PubSubClient/src/PubSubClient.h, increase it to at least 1000"
#endif

Made 3393b51 for that.

As explained on arendst#2130, language should be better to be:

From original webserver.ino:

#ifdef LANGUAGE_MODULE_NAME
  "<div style='text-align:center;'><h3>" D_MODULE " {ha</h3><h2>{h}</h2></div>";
#else
  "<div style='text-align:center;'><h3>{ha " D_MODULE "</h3><h2>{h}</h2></div>";
#endif

to:

  "<div style='text-align:center;'><h3>{ha: " D_MODULE "</h3><h2>{h}</h2></div>";

Made dd24a18 for that.

EDIT: Reversed change to Original Tasmota because in actual version this issue is solved.