mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-28 07:02:17 +03:00
working wersion with elements
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "Utils/TimeUtils.h"
|
||||
#include "Utils/PrintMessage.h"
|
||||
#include "Global.h"
|
||||
#include "Clock.h"
|
||||
|
||||
#ifdef ESP8266
|
||||
#include "sntp.h"
|
||||
@@ -69,7 +71,7 @@ class Clock {
|
||||
|
||||
void startSync() {
|
||||
if (!_configured) {
|
||||
pm.info("sync to: " + _ntp + " timezone: " + String(_timezone));
|
||||
//pm.info("sync to: " + _ntp + " timezone: " + String(_timezone));
|
||||
setupSntp();
|
||||
_configured = true;
|
||||
// лучше не ждать, проверим в следующий раз
|
||||
@@ -77,9 +79,9 @@ class Clock {
|
||||
}
|
||||
_hasSynced = hasTimeSynced();
|
||||
if (_hasSynced) {
|
||||
pm.info("synced " + getDateDotFormated() + " " + getTime());
|
||||
//pm.info("synced " + getDateDotFormated() + " " + getTime());
|
||||
} else {
|
||||
pm.error("failed to obtain");
|
||||
//pm.error("failed to obtain");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,16 +2,18 @@
|
||||
/*
|
||||
* Main consts
|
||||
*/
|
||||
#define FIRMWARE_VERSION "2.3.5"
|
||||
#define FIRMWARE_VERSION "2.4.0"
|
||||
#define NUM_BUTTONS 6
|
||||
#define LED_PIN 2
|
||||
#define FLASH_4MB true
|
||||
|
||||
#define MQTT_RECONNECT_INTERVAL 20000
|
||||
|
||||
#define TELEMETRY_UPDATE_INTERVAL 7200000
|
||||
|
||||
#define DEVICE_CONFIG_FILE "conf.csv"
|
||||
#define DEVICE_SCENARIO_FILE "dev_scen.txt"
|
||||
#define DEVICE_CONFIG_FILE "s.conf.csv"
|
||||
#define DEVICE_SCENARIO_FILE "s.scen.txt"
|
||||
|
||||
#define DEFAULT_PRESET 100
|
||||
#define DEFAULT_SCENARIO 100
|
||||
|
||||
@@ -26,17 +28,22 @@
|
||||
//#define MDNS_ENABLED
|
||||
//#define WEBSOCKET_ENABLED
|
||||
//#define LAYOUT_IN_RAM
|
||||
#define UDP_ENABLED
|
||||
//#define UDP_ENABLED
|
||||
|
||||
/*
|
||||
* Sensor
|
||||
*/
|
||||
#define TANK_LEVEL_SAMPLES 10
|
||||
#define LEVEL_ENABLED
|
||||
|
||||
#define ANALOG_ENABLED
|
||||
|
||||
|
||||
#define DALLAS_ENABLED
|
||||
#define DHT_ENABLED
|
||||
|
||||
#define BMP_ENABLED
|
||||
|
||||
#define BME_ENABLED
|
||||
|
||||
/*
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
|
||||
extern void addItem(String name);
|
||||
extern void delAllItems();
|
||||
extern int getNewElementNumber(String file);
|
||||
extern uint8_t getNewElementNumber(String file);
|
||||
extern uint8_t getFreePin();
|
||||
@@ -14,4 +14,6 @@ String jsonWriteInt(String& json, String name, int value);
|
||||
|
||||
String jsonWriteFloat(String& json, String name, float value);
|
||||
|
||||
String jsonWriteBool(String& json, String name, boolean value);
|
||||
String jsonWriteBool(String& json, String name, boolean value);
|
||||
|
||||
void saveConfig();
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "Utils\StringUtils.h"
|
||||
#include "Utils\TimeUtils.h"
|
||||
#include "Errors.h"
|
||||
#include "Global.h"
|
||||
|
||||
|
||||
#define pm PrintMessage(MODULE)
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "Global.h"
|
||||
|
||||
const String getChipId();
|
||||
|
||||
void setLedStatus(LedStatus_t status);
|
||||
|
||||
const String getUniqueId(const String& name);
|
||||
|
||||
const String printMemoryStatus();
|
||||
|
||||
const String getHeapStats();
|
||||
|
||||
const String getMacAddress();
|
||||
const String getMacAddress();
|
||||
|
||||
void setChipId();
|
||||
@@ -1,73 +1,7 @@
|
||||
#pragma once
|
||||
#include "HttpServer.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
extern String getURL(const String& urls);
|
||||
extern const String getMethodName(AsyncWebServerRequest* request);
|
||||
extern const String getRequestInfo(AsyncWebServerRequest* request);
|
||||
6
include/Web.h
Normal file
6
include/Web.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include "Arduino.h"
|
||||
|
||||
|
||||
void web_init();
|
||||
void setConfigParam(const char* param, const String& value);
|
||||
Reference in New Issue
Block a user