mirror of https://github.com/arendst/Tasmota.git
6.4.1.18 - Fix some exceptions and watchdogs
6.4.1.18 20191221 * Fix some exceptions and watchdogs due to lack of stack space - part 1 (#5215)
This commit is contained in:
parent
b0227d6d28
commit
05b0280019
|
@ -1,4 +1,7 @@
|
||||||
/* 6.4.1.17 20190214
|
/* 6.4.1.18 20191221
|
||||||
|
* Fix some exceptions and watchdogs due to lack of stack space - part 1 (#5215)
|
||||||
|
*
|
||||||
|
* 6.4.1.17 20190214
|
||||||
* Change template update by removing possibility to add user module config keeping template as defined (#5222)
|
* Change template update by removing possibility to add user module config keeping template as defined (#5222)
|
||||||
* Fix regression from 6.4.1.16 where GPIO9 and GPIO10 connected devices did not work (#5197)
|
* Fix regression from 6.4.1.16 where GPIO9 and GPIO10 connected devices did not work (#5197)
|
||||||
* Fix GUI wifi password acception starting with asteriks (*) (#5231, #5242)
|
* Fix GUI wifi password acception starting with asteriks (*) (#5231, #5242)
|
||||||
|
|
|
@ -964,40 +964,11 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (data_len > 9) { // Workaround exception if empty JSON like {} - Needs checks
|
else if (data_len > 9) { // Workaround exception if empty JSON like {} - Needs checks
|
||||||
StaticJsonBuffer<350> jb; // 331 from https://arduinojson.org/v5/assistant/
|
if (JsonTemplate(dataBuf)) { // Free 336 bytes StaticJsonBuffer stack space by moving code to function
|
||||||
JsonObject& obj = jb.parseObject(dataBuf);
|
if (USER_MODULE == Settings.module) { restart_flag = 2; }
|
||||||
if (!obj.success()) {
|
} else {
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_INVALID_JSON);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_INVALID_JSON);
|
||||||
error = true;
|
error = true;
|
||||||
} else {
|
|
||||||
// All parameters are optional allowing for partial changes
|
|
||||||
const char* name = obj[D_JSON_NAME];
|
|
||||||
if (name != nullptr) {
|
|
||||||
strlcpy(Settings.user_template.name, name, sizeof(Settings.user_template.name));
|
|
||||||
}
|
|
||||||
if (obj[D_JSON_GPIO].success()) {
|
|
||||||
for (uint8_t i = 0; i < sizeof(mycfgio); i++) {
|
|
||||||
Settings.user_template.gp.io[i] = obj[D_JSON_GPIO][i] | 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (obj[D_JSON_FLAG].success()) {
|
|
||||||
uint8_t flag = obj[D_JSON_FLAG] | 0;
|
|
||||||
memcpy(&Settings.user_template.flag, &flag, sizeof(gpio_flag));
|
|
||||||
}
|
|
||||||
if (obj[D_JSON_BASE].success()) {
|
|
||||||
uint8_t base = obj[D_JSON_BASE];
|
|
||||||
if ((0 == base) || (base >= MAXMODULE)) { base = 17; } else { base--; }
|
|
||||||
Settings.user_template_base = base; // Default WEMOS
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate GPIO
|
|
||||||
// for (uint8_t i = 0; i < sizeof(mycfgio); i++) {
|
|
||||||
// For now do not allow non-user configurable GPIO
|
|
||||||
// if ((Settings.user_template.gp.io[i] > GPIO_FIX_START) && (Settings.user_template.gp.io[i] < GPIO_USER)) {
|
|
||||||
// Settings.user_template.gp.io[i] = GPIO_NONE;
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
if (USER_MODULE == Settings.module) { restart_flag = 2; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!error) { TemplateJson(); }
|
if (!error) { TemplateJson(); }
|
||||||
|
@ -2223,7 +2194,8 @@ void ArduinoOTAInit(void)
|
||||||
void SerialInput(void)
|
void SerialInput(void)
|
||||||
{
|
{
|
||||||
while (Serial.available()) {
|
while (Serial.available()) {
|
||||||
yield();
|
// yield();
|
||||||
|
delay(0);
|
||||||
serial_in_byte = Serial.read();
|
serial_in_byte = Serial.read();
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------------------------*\
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef _SONOFF_VERSION_H_
|
#ifndef _SONOFF_VERSION_H_
|
||||||
#define _SONOFF_VERSION_H_
|
#define _SONOFF_VERSION_H_
|
||||||
|
|
||||||
#define VERSION 0x06040111
|
#define VERSION 0x06040112
|
||||||
|
|
||||||
#define D_PROGRAMNAME "Sonoff-Tasmota"
|
#define D_PROGRAMNAME "Sonoff-Tasmota"
|
||||||
#define D_AUTHOR "Theo Arends"
|
#define D_AUTHOR "Theo Arends"
|
||||||
|
|
|
@ -845,6 +845,42 @@ bool GetUsedInModule(uint8_t val, uint8_t *arr)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JsonTemplate(const char* dataBuf)
|
||||||
|
{
|
||||||
|
StaticJsonBuffer<350> jb; // 331 from https://arduinojson.org/v5/assistant/
|
||||||
|
JsonObject& obj = jb.parseObject(dataBuf);
|
||||||
|
if (!obj.success()) { return false; }
|
||||||
|
|
||||||
|
// All parameters are optional allowing for partial changes
|
||||||
|
const char* name = obj[D_JSON_NAME];
|
||||||
|
if (name != nullptr) {
|
||||||
|
strlcpy(Settings.user_template.name, name, sizeof(Settings.user_template.name));
|
||||||
|
}
|
||||||
|
if (obj[D_JSON_GPIO].success()) {
|
||||||
|
for (uint8_t i = 0; i < sizeof(mycfgio); i++) {
|
||||||
|
Settings.user_template.gp.io[i] = obj[D_JSON_GPIO][i] | 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (obj[D_JSON_FLAG].success()) {
|
||||||
|
uint8_t flag = obj[D_JSON_FLAG] | 0;
|
||||||
|
memcpy(&Settings.user_template.flag, &flag, sizeof(gpio_flag));
|
||||||
|
}
|
||||||
|
if (obj[D_JSON_BASE].success()) {
|
||||||
|
uint8_t base = obj[D_JSON_BASE];
|
||||||
|
if ((0 == base) || (base >= MAXMODULE)) { base = 17; } else { base--; }
|
||||||
|
Settings.user_template_base = base; // Default WEMOS
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate GPIO
|
||||||
|
// for (uint8_t i = 0; i < sizeof(mycfgio); i++) {
|
||||||
|
// For now do not allow non-user configurable GPIO
|
||||||
|
// if ((Settings.user_template.gp.io[i] > GPIO_FIX_START) && (Settings.user_template.gp.io[i] < GPIO_USER)) {
|
||||||
|
// Settings.user_template.gp.io[i] = GPIO_NONE;
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void TemplateJson()
|
void TemplateJson()
|
||||||
{
|
{
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), Settings.user_template.name);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), Settings.user_template.name);
|
||||||
|
|
|
@ -1968,6 +1968,7 @@ void HandleHttpCommand(void)
|
||||||
if (JSON) { // Is it a JSON message (and not only [15:26:08 MQT: stat/wemos5/POWER = O])
|
if (JSON) { // Is it a JSON message (and not only [15:26:08 MQT: stat/wemos5/POWER = O])
|
||||||
if (message.length() > 1) { message += F(","); }
|
if (message.length() > 1) { message += F(","); }
|
||||||
size_t JSONlen = len - (JSON - tmp);
|
size_t JSONlen = len - (JSON - tmp);
|
||||||
|
if (JSONlen > sizeof(mqtt_data)) { JSONlen = sizeof(mqtt_data); }
|
||||||
strlcpy(mqtt_data, JSON +1, JSONlen -2);
|
strlcpy(mqtt_data, JSON +1, JSONlen -2);
|
||||||
message += mqtt_data;
|
message += mqtt_data;
|
||||||
}
|
}
|
||||||
|
@ -2047,6 +2048,7 @@ void HandleAjaxConsoleRefresh(void)
|
||||||
} else {
|
} else {
|
||||||
cflg = true;
|
cflg = true;
|
||||||
}
|
}
|
||||||
|
if (len > sizeof(mqtt_data) -2) { len = sizeof(mqtt_data); }
|
||||||
strlcpy(mqtt_data, tmp, len);
|
strlcpy(mqtt_data, tmp, len);
|
||||||
message += mqtt_data; // mqtt_data used as scratch space
|
message += mqtt_data; // mqtt_data used as scratch space
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue