remoove all

This commit is contained in:
Dmitry Borisenko
2021-01-04 00:33:32 +01:00
parent 50c616c61b
commit bf9855aa60
392 changed files with 0 additions and 34898 deletions

View File

@@ -1,64 +0,0 @@
#pragma once
#include <Arduino.h>
extern void loopCmdAdd(const String& cmdStr);
extern void fileCmdExecute(const String& filename);
extern void csvCmdExecute(String& cmdStr);
extern void spaceCmdExecute(String& cmdStr);
extern void loopCmdExecute();
extern void addKey(String& key, String& keyNumberTable, int number);
extern int getKeyNum(String& key, String& keyNumberTable);
extern void buttonOut();
extern void buttonOutSet();
extern void pwmOut();
extern void pwmOutSet();
extern void buttonIn();
extern void buttonInSet();
extern void inputDigit();
extern void inputDigitSet();
extern void inputTime();
extern void inputTimeSet();
extern void textOut();
extern void textOutSet();
extern void analogAdc();
extern void analogReading();
extern void ultrasonicCm();
extern void ultrasonicReading();
extern void dallasTemp();
extern void dallasReading();
extern void dhtTemp();
extern void dhtReadingTemp();
extern void dhtHum();
extern void dhtReadingHum();
extern void bme280Temp();
extern void bme280ReadingTemp();
extern void bme280Hum();
extern void bme280ReadingHum();
extern void bme280Press();
extern void bme280ReadingPress();
extern void bmp280Temp();
extern void bmp280ReadingTemp();
extern void bmp280Press();
extern void bmp280ReadingPress();
//extern void modbus();
//extern void modbusReading();
extern void sysUptime();
extern void uptimeReading();
extern void logging();
extern void impuls();

View File

@@ -1,4 +0,0 @@
#pragma once
#include <Arduino.h>
void busInit();
String i2c_scan();

View File

@@ -1,26 +0,0 @@
#pragma once
#include <Arduino.h>
#include <stdint.h>
#include <functional>
// Декларируем тип - сигнатуру метода , который мы готовы принять в данном случае это
// должен быть метод без результата и без параметров.
// Новый тип мы называем AsynсActionCb - хотя можешь назвать вообще как нравиться а что значит callBack
typedef std::function<void()> AsyncActionCb; //метод без результата и параметров
typedef std::function<bool(const String)> AsyncParamActionCb; //метод без результата и параметров
class CallBackTest {
private:
long count;
AsyncActionCb _cb;
AsyncParamActionCb _pcb;
public:
CallBackTest();
void loop();
void setCallback(AsyncActionCb cb);
void setCallback(AsyncParamActionCb pcb);
};
//extern CallBackTest* CB;

View File

@@ -1,237 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Global.h"
#include "Utils/JsonUtils.h"
class LineParsing {
protected:
String _key;
String _file;
String _page;
String _descr;
String _order;
String _addr;
String _reg;
String _pin;
String _map;
String _c;
String _inv;
String _state;
String _db;
String _type;
String _int;
String _cnt;
String _val;
String _index;
public:
LineParsing() :
_key{""},
_file{""},
_page{""},
_descr{""},
_order{""},
_addr{""},
_reg{""},
_pin{""},
_map{""},
_c{""},
_inv{""},
_state{""},
_db{""},
_type{""},
_int{""},
_cnt{""},
_val{""},
_index{""}
{};
void update() {
//String order = sCmd.order();
//SerialPrint("I","module","create '" + order + "'");
for (int i = 1; i < 12; i++) {
if (i == 1) _key = sCmd.next();
if (i == 2) _file = sCmd.next();
if (i == 3) _page = sCmd.next();
if (i == 4) _descr = sCmd.next();
if (i == 5) _order = sCmd.next();
}
for (int i = 1; i < 10; i++) {
String arg = sCmd.next();
if (arg != "") {
if (arg.indexOf("pin[") != -1) {
_pin = extractInner(arg);
}
if (arg.indexOf("inv[") != -1) {
_inv = extractInner(arg);
}
if (arg.indexOf("st[") != -1) {
_state = extractInner(arg);
}
if (arg.indexOf("db[") != -1) {
_db = extractInner(arg);
}
if (arg.indexOf("map[") != -1) {
_map = extractInner(arg);
}
if (arg.indexOf("c[") != -1) {
_c = extractInner(arg);
}
if (arg.indexOf("type[") != -1) {
_type = extractInner(arg);
}
if (arg.indexOf("addr[") != -1) {
_addr = extractInner(arg);
}
if (arg.indexOf("reg[") != -1) {
_reg = extractInner(arg);
}
if (arg.indexOf("int[") != -1) {
_int = extractInner(arg);
}
if (arg.indexOf("cnt[") != -1) {
_cnt = extractInner(arg);
}
if (arg.indexOf("val[") != -1) {
_val = extractInner(arg);
}
if (arg.indexOf("index[") != -1) {
_index = extractInner(arg);
}
}
}
_page.replace("#", " ");
_descr.replace("#", " ");
_descr.replace("%ver%", String(FIRMWARE_VERSION));
_descr.replace("%name%", jsonReadStr(configSetupJson, F("name")));
createWidget(_descr, _page, _order, _file, _key);
}
//jsonWriteStr(configOptionJson, _key + "_pin", _pin);
String gkey() {
return _key;
}
String gfile() {
return _file;
}
String gpage() {
return _page;
}
String gdescr() {
return _descr;
}
String gorder() {
return _order;
}
String gpin() {
return _pin;
}
String ginv() {
return _inv;
}
String gstate() {
return _state;
}
String gmap() {
return _map;
}
String gc() {
return _c;
}
String gtype() {
return _type;
}
String gaddr() {
return _addr;
}
String gregaddr() {
return _reg;
}
String gint() {
return _int;
}
String gcnt() {
return _cnt;
}
String gval() {
return _val;
}
String gindex() {
return _index;
}
void clear() {
_key = "";
_file = "";
_page = "";
_descr = "";
_order = "";
_addr = "";
_reg = "";
_pin = "";
_map = "";
_c = "";
_inv = "";
_state = "";
_db = "";
_type = "";
_int = "";
_cnt = "";
_val = "";
_index = "";
}
String extractInnerDigit(String str) {
int p1 = str.indexOf("[");
int p2 = str.indexOf("]");
return str.substring(p1 + 1, p2);
}
void createWidget(String descr, String page, String order, String filename, String topic) {
if (filename != "na") {
String buf = "{}";
if (!loadWidget(filename, buf)) {
return;
}
if(filename.indexOf("chart") != -1) jsonWriteStr(buf, "maxCount", _cnt);
jsonWriteStr(buf, "page", page);
jsonWriteStr(buf, "order", order);
jsonWriteStr(buf, "descr", descr);
jsonWriteStr(buf, "topic", prex + "/" + topic);
#ifdef LAYOUT_IN_RAM
all_widgets += widget + "\r\n";
#else
addFileLn("layout.txt", buf);
#endif
}
}
bool loadWidget(const String& filename, String& buf) {
buf = readFile(getWidgetFile(filename), 2048);
bool res = !(buf == "Failed" || buf == "Large");
if (!res) {
//SerialPrint("[E]","module","on load" + filename);
}
return res;
}
const String getWidgetFile(const String& name) {
return "/widgets/" + name + ".json";
}
};
extern LineParsing myLineParsing;

View File

@@ -1,32 +0,0 @@
#pragma once
#include <Arduino.h>
#include <stdint.h>
#include <functional>
typedef std::function<void(void*)> NotAsyncCb;
struct NotAsyncItem {
bool test;
NotAsyncCb cb;
void* cb_arg;
volatile bool is_used = false;
};
class NotAsync {
private:
uint8_t size;
uint8_t task = 0;
NotAsyncItem* items = NULL;
void handle(NotAsyncCb f, void* arg);
public:
NotAsync(uint8_t size);
~NotAsync();
void add(uint8_t i, NotAsyncCb, void* arg);
void make(uint8_t task);
void loop();
};
extern NotAsync* myNotAsyncActions;

View File

@@ -1,69 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Cmd.h"
#include "Global.h"
class Scenario {
public:
void loop() {
String allBlocks = scenario;
allBlocks.replace("\r\n", "\n");
allBlocks.replace("\r", "\n");
allBlocks += "\n";
String incommingEvent = selectToMarker(eventBuf, ",");
while (allBlocks.length() > 1) {
String oneBlock = selectToMarker(allBlocks, "end\n");
String condition = selectToMarker(oneBlock, "\n");
String setEvent = selectFromMarkerToMarker(condition, " ", 0);
String setEventSign = selectFromMarkerToMarker(condition, " ", 1);
String setEventValue = selectFromMarkerToMarker(condition, " ", 2);
if (!isDigitStr(setEventValue)) setEventValue = jsonReadStr(configLiveJson, setEventValue);
String incommingEventValue = jsonReadStr(configLiveJson, incommingEvent);
if (incommingEvent == setEvent) {
boolean flag = false;
if (setEventSign == "=") {
flag = incommingEventValue == setEventValue;
}
else if (setEventSign == "!=") {
flag = incommingEventValue != setEventValue;
}
else if (setEventSign == "<") {
flag = incommingEventValue.toFloat() < setEventValue.toFloat();
}
else if (setEventSign == ">") {
flag = incommingEventValue.toFloat() > setEventValue.toFloat();
}
else if (setEventSign == ">=") {
flag = incommingEventValue.toFloat() >= setEventValue.toFloat();
}
else if (setEventSign == "<=") {
flag = incommingEventValue.toFloat() <= setEventValue.toFloat();
}
if (flag) {
//SerialPrint("I", "Scenario", "incomming Event Value: " + incommingEventValue);
//SerialPrint("I", "Scenario", "set Event Value: " + setEventValue);
oneBlock = deleteBeforeDelimiter(oneBlock, "\n");
oneBlock.replace("end", "");
SerialPrint("I", "Scenario", condition + " set:\n" + oneBlock);
spaceCmdExecute(oneBlock);
}
}
allBlocks = deleteBeforeDelimiter(allBlocks, "end\n");
}
eventBuf = deleteBeforeDelimiter(eventBuf, ",");
}
};
extern Scenario* myScenario;

View File

@@ -1,70 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Cmd.h"
#include "Global.h"
class Scenario {
public:
void loop() {
String allBlocks = scenario;
allBlocks.replace("\r\n", "\n");
allBlocks.replace("\r", "\n");
allBlocks += "\n";
String incommingEvent = selectToMarker(eventBuf, ",");
String incommingEventKey = selectToMarker(incommingEvent, " ");
String incommingEventValue = selectToMarkerLast(incommingEvent, " ");
while (allBlocks.length() > 1) {
String oneBlock = selectToMarker(allBlocks, "end\n");
String condition = selectToMarker(oneBlock, "\n");
String setEventKey = selectFromMarkerToMarker(condition, " ", 0);
if (incommingEventKey == setEventKey) {
String setEventSign = selectFromMarkerToMarker(condition, " ", 1);
String setEventValue = selectFromMarkerToMarker(condition, " ", 2);
if (!isDigitStr(setEventValue)) setEventValue = jsonReadStr(configLiveJson, setEventValue);
boolean flag = false;
if (setEventSign == "=") {
flag = incommingEventValue == setEventValue;
}
else if (setEventSign == "!=") {
flag = incommingEventValue != setEventValue;
}
else if (setEventSign == "<") {
flag = incommingEventValue.toFloat() < setEventValue.toFloat();
}
else if (setEventSign == ">") {
flag = incommingEventValue.toFloat() > setEventValue.toFloat();
}
else if (setEventSign == ">=") {
flag = incommingEventValue.toFloat() >= setEventValue.toFloat();
}
else if (setEventSign == "<=") {
flag = incommingEventValue.toFloat() <= setEventValue.toFloat();
}
if (flag) {
//SerialPrint("I", "Scenario", "incomming Event Value: " + incommingEventValue);
//SerialPrint("I", "Scenario", "set Event Value: " + setEventValue);
oneBlock = deleteBeforeDelimiter(oneBlock, "\n");
oneBlock.replace("end", "");
SerialPrint("I", "Scenario", condition + " \n" + oneBlock);
spaceCmdExecute(oneBlock);
}
}
allBlocks = deleteBeforeDelimiter(allBlocks, "end\n");
}
eventBuf = deleteBeforeDelimiter(eventBuf, ",");
}
};
extern Scenario* myScenario;

View File

@@ -1,166 +0,0 @@
#pragma once
#include "Clock.h"
#include "Global.h"
#include "Utils/TimeUtils.h"
#include "Utils/SerialPrint.h"
extern void clock_init();
#ifdef ESP8266
#include "sntp.h"
#endif
class Clock {
private:
Time_t _time_local;
Time_t _time_utc;
unsigned long _uptime;
unsigned long _unixtime;
int _timezone;
String _ntp;
bool _hasSynced;
bool _configured;
public:
Clock() : _uptime{0}, _timezone{0}, _ntp{""}, _hasSynced{false}, _configured{false} {};
void loop() {
unsigned long passed = millis_since(_uptime);
if (passed < ONE_SECOND_ms) {
return;
}
_uptime += passed;
// world time
time_t now = getSystemTime();
time_t estimated = _unixtime + (passed / ONE_SECOND_ms);
double drift = difftime(now, estimated);
if (drift > 1) {
// Обработать ситуации c дрифтом времени на значительные величины
}
_unixtime = now;
breakEpochToTime(_unixtime, _time_utc);
breakEpochToTime(_unixtime + getOffsetInSeconds(_timezone), _time_local);
}
bool hasSync() {
if (!_hasSynced) {
startSync();
}
return _hasSynced;
}
void setNtpPool(String ntp) {
if (!_ntp.equals(ntp)) {
_ntp = ntp;
_configured = false;
}
}
void setTimezone(int timezone) {
if (_timezone != timezone) {
_timezone = timezone;
_configured = false;
}
}
void startSync() {
if (!_configured) {
SerialPrint("I", "NTP", "sync to: " + _ntp + " timezone: " + String(_timezone));
setupSntp();
_configured = true;
return;
}
_hasSynced = hasTimeSynced();
if (_hasSynced) {
SerialPrint("I", "NTP", "synced " + getDateDotFormated() + " " + getTime());
} else {
SerialPrint("E", "NTP", "failed to obtain time");
}
}
void setupSntp() {
#ifdef ESP8266
sntp_setservername(0, _ntp.c_str());
sntp_setservername(1, "ru.pool.ntp.org");
sntp_setservername(2, "pool.ntp.org");
sntp_stop();
sntp_set_timezone(0);
sntp_init();
#else
configTime(0, 0, _ntp.c_str(), "ru.pool.ntp.org", "pool.ntp.org");
#endif
}
bool hasTimeSynced() const {
return _unixtime > MIN_DATETIME;
}
time_t getSystemTime() const {
timeval tv{0, 0};
timezone tz = timezone{0, 0};
time_t epoch = 0;
if (gettimeofday(&tv, &tz) != -1) {
epoch = tv.tv_sec;
}
return epoch;
}
const String getTimeUnix() {
return String(_unixtime);
}
/*
* Локальное время "дд.ММ.гг"
*/
const String getDateDotFormated() {
char buf[32];
sprintf(buf, "%02d.%02d.%02d", _time_local.day_of_month, _time_local.month, _time_local.year);
return String(buf);
}
/*
* Локальное дата время "дд.ММ.гг чч.мм.cc"
*/
const String getDateTimeDotFormated() {
char buf[32];
sprintf(buf, "%02d.%02d.%02d %02d:%02d:%02d", _time_local.day_of_month, _time_local.month, _time_local.year, _time_local.hour, _time_local.minute, _time_local.second);
return String(buf);
}
/*
* Локальное время "чч:мм:cc"
*/
const String getTime() {
char buf[32];
sprintf(buf, "%02d:%02d:%02d", _time_local.hour, _time_local.minute, _time_local.second);
return String(buf);
}
const String getTimeJson() {
char buf[32];
sprintf(buf, "%02d-%02d-%02d", _time_local.hour, _time_local.minute, _time_local.second);
return String(buf);
}
/*
* Локальное время "чч:мм"
*/
const String getTimeWOsec() {
char buf[32];
sprintf(buf, "%02d:%02d", _time_local.hour, _time_local.minute);
return String(buf);
}
/*
* Время с момента запуска "чч:мм:cc" далее "дд чч:мм"
*/
const String getUptime() {
return prettyMillis(_uptime);
}
};
extern Clock* timeNow;

View File

@@ -1,65 +0,0 @@
#pragma once
#include <Arduino.h>
extern void cmd_init();
extern void sensorsInit();
//extern void levelPr();
//extern void ultrasonicCm();
//extern void ultrasonic_reading();
extern void analog_reading1();
extern void analog_reading2();
extern void dallas_reading();
extern void dhtT_reading();
//extern void dallas();
extern void bmp280T();
extern void bmp280P();
extern void bmp280T_reading();
extern void bmp280P_reading();
extern void bme280T();
extern void bme280P();
extern void bme280H();
extern void bme280A();
extern void bme280T_reading();
extern void bme280P_reading();
extern void bme280H_reading();
extern void bme280A_reading();
//extern void dhtT();
//extern void dhtH();
//extern void dhtP();
//extern void dhtC();
//extern void dhtD();
//extern void dhtH_reading();
//extern void dhtP_reading();
//extern void dhtC_reading();
//extern void dhtD_reading();
extern void handle_time_init();
extern void stepper();
extern void stepperSet();
extern void servo_();
extern void servoSet();
extern void serialBegin();
extern void serialWrite();
extern void logging();
extern void button();
extern void timeSet();
extern void mqttOrderSend();
extern void httpOrderSend();
extern void firmwareVersion();
extern void firmwareUpdate();
extern void loadScenario();
extern void fileCmdExecute(const String& filename);
extern void csvCmdExecute(String& cmdStr);
extern void spaceCmdExecute(String& cmdStr);

View File

@@ -1,112 +0,0 @@
#pragma once
//===========Firmware=============================================================================================================================================
#ifdef ESP8266
#define FIRMWARE_NAME "esp8266-iotm"
#define FIRMWARE_VERSION 267
#endif
#ifdef ESP32
#define FIRMWARE_NAME "esp32-iotm"
#define FIRMWARE_VERSION 267
#endif
#define FLASH_4MB true
//===========FSystem==============================================================================================================================================
#define NUM_BUTTONS 6
#define LED_PIN 2
//===========MQTT=================================================================================================================================================
#define MQTT_RECONNECT_INTERVAL 20000
//==========Telemetry=============================================================================================================================================
#define TELEMETRY_UPDATE_INTERVAL_MIN 60
//=========Configuration==========================================================================================================================================
#define DEVICE_CONFIG_FILE "s.conf.csv"
#define DEVICE_SCENARIO_FILE "s.scen.txt"
//=========System parts===========================================================================================================================================
//#define OTA_UPDATES_ENABLED
//#define MDNS_ENABLED
//#define WEBSOCKET_ENABLED
//#define LAYOUT_IN_RAM
//#define UDP_ENABLED
//#define SSDP_ENABLED
//=========Sensors enable/disable=================================================================================================================================
#define TANK_LEVEL_SAMPLES 10
#define LEVEL_ENABLED
#define ANALOG_ENABLED
#define DALLAS_ENABLED
#define DHT_ENABLED
#define BMP_ENABLED
#define BME_ENABLED
//=========Gears enable/disable===================================================================================================================================
#define STEPPER_ENABLED
#define SERVO_ENABLED
//========Other enable/disable====================================================================================================================================
#define LOGGING_ENABLED
#define SERIAL_ENABLED
#define PUSH_ENABLED
struct Time_t {
uint8_t second;
uint8_t minute;
uint8_t hour;
uint8_t day_of_week;
uint8_t day_of_month;
uint8_t month;
uint16_t day_of_year;
uint16_t year;
unsigned long days;
unsigned long valid;
};
//================================================================================================================================================================
enum TimerTask_t { WIFI_SCAN,
WIFI_MQTT_CONNECTION_CHECK,
SENSORS10SEC,
SENSORS30SEC,
TIMER_COUNTDOWN,
TIME,
TIME_SYNC,
STATISTICS,
STATISTICS_WORK,
UPTIME,
UDP,
UDP_DB,
TEST };
enum NotAsyncActions {
do_ZERO,
do_UPGRADE,
do_GETLASTVERSION,
do_UDPDATAPARSE,
do_MQTTUDP,
do_BUSSCAN,
do_MQTTPARAMSCHANGED,
do_deviceInit,
do_delChoosingItems,
do_LAST,
};
enum LedStatus_t {
LED_OFF,
LED_ON,
LED_SLOW,
LED_FAST
};
enum ConfigType_t {
CT_CONFIG,
CT_SCENARIO
};
//07.11.2020
//RAM: [===== ] 46.8% (used 38376 bytes from 81920 bytes)
//Flash: [===== ] 54.2% (used 566004 bytes from 1044464 bytes)

View File

@@ -1,26 +0,0 @@
#pragma once
#ifdef ESP32
// don't change order
#include "WiFi.h"
//
#include "ESPAsyncWebServer.h"
#include "SPIFFSEditor.h"
// don't change order
#include <AsyncUDP.h>
#include <ESP32Servo.h>
#include <HTTPClient.h>
#include <HTTPUpdate.h>
//
#include <WiFi.h>
#include <analogWrite.h>
#ifdef MDNS_ENABLED
#include <ESPmDNS.h>
#endif
extern AsyncUDP udp;
#endif

View File

@@ -1,19 +0,0 @@
#pragma once
#ifdef ESP8266
#include <ESP8266WebServer.h>
#include <ESP8266httpUpdate.h>
#include "ESPAsyncTCP.h"
#include "ESPAsyncWebServer.h"
#include <LittleFS.h>
#include <SPIFFSEditor.h>
#include <Servo.h>
#include <WiFiUdp.h>
#include <SoftwareSerial.h>
#ifdef MDNS_ENABLED
#include <ESP8266mDNS.h>
#endif
extern WiFiUDP udp;
#endif

View File

@@ -1,33 +0,0 @@
#pragma once
#include <ESPAsyncWebServer.h>
#include <FS.h>
#ifdef ESP8266
#include <LittleFS.h>
#endif
class FSEditor : public AsyncWebHandler {
private:
fs::FS _fs;
String _username;
String _password;
bool _authenticated;
uint32_t _startTime;
private:
void getDirList(const String& path, String& output);
public:
#ifdef ESP32
FSEditor(const fs::FS& fs, const String& username = String(), const String& password = String());
#else
FSEditor(const String& username = String(), const String& password = String(), const fs::FS& fs = LittleFS);
#endif
virtual bool canHandle(AsyncWebServerRequest* request) override final;
virtual void handleRequest(AsyncWebServerRequest* request) override final;
virtual void handleUpload(AsyncWebServerRequest* request, const String& filename, size_t index, uint8_t* data, size_t len, bool final) override final;
virtual bool isRequestHandlerTrivial() override final {
return false;
}
};

View File

@@ -1,132 +0,0 @@
#pragma once
//===================Libraries===================================================================================================================================================
#include <Adafruit_BME280.h>
#include <Adafruit_BMP280.h>
#include <Arduino.h>
#include "CTBot.h"
#include <ArduinoJson.h>
#include <ArduinoOTA.h>
#include <Bounce2.h>
#include <DHTesp.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <PubSubClient.h>
#include <StringCommand.h>
#include <TickerScheduler.h>
#include <Wire.h>
#include <time.h>
#include "Clock.h"
#include "Consts.h"
#include "ESP32.h"
#include "ESP8266.h"
#include "GyverFilters.h"
#include "MqttClient.h"
#include "Upgrade.h"
#include "Utils/FileUtils.h"
#include "Utils/JsonUtils.h"
#include "Utils/SerialPrint.h"
#include "Utils/StringUtils.h"
#include "Utils/SysUtils.h"
#include "Utils/WiFiUtils.h"
#ifdef WEBSOCKET_ENABLED
extern AsyncWebSocket ws;
//extern AsyncEventSource events;
#endif
extern TickerScheduler ts;
extern WiFiClient espClient;
extern PubSubClient mqtt;
extern StringCommand sCmd;
extern AsyncWebServer server;
extern boolean but[NUM_BUTTONS];
extern Bounce* buttons;
//Global vars
extern boolean just_load;
extern boolean telegramInitBeen;
// Json
extern String configSetupJson; //все настройки
extern String configLiveJson; //все данные с датчиков (связан с mqtt)
extern String configOptionJson; //для трансфера
// Mqtt
extern String chipId;
extern String prex;
extern String all_widgets;
extern String scenario;
//orders and events
extern String orderBuf;
extern String eventBuf;
extern String itemsFile;
extern String itemsLine;
//key lists and numbers
extern String impulsKeyList;
extern int impulsEnterCounter;
// Sensors
extern String sensorReadingMap10sec;
extern String sensorReadingMap30sec;
extern String loggingKeyList;
extern int enter_to_logging_counter;
extern int scenario_line_status[40];
extern int lastVersion;
// Main
extern void setChipId();
extern void saveConfig();
extern void setConfigParam(const char* param, const String& value);
extern String getURL(const String& urls);
extern void do_fscheck();
extern void doBusScan();
extern void servo_();
extern void setLedStatus(LedStatus_t);
//Scenario
extern void eventGen2(String eventName, String eventValue);
extern String add_set(String param_name);
//Timers
extern void Timer_countdown_init();
extern void timerStart_();
extern void addTimer(String number, String time);
extern void timerStop_();
extern void delTimer(String number);
extern int readTimer(int number);
extern void upgradeInit();
// widget
extern void createWidgetByType(String widget_name, String page_name, String page_number, String file, String topic);
extern void createWidgetParam(String widget_name, String page_name, String page_number, String file, String topic, String name1, String param1, String name2, String param2, String name3, String param3);
extern void createWidget(String widget_name, String page_name, String page_number, String type, String topik);
extern void createChart(String widget_name, String page_name, String page_number, String file, String topic, String maxCount);
// PushingBox
extern void pushControl();
// UDP
//extern void udpInit();
//extern void do_udp_data_parse();
//extern void do_mqtt_send_settings_to_udp();
extern void do_update();
// Init
extern void uptime_init();
// Web
extern void web_init();
// Upgrade
extern String serverIP;

View File

@@ -1,9 +0,0 @@
#pragma once
#include "Global.h"
namespace HttpServer {
void init();
} // namespace HttpServer

View File

@@ -1,10 +0,0 @@
#pragma once
extern void loadConfig();
extern void all_init();
extern void statistics_init();
extern void loadScenario();
extern void Device_init();
extern void prsets_init();
extern void handle_uptime();
extern void handle_statistics();

View File

@@ -1,13 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Global.h"
extern void itemsListInit();
extern void addItem(String name);
extern void addPreset(String name);
extern void delChoosingItems();
extern void delAllItems();
extern uint8_t getNewElementNumber(String file);
extern uint8_t getFreePinAll();
extern uint8_t getFreePinAnalog();

View File

@@ -1,72 +0,0 @@
#pragma once
#include <Arduino.h>
class CharBuffer : Print {
public:
CharBuffer(size_t size) : _capacity(size < 2 ? 2 : size), _write(0), _read(0) {
_pool = new char[_capacity + 1];
memset(_pool, 0, _capacity + 1);
}
CharBuffer(const CharBuffer &src) {
_capacity = src._capacity;
_write = src._write;
memcpy(_pool, src._pool, src._write);
}
CharBuffer(const char *str) : CharBuffer(strlen(str) + 1) {
write((const uint8_t *)str, strlen(str));
}
~CharBuffer() {
delete _pool;
}
void clear() {
memset(_pool, 0, _capacity);
_write = 0;
_read = 0;
}
size_t size() const { return _capacity; }
size_t free() const { return _capacity - _write - 2; }
size_t available() const { return _write; }
const char *c_str() {
if (_pool[_write] != '\x00')
_pool[_write] = '\x00';
return _pool;
}
size_t write(char ch) {
return write((uint8_t)ch);
};
size_t write(const uint8_t ch) {
size_t n = 0;
if (_write < (_capacity - 2)) {
_pool[_write++] = ch;
n = 1;
}
return n;
}
size_t write(const uint8_t *ptr, const size_t size) {
size_t n = 0;
while (n < size) {
uint8_t ch = ptr[n++];
if (!write(ch))
break;
}
return n;
}
protected:
char *_pool;
size_t _capacity;
size_t _write;
size_t _read;
};

View File

@@ -1,86 +0,0 @@
#pragma once
#include <Arduino.h>
template <typename T, size_t BUFFER_SIZE>
class CircularBuffer {
public:
CircularBuffer() : _head{0}, _tail{0}, _full{false} {}
~CircularBuffer() {}
void reset() {
_head = _tail = _full = 0;
}
bool empty() const {
return _head == _tail && !_full;
}
bool full() const {
return _full;
}
size_t size() const {
size_t res = 0;
if (!_full) {
if (_head < _tail)
res = BUFFER_SIZE + _head - _tail;
else
res = _head - _tail;
} else {
res = BUFFER_SIZE;
}
return res;
}
void push(const T &item) {
if (_full) {
_tail++;
if (_tail == BUFFER_SIZE)
_tail = 0;
}
_pool[_head++] = item;
if (_head == BUFFER_SIZE)
_head = 0;
if (_head == _tail)
_full = true;
}
bool pop(T &item) {
bool res = false;
if (!empty()) {
item = _pool[_tail++];
if (_tail == BUFFER_SIZE) _tail = 0;
_full = false;
res = true;
}
return res;
}
bool pop_back(T &item) {
bool res = false;
if (!empty()) {
item = _pool[--_head];
_full = false;
res = true;
}
return res;
}
bool peek(T &item) const {
bool res = false;
if (!empty()) {
item = _pool[_tail];
res = true;
}
return res;
}
private:
T _pool[BUFFER_SIZE];
size_t _head;
size_t _tail;
bool _full;
};

View File

@@ -1,45 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Module/Terminal.h"
#include "Module/CircularBuffer.h"
#include "Module/Runner.h"
class CommandShell {
public:
CommandShell(Runner *runner);
void setTerm(Terminal *term);
Terminal *term();
void showGreetings(bool = true);
void showFarewell(bool = true);
void clearHistory();
void addHistory(const char *);
bool getHistoryInput(String &);
void setEditLine(const String &);
bool active();
void loop();
private:
size_t printGreetings(Print *);
size_t printFarewell(Print *);
size_t printPrompt(Print *);
void onOpen(Print *out);
void onClose(Print *out);
void onData(const char *);
void onHistory(Print *out);
bool getLastInput(String &);
private:
CircularBuffer<String, 4> _history;
Terminal *_term;
Runner *_runner;
String _path;
bool _active;
bool _greetings;
bool _farewell;
};

View File

@@ -1,68 +0,0 @@
#pragma once
#include "Module/CharBuffer.h"
class EditLine : public CharBuffer {
public:
EditLine(size_t size) : CharBuffer(size){};
char &operator[](size_t i) { return _pool[i]; }
char operator[](size_t i) const { return _pool[i]; }
EditLine &operator=(const EditLine &src) {
delete[] _pool;
_pool = new char[src._capacity];
memcpy(_pool, src._pool, src._capacity);
_read = src._read;
_write = src._write;
return *this;
}
void del() {
size_t i;
for (i = _write; i < _capacity; ++i)
_pool[i] = _pool[i + 1];
_pool[i] = '\x00';
}
bool backspace() {
bool res = false;
if (prev()) {
del();
res = true;
}
return res;
}
bool next() {
bool res = false;
if (_write < _capacity - 1) {
_write++;
res = true;
}
return res;
}
bool prev() {
bool res = false;
if (_write > 0) {
_write--;
res = true;
}
return res;
}
size_t home() {
size_t res = _write;
_write = 0;
return res;
}
size_t end() {
size_t n;
for (n = 0; n < _capacity - 1; ++n)
if (_pool[n] == '\x00') break;
return n;
}
};

View File

@@ -1,84 +0,0 @@
#pragma once
#include <Arduino.h>
enum ModuleState_t {
MOD_INIT,
MOD_INIT_FAILED,
MOD_INIT_COMPLETE,
MOD_START_FAILED,
MOD_ACTIVE
};
class Module {
protected:
virtual bool onInit() { return true; };
virtual void onEnd(){};
virtual bool onStart() { return true; }
virtual void onStop(){};
virtual void onLoop() = 0;
protected:
Print *_out;
public:
Module() : _state{MOD_INIT} {}
bool init(bool force = false) {
if (_state > MOD_INIT_COMPLETE) {
return true;
}
if (_state == MOD_INIT_FAILED && !force) {
return false;
}
_state = onInit() ? MOD_INIT_COMPLETE : MOD_INIT_FAILED;
return _state == MOD_INIT_COMPLETE;
}
bool start(bool force = false) {
if (_state == MOD_ACTIVE) {
return true;
}
if (_state == MOD_START_FAILED && !force) {
return false;
}
if (_state < MOD_INIT_COMPLETE) {
if (!init(force)) {
return false;
}
}
_state = onStart() ? MOD_ACTIVE : MOD_START_FAILED;
return _state == MOD_ACTIVE;
}
void stop() {
if (_state < MOD_ACTIVE) {
return;
}
onStop();
_state = MOD_INIT_COMPLETE;
};
void end() {
if (_state < MOD_INIT_FAILED) {
return;
}
onEnd();
_state = MOD_INIT;
};
void loop() {
if (_state == MOD_ACTIVE || start()) onLoop();
};
void setOutput(Print *p) { _out = p; }
ModuleState_t getState() {
return _state;
}
private:
ModuleState_t _state;
};

View File

@@ -1,17 +0,0 @@
#pragma once
#include <Print.h>
#include "Cmd.h"
class Runner {
public:
virtual void run(const char*, Print*);
};
class CmdRunner : public Runner {
public:
void run(const char* cmd, Print* out) override {
String cmdStr{cmd};
csvCmdExecute(cmdStr);
}
};

View File

@@ -1,51 +0,0 @@
#pragma once
#include "Global.h"
#include "Module/Module.h"
#include "Module/Terminal.h"
#include "Module/CommandShell.h"
#include <functional>
enum TelnetEvent_t {
TE_CONNECTED,
TE_DISCONNECTED
};
typedef std::function<void(TelnetEvent_t, WiFiClient*)> TelnetEventHandler;
class Telnet : public Module {
public:
Telnet(uint16_t port) : _port{port}, _lastConnected{false} {};
public:
void setEventHandler(TelnetEventHandler);
void sendData(const String&);
bool hasClient();
bool isShellActive();
void setCommandShell(CommandShell*);
protected:
bool onInit() override;
void onEnd() override;
bool onStart() override;
void onStop() override;
void onLoop() override;
private:
void onConnect();
void onDisconnect();
void onData();
void onOpen();
void onClose();
private:
TelnetEventHandler _eventHandler;
uint16_t _port;
bool _lastConnected;
WiFiClient _client;
WiFiServer* _server;
Terminal* _term;
CommandShell* _shell;
};

View File

@@ -1,186 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Module/EditLine.h"
#include <functional>
#define A_NORMAL 0x0000 // normal
#define A_UNDERLINE 0x0001 // underline
#define A_REVERSE 0x0002 // reverse
#define A_BLINK 0x0004 // blink
#define A_BOLD 0x0008 // bold
#define A_DIM 0x0010 // dim
#define A_STANDOUT A_BOLD // standout (same as bold)
#define F_BLACK 0x0100 // foreground black
#define F_RED 0x0200 // foreground red
#define F_GREEN 0x0300 // foreground green
#define F_BROWN 0x0400 // foreground brown
#define F_BLUE 0x0500 // foreground blue
#define F_MAGENTA 0x0600 // foreground magenta
#define F_CYAN 0x0700 // foreground cyan
#define F_WHITE 0x0800 // foreground white
#define F_YELLOW F_BROWN // some terminals show brown as yellow (with A_BOLD)
#define F_COLOR 0x0F00 // foreground mask
#define B_BLACK 0x1000 // background black
#define B_RED 0x2000 // background red
#define B_GREEN 0x3000 // background green
#define B_BROWN 0x4000 // background brown
#define B_BLUE 0x5000 // background blue
#define B_MAGENTA 0x6000 // background magenta
#define B_CYAN 0x7000 // background cyan
#define B_WHITE 0x8000 // background white
#define B_YELLOW B_BROWN // some terminals show brown as yellow (with A_BOLD)
#define B_COLOR 0xF000 // background mask
#define CHAR_NULL 0x00
#define CHAR_BEL 0x07
#define CHAR_BS 0x08
#define CHAR_SPACE 0x20
#define CHAR_TAB 0x09
#define CHAR_LF 0x0a
#define CHAR_CR 0x0d
#define CHR_ZERO 0x30
#define KEY_DEL 0x7f
#define KEY_DOWN 0x80
#define KEY_UP 0x81
#define KEY_LEFT 0x82
#define KEY_RIGHT 0x83
#define KEY_HOME 0x84
#define KEY_INS 0x86
#define KEY_PAGE_DOWN 0x87
#define KEY_PAGE_UP 0x88
#define KEY_END 0x89
#define CHAR_LT 0x8b
#define CHAR_CSI 0x9b
#define CHAR_ESC 0x1b
#define CHAR_BIN 0xFF
#define ESC_CURSOR_HOME "\x1b[H"
#define ESC_SAVE_CURSOR "\x1b[s"
#define ESC_UNSAVE_CURSOR "\x1b[u"
#define ESC_SAVE_CURSOR_AND_ATTRS "\x1b[7"
#define ESC_RESTORE_CURSOR_AND_ATTRS "\x1b[8"
#define ESC_CLEAR "\x1b[2J"
#define ESC_CLEAR_BOTTOM "\x1b[J"
#define ESC_CLEAR_EOL "\x1b[0K"
#define ESC_CURSOR_UP "\x1b[1A"
#define ESC_CURSOR_DOWN "\x1b[1B"
#define ESC_CURSOR_FORWARD "\x1b[1C"
#define ESC_CURSOR_BACKWARD "\x1b[1D"
#define SEQ_CSI PSTR("\033[") // code introducer
#define SEQ_LOAD_G1 PSTR("\033)0") // load G1 character set
#define SEQ_CLEAR PSTR("\033[2J") // clear screen
#define SEQ_ATTRSET PSTR("\033[0") // set attributes, e.g. "\033[0;7;1m"
#define SEQ_ATTRSET_BOLD PSTR(";1") // bold
#define SEQ_ATTRSET_DIM PSTR(";2") // dim
#define SEQ_ATTRSET_FCOLOR PSTR(";3") // forground color
#define SEQ_ATTRSET_UNDERLINE PSTR(";4") // underline
#define SEQ_ATTRSET_BCOLOR PSTR(";4") // background color
#define SEQ_ATTRSET_BLINK PSTR(";5") // blink
#define SEQ_ATTRSET_REVERSE PSTR(";7") // reverse
enum TerminalEventEnum {
EVENT_OPEN,
EVENT_CLOSE,
EVENT_TAB
};
enum SpecialKeyEnum { SPEC_KEY_UP,
SPEC_KEY_TAB,
SPEC_KEY_ENTER,
SPEC_KEY_ESC };
typedef std::function<bool(SpecialKeyEnum key)> SpecialKeyPressedEvent;
typedef std::function<void(TerminalEventEnum, Stream *)> TerminalEventHandler;
typedef std::function<void(const char *)> TerminalInputEventHandler;
enum EOLType_t { CRLF,
LFCR,
LF,
CR };
enum State { ST_INACTIVE,
ST_NORMAL,
ST_ESC_SEQ,
ST_CTRL_SEQ };
class Terminal : public Print {
public:
Terminal(Stream *stream = nullptr);
void setStream(Stream *stream);
void setEOL(EOLType_t code);
void enableControlCodes(bool enabled = true);
void enableEcho(bool enabled = true);
void enableColors(bool enabled = true);
void setOnEvent(TerminalEventHandler);
void setOnSpecKeyPress(SpecialKeyPressedEvent);
void setOnReadLine(TerminalInputEventHandler);
bool setLine(const uint8_t *bytes, size_t size);
CharBuffer &getLine();
void backsp();
void clear();
void clear_line();
size_t println(const char *str);
size_t println(void);
size_t write_P(PGM_P str);
size_t write(uint8_t c);
size_t write(const uint8_t *buf, size_t size);
void writeByDigit(uint8_t i);
bool available();
void loop();
void start();
void quit();
void initscr();
void attrset(uint16_t attr);
private:
void move(uint8_t y, uint8_t x);
TerminalEventHandler eventHandler_;
TerminalInputEventHandler inputHandler_;
uint8_t attr = 0xff;
uint8_t curY = 0xff;
uint8_t curX = 0xff;
unsigned long _lastReceived = 0;
State state;
Stream *_stream;
EditLine _line;
char _cc_buf[32] = {0};
size_t _cc_pos = 0;
bool _color = false;
bool _controlCodes = false;
bool _echo = false;
EOLType_t _eol = CRLF;
struct ControlCode {
const char *cc;
const char ch;
};
ControlCode keyMap[10] = {
{"G", KEY_HOME}, // 71 Home key
{"H", KEY_UP}, // 72 Up arrow
{"I", KEY_PAGE_UP}, // 73 PageUp
{"K", KEY_LEFT}, // 75 Left arrow
{"M", KEY_RIGHT}, // 77 Right arrow
{"O", KEY_END}, // 79 End key
{"P", KEY_DOWN}, // 80 Down arrow
{"Q", KEY_PAGE_DOWN}, // 81 PageDown
{"R", KEY_INS}, // 82 Insert
{"S", KEY_DEL}, // 83 Delete
};
};

View File

@@ -1,23 +0,0 @@
#pragma once
#include <Arduino.h>
void mqttInit();
boolean mqttConnect();
void mqttReconnect();
void mqttLoop();
void mqttSubscribe();
boolean publish(const String& topic, const String& data);
boolean publishData(const String& topic, const String& data);
boolean publishChart(const String& topic, const String& data);
boolean publishControl(String id, String topic, String state);
boolean publishChart_test(const String& topic, const String& data);
boolean publishStatus(const String& topic, const String& data);
void publishWidgets();
void publishState();
void mqttCallback(char* topic, uint8_t* payload, size_t length);
const String getStateStr();

View File

@@ -1,8 +0,0 @@
#pragma once
#include "Utils/SysUtils.h"
namespace Discovery {
}

View File

@@ -1,9 +0,0 @@
#pragma once
#ifdef ESP8266
#include "ESPAsyncUDP.h"
extern AsyncUDP asyncUdp;
extern void asyncUdpInit();
extern String uint8tToString(uint8_t* data, size_t len);
extern bool udpPacketValidation(String& data);
extern void udpPacketParse(String& data);
#endif

View File

@@ -1,9 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Consts.h"
#ifdef SSDP_ENABLED
void SsdpInit();
#endif

View File

@@ -1,3 +0,0 @@
#pragma once

View File

@@ -1,29 +0,0 @@
#pragma once
#include <Arduino.h>
#ifdef ESP8266
#include <Servo.h>
#else
#include <ESP32Servo.h>
#endif
struct Servo_t {
uint8_t num;
uint8_t pin;
Servo* obj;
Servo_t(uint8_t num, uint8_t pin) : num{num}, pin{pin}, obj{nullptr} {};
};
class Servos {
public:
Servos();
Servo* get(uint8_t num);
Servo* create(uint8_t num, uint8_t pin);
size_t count();
private:
std::vector<Servo_t> _items;
};
extern Servos myServo;

View File

@@ -1,139 +0,0 @@
#pragma once
//Strings
// #include <stdafx.h>
#include <stdio.h>
#include <cstring>
#include <iostream>
class char_array {
private:
char *p_stringarray; //initial input array
char *p_inputstring; //holds actual length data
//char **pp_database_string; //allocate data database.cpp
int stringsize; //holds array size to allocate memory
int charinput; //holds array input size
public:
inline char_array(); //inline so other functions can call on it
inline ~char_array();
inline void getinput(char *&); //retrieves user input
inline void grabline(char *&); //retrieve line with whitespace included NOT COMPLETE, may not need
inline int sortline(char **&, char *&); //sorts line into an array of strings and returns number of separate strings
inline int arraysize(); //returns size of string array
inline void printinput(); //print input string
inline void changedefaultsize(); //change default input size NOT COMPLETE
};
inline char_array::char_array() //constructor
{
stringsize = 0;
charinput = 64;
p_stringarray = new char[charinput];
}
inline char_array::~char_array() //destructor
{
delete[] p_inputstring;
delete[] p_stringarray;
}
inline void char_array::getinput(char *&p_stringin) {
stringsize = 0;
scanf("%63s", p_stringarray); //get input string
while (p_stringarray[stringsize] != 0) //finding out the size of string array
{
stringsize++;
}
stringsize++;
p_inputstring = new char[stringsize]; //reallocate memory block and set array inside
for (int i = 0; i < stringsize; i++) {
p_inputstring[i] = p_stringarray[i];
}
p_inputstring[stringsize - 1] = '\x00';
p_stringin = new char[stringsize]; //set pp_stringin
p_stringin = p_inputstring;
}
inline void char_array::grabline(char *&p_stringin) {
stringsize = 0;
std::cin.getline(p_stringarray, charinput);
while (p_stringarray[stringsize] != 0) {
stringsize++;
}
stringsize++;
p_inputstring = new char[stringsize];
for (int i = 0; i < stringsize; i++) {
p_inputstring[i] = p_stringarray[i];
}
p_stringin = new char[stringsize];
p_stringin = p_inputstring;
}
inline int char_array::sortline(char **&pp_stringin, char *&p_string) {
int position = 0; //position in string
int charcount = 1; //how many characters there are
int wordnum; //which word is being processed
int wordcount = 1; //number of words in string
int bookmark = 0; //holds last known position
while (p_string[position] == ' ') {
position++;
}
wordnum = position; //borrow wordnum to hold position value
while (p_string[position] != '\x00') //find total inputted string word length
{
if ((p_string[position] == ' ') && ((p_string[position + 1] != ' ') || (p_string[position + 1] != '\x00'))) {
wordcount++;
}
position++;
}
position = wordnum; //set position to original value
for (wordnum = 0; wordnum < wordcount; wordnum++) {
charcount = 1;
while (p_string[position] == ' ') {
position++;
}
while ((p_string[position] != ' ') && (p_string[position] != '\x00')) {
position++;
charcount++;
}
pp_stringin[wordnum] = new char[charcount];
for (int i = 0; i < charcount; i++) {
pp_stringin[wordnum][i] = p_string[i + bookmark];
}
pp_stringin[wordnum][charcount - 1] = '\x00';
bookmark = position + 1;
}
return wordcount;
}
inline int char_array::arraysize() {
if (stringsize != 0) {
return stringsize;
} else {
printf("Array size is set at 0\n");
return 0;
}
}
inline void char_array::printinput() {
printf("%s", p_inputstring);
}
inline void char_array::changedefaultsize() {
printf("Input new default input string size: ");
scanf("%i", charinput);
}

View File

@@ -1,9 +0,0 @@
#pragma once
#include "Global.h"
extern void sendTelegramMsg();
extern void telegramInit();
extern void handleTelegram();
extern bool isTelegramEnabled();
extern void telegramMsgParse(String msg);
extern String returnListOfParams();

View File

@@ -1,10 +0,0 @@
#pragma once
#include <Arduino.h>
extern void upgradeInit();
extern void getLastVersion();
extern void upgrade_firmware(int type);
extern bool upgradeFS();
extern bool upgradeBuild();
extern void restartEsp();

View File

@@ -1,55 +0,0 @@
#pragma once
#include <Arduino.h>
#include "FS.h"
#ifdef ESP32
#include "LITTLEFS.h"
#define LittleFS LITTLEFS
#endif
#ifdef ESP8266
#include <LittleFS.h>
#endif
class FileHelper {
public:
FileHelper(const String filename);
/*
* Проверить существование
*/
void exists();
/*
* Удалить файл
*/
void remove();
/*
* Открыть файл установить позицию @position
*/
File seek(size_t position = 0);
/*
* Чтение строки с содержащей @substr
*/
String readFileString(const String substr);
/*
* Добовление строки @str в файл
*/
String appendStr(const String str);
/*
* Запись строки
*/
String writeStr(const String);
/*
* Чтение в строку
*/
String readStr(size_t);
/*
* Размер в байтах
*/
size_t getSize();
};

View File

@@ -1,67 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Consts.h"
#include "FS.h"
#ifdef ESP32
#include "LITTLEFS.h"
#define LittleFS LITTLEFS
#endif
#ifdef ESP8266
#include <LittleFS.h>
#endif
/*
* Инициализация ФС
*/
bool fileSystemInit();
/*
* Удалить файл
*/
void removeFile(const String& filename);
/*
* Открыть файл на позиции
*/
File seekFile(const String& filename, size_t position = 0);
/*
* Чтение строки из файла
* возвращает стоку из файла в которой есть искомое слово found
*/
const String readFileString(const String& filename, const String& to_find);
/*
* Добовление строки в файл
*/
const String addFileLn(const String& filename, const String& str);
/*
* Добовление строки в файл
*/
const String addFile(const String& filename, const String& str);
/*
* Запись строки в файл
*/
const String writeFile(const String& filename, const String& str);
/*
* Чтение файла в строку
*/
const String readFile(const String& filename, size_t max_size);
/*
* Размер файла
*/
const String getFileSize(const String& filename);
bool copyFile(const String& src, const String& dst, bool overwrite = true);
const String getFSSizeInfo();
const String getConfigFile(uint8_t preset, ConfigType_t type);

View File

@@ -1,19 +0,0 @@
#pragma once
#include <Arduino.h>
String jsonReadStr(String& json, String name);
int jsonReadInt(String& json, String name);
boolean jsonReadBool(String& json, String name);
String jsonWriteStr(String& json, String name, String value);
String jsonWriteInt(String& json, String name, int value);
String jsonWriteFloat(String& json, String name, float value);
String jsonWriteBool(String& json, String name, boolean value);
void saveConfig();

View File

@@ -1,3 +0,0 @@
#pragma once
#include <Arduino.h>
void SerialPrint(String errorLevel, String module, String msg);

View File

@@ -1,22 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Global.h"
extern void initSt();
extern String updateDevicePsn(String lat, String lon, String accur);
extern String updateDeviceStatus();
extern String addNewDevice();
extern void decide();
extern void getPsn();
extern String getUptimeTotal();
extern uint8_t getNextNumber(String file);
extern uint8_t getCurrentNumber(String file);
//extern int plusOneHour();
//extern void eeWriteInt(int pos, int val);
//extern int eeGetInt(int pos);
//extern void updateDeviceList();
//extern void saveId(String file, int id);
//extern int getId(String file);

View File

@@ -1,30 +0,0 @@
#pragma once
#include <Arduino.h>
uint8_t hexStringToUint8(String hex);
uint16_t hexStringToUint16(String hex);
String selectToMarkerLast(String str, String found);
String selectToMarker(String str, String found);
String extractInner(String str);
String deleteAfterDelimiter(String str, String found);
String deleteBeforeDelimiter(String str, String found);
String deleteBeforeDelimiterTo(String str, String found);
String deleteToMarkerLast(String str, String found);
String selectFromMarkerToMarker(String str, String found, int number);
size_t itemsCount(String str, const String& separator);
boolean isDigitStr(const String&);
String prettyBytes(size_t size);

View File

@@ -1,19 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Global.h"
uint32_t ESP_getChipId();
const String getChipId();
void setLedStatus(LedStatus_t status);
const String getUniqueId(const String& name);
const String printMemoryStatus();
const String getHeapStats();
const String getMacAddress();
void setChipId();

View File

@@ -1,51 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Consts.h"
#define ONE_MINUTE_s 60
#define ONE_HOUR_m 60
#define ONE_HOUR_s 60 * ONE_MINUTE_s
#define LEAP_YEAR(Y) (((1970 + Y) > 0) && !((1970 + Y) % 4) && (((1970 + Y) % 100) || !((1970 + Y) % 400)))
#define MIN_DATETIME 1575158400
#define ONE_SECOND_ms 1000
/*
* Время (мс) прошедщее с @since
*/
unsigned long millis_since(unsigned long sinse);
/*
* Интерввал времени (мс) между @start и @finish
*/
unsigned long millis_passed(unsigned long start, unsigned long finish);
/*
* Форматиронное время интервала (мс)
* "чч:мм:cc",
* "дд чч:мм", если > 24 часов
*/
const String prettyMillis(unsigned long time_ms = millis());
/*
* Форматиронное время интервала (c)
* "чч:мм:cc",
* "дд чч:мм", если > 24 часов
*/
const String prettySeconds(unsigned long time_s);
/*
* Тайм зона в секундах
*/
int getOffsetInSeconds(int timezone);
/*
* Тайм зона в минутах
*/
int getOffsetInMinutes(int timezone);
/*
* Разбивает время на составляющие
*/
void breakEpochToTime(unsigned long epoch, Time_t& tm);

View File

@@ -1,71 +0,0 @@
#include <Arduino.h>
enum Timings_t { MT_ONE,
MT_TWO,
NUM_TIMINGS };
struct Timing {
unsigned long _total_mu;
unsigned long _min_mu;
unsigned long _max_mu;
Timing() : _total_mu{0}, _min_mu{999999}, _max_mu{0} {};
void reset() {
_total_mu = 0;
_min_mu = 999999;
_max_mu = 0;
}
void add(unsigned long time_mu) {
if (time_mu == 0) return;
_total_mu += time_mu;
if (_min_mu > time_mu) {
_min_mu = time_mu;
}
if (_max_mu < time_mu) {
_max_mu = time_mu;
}
}
};
static const char* module_name[NUM_TIMINGS] = {"strings", "boolean"};
struct Timings {
Timing mu[NUM_TIMINGS];
unsigned long _counter;
unsigned long _start;
unsigned long long _total;
Timings() : _counter{0}, _start{0} {};
void add(size_t module, unsigned long now = micros()) {
unsigned long time = now - _start;
_total += time;
mu[module].add(time);
_start = now;
}
void count() {
_counter++;
_start = micros();
}
void print() {
if (!_counter) {
return;
};
Serial.printf("lp/ms: %llu ", _counter / _total);
for (size_t i = 0; i < NUM_TIMINGS; i++) {
Serial.printf("%s: %.2f%% ", module_name[i], ((float)mu[i]._total_mu / _total) * 100);
mu[i].reset();
}
Serial.println();
_counter = 0;
_total = 0;
};
};

View File

@@ -1,7 +0,0 @@
#pragma once
#include "HttpServer.h"
#include <Arduino.h>
extern String getURL(const String& urls);
extern const String getMethodName(AsyncWebServerRequest* request);
extern const String getRequestInfo(AsyncWebServerRequest* request);

View File

@@ -1,12 +0,0 @@
#pragma once
#include "Global.h"
boolean isNetworkActive();
void routerConnect();
bool startAPMode();
boolean RouterFind(String ssid);

View File

@@ -1,6 +0,0 @@
#pragma once
#include "Arduino.h"
void web_init();
void setConfigParam(const char* param, const String& value);

View File

@@ -1,61 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
class ButtonInClass : public LineParsing {
protected:
int numberEntering = 0;
int state = _state.toInt();
public:
ButtonInClass() : LineParsing(){};
void init() {
if (_pin != "") {
int number = numberEntering++;
buttons[number].attach(_pin.toInt());
buttons[number].interval(_db.toInt());
but[number] = true;
jsonWriteStr(configOptionJson, "switch_num_" + String(number), _key);
}
}
void loop() {
static uint8_t switch_number = 1;
if (but[switch_number]) {
buttons[switch_number].update();
if (buttons[switch_number].fell()) {
String key = jsonReadStr(configOptionJson, "switch_num_" + String(switch_number));
state = 1;
switchChangeVirtual(key, String(state));
}
if (buttons[switch_number].rose()) {
String key = jsonReadStr(configOptionJson, "switch_num_" + String(switch_number));
state = 0;
switchChangeVirtual(key, String(state));
}
}
switch_number++;
if (switch_number == NUM_BUTTONS) {
switch_number = 0;
}
}
void switchStateSetDefault() {
if (_state != "") {
switchChangeVirtual(_key, _state);
}
}
void switchChangeVirtual(String key, String state) {
eventGen2(key, state);
jsonWriteInt(configLiveJson, key, state.toInt());
publishStatus(key, state);
}
};
extern ButtonInClass myButtonIn;

View File

@@ -1,41 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
class ButtonOutClass : public LineParsing {
public:
ButtonOutClass() : LineParsing() {};
void init() {
if (_pin != "") {
pinMode(_pin.toInt(), OUTPUT);
}
jsonWriteStr(configOptionJson, _key + "_pin", _pin);
jsonWriteStr(configOptionJson, _key + "_inv", _inv);
}
void pinStateSetDefault() {
pinChange(_key, _state);
}
void pinChange(String key, String state) {
String pin = jsonReadStr(configOptionJson, key + "_pin");
String inv = jsonReadStr(configOptionJson, key + "_inv");
int pinInt = pin.toInt();
if (inv == "") {
digitalWrite(pinInt, state.toInt());
}
else {
digitalWrite(pinInt, !state.toInt());
}
eventGen2(key, state);
jsonWriteInt(configLiveJson, key, state.toInt());
publishStatus(key, state);
}
};
extern ButtonOutClass myButtonOut;

View File

@@ -1,31 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Global.h"
class ImpulsOutClass;
typedef std::vector<ImpulsOutClass> MyImpulsOutVector;
class ImpulsOutClass {
public:
ImpulsOutClass(unsigned int impulsPin);
~ImpulsOutClass();
void loop();
void execute(unsigned long impulsPeriod, unsigned int impulsCount);
private:
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long _impulsPeriod = 0;
unsigned int _impulsCount = 0;
unsigned int _impulsCountBuf = 0;
unsigned int _impulsPin = 0;
};
extern MyImpulsOutVector* myImpulsOut;
extern void impulsExecute();

View File

@@ -1,31 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
class InputClass : public LineParsing {
public:
InputClass() : LineParsing(){};
void inputSetDefaultFloat() {
inputSetFloat(_key, _state);
}
void inputSetDefaultStr() {
inputSetStr(_key, _state);
}
void inputSetFloat(String key, String state) {
eventGen2(key, state);
jsonWriteFloat(configLiveJson, key, state.toFloat());
publishStatus(key, state);
}
void inputSetStr(String key, String state) {
eventGen2(key, state);
jsonWriteStr(configLiveJson, key, state);
publishStatus(key, state);
}
};
extern InputClass myInput;

View File

@@ -1,34 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Global.h"
class LoggingClass;
typedef std::vector<LoggingClass> MyLoggingVector;
class LoggingClass {
public:
LoggingClass(unsigned long period, unsigned int maxPoints, String loggingValueKey, String key);
~LoggingClass();
void loop();
private:
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long _period;
unsigned int _maxPoints;
String _loggingValueKey;
String _key;
void addNewDelOldData(const String filename, size_t maxPoints, String payload);
};
extern MyLoggingVector* myLogging;
extern void choose_log_date_and_send();
extern void sendLogData(String file, String topic);
extern void clean_log_date();

View File

@@ -1,23 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
class OutputTextClass : public LineParsing {
public:
OutputTextClass() : LineParsing(){};
void OutputModuleStateSetDefault() {
if (_state != "") {
OutputModuleChange(_key, _state);
}
}
void OutputModuleChange(String key, String state) {
state.replace("#", " ");
eventGen2(key, state);
jsonWriteStr(configLiveJson, key, state);
publishStatus(key, state);
}
};
extern OutputTextClass myOutputText;

View File

@@ -1,31 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
class PwmOutClass : public LineParsing {
public:
PwmOutClass() : LineParsing(){};
void pwmModeSet() {
if (_pin != "") {
pinMode(_pin.toInt(), INPUT);
}
}
void pwmStateSetDefault() {
if (_state != "") {
pwmChange(_key, _pin, _state);
}
}
void pwmChange(String key, String pin, String state) {
int pinInt = pin.toInt();
analogWrite(pinInt, state.toInt());
eventGen2(key, state);
jsonWriteInt(configLiveJson, key, state.toInt());
publishStatus(key, state);
}
};
extern PwmOutClass myPwmOut;

View File

@@ -1,36 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
#include "items/SensorConvertingClass.h"
class SensorAnalogClass : public SensorConvertingClass {
public:
SensorAnalogClass() : SensorConvertingClass(){};
void SensorAnalogInit() {
jsonWriteStr(configOptionJson, _key + "_pin", _pin);
jsonWriteStr(configOptionJson, _key + "_map", _map);
jsonWriteStr(configOptionJson, _key + "_с", _c);
}
int SensorAnalogRead(String key, String pin) {
int value;
#ifdef ESP32
int pinInt = pin.toInt();
value = analogRead(pinInt);
#endif
#ifdef ESP8266
value = analogRead(A0);
#endif
value = this->mapping(key, value);
float valueFl = this->correction(key, value);
eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
return value;
}
};
extern SensorAnalogClass mySensorAnalog;

View File

@@ -1,55 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
#include "items/SensorConvertingClass.h"
Adafruit_BME280 bme;
Adafruit_Sensor *bme_temp = bme.getTemperatureSensor();
Adafruit_Sensor *bme_pressure = bme.getPressureSensor();
Adafruit_Sensor *bme_humidity = bme.getHumiditySensor();
class SensorBme280Class : public SensorConvertingClass {
public:
SensorBme280Class() : SensorConvertingClass(){};
void SensorBme280Init() {
bme.begin(hexStringToUint8(_addr));
jsonWriteStr(configOptionJson, _key + "_map", _map);
jsonWriteStr(configOptionJson, _key + "_с", _c);
sensorReadingMap10sec += _key + ",";
}
void SensorBme280ReadTmp(String key) {
float value;
value = bme.readTemperature();
float valueFl = this->correction(key, value);
eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
}
void SensorBme280ReadHum(String key) {
float value;
value = bme.readHumidity();
float valueFl = this->correction(key, value);
eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
}
void SensorBme280ReadPress(String key) {
float value;
value = bme.readPressure();
value = value / 1.333224 / 100;
float valueFl = this->correction(key, value);
eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
}
};
extern SensorBme280Class mySensorBme280;

View File

@@ -1,48 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
#include "items/SensorConvertingClass.h"
Adafruit_BMP280 bmp;
Adafruit_Sensor *bmp_temp = bmp.getTemperatureSensor();
Adafruit_Sensor *bmp_pressure = bmp.getPressureSensor();
class SensorBmp280Class : public SensorConvertingClass {
public:
SensorBmp280Class() : SensorConvertingClass(){};
void SensorBmp280Init() {
bmp.begin(hexStringToUint8(_addr));
jsonWriteStr(configOptionJson, _key + "_map", _map);
jsonWriteStr(configOptionJson, _key + "_с", _c);
sensorReadingMap10sec += _key + ",";
}
void SensorBmp280ReadTmp(String key) {
float value;
sensors_event_t temp_event;
bmp_temp->getEvent(&temp_event);
value = temp_event.temperature;
float valueFl = this->correction(key, value);
eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
}
void SensorBmp280ReadPress(String key) {
float value;
sensors_event_t pressure_event;
bmp_pressure->getEvent(&pressure_event);
value = pressure_event.pressure;
value = value / 1.333224;
float valueFl = this->correction(key, value);
eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
}
};
extern SensorBmp280Class mySensorBmp280;

View File

@@ -1,32 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
class SensorConvertingClass : public LineParsing {
public:
SensorConvertingClass() : LineParsing(){};
int mapping(String key, int input) {
String map_ = jsonReadStr(configOptionJson, key + "_map");
if (map_ != "") {
input = map(input,
selectFromMarkerToMarker(map_, ",", 0).toInt(),
selectFromMarkerToMarker(map_, ",", 1).toInt(),
selectFromMarkerToMarker(map_, ",", 2).toInt(),
selectFromMarkerToMarker(map_, ",", 3).toInt());
}
return input;
}
float correction(String key, float input) {
String corr = jsonReadStr(configOptionJson, key + "_с");
if (corr != "") {
float coef = corr.toFloat();
input = input * coef;
}
return input;
}
};

View File

@@ -1,36 +0,0 @@
#pragma once
#include "Global.h"
#include <Arduino.h>
extern DallasTemperature sensors;
extern OneWire* oneWire;
class SensorDallas;
typedef std::vector<SensorDallas> MySensorDallasVector;
class SensorDallas {
public:
SensorDallas(unsigned long interval, unsigned int pin, unsigned int index, String key);
~SensorDallas();
void loop();
void readDallas();
private:
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long _interval;
String _key;
unsigned int _pin;
unsigned int _index;
};
extern MySensorDallasVector* mySensorDallas2;
extern void dallas();

View File

@@ -1,78 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
#include "items/SensorConvertingClass.h"
DHTesp dht;
class SensorDhtClass : public SensorConvertingClass {
public:
SensorDhtClass() : SensorConvertingClass(){};
void SensorDhtInit() {
if (_type == "dht11") {
dht.setup(_pin.toInt(), DHTesp::DHT11);
}
if (_type == "dht22") {
dht.setup(_pin.toInt(), DHTesp::DHT22);
}
sensorReadingMap10sec += _key + ",";
//to do если надо будет читать несколько dht
//dhtEnterCounter++;
//jsonWriteInt(configOptionJson, _key + "_num", dhtEnterCounter);
jsonWriteStr(configOptionJson, _key + "_map", _map);
jsonWriteStr(configOptionJson, _key + "_с", _c);
}
void SensorDhtReadTemp(String key) {
//to do если надо будет читать несколько dht
//int cnt = jsonReadInt(configOptionJson, key + "_num");
float value;
static int counter;
if (dht.getStatus() != 0 && counter < 5) {
counter++;
//return;
} else {
counter = 0;
value = dht.getTemperature();
if (String(value) != "nan") {
//value = this->mapping(key, value);
float valueFl = this->correction(key, value);
eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
} else {
Serial.println("[E] sensor '" + key);
}
}
}
void SensorDhtReadHum(String key) {
//to do если надо будет читать несколько dht
//int cnt = jsonReadInt(configOptionJson, key + "_num");
float value;
static int counter;
if (dht.getStatus() != 0 && counter < 5) {
counter++;
//return;
} else {
counter = 0;
value = dht.getHumidity();
if (String(value) != "nan") {
//value = this->mapping(key, value);
float valueFl = this->correction(key, value);
eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
} else {
Serial.println("[E] sensor '" + key);
}
}
}
};
extern SensorDhtClass mySensorDht;

View File

@@ -1,83 +0,0 @@
//#pragma once
//#include <Arduino.h>
//#include <ModbusMaster.h>
//#include <SoftwareSerial.h>
//
//#include "Class/LineParsing.h"
//#include "Global.h"
//#include "items/SensorConvertingClass.h"
//
//ModbusMaster modbus1;
//SoftwareSerial uart(13, 12); // RX, TX
//
//class SensorModbusClass : public SensorConvertingClass {
// public:
// SensorModbusClass() : SensorConvertingClass(){};
//
// void SensorModbusInit() {
// uart.begin(9600);
// jsonWriteStr(configOptionJson, _key + "_map", _map);
// jsonWriteStr(configOptionJson, _key + "_с", _c);
// sensorReadingMap10sec += _key + " " + _addr + " " + _reg + ",";
// Serial.println(sensorReadingMap10sec);
// }
//
// void SensorModbusRead(String key, uint8_t slaveAddress, uint16_t regAddress) {
// int value;
//
// modbus1.begin(slaveAddress, uart);
// uint16_t reqisterValue = modbus1.readHoldingRegisters(regAddress, 1);
// if (getResultMsg(&modbus1, reqisterValue)) {
// reqisterValue = modbus1.getResponseBuffer(0);
// value = reqisterValue;
// } else {
// value = NULL;
// }
//
// int valueFl = this->correction(key, value);
// eventGen2(key, String(valueFl));
// jsonWriteStr(configLiveJson, key, String(valueFl));
// publishStatus(key, String(valueFl));
// SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl) + ", Slave dev addr: " + String(slaveAddress) + ", Register: " + String(regAddress));
// }
//
// bool getResultMsg(ModbusMaster* modbus1, uint16_t result) {
// String tmpstr;
// switch (result) {
// case modbus1->ku8MBSuccess:
// return true;
// tmpstr += "Ok";
// break;
// case modbus1->ku8MBIllegalFunction:
// tmpstr += "Illegal Function";
// break;
// case modbus1->ku8MBIllegalDataAddress:
// tmpstr += "Illegal Data Address";
// break;
// case modbus1->ku8MBIllegalDataValue:
// tmpstr += "Illegal Data Value";
// break;
// case modbus1->ku8MBSlaveDeviceFailure:
// tmpstr += "Slave Device Failure";
// break;
// case modbus1->ku8MBInvalidSlaveID:
// tmpstr += "Invalid Slave ID";
// break;
// case modbus1->ku8MBInvalidFunction:
// tmpstr += "Invalid Function";
// break;
// case modbus1->ku8MBResponseTimedOut:
// tmpstr += "Response Timed Out";
// break;
// case modbus1->ku8MBInvalidCRC:
// tmpstr += "Invalid CRC";
// break;
// default:
// tmpstr += "Unknown error: " + String(result);
// break;
// }
// SerialPrint("I", "Modbus", tmpstr);
// return false;
// }
//};
//extern SensorModbusClass mySensorModbus;

View File

@@ -1,49 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
#include "items/SensorConvertingClass.h"
#include "GyverFilters.h"
GMedian<6, int> testFilter;
class SensorUltrasonic : public SensorConvertingClass {
public:
SensorUltrasonic() : SensorConvertingClass(){};
void init() {
sensorReadingMap10sec += _key + ",";
String trig = selectFromMarkerToMarker(_pin, ",", 0);
String echo = selectFromMarkerToMarker(_pin, ",", 1);
pinMode(trig.toInt(), OUTPUT);
pinMode(echo.toInt(), INPUT);
jsonWriteStr(configOptionJson, _key + "_trig", trig);
jsonWriteStr(configOptionJson, _key + "_echo", echo);
jsonWriteStr(configOptionJson, _key + "_map", _map);
jsonWriteStr(configOptionJson, _key + "_с", _c);
}
void SensorUltrasonicRead(String key) {
int trig = jsonReadStr(configOptionJson, key + "_trig").toInt();
int echo = jsonReadStr(configOptionJson, key + "_echo").toInt();
int value;
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
long duration_ = pulseIn(echo, HIGH, 30000); // 3000 µs = 50cm // 30000 µs = 5 m
value = duration_ / 29 / 2;
value = testFilter.filtered(value);
value = this->mapping(key, value);
float valueFl = this->correction(key, value);
eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
}
};
extern SensorUltrasonic mySensorUltrasonic;

View File

@@ -1,3 +0,0 @@
#pragma once
//void myCallback;