Add backward compatibility to Template CMND fieldpair using | as command separator

Add backward compatibility to Template CMND fieldpair using | as command separator (#11788)
This commit is contained in:
Theo Arends 2021-04-29 17:00:04 +02:00
parent cf4f1a964c
commit 89b922675d
4 changed files with 10 additions and 9 deletions

View File

@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
## [9.4.0.2]
### Added
- Initial support for optional ``Template`` JSON fieldpair ``"CMND":"<any template related command>;<any template related command>;..."`` (#11788)
- Initial support for optional ``Template`` JSON fieldpair ``"CMND":"<any template related command>|<any template related command>|..."`` (#11788)
- ESP32 pulldown buttons ``Button_d`` and ``Button_id`` and switches ``Switch_d`` (#10814)
- Support for MQTT using Azure IoT Hub by Kevin Saye (#11906)

View File

@ -78,7 +78,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
## Changelog v9.4.0.2
### Added
- Initial support for optional ``Template`` JSON fieldpair ``"CMND":"<any template related command>;<any template related command>;..."`` [#11788](https://github.com/arendst/Tasmota/issues/11788)
- Initial support for optional ``Template`` JSON fieldpair ``"CMND":"<any template related command>|<any template related command>|..."`` [#11788](https://github.com/arendst/Tasmota/issues/11788)
- ESP32 pulldown buttons ``Button_d`` and ``Button_id`` and switches ``Switch_d`` [#10814](https://github.com/arendst/Tasmota/issues/10814)
- Support for MQTT using Azure IoT Hub by Kevin Saye [#11906](https://github.com/arendst/Tasmota/issues/11906)

View File

@ -515,7 +515,7 @@ char* UpperCase_P(char* dest, const char* source)
return dest;
}
char* StrStr_P(const char* source, const char* search) {
char* StrCaseStr_P(const char* source, const char* search) {
char case_source[strlen(source) +1];
UpperCase_P(case_source, source);
char case_search[strlen(search) +1];
@ -1412,7 +1412,7 @@ bool ValidTemplate(const char *search) {
return (strstr(template_name, search_name) != nullptr);
*/
return (StrStr_P(SettingsText(SET_TEMPLATE_NAME), search) != nullptr);
return (StrCaseStr_P(SettingsText(SET_TEMPLATE_NAME), search) != nullptr);
}
String AnyModuleName(uint32_t index)
@ -1658,13 +1658,14 @@ bool JsonTemplate(char* dataBuf)
val = root[PSTR(D_JSON_CMND)];
if (val) {
if ((USER_MODULE == Settings.module) || (StrStr_P(val.getStr(), PSTR(D_CMND_MODULE " 0")))) { // Only execute if current module = USER_MODULE = this template
if ((USER_MODULE == Settings.module) || (StrCaseStr_P(val.getStr(), PSTR(D_CMND_MODULE " 0")))) { // Only execute if current module = USER_MODULE = this template
char* backup_data = XdrvMailbox.data;
XdrvMailbox.data = (char*)val.getStr(); // Backlog commands
XdrvMailbox.data = (char*)val.getStr(); // Backlog commands
ReplaceChar(XdrvMailbox.data, '|', ';'); // Support '|' as command separator for JSON backwards compatibility
uint32_t backup_data_len = XdrvMailbox.data_len;
XdrvMailbox.data_len = 1; // Any data
XdrvMailbox.data_len = 1; // Any data
uint32_t backup_index = XdrvMailbox.index;
XdrvMailbox.index = 0; // Backlog0 - no delay
XdrvMailbox.index = 0; // Backlog0 - no delay
CmndBacklog();
XdrvMailbox.index = backup_index;
XdrvMailbox.data_len = backup_data_len;

View File

@ -1149,7 +1149,7 @@ void Every250mSeconds(void)
}
#endif // FIRMWARE_MINIMAL
if (ota_retry_counter < OTA_ATTEMPTS / 2) {
if (StrStr_P(TasmotaGlobal.mqtt_data, PSTR(".gz"))) {
if (StrCaseStr_P(TasmotaGlobal.mqtt_data, PSTR(".gz"))) {
ota_retry_counter = 1;
} else {
strcat_P(TasmotaGlobal.mqtt_data, PSTR(".gz"));