From ad4a7e91acd3e7eccce345b50269b4604a356fb9 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 22 Dec 2019 15:23:52 +0100 Subject: [PATCH 1/2] Add support for max 150 characters Add support for max 150 characters in most command parameter strings (#3686, #4754) --- RELEASENOTES.md | 2 ++ tasmota/CHANGELOG.md | 2 ++ tasmota/settings.h | 2 +- tasmota/settings.ino | 2 +- tasmota/support_command.ino | 2 +- tasmota/support_tasmota.ino | 2 +- tasmota/tasmota.h | 4 ++-- tasmota/tasmota.ino | 6 +++--- tasmota/xdrv_01_webserver.ino | 14 +++++++------- tasmota/xdrv_02_mqtt.ino | 4 ++-- tasmota/xdrv_10_scripter.ino | 14 +++++++------- 11 files changed, 29 insertions(+), 25 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index bf21cf32b..7f07caaaa 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -49,3 +49,5 @@ The following binary downloads have been compiled with ESP8266/Arduino library c ### Version 8.0.0.1 - Change Settings text handling allowing variable length text within a total text pool of 699 characters +- Change Smoother ``Fade`` using 100Hz instead of 20Hz animation (#7179) +- Add support for max 150 characters in command parameter strings (#3686, #4754) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index c7d34cbea..6930b6ab4 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -4,12 +4,14 @@ - Change Settings text handling allowing variable length text within a total text pool of 699 characters - Change Smoother ``Fade`` using 100Hz instead of 20Hz animation (#7179) +- Add support for max 150 characters in most command parameter strings (#3686, #4754) ## Released ### 7.2.0 20191221 - Release +- Change basic version string to lite (#7291) - Fix Arduino IDE compile error (#7277) - Fix restore ShutterAccuracy, MqttLog, WifiConfig, WifiPower and SerialConfig (#7281) - Fix no AP on initial install (#7282) diff --git a/tasmota/settings.h b/tasmota/settings.h index 0b3990578..c55d85b34 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -419,7 +419,7 @@ struct SYSCFG { unsigned long weight_calibration; // 7C4 unsigned long energy_frequency_calibration; // 7C8 also used by HX711 to save last weight uint16_t web_refresh; // 7CC - char mems[MAX_RULE_MEMS][10]; // 7CE - Used by scripter as script_pram + char mems[5][10]; // 7CE - Used by scripter as script_pram char rules[MAX_RULE_SETS][MAX_RULE_SIZE]; // 800 uses 512 bytes in v5.12.0m, 3 x 512 bytes in v5.14.0b diff --git a/tasmota/settings.ino b/tasmota/settings.ino index a1da16764..b0241f9fb 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -533,7 +533,7 @@ bool SettingsUpdateText(uint32_t index, const char* replace_me) int too_long = (char_len + diff) - settings_text_size; if (too_long > 0) { -// AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_CONFIG "Text too long by %d char(s)"), too_long); + AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_CONFIG "Text overflow by %d char(s)"), too_long); return false; // Replace text too long } diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index b8fbd4a7a..265926b59 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -326,7 +326,7 @@ void CmndStatus(void) uint32_t option = STAT; char stemp[200]; - char stemp2[100]; + char stemp2[TOPSZ]; // Workaround MQTT - TCP/IP stack queueing when SUB_PREFIX = PUB_PREFIX if (!strcmp(SettingsText(SET_MQTTPREFIX1), SettingsText(SET_MQTTPREFIX2)) && (!payload)) { option++; } // TELE diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 900ba3dd4..c649d9379 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -546,7 +546,7 @@ void MqttShowPWMState(void) void MqttShowState(void) { - char stemp1[33]; + char stemp1[TOPSZ]; ResponseAppendTime(); ResponseAppend_P(PSTR(",\"" D_JSON_UPTIME "\":\"%s\",\"UptimeSec\":%u"), GetUptime().c_str(), UpTime()); diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index c93c3ea9e..d68907185 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -70,10 +70,10 @@ const uint8_t MAX_XSNS_DRIVERS = 96; // Max number of allowed sensor driv const uint8_t MAX_I2C_DRIVERS = 96; // Max number of allowed i2c drivers const uint8_t MAX_SHUTTERS = 4; // Max number of shutters const uint8_t MAX_PCF8574 = 8; // Max number of PCF8574 devices -const uint8_t MAX_RULE_MEMS = 5; // Max number of saved vars const uint8_t MAX_RULE_SETS = 3; // Max number of rule sets of size 512 characters const uint16_t MAX_RULE_SIZE = 512; // Max number of characters in rules +const uint8_t MAX_RULE_MEMS = 5; // Max number of saved vars const uint8_t MAX_HUE_DEVICES = 15; // Max number of Philips Hue device per emulation const char MQTT_TOKEN_PREFIX[] PROGMEM = "%prefix%"; // To be substituted by mqtt_prefix[x] @@ -118,7 +118,7 @@ const uint8_t OTA_ATTEMPTS = 5; // Number of times to try fetching t const uint16_t INPUT_BUFFER_SIZE = 520; // Max number of characters in (serial and http) command buffer const uint16_t FLOATSZ = 16; // Max number of characters in float result from dtostrfd (max 32) const uint16_t CMDSZ = 24; // Max number of characters in command -const uint16_t TOPSZ = 100; // Max number of characters in topic string +const uint16_t TOPSZ = 151; // Max number of characters in topic string const uint16_t LOGSZ = 700; // Max number of characters in log const uint16_t MIN_MESSZ = 893; // Min number of characters in MQTT message diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 67be9d35f..e80331366 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -68,7 +68,7 @@ // Structs #include "settings.h" -const char kCodeImage[] PROGMEM = "tasmota|minimal|sensors|knx|basic|display|ir"; +const char kCodeImage[] PROGMEM = "tasmota|minimal|sensors|knx|lite|display|ir"; /*********************************************************************************************\ * Global variables @@ -161,8 +161,8 @@ StateBitfield global_state; // Global states (currently Wifi and char my_version[33]; // Composed version string char my_image[33]; // Code image and/or commit char my_hostname[33]; // Composed Wifi hostname -char mqtt_client[33]; // Composed MQTT Clientname -char mqtt_topic[33]; // Composed MQTT topic +char mqtt_client[TOPSZ]; // Composed MQTT Clientname +char mqtt_topic[TOPSZ]; // Composed MQTT topic char serial_in_buffer[INPUT_BUFFER_SIZE]; // Receive buffer char mqtt_data[MESSZ]; // MQTT publish buffer and web page ajax buffer char log_data[LOGSZ]; // Logging diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 8aece2be8..104e71f67 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -1694,7 +1694,7 @@ void HandleWifiConfiguration(void) void WifiSaveSettings(void) { - char tmp[100]; // Max length is currently 65 + char tmp[TOPSZ]; // Max length is currently 150 WebGetArg("h", tmp, sizeof(tmp)); SettingsUpdateText(SET_HOSTNAME, (!strlen(tmp)) ? WIFI_HOSTNAME : tmp); @@ -1757,7 +1757,7 @@ void HandleLoggingConfiguration(void) void LoggingSaveSettings(void) { - char tmp[100]; // Max length is currently 33 + char tmp[TOPSZ]; // Max length is currently 33 WebGetArg("l0", tmp, sizeof(tmp)); SetSeriallog((!strlen(tmp)) ? SERIAL_LOG_LEVEL : atoi(tmp)); @@ -1843,7 +1843,7 @@ void HandleOtherConfiguration(void) void OtherSaveSettings(void) { - char tmp[128]; + char tmp[TOPSZ]; char webindex[5]; char friendlyname[TOPSZ]; @@ -1890,7 +1890,7 @@ void HandleBackupConfiguration(void) WiFiClient myClient = WebServer->client(); WebServer->setContentLength(sizeof(Settings)); - char attachment[100]; + char attachment[TOPSZ]; // char friendlyname[TOPSZ]; // snprintf_P(attachment, sizeof(attachment), PSTR("attachment; filename=Config_%s_%s.dmp"), NoAlNumToUnderscore(friendlyname, SettingsText(SET_FRIENDLYNAME1)), my_version); @@ -2095,12 +2095,12 @@ void HandleUpgradeFirmwareStart(void) { if (!HttpCheckPriviledgedAccess()) { return; } - char command[128]; // OtaUrl + char command[TOPSZ + 10]; // OtaUrl AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPGRADE_STARTED)); WifiConfigCounter(); - char otaurl[101]; + char otaurl[TOPSZ]; WebGetArg("o", otaurl, sizeof(otaurl)); if (strlen(otaurl)) { snprintf_P(command, sizeof(command), PSTR(D_CMND_OTAURL " %s"), otaurl); @@ -2637,7 +2637,7 @@ int WebSend(char *buffer) if (user) { user = strtok_r(user, ":", &password); // user = |admin|, password = |joker| if (user && password) { - char userpass[128]; + char userpass[200]; snprintf_P(userpass, sizeof(userpass), PSTR("user=%s&password=%s&"), user, password); url += userpass; // url = |http://192.168.178.86/cm?user=admin&password=joker&| } diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index 47838e223..f9ff3e67d 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -1190,7 +1190,7 @@ void HandleMqttConfiguration(void) return; } - char str[33]; + char str[TOPSZ]; WSContentStart_P(S_CONFIGURE_MQTT); WSContentSendStyle(); @@ -1209,7 +1209,7 @@ void HandleMqttConfiguration(void) void MqttSaveSettings(void) { - char tmp[100]; + char tmp[TOPSZ]; char stemp[TOPSZ]; char stemp2[TOPSZ]; diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 68df13984..da63dbb22 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -56,7 +56,7 @@ keywords if then else endif, or, and are better readable for beginners (others m #define SCRIPT_MAXSSIZE 48 #define SCRIPT_EOL '\n' #define SCRIPT_FLOAT_PRECISION 2 -#define SCRIPT_MAXPERM (MAX_RULE_MEMS*10)-4/sizeof(float) +#define SCRIPT_MAXPERM (5*10)-4/sizeof(float) #define MAX_SCRIPT_SIZE MAX_RULE_SIZE*MAX_RULE_SETS // offsets epoch readings by 1.1.2019 00:00:00 to fit into float with second resolution @@ -1041,7 +1041,7 @@ char *isvar(char *lp, uint8_t *vtype,struct T_INDEX *tind,float *fp,char *sp,Jso if (sp) strlcpy(sp,str_value,SCRIPT_MAXSSIZE); return lp+len; } - + } else { if (fp) { if (!strncmp(vn.c_str(),"Epoch",5)) { @@ -1575,7 +1575,7 @@ chknext: case 'r': if (!strncmp(vname,"ram",3)) { - fvar=glob_script_mem.script_mem_size+(glob_script_mem.script_size)+(MAX_RULE_MEMS*10); + fvar=glob_script_mem.script_mem_size+(glob_script_mem.script_size)+(5*10); goto exit; } break; @@ -2995,7 +2995,7 @@ void ScripterEvery100ms(void) { if (fast_script==99) Run_Scripter(">F",2,0); } -//mems[MAX_RULE_MEMS] is 50 bytes in 6.5 +//mems[5] is 50 bytes in 6.5 // can hold 11 floats or floats + strings // should report overflow later void Scripter_save_pvars(void) { @@ -3007,7 +3007,7 @@ void Scripter_save_pvars(void) { if (vtp[count].bits.is_permanent && !vtp[count].bits.is_string) { uint8_t index=vtp[count].index; mlen+=sizeof(float); - if (mlen>MAX_RULE_MEMS*10) { + if (mlen>5*10) { vtp[count].bits.is_permanent=0; return; } @@ -3021,7 +3021,7 @@ void Scripter_save_pvars(void) { char *sp=glob_script_mem.glob_snp+(index*glob_script_mem.max_ssize); uint8_t slen=strlen(sp); mlen+=slen+1; - if (mlen>MAX_RULE_MEMS*10) { + if (mlen>5*10) { vtp[count].bits.is_permanent=0; return; } @@ -4755,7 +4755,7 @@ bool Xdrv10(uint8_t function) glob_script_mem.script_size=MAX_SCRIPT_SIZE; glob_script_mem.flags=0; glob_script_mem.script_pram=(uint8_t*)Settings.mems[0]; - glob_script_mem.script_pram_size=MAX_RULE_MEMS*10; + glob_script_mem.script_pram_size=5*10; #ifdef USE_BUTTON_EVENT for (uint32_t cnt=0;cnt Date: Sun, 22 Dec 2019 15:36:20 +0100 Subject: [PATCH 2/2] Change max number of rule ``Mem``s to 16 Change max number of rule ``Mem``s from 5 to 16 (#4933) --- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 1 + tasmota/tasmota.h | 2 +- tasmota/xdrv_10_rules.ino | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 7f07caaaa..b2bff6a7a 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -50,4 +50,5 @@ The following binary downloads have been compiled with ESP8266/Arduino library c - Change Settings text handling allowing variable length text within a total text pool of 699 characters - Change Smoother ``Fade`` using 100Hz instead of 20Hz animation (#7179) +- Change max number of rule ``Mem``s from 5 to 16 (#4933) - Add support for max 150 characters in command parameter strings (#3686, #4754) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 6930b6ab4..1c99c7223 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -4,6 +4,7 @@ - Change Settings text handling allowing variable length text within a total text pool of 699 characters - Change Smoother ``Fade`` using 100Hz instead of 20Hz animation (#7179) +- Change max number of rule ``Mem``s from 5 to 16 (#4933) - Add support for max 150 characters in most command parameter strings (#3686, #4754) ## Released diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index d68907185..bdbe5d177 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -73,7 +73,7 @@ const uint8_t MAX_PCF8574 = 8; // Max number of PCF8574 devices const uint8_t MAX_RULE_SETS = 3; // Max number of rule sets of size 512 characters const uint16_t MAX_RULE_SIZE = 512; // Max number of characters in rules -const uint8_t MAX_RULE_MEMS = 5; // Max number of saved vars +const uint8_t MAX_RULE_MEMS = 16; // Max number of saved vars const uint8_t MAX_HUE_DEVICES = 15; // Max number of Philips Hue device per emulation const char MQTT_TOKEN_PREFIX[] PROGMEM = "%prefix%"; // To be substituted by mqtt_prefix[x] diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index 6e1636518..72276f94b 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -174,8 +174,8 @@ char rules_vars[MAX_RULE_VARS][33] = {{ 0 }}; #if (MAX_RULE_VARS>16) #error MAX_RULE_VARS is bigger than 16 #endif -#if (MAX_RULE_MEMS>5) -#error MAX_RULE_MEMS is bigger than 5 +#if (MAX_RULE_MEMS>16) +#error MAX_RULE_MEMS is bigger than 16 #endif /*******************************************************************************************/