Files
IoTManager/set.h

153 lines
4.9 KiB
C
Raw Normal View History

2020-03-17 17:54:57 +01:00
String firmware_version = "2.3.1";
2020-03-04 00:27:35 +03:00
String new_version;
2020-03-22 01:50:31 +01:00
//23560
2020-03-01 20:41:16 +03:00
//#define OTA_enable
//#define MDNS_enable
2020-03-17 00:54:27 +01:00
//#define WS_enable
2020-03-01 20:41:16 +03:00
#define TIME_COMPILING String(__TIME__)
#define DATE_COMPILING String(__DATE__)
2020-03-18 09:57:46 +01:00
//-----------------------------------------------------------------
2020-03-01 20:41:16 +03:00
#define wifi_mqtt_reconnecting 20000
//-----------------------------------------------------------------
#define analog_update_int 5000
//-----------------------------------------------------------------
#define ph_shooting_interval 500 //интервал выстрела датчика
#define ph_times_to_send 10 //после скольки выстрелов делать отправку данных
//-----------------------------------------------------------------
#define temp_update_int 5000
//-----------------------------------------------------------------
#define tank_level_shooting_interval 500 //интервал выстрела датчика
#define tank_level_times_to_send 20 //после скольки выстрелов делать отправку данных
//-----------------------------------------------------------------
#define dhtT_update_int 10000
#define dhtH_update_int 10000
#define dht_calculation_update_int 10000
2020-03-17 00:54:27 +01:00
#define statistics_update 1000 * 60 * 60 * 4
2020-03-01 20:41:16 +03:00
//-----------------------------------------------------------------
2019-12-24 11:53:26 +03:00
//==библиотеки и объекты для ESP8266==//
#ifdef ESP8266
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESPAsyncTCP.h>
#include <ESP8266mDNS.h>
2020-03-01 20:41:16 +03:00
#include <ESP8266httpUpdate.h>
#include <ESP8266HTTPUpdateServer.h>
ESP8266HTTPUpdateServer httpUpdater;
2019-12-24 11:53:26 +03:00
#endif
//==библиотеки и объекты для ESP32==//
#ifdef ESP32
#include <WiFi.h>
#include <SPIFFS.h>
#ifdef MDNS_enable
#include <ESPmDNS.h>
#endif
#include <AsyncTCP.h>
#include <analogWrite.h>
2020-03-01 20:41:16 +03:00
#include <HTTPUpdate.h>
2019-12-24 11:53:26 +03:00
#include <HTTPClient.h>
2020-03-01 20:41:16 +03:00
//HTTPClient http;
2020-03-20 21:00:11 +01:00
#include <rom/rtc.h>
2019-12-24 11:53:26 +03:00
#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
#include <FS.h>
#include <ArduinoJson.h>
#include <ESPAsyncWebServer.h>
#include <SPIFFSEditor.h>
AsyncWebServer server(80);
#ifdef WS_enable
AsyncWebSocket ws("/ws");
#endif
AsyncEventSource events("/events");
2020-03-22 01:50:31 +01:00
//---------------------------------------------------------------
2019-12-24 11:53:26 +03:00
#include "time.h"
2020-03-22 01:50:31 +01:00
//---------------------------------------------------------------
2019-12-24 11:53:26 +03:00
#include <TickerScheduler.h>
TickerScheduler ts(30);
2020-03-22 01:50:31 +01:00
enum {ROUTER_SEARCHING, WIFI_MQTT_CONNECTION_CHECK, LEVEL, ANALOG_, DALLAS, DHTT, DHTH, DHTC, DHTP, DHTD, STEPPER1, STEPPER2, ANALOG_LOG, LEVEL_LOG, DALLAS_LOG, CMD, TIMER_COUNTDOWN, TIMERS, TIME, STATISTICS, TEST};
//---------------------------------------------------------------
2019-12-24 11:53:26 +03:00
//ssl//#include "dependencies/WiFiClientSecure/WiFiClientSecure.h" //using older WiFiClientSecure
2020-03-18 09:57:46 +01:00
//#include "Ticker_for_TickerScheduler/Ticker/Ticker.h"
2020-03-22 01:50:31 +01:00
//---------------------------------------------------------------
2019-12-24 11:53:26 +03:00
#include <PubSubClient.h>
WiFiClient espClient;
//ssl//WiFiClientSecure espClient;
PubSubClient client(espClient);
//---------------------------------------------------------------
#include <StringCommand.h>
StringCommand sCmd;
//---------------------------------------------------------------
#include <Bounce2.h>
#define NUM_BUTTONS 6
boolean but[NUM_BUTTONS];
Bounce * buttons = new Bounce[NUM_BUTTONS];
//----------------------------------------------------------------
#include "GyverFilters.h" //настраивается в GyverHacks.h - MEDIAN_FILTER_SIZE
GMedian medianFilter;
//----------------------------------------------------------------
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire *oneWire;
DallasTemperature sensors;
2020-02-10 01:06:18 +03:00
//----------------------------------------------------------------
2020-02-15 20:17:25 +03:00
#include "DHTesp.h"
DHTesp dht;
2020-02-10 01:06:18 +03:00
//----------------------------------------------------------------
2020-03-22 01:50:31 +01:00
//#include "Adafruit_Si7021.h" //https://github.com/adafruit/Adafruit_Si7021
//Adafruit_Si7021 sensor_Si7021 = Adafruit_Si7021();
2020-02-10 01:06:18 +03:00
//-----------------------------------------------------------------
2019-12-24 11:53:26 +03:00
2020-03-22 01:50:31 +01:00
boolean just_load = true;
2020-03-16 00:00:59 +01:00
2020-03-01 20:41:16 +03:00
const char* hostName = "IoT Manager";
2019-12-24 11:53:26 +03:00
2020-03-20 21:00:11 +01:00
String configSetup = "{}"; //setup
String configJson = "{}"; //live
2019-12-24 11:53:26 +03:00
String optionJson = "{}";
2020-03-16 00:00:59 +01:00
String json = "{}";
2019-12-24 11:53:26 +03:00
String chipID = "";
String prex;
String ids;
String all_vigets = "";
String scenario;
String order_loop;
boolean flagLoggingAnalog = false;
boolean flagLoggingLevel = false;
boolean flagLoggingDallas = false;
boolean flagLoggingPh = false;
const char* ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 3600;
const int daylightOffset_sec = 3600;
const String ssdpS = "SSDP";
String current_time;
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};
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;
2020-03-01 20:41:16 +03:00
String var;
2020-03-04 00:27:35 +03:00
boolean upgrade_flag = false;
boolean get_url_flag = false;
2020-03-22 01:50:31 +01:00
boolean start_connection = false;