удаление часов реального времени

This commit is contained in:
Dmitry Borisenko
2022-08-12 22:13:50 +02:00
parent ca95a4528d
commit d22580aac9
17 changed files with 278 additions and 387 deletions

View File

@@ -1,9 +1,7 @@
#include "ESPConfiguration.h"
#include "classes/IoTGpio.h"
#include "classes/IoTRTC.h"
extern IoTGpio IoTgpio;
extern IoTRTC *watch;
std::list<IoTItem*> IoTItems;
void* getAPI(String subtype, String params);
@@ -25,24 +23,12 @@ void configure(String path) {
SerialPrint(F("E"), F("Config"), "json error " + subtype);
continue;
} else {
//(IoTItem*) - getAPI вернула ссылку, что бы ее привести к классу IoTItem используем
myIoTItem = (IoTItem*)getAPI(subtype, jsonArrayElement);
if (myIoTItem) {
// пробуем спросить драйвер GPIO
IoTGpio* gpiotmp = myIoTItem->getGpioDriver();
if (gpiotmp) IoTgpio.regDriver(gpiotmp);
// пробуем спросить драйвер RTC
iarduino_RTC_BASE* rtctmp = myIoTItem->getRtcDriver();
if (rtctmp) {
Serial.println("Start delete watch objClass");
delete watch->objClass;
watch->objClass = rtctmp;
int valPeriod_save = watch->valPeriod;
watch->valPeriod = 0;
watch->gettime();
watch->valPeriod = valPeriod_save;
}
if (myIoTItem->isGpioDriver()) IoTgpio.regDriver((IoTGpio*)myIoTItem);
IoTItems.push_back(myIoTItem);
}
}
@@ -54,7 +40,7 @@ void configure(String path) {
void clearConfigure() {
Serial.printf("Start clearing config\n");
for (std::list<IoTItem*>::iterator it=IoTItems.begin(); it != IoTItems.end(); ++it) {
for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
Serial.printf("Start delete iotitem %s \n", (*it)->getID().c_str());
if (*it) delete *it;
}