2022-01-14 21:48:43 +01:00
|
|
|
#include "Utils/JsonUtils.h"
|
|
|
|
|
#include "Utils/SerialPrint.h"
|
|
|
|
|
#include "Classes/ScenarioClass3.h"
|
|
|
|
|
#include "Classes/IoTSensor.h"
|
|
|
|
|
|
|
|
|
|
|
2022-02-01 12:51:34 +03:00
|
|
|
IoTSensor::IoTSensor(String parameters) {
|
|
|
|
|
_interval = jsonReadInt(parameters, "int") * 1000;
|
|
|
|
|
_subtype = jsonReadStr(parameters, "subtype");
|
|
|
|
|
_id = jsonReadStr(parameters, "id");
|
|
|
|
|
}
|
2022-01-14 21:48:43 +01:00
|
|
|
IoTSensor::~IoTSensor() {}
|
|
|
|
|
|
2022-02-01 12:30:13 +03:00
|
|
|
String IoTSensor::getSubtype() {
|
|
|
|
|
return _subtype;
|
2022-01-14 21:48:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String IoTSensor::getID() {
|
|
|
|
|
return _id;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void IoTSensor::loop() {
|
|
|
|
|
currentMillis = millis();
|
|
|
|
|
difference = currentMillis - prevMillis;
|
|
|
|
|
if (difference >= _interval) {
|
|
|
|
|
prevMillis = millis();
|
|
|
|
|
this->doByInterval();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IoTSensor::regEvent(String value, String consoleInfo = "") {
|
|
|
|
|
eventGen2(_id, String(value));
|
|
|
|
|
jsonWriteStr(paramsFlashJson, _id, String(value));
|
|
|
|
|
publishStatus(_id, String(value));
|
2022-01-15 17:10:14 +01:00
|
|
|
SerialPrint("I", "Sensor " + consoleInfo, "'" + _id + "' data: " + String(value) + "'");
|
2022-01-14 21:48:43 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-15 16:30:34 +01:00
|
|
|
void IoTSensor::doByInterval() {}
|
|
|
|
|
|
|
|
|
|
IoTSensor* myIoTSensor;
|