Files
IoTManager/src/Global.cpp

135 lines
2.5 KiB
C++
Raw Normal View History

2020-06-19 01:50:19 +03:00
#include "Global.h"
2020-06-19 07:27:06 +03:00
#include "JsonUtils.h"
2020-06-19 22:14:50 +02:00
//==============================Objects.cpp(с данными)==================================
#ifdef WS_enable
AsyncWebSocket ws;
#endif
//AsyncEventSource events;
2020-06-19 01:50:19 +03:00
TickerScheduler ts(TEST + 1);
WiFiClient espClient;
2020-06-19 22:14:50 +02:00
2020-06-19 01:50:19 +03:00
PubSubClient client_mqtt(espClient);
2020-06-19 22:14:50 +02:00
2020-06-19 01:50:19 +03:00
StringCommand sCmd;
AsyncWebServer server(80);
2020-06-19 22:14:50 +02:00
//AsyncWebSocket ws("/ws");
//AsyncEventSource events("/events");
#define NUM_BUTTONS 6
boolean but[NUM_BUTTONS];
Bounce * buttons = new Bounce[NUM_BUTTONS];
GMedian<10, int> medianFilter;
OneWire *oneWire;
DallasTemperature sensors;
DHTesp dht;
Adafruit_BMP280 bmp;
Adafruit_Sensor *bmp_temp;
Adafruit_Sensor *bmp_pressure;
Adafruit_BME280 bme;
Adafruit_Sensor *bme_temp;
Adafruit_Sensor *bme_pressure;
Adafruit_Sensor *bme_humidity;
2020-06-19 01:50:19 +03:00
2020-06-19 22:14:50 +02:00
uptime_interval myUpTime(10);
////////////////////////////////////// Global vars ////////////////////////////////////////////////////////////////////
2020-06-19 01:50:19 +03:00
boolean just_load = true;
const char *hostName = "IoT Manager";
// Json
2020-06-19 14:50:34 +02:00
String configSetupJson = "{}";
String configLiveJson = "{}";
String configOptionJson = "{}";
2020-06-19 01:50:19 +03:00
// Mqtt
String chipID = "";
String prex;
String all_widgets = "";
String scenario;
String order_loop;
// Sensors
String analog_value_names_list;
int enter_to_analog_counter;
2020-06-19 15:22:22 +02:00
String levelPr_value_name;
String ultrasonicCm_value_name;
2020-06-19 01:50:19 +03:00
String dhtT_value_name;
String dhtH_value_name;
String bmp280T_value_name;
String bmp280P_value_name;
String bme280T_value_name;
String bme280P_value_name;
String bme280H_value_name;
String bme280A_value_name;
int sensors_reading_map[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// Logging
String logging_value_names_list;
int enter_to_logging_counter;
// Ntp and time
String current_time;
// Scenario
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
int wifi_lost_error = 0;
int mqtt_lost_error = 0;
String last_version;
// Async actions
boolean upgrade_url = false;
boolean upgrade = false;
boolean mqtt_connection = false;
boolean udp_data_parse = false;
boolean mqtt_send_settings_to_udp = false;
boolean i2c_scanning = false;
2020-06-19 22:14:50 +02:00
2020-06-19 01:50:19 +03:00
//Buttons
2020-06-19 22:14:50 +02:00
//boolean but[6];
2020-06-19 01:50:19 +03:00
// Udp
boolean udp_busy = false;
unsigned int udp_port = 4210;
#ifdef ESP8266
IPAddress udp_multicastIP(255, 255, 255, 255);
#endif
#ifdef ESP32
IPAddress udp_multicastIP(239, 255, 255, 255);
AsyncUDP udp;
#endif
String received_ip;
String received_udp_line;
int udp_period;
// i2c
String i2c_list;
2020-06-19 02:31:56 +02:00
2020-06-19 03:49:56 +03:00