mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-29 13:46:37 +00:00
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:
parent
cf4f1a964c
commit
89b922675d
@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
## [9.4.0.2]
|
## [9.4.0.2]
|
||||||
### Added
|
### 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)
|
- ESP32 pulldown buttons ``Button_d`` and ``Button_id`` and switches ``Switch_d`` (#10814)
|
||||||
- Support for MQTT using Azure IoT Hub by Kevin Saye (#11906)
|
- Support for MQTT using Azure IoT Hub by Kevin Saye (#11906)
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
|
|||||||
|
|
||||||
## Changelog v9.4.0.2
|
## Changelog v9.4.0.2
|
||||||
### Added
|
### 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)
|
- 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)
|
- Support for MQTT using Azure IoT Hub by Kevin Saye [#11906](https://github.com/arendst/Tasmota/issues/11906)
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ char* UpperCase_P(char* dest, const char* source)
|
|||||||
return dest;
|
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];
|
char case_source[strlen(source) +1];
|
||||||
UpperCase_P(case_source, source);
|
UpperCase_P(case_source, source);
|
||||||
char case_search[strlen(search) +1];
|
char case_search[strlen(search) +1];
|
||||||
@ -1412,7 +1412,7 @@ bool ValidTemplate(const char *search) {
|
|||||||
|
|
||||||
return (strstr(template_name, search_name) != nullptr);
|
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)
|
String AnyModuleName(uint32_t index)
|
||||||
@ -1658,13 +1658,14 @@ bool JsonTemplate(char* dataBuf)
|
|||||||
|
|
||||||
val = root[PSTR(D_JSON_CMND)];
|
val = root[PSTR(D_JSON_CMND)];
|
||||||
if (val) {
|
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;
|
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;
|
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;
|
uint32_t backup_index = XdrvMailbox.index;
|
||||||
XdrvMailbox.index = 0; // Backlog0 - no delay
|
XdrvMailbox.index = 0; // Backlog0 - no delay
|
||||||
CmndBacklog();
|
CmndBacklog();
|
||||||
XdrvMailbox.index = backup_index;
|
XdrvMailbox.index = backup_index;
|
||||||
XdrvMailbox.data_len = backup_data_len;
|
XdrvMailbox.data_len = backup_data_len;
|
||||||
|
@ -1149,7 +1149,7 @@ void Every250mSeconds(void)
|
|||||||
}
|
}
|
||||||
#endif // FIRMWARE_MINIMAL
|
#endif // FIRMWARE_MINIMAL
|
||||||
if (ota_retry_counter < OTA_ATTEMPTS / 2) {
|
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;
|
ota_retry_counter = 1;
|
||||||
} else {
|
} else {
|
||||||
strcat_P(TasmotaGlobal.mqtt_data, PSTR(".gz"));
|
strcat_P(TasmotaGlobal.mqtt_data, PSTR(".gz"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user