mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Update template using JSMN
This commit is contained in:
parent
7a73dd7019
commit
b51ee2aa22
@ -1516,23 +1516,38 @@ bool JsonTemplate(char* dataBuf)
|
|||||||
}
|
}
|
||||||
JsonParserArray arr = root[PSTR(D_JSON_GPIO)];
|
JsonParserArray arr = root[PSTR(D_JSON_GPIO)];
|
||||||
if (arr) {
|
if (arr) {
|
||||||
for (uint32_t i = 0; i < ARRAY_SIZE(Settings.user_template.gp.io); i++) {
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
Settings.user_template.gp.io[i] = arr[i].getUInt();
|
if (!arr[13].getUInt()) { // Old template
|
||||||
#else // ESP32
|
|
||||||
|
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TPL: Converting template ..."));
|
||||||
|
|
||||||
|
uint8_t template8[sizeof(mytmplt8285)] = { GPIO_NONE };
|
||||||
|
for (uint32_t i = 0; i < ARRAY_SIZE(template8) -1; i++) {
|
||||||
|
template8[i] = arr[i].getUInt();
|
||||||
|
}
|
||||||
|
val = root[PSTR(D_JSON_FLAG)];
|
||||||
|
if (val) {
|
||||||
|
template8[ARRAY_SIZE(template8) -1] = val.getUInt() & 0x0F;
|
||||||
|
}
|
||||||
|
TemplateConvert(template8, Settings.user_template.gp.io);
|
||||||
|
Settings.user_template.flag.data = 0;
|
||||||
|
} else {
|
||||||
|
#endif
|
||||||
|
for (uint32_t i = 0; i < ARRAY_SIZE(Settings.user_template.gp.io); i++) {
|
||||||
uint16_t gpio = arr[i].getUInt();
|
uint16_t gpio = arr[i].getUInt();
|
||||||
if (gpio == (AGPIO(GPIO_NONE) +1)) {
|
if (gpio == (AGPIO(GPIO_NONE) +1)) {
|
||||||
gpio = AGPIO(GPIO_USER);
|
gpio = AGPIO(GPIO_USER);
|
||||||
}
|
}
|
||||||
Settings.user_template.gp.io[i] = gpio;
|
Settings.user_template.gp.io[i] = gpio;
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val = root[PSTR(D_JSON_FLAG)];
|
val = root[PSTR(D_JSON_FLAG)];
|
||||||
if (val) {
|
if (val) {
|
||||||
uint32_t flag = val.getUInt();
|
Settings.user_template.flag.data = val.getUInt();
|
||||||
memcpy(&Settings.user_template.flag, &flag, sizeof(gpio_flag));
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#ifdef ESP8266
|
||||||
|
}
|
||||||
|
#endif
|
||||||
val = root[PSTR(D_JSON_BASE)];
|
val = root[PSTR(D_JSON_BASE)];
|
||||||
if (val) {
|
if (val) {
|
||||||
uint32_t base = val.getUInt();
|
uint32_t base = val.getUInt();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user