версия 404, много исправлений

This commit is contained in:
Dmitry Borisenko
2022-02-16 00:53:52 +01:00
parent 218a0408a5
commit 5110c609c3
21 changed files with 101 additions and 75 deletions

View File

@@ -14,27 +14,32 @@ void configure(String path) {
if (jsonArrayElement.startsWith(",")) {
jsonArrayElement = jsonArrayElement.substring(1, jsonArrayElement.length()); //это нужно оптимизировать в последствии
}
String subtype;
if (!jsonRead(jsonArrayElement, F("subtype"), subtype)) { //если нет такого ключа в представленном json или он не валидный
SerialPrint(F("E"), F("Config"), "json error " + subtype);
continue;
} else {
myIoTItem = (IoTItem*)getAPI(subtype, jsonArrayElement);
if (myIoTItem) {
IoTGpio* tmp = myIoTItem->getGpioDriver();
if (tmp) IoTgpio.regDriver(tmp);
IoTItems.push_back(myIoTItem);
if (jsonArrayElement == "]}") {
jsonArrayElement = "";
}
if (jsonArrayElement != "") {
String subtype;
if (!jsonRead(jsonArrayElement, F("subtype"), subtype)) { //если нет такого ключа в представленном json или он не валидный
SerialPrint(F("E"), F("Config"), "json error " + subtype);
continue;
} else {
myIoTItem = (IoTItem*)getAPI(subtype, jsonArrayElement);
if (myIoTItem) {
IoTGpio* tmp = myIoTItem->getGpioDriver();
if (tmp) IoTgpio.regDriver(tmp);
IoTItems.push_back(myIoTItem);
}
}
}
}
file.close();
SerialPrint("i", "Config", "Configured");
}
void clearConfigure() {
Serial.printf("Start clearing config\n");
for (unsigned int i = 0; i < IoTItems.size(); i++) {
if (IoTItems[i]) delete IoTItems[i];
if (IoTItems[i]) delete IoTItems[i];
}
IoTItems.clear();
}