Files
IoTManager/src/Configuration.cpp

31 lines
1.2 KiB
C++
Raw Normal View History

#include "Configuration.h"
#include "modules/IoTSensorA.h"
2022-01-14 20:22:52 +01:00
std::vector<IoTSensor*> iotSensors;
void configure(String path) {
File file = seekFile(path);
file.find("[");
while (file.available()) {
String jsonArrayElement = file.readStringUntil('}') + "}";
if (jsonArrayElement.startsWith(",")) {
jsonArrayElement = jsonArrayElement.substring(1, jsonArrayElement.length()); //это нужно оптимизировать в последствии
}
String subtype;
if (jsonRead(jsonArrayElement, F("subtype"), subtype)) {
if (subtype == F("button-out")) {
//=============================
} else if (subtype == F("pwm-out")) {
//=============================
} else if (subtype == F("analog-adc")) {
mySensorAnalog = new IoTSensorA(jsonArrayElement);
iotSensors.push_back(mySensorAnalog);
} else {
SerialPrint(F("E"), F("Config"), "type not exist " + subtype);
}
} else {
SerialPrint(F("E"), F("Config"), F("json error"));
}
}
file.close();
2022-01-14 20:22:52 +01:00
}