mirror of https://github.com/arendst/Tasmota.git
Add support for longer template names
Add support for longer template names
This commit is contained in:
parent
42b3272e83
commit
d713468c0c
|
@ -52,7 +52,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||
|
||||
## Changelog
|
||||
|
||||
### Version 8.2.0.2
|
||||
### Version 8.2.0.3
|
||||
|
||||
- Change HM-10 sensor type detection and add features (#7962)
|
||||
- Fix possible Relay toggle on (OTA) restart
|
||||
|
@ -63,3 +63,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||
- Add support for 64x48 SSD1306 OLED (#6740)
|
||||
- Add support for up to four MQTT GroupTopics using the same optional Device Group names (#8014)
|
||||
- Add console command history (#7483, #8015)
|
||||
- Add support for longer template names
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
## Unreleased (development)
|
||||
|
||||
### 8.2.0.3 20200329
|
||||
|
||||
- Add support for longer template names
|
||||
|
||||
### 8.2.0.2 20200328
|
||||
|
||||
- Add support for up to four MQTT GroupTopics using the same optional Device Group names (#8014)
|
||||
|
|
|
@ -397,7 +397,9 @@ struct SYSCFG {
|
|||
uint16_t mcp230xx_int_timer; // 718
|
||||
uint8_t rgbwwTable[5]; // 71A
|
||||
uint8_t user_template_base; // 71F
|
||||
char user_template_name[15]; // 720 15 bytes
|
||||
|
||||
char user_template_name[15]; // 720 15 bytes - Backward compatibility since v8.2.0.3
|
||||
|
||||
mytmplt user_template; // 72F 14 bytes
|
||||
uint8_t novasds_startingoffset; // 73D
|
||||
uint8_t web_color[18][3]; // 73E
|
||||
|
|
|
@ -589,6 +589,12 @@ char* SettingsText(uint32_t index)
|
|||
* Config Save - Save parameters to Flash ONLY if any parameter has changed
|
||||
\*********************************************************************************************/
|
||||
|
||||
void UpdateBackwardCompatibility(void)
|
||||
{
|
||||
// Perform updates for backward compatibility
|
||||
strlcpy(Settings.user_template_name, SettingsText(SET_TEMPLATE_NAME), sizeof(Settings.user_template_name));
|
||||
}
|
||||
|
||||
uint32_t GetSettingsAddress(void)
|
||||
{
|
||||
return settings_location * SPI_FLASH_SEC_SIZE;
|
||||
|
@ -605,6 +611,7 @@ void SettingsSave(uint8_t rotate)
|
|||
* stop_flash_rotate 1 = Allow only eeprom flash slot use (SetOption12 1)
|
||||
*/
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
UpdateBackwardCompatibility();
|
||||
if ((GetSettingsCrc32() != settings_crc32) || rotate) {
|
||||
if (1 == rotate) { // Use eeprom flash slot only and disable flash rotate from now on (upgrade)
|
||||
stop_flash_rotate = 1;
|
||||
|
@ -1394,7 +1401,6 @@ void SettingsDelta(void)
|
|||
Settings.mqtt_port = Settings.ex_mqtt_port; // 20A -> EFC
|
||||
memcpy((char*)&Settings.serial_config, (char*)&Settings.ex_serial_config, 5); // 1E4 -> EFE
|
||||
}
|
||||
|
||||
if (Settings.version < 0x08000000) {
|
||||
char temp[strlen(Settings.text_pool) +1]; strncpy(temp, Settings.text_pool, sizeof(temp)); // Was ota_url
|
||||
char temp21[strlen(Settings.ex_mqtt_prefix[0]) +1]; strncpy(temp21, Settings.ex_mqtt_prefix[0], sizeof(temp21));
|
||||
|
@ -1466,6 +1472,9 @@ void SettingsDelta(void)
|
|||
SettingsUpdateText(SET_FRIENDLYNAME3, Settings.ex_friendlyname[2]);
|
||||
SettingsUpdateText(SET_FRIENDLYNAME4, Settings.ex_friendlyname[3]);
|
||||
}
|
||||
if (Settings.version < 0x08020003) {
|
||||
SettingsUpdateText(SET_TEMPLATE_NAME, Settings.user_template_name);
|
||||
}
|
||||
|
||||
Settings.version = VERSION;
|
||||
SettingsSave(1);
|
||||
|
|
|
@ -1098,9 +1098,9 @@ bool ValidModule(uint32_t index)
|
|||
String AnyModuleName(uint32_t index)
|
||||
{
|
||||
if (USER_MODULE == index) {
|
||||
return String(Settings.user_template_name);
|
||||
return String(SettingsText(SET_TEMPLATE_NAME));
|
||||
} else {
|
||||
char name[15];
|
||||
char name[TOPSZ];
|
||||
return String(GetTextIndexed(name, sizeof(name), index, kModuleNames));
|
||||
}
|
||||
}
|
||||
|
@ -1154,7 +1154,8 @@ void ModuleDefault(uint32_t module)
|
|||
{
|
||||
if (USER_MODULE == module) { module = WEMOS; } // Generic
|
||||
Settings.user_template_base = module;
|
||||
GetTextIndexed(Settings.user_template_name, sizeof(Settings.user_template_name), module, kModuleNames);
|
||||
char name[TOPSZ];
|
||||
SettingsUpdateText(SET_TEMPLATE_NAME, GetTextIndexed(name, sizeof(name), module, kModuleNames));
|
||||
memcpy_P(&Settings.user_template, &kModules[module], sizeof(mytmplt));
|
||||
}
|
||||
|
||||
|
@ -1263,14 +1264,14 @@ bool JsonTemplate(const char* dataBuf)
|
|||
|
||||
if (strlen(dataBuf) < 9) { return false; } // Workaround exception if empty JSON like {} - Needs checks
|
||||
|
||||
StaticJsonBuffer<350> jb; // 331 from https://arduinojson.org/v5/assistant/
|
||||
StaticJsonBuffer<400> 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));
|
||||
SettingsUpdateText(SET_TEMPLATE_NAME, name);
|
||||
}
|
||||
if (obj[D_JSON_GPIO].success()) {
|
||||
for (uint32_t i = 0; i < sizeof(mycfgio); i++) {
|
||||
|
@ -1291,7 +1292,7 @@ bool JsonTemplate(const char* dataBuf)
|
|||
|
||||
void TemplateJson(void)
|
||||
{
|
||||
Response_P(PSTR("{\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), Settings.user_template_name);
|
||||
Response_P(PSTR("{\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), SettingsText(SET_TEMPLATE_NAME));
|
||||
for (uint32_t i = 0; i < sizeof(Settings.user_template.gp); i++) {
|
||||
ResponseAppend_P(PSTR("%s%d"), (i>0)?",":"", Settings.user_template.gp.io[i]);
|
||||
}
|
||||
|
|
|
@ -1064,7 +1064,7 @@ void CmndTemplate(void)
|
|||
if (Settings.module != USER_MODULE) {
|
||||
ModuleDefault(Settings.module);
|
||||
}
|
||||
snprintf_P(Settings.user_template_name, sizeof(Settings.user_template_name), PSTR("Merged"));
|
||||
SettingsUpdateText(SET_TEMPLATE_NAME, "Merged");
|
||||
uint32_t j = 0;
|
||||
for (uint32_t i = 0; i < sizeof(mycfgio); i++) {
|
||||
if (6 == i) { j = 9; }
|
||||
|
|
|
@ -302,6 +302,7 @@ enum SettingsTextIndex { SET_OTAURL,
|
|||
SET_BUTTON1, SET_BUTTON2, SET_BUTTON3, SET_BUTTON4, SET_BUTTON5, SET_BUTTON6, SET_BUTTON7, SET_BUTTON8,
|
||||
SET_BUTTON9, SET_BUTTON10, SET_BUTTON11, SET_BUTTON12, SET_BUTTON13, SET_BUTTON14, SET_BUTTON15, SET_BUTTON16,
|
||||
SET_MQTT_GRP_TOPIC2, SET_MQTT_GRP_TOPIC3, SET_MQTT_GRP_TOPIC4,
|
||||
SET_TEMPLATE_NAME,
|
||||
SET_MAX };
|
||||
|
||||
enum DeviceGroupMessageType { DGR_MSGTYP_FULL_STATUS, DGR_MSGTYP_PARTIAL_UPDATE, DGR_MSGTYP_UPDATE, DGR_MSGTYP_UPDATE_MORE_TO_COME, DGR_MSGTYP_UPDATE_DIRECT, DGR_MSGTYP_REUPDATE };
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef _TASMOTA_VERSION_H_
|
||||
#define _TASMOTA_VERSION_H_
|
||||
|
||||
const uint32_t VERSION = 0x08020002;
|
||||
const uint32_t VERSION = 0x08020003;
|
||||
|
||||
// Lowest compatible version
|
||||
const uint32_t VERSION_COMPATIBLE = 0x07010006;
|
||||
|
|
|
@ -1510,9 +1510,9 @@ void HandleTemplateConfiguration(void)
|
|||
|
||||
void TemplateSaveSettings(void)
|
||||
{
|
||||
char tmp[sizeof(Settings.user_template_name)]; // WebGetArg NAME and GPIO/BASE/FLAG byte value
|
||||
char tmp[TOPSZ]; // WebGetArg NAME and GPIO/BASE/FLAG byte value
|
||||
char webindex[5]; // WebGetArg name
|
||||
char svalue[128]; // Template command string
|
||||
char svalue[200]; // Template command string
|
||||
|
||||
WebGetArg("s1", tmp, sizeof(tmp)); // NAME
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_TEMPLATE " {\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), tmp);
|
||||
|
@ -1528,11 +1528,11 @@ void TemplateSaveSettings(void)
|
|||
j++;
|
||||
}
|
||||
|
||||
WebGetArg("g17", tmp, sizeof(tmp)); // FLAG - ADC0
|
||||
WebGetArg("g17", tmp, sizeof(tmp)); // FLAG - ADC0
|
||||
uint32_t flag = atoi(tmp);
|
||||
for (uint32_t i = 0; i < GPIO_FLAG_USED; i++) {
|
||||
snprintf_P(webindex, sizeof(webindex), PSTR("c%d"), i);
|
||||
uint32_t state = WebServer->hasArg(webindex) << i +4; // FLAG
|
||||
uint32_t state = WebServer->hasArg(webindex) << i +4; // FLAG
|
||||
flag += state;
|
||||
}
|
||||
WebGetArg("g99", tmp, sizeof(tmp)); // BASE
|
||||
|
|
Loading…
Reference in New Issue