mirror of https://github.com/arendst/Tasmota.git
Fix Template using ``#define USER_TEMPLATE``
Fix Template using ``#define USER_TEMPLATE`` (#9506)
This commit is contained in:
parent
cee37abe1a
commit
490e7d838e
|
@ -427,6 +427,7 @@ bool SettingsUpdateText(uint32_t index, const char* replace_me) {
|
|||
uint32_t replace_len = strlen_P(replace_me);
|
||||
char replace[replace_len +1];
|
||||
memcpy_P(replace, replace_me, sizeof(replace));
|
||||
uint32_t index_save = index;
|
||||
|
||||
uint32_t start_pos = 0;
|
||||
uint32_t end_pos = 0;
|
||||
|
@ -472,6 +473,7 @@ bool SettingsUpdateText(uint32_t index, const char* replace_me) {
|
|||
settings_text_mutex = false;
|
||||
}
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "CR %d/%d, Busy %d, Id %d = \"%s\""), GetSettingsTextLen(), settings_text_size, settings_text_busy_count, index_save, replace);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "CR %d/%d, Busy %d"), GetSettingsTextLen(), settings_text_size, settings_text_busy_count);
|
||||
|
||||
return true;
|
||||
|
@ -1081,8 +1083,9 @@ void SettingsDefaultSet2(void)
|
|||
flag4.mqtt_no_retain |= MQTT_NO_RETAIN;
|
||||
|
||||
#ifdef USER_TEMPLATE
|
||||
JsonTemplate(USER_TEMPLATE);
|
||||
JsonTemplate((char *)USER_TEMPLATE);
|
||||
#endif
|
||||
Settings.gpio16_converted = 0xF5A0;
|
||||
|
||||
Settings.flag = flag;
|
||||
Settings.flag2 = flag2;
|
||||
|
|
|
@ -1508,6 +1508,8 @@ bool JsonTemplate(char* dataBuf)
|
|||
// Old: {"NAME":"Shelly 2.5","GPIO":[56,0,17,0,21,83,0,0,6,82,5,22,156],"FLAG":2,"BASE":18}
|
||||
// New: {"NAME":"Shelly 2.5","GPIO":[320,0,32,0,224,193,0,0,640,192,608,225,3456,4736],"FLAG":0,"BASE":18}
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TPL: |%s|"), dataBuf);
|
||||
|
||||
if (strlen(dataBuf) < 9) { return false; } // Workaround exception if empty JSON like {} - Needs checks
|
||||
|
||||
JsonParser parser((char*) dataBuf);
|
||||
|
@ -1570,11 +1572,18 @@ bool JsonTemplate(char* dataBuf)
|
|||
if ((0 == base) || !ValidTemplateModule(base -1)) { base = 18; }
|
||||
Settings.user_template_base = base -1; // Default WEMOS
|
||||
}
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TPL: Converted"));
|
||||
// AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)&Settings.user_template, sizeof(Settings.user_template) / 2, 2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TemplateJson(void)
|
||||
{
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TPL: Show"));
|
||||
// AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)&Settings.user_template, sizeof(Settings.user_template) / 2, 2);
|
||||
|
||||
Response_P(PSTR("{\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), SettingsText(SET_TEMPLATE_NAME));
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(Settings.user_template.gp.io); i++) {
|
||||
uint16_t gpio = Settings.user_template.gp.io[i];
|
||||
|
|
|
@ -1079,7 +1079,7 @@ void Every250mSeconds(void)
|
|||
} else {
|
||||
Settings.power = 0;
|
||||
}
|
||||
SettingsSave(0);
|
||||
if (!restart_flag) { SettingsSave(0); }
|
||||
save_data_counter = Settings.save_data;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue