Add support for max 150 characters

Add support for max 150 characters in most command parameter strings (#3686, #4754)
This commit is contained in:
Theo Arends 2019-12-22 15:23:52 +01:00
parent f642f014b7
commit ad4a7e91ac
11 changed files with 29 additions and 25 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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());

View File

@ -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

View File

@ -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

View File

@ -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&|
}

View File

@ -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];

View File

@ -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<MAX_KEYS;cnt++) {