mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
dell all
This commit is contained in:
@@ -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();
|
||||
};
|
||||
@@ -1,56 +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
|
||||
|
||||
/*
|
||||
* Инициализация ФС
|
||||
*/
|
||||
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 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);
|
||||
@@ -1,15 +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);
|
||||
@@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "CommonTypes.h"
|
||||
|
||||
const String getConfigFile(uint8_t preset, ConfigType_t type);
|
||||
|
||||
const String getItemName(Item_t item);
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "CommonTypes.h"
|
||||
#include "Utils\StringUtils.h"
|
||||
#include "Utils\TimeUtils.h"
|
||||
#include "Errors.h"
|
||||
|
||||
#define pm PrintMessage(MODULE)
|
||||
|
||||
class PrintMessage {
|
||||
public:
|
||||
PrintMessage(const char* module) {
|
||||
_module = module;
|
||||
}
|
||||
|
||||
void error(const String& str) {
|
||||
print(EL_ERROR, str);
|
||||
}
|
||||
|
||||
void info(const String& str) {
|
||||
print(EL_INFO, str);
|
||||
}
|
||||
|
||||
private:
|
||||
void print(const ErrorLevel_t level, const String& str) {
|
||||
Serial.printf("%s [%s] [%s] %s\n", prettyMillis(millis()).c_str(), getErrorLevelStr(level).c_str(), _module, str.c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
const char* _module;
|
||||
};
|
||||
@@ -1,27 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "CommonTypes.h"
|
||||
|
||||
uint8_t hexStringToUint8(String hex);
|
||||
|
||||
uint16_t hexStringToUint16(String hex);
|
||||
|
||||
String selectToMarkerLast(String str, String found);
|
||||
|
||||
String selectToMarker(String str, String found);
|
||||
|
||||
String deleteAfterDelimiter(String str, String found);
|
||||
|
||||
String deleteBeforeDelimiter(String str, String found);
|
||||
|
||||
String deleteBeforeDelimiterTo(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);
|
||||
@@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
const String getChipId();
|
||||
|
||||
const String getUniqueId(const String& name);
|
||||
|
||||
const String printMemoryStatus();
|
||||
|
||||
const String getHeapStats();
|
||||
|
||||
const String getMacAddress();
|
||||
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "CommonTypes.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);
|
||||
@@ -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;
|
||||
};
|
||||
};
|
||||
@@ -1,73 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "ESPAsyncWebServer.h"
|
||||
|
||||
const String getMethodName(AsyncWebServerRequest* request) {
|
||||
String res = F("UNKNOWN");
|
||||
if (request->method() == HTTP_GET)
|
||||
res = F("GET");
|
||||
else if (request->method() == HTTP_POST)
|
||||
res = F("POST");
|
||||
else if (request->method() == HTTP_DELETE)
|
||||
res = F("DELETE");
|
||||
else if (request->method() == HTTP_PUT)
|
||||
res = F("PUT");
|
||||
else if (request->method() == HTTP_PATCH)
|
||||
res = F("PATCH");
|
||||
else if (request->method() == HTTP_HEAD)
|
||||
res = F("HEAD");
|
||||
else if (request->method() == HTTP_OPTIONS)
|
||||
res = F("OPTIONS");
|
||||
return res;
|
||||
}
|
||||
|
||||
const String getRequestInfo(AsyncWebServerRequest* request) {
|
||||
String res = getMethodName(request);
|
||||
res += ' ';
|
||||
res += "http://";
|
||||
res += request->host();
|
||||
res += request->url();
|
||||
res += '\n';
|
||||
if (request->contentLength()) {
|
||||
res += "content-type: ";
|
||||
res += request->contentType();
|
||||
res += " content-lenght: ";
|
||||
res += prettyBytes(request->contentLength());
|
||||
res += '\n';
|
||||
}
|
||||
|
||||
if (request->headers()) {
|
||||
res += "headers:\n";
|
||||
for (size_t i = 0; i < request->headers(); i++) {
|
||||
AsyncWebHeader* h = request->getHeader(i);
|
||||
res += h->name();
|
||||
res += '=';
|
||||
res += h->value();
|
||||
res += '\n';
|
||||
}
|
||||
}
|
||||
|
||||
if (request->params()) {
|
||||
res += "params:\n";
|
||||
for (size_t i = 0; i < request->params(); i++) {
|
||||
AsyncWebParameter* p = request->getParam(i);
|
||||
if (p->isFile()) {
|
||||
res += "FILE";
|
||||
} else if (p->isPost()) {
|
||||
res += "POST";
|
||||
} else {
|
||||
res += "GET";
|
||||
}
|
||||
res += ' ';
|
||||
res += p->name();
|
||||
res += ':';
|
||||
res += p->value();
|
||||
if (p->isFile()) {
|
||||
res += " size:";
|
||||
res += p->size();
|
||||
}
|
||||
res += '\n';
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
boolean isNetworkActive();
|
||||
|
||||
void startSTAMode();
|
||||
|
||||
bool startAPMode();
|
||||
|
||||
boolean scanWiFi(String ssid);
|
||||
|
||||
Reference in New Issue
Block a user