Files
IoTManager/set.h

162 lines
4.1 KiB
C
Raw Normal View History

//===============FIRMWARE SETTINGS=====================================
2020-04-22 20:35:50 +02:00
String firmware_version = "2.3.3";
2020-04-05 01:52:02 +02:00
boolean mb_4_of_memory = true;
2020-03-01 20:41:16 +03:00
//#define OTA_enable
//#define MDNS_enable
//#define WS_enable
//#define layout_in_ram
2020-03-01 20:41:16 +03:00
#define wifi_mqtt_reconnecting 20000
#define analog_update_int 5000
#define temp_update_int 5000
2020-03-01 20:41:16 +03:00
#define tank_level_shooting_interval 500 //интервал выстрела датчика
#define tank_level_times_to_send 20 //после скольки выстрелов делать отправку данных
2020-03-01 20:41:16 +03:00
#define dhtT_update_int 10000
#define dhtH_update_int 10000
#define dht_calculation_update_int 10000
#define statistics_update 1000 * 60 * 60 * 2
//======================================================================
2020-03-01 20:41:16 +03:00
#define TIME_COMPILING String(__TIME__)
#define DATE_COMPILING String(__DATE__)
2020-03-01 20:41:16 +03:00
//===============библиотеки и объекты для ESP8266========================
2019-12-24 11:53:26 +03:00
#ifdef ESP8266
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
2020-03-01 20:41:16 +03:00
#include <ESP8266httpUpdate.h>
#include <ESP8266HTTPUpdateServer.h>
ESP8266HTTPUpdateServer httpUpdater;
#include <WiFiUdp.h>
WiFiUDP Udp;
2020-04-25 16:39:36 +02:00
#include <Servo.h>
Servo myServo1;
Servo myServo2;
#ifdef MDNS_enable
#include <ESP8266mDNS.h>
2019-12-24 11:53:26 +03:00
#endif
#endif
//===============библиотеки и объекты для ESP32===========================
2019-12-24 11:53:26 +03:00
#ifdef ESP32
#include <WiFi.h>
2020-04-25 16:39:36 +02:00
#include <HTTPClient.h>
#include <HTTPUpdate.h>
2019-12-24 11:53:26 +03:00
#include <SPIFFS.h>
#include <AsyncTCP.h>
#include <analogWrite.h>
#include "AsyncUDP.h"
AsyncUDP udp;
2020-04-25 16:39:36 +02:00
#include <ESP32_Servo.h>
Servo myServo1;
Servo myServo2;
#ifdef MDNS_enable
#include <ESPmDNS.h>
2019-12-24 11:53:26 +03:00
#endif
#endif
//===============общие библиотеки и объекты===============================
2020-03-16 00:00:59 +01:00
#include <Arduino.h>
2020-02-13 20:20:34 +03:00
#include "time.h"
2019-12-24 11:53:26 +03:00
#ifdef OTA_enable
#include <ArduinoOTA.h>
#endif
2019-12-24 11:53:26 +03:00
#include <FS.h>
#include <ArduinoJson.h>
#include <ESPAsyncWebServer.h>
2019-12-24 11:53:26 +03:00
#include <SPIFFSEditor.h>
AsyncWebServer server(80);
2019-12-24 11:53:26 +03:00
#ifdef WS_enable
AsyncWebSocket ws("/ws");
#endif
2019-12-24 11:53:26 +03:00
AsyncEventSource events("/events");
2020-04-02 22:56:01 +02:00
#include <time.h>
2019-12-24 11:53:26 +03:00
#include <TickerScheduler.h>
TickerScheduler ts(30);
2020-04-05 01:52:02 +02:00
enum {ROUTER_SEARCHING, WIFI_MQTT_CONNECTION_CHECK, LEVEL, ANALOG_, DALLAS, DHTT, DHTH, DHTC, DHTP, DHTD, STEPPER1, STEPPER2, ANALOG_LOG, LEVEL_LOG, DALLAS_LOG, dhtT_LOG, dhtH_LOG, CMD, TIMER_COUNTDOWN, TIMERS, TIME, TIME_SYNC, STATISTICS, UDP, UDP_DB, TEST};
2019-12-24 11:53:26 +03:00
#include <PubSubClient.h>
WiFiClient espClient;
2019-12-24 11:53:26 +03:00
PubSubClient client(espClient);
2019-12-24 11:53:26 +03:00
#include <StringCommand.h>
StringCommand sCmd;
2019-12-24 11:53:26 +03:00
#include <Bounce2.h>
#define NUM_BUTTONS 6
boolean but[NUM_BUTTONS];
Bounce * buttons = new Bounce[NUM_BUTTONS];
2019-12-24 11:53:26 +03:00
#include "GyverFilters.h" //настраивается в GyverHacks.h - MEDIAN_FILTER_SIZE
GMedian medianFilter;
2019-12-24 11:53:26 +03:00
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire *oneWire;
DallasTemperature sensors;
2020-04-02 22:56:01 +02:00
#include <DHTesp.h>
2020-02-15 20:17:25 +03:00
DHTesp dht;
2019-12-24 11:53:26 +03:00
2020-04-25 16:39:36 +02:00
#include <Wire.h>
//===============FIRMWARE VARS========================
2020-03-22 01:50:31 +01:00
boolean just_load = true;
2020-03-01 20:41:16 +03:00
const char* hostName = "IoT Manager";
//JSON
String configSetup = "{}";
String configJson = "{}";
2019-12-24 11:53:26 +03:00
String optionJson = "{}";
//MQTT
2019-12-24 11:53:26 +03:00
String chipID = "";
String prex;
2020-03-24 19:01:11 +01:00
String all_widgets = "";
2019-12-24 11:53:26 +03:00
String scenario;
String order_loop;
//SENSORS
2019-12-24 11:53:26 +03:00
boolean flagLoggingAnalog = false;
boolean flagLoggingLevel = false;
boolean flagLoggingDallas = false;
boolean flagLoggingdhtT = false;
boolean flagLoggingdhtH = false;
//NTP
2019-12-24 11:53:26 +03:00
const char* ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 3600;
const int daylightOffset_sec = 3600;
String current_time;
//SCENARIO
2019-12-24 11:53:26 +03:00
int scenario_line_status [] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
//ERRORS
2020-02-19 03:14:21 +03:00
int wifi_lost_error = 0;
2020-03-18 09:57:46 +01:00
int mqtt_lost_error = 0;
String last_version;
//ASYNC ACTIONS
2020-04-05 01:52:02 +02:00
boolean upgrade_url = false;
boolean upgrade = false;
boolean mqtt_connection = false;
boolean udp_data_parse = false;
boolean mqtt_send_settings_to_udp = false;
//UDP
2020-04-05 01:52:02 +02:00
boolean udp_busy = false;
2020-03-30 01:45:42 +02:00
boolean chart_data_in_solid_array;
2020-04-05 01:52:02 +02:00
unsigned int udp_port = 4210;
#ifdef ESP8266
2020-04-05 01:52:02 +02:00
IPAddress udp_multicastIP (255, 255, 255, 255);
#endif
#ifdef ESP32
IPAddress udp_multicastIP (239, 255, 255, 255);
#endif
2020-04-05 01:52:02 +02:00
String received_ip;
String received_udp_line;
2020-04-22 20:35:50 +02:00
int udp_period;