mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 14:42:18 +03:00
first
This commit is contained in:
49
src/Class/CallBackTest.cpp
Normal file
49
src/Class/CallBackTest.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "Class/CallBackTest.h"
|
||||
|
||||
CallBackTest::CallBackTest(){};
|
||||
|
||||
void CallBackTest::loop() {
|
||||
count++;
|
||||
if (count > 5000) {
|
||||
// Проверяем что переменная содержит указатель - не пустая не null
|
||||
// и непосредственно вызываем то, на что это указывает
|
||||
// просто пишем имя - без () - это указатель на фунецию.
|
||||
// () - вызываем функцию - с пустым набором параметров
|
||||
|
||||
if (_cb != NULL) {
|
||||
_cb();
|
||||
}
|
||||
//или ровно тоже самое
|
||||
//if (_cb) _cb();
|
||||
|
||||
if (_pcb) {
|
||||
if (_pcb("SomeTextValue")) {
|
||||
Serial.println("Got true!");
|
||||
} else {
|
||||
Serial.println("Got false!");
|
||||
}
|
||||
}
|
||||
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//передаем внутрь класса функцию любую void функцию без агрументов
|
||||
void CallBackTest::setCallback(AsyncActionCb cb) {
|
||||
_cb = cb;
|
||||
}
|
||||
|
||||
//передаем внутрь класса функцию любую void функцию с аргументами
|
||||
void CallBackTest::setCallback(AsyncParamActionCb pcb) {
|
||||
_pcb = pcb;
|
||||
}
|
||||
//CallBackTest* CB;
|
||||
|
||||
//CB->setCallback([]() {
|
||||
// Serial.println("123");
|
||||
//});
|
||||
//
|
||||
//CB->setCallback([](const String str) {
|
||||
// Serial.println(str);
|
||||
// return true;
|
||||
//});
|
||||
2
src/Class/LineParsing.cpp
Normal file
2
src/Class/LineParsing.cpp
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "Class/LineParsing.h"
|
||||
LineParsing myLineParsing;
|
||||
30
src/Class/NotAsync.cpp
Normal file
30
src/Class/NotAsync.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "Class/NotAsync.h"
|
||||
|
||||
NotAsync::NotAsync(uint8_t size) {
|
||||
this->items = new NotAsyncItem[size];
|
||||
this->size = size;
|
||||
}
|
||||
|
||||
NotAsync::~NotAsync() {}
|
||||
|
||||
void NotAsync::add(uint8_t i, NotAsyncCb f, void* arg) {
|
||||
this->items[i].cb = f;
|
||||
this->items[i].cb_arg = arg;
|
||||
this->items[i].is_used = true;
|
||||
}
|
||||
|
||||
void NotAsync::loop() {
|
||||
if (this->items[task].is_used) {
|
||||
handle(this->items[task].cb, this->items[task].cb_arg);
|
||||
task = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void NotAsync::make(uint8_t task) {
|
||||
this->task = task;
|
||||
}
|
||||
|
||||
void NotAsync::handle(NotAsyncCb f, void* arg) {
|
||||
f(arg);
|
||||
}
|
||||
NotAsync* myNotAsyncActions;
|
||||
33
src/Class/ScenarioClass3.cpp
Normal file
33
src/Class/ScenarioClass3.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "Class/ScenarioClass3.h"
|
||||
|
||||
#include "MqttClient.h"
|
||||
#include "RemoteOrdersUdp.h"
|
||||
Scenario* myScenario;
|
||||
|
||||
void eventGen2(String eventName, String eventValue) {
|
||||
if (!jsonReadBool(configSetupJson, "scen")) {
|
||||
return;
|
||||
}
|
||||
String event = eventName + " " + eventValue + ",";
|
||||
eventBuf += event;
|
||||
|
||||
if (jsonReadBool(configSetupJson, "MqttOut")) {
|
||||
if (eventName != "timenow") {
|
||||
publishEvent(eventName, eventValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void streamEventUDP(String event) {
|
||||
#ifdef UDP_ENABLED
|
||||
|
||||
if (!jsonReadBool(configSetupJson, "snaUdp")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.indexOf("timenow") == -1) {
|
||||
event = "iotm;event:" + event;
|
||||
asyncUdp.broadcastTo(event.c_str(), 4210);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user