mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
broken - need repair
This commit is contained in:
36
include/Cmd.h
Normal file
36
include/Cmd.h
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
extern void CMD_init();
|
||||
extern void button();
|
||||
extern void buttonSet();
|
||||
extern void buttonChange();
|
||||
extern void pinSet();
|
||||
extern void pinChange();
|
||||
extern void handle_time_init();
|
||||
extern void pwm();
|
||||
extern void switch_();
|
||||
extern void pwmSet();
|
||||
extern void stepper();
|
||||
extern void stepperSet();
|
||||
extern void servo_();
|
||||
extern void servoSet();
|
||||
extern void serialBegin();
|
||||
extern void serialWrite();
|
||||
extern void logging();
|
||||
extern void inputDigit();
|
||||
extern void digitSet();
|
||||
extern void inputTime();
|
||||
extern void button();
|
||||
extern void timeSet();
|
||||
extern void text();
|
||||
extern void textSet();
|
||||
extern void mqttOrderSend();
|
||||
extern void httpOrderSend();
|
||||
extern void firmware();
|
||||
extern void update_firmware();
|
||||
extern void Scenario_init();
|
||||
extern void txtExecution(String file);
|
||||
extern void stringExecution(String str);
|
||||
6
include/FileSystem.h
Normal file
6
include/FileSystem.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <SPIFFS.h>
|
||||
|
||||
extern void File_system_init();
|
||||
5
include/Init.h
Normal file
5
include/Init.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
extern void Scenario_init();
|
||||
extern void Device_init();
|
||||
extern void prsets_init();
|
||||
6
include/Logging.h
Normal file
6
include/Logging.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern void logging();
|
||||
extern void deleteOldDate(String file, int seted_number_of_lines, String date_to_add);
|
||||
11
include/Mqtt.h
Normal file
11
include/Mqtt.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern boolean MQTT_Connecting();
|
||||
extern boolean sendMQTT(String end_of_topik, String data);
|
||||
extern boolean sendCHART(String topik, String data);
|
||||
extern void sendSTATUS(String topik, String state);
|
||||
extern void sendCONTROL(String id, String topik, String state);
|
||||
|
||||
extern void do_mqtt_connection();
|
||||
5
include/Scenario.h
Normal file
5
include/Scenario.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern void eventGen(String event_name, String number);
|
||||
3
include/Sensors.h
Normal file
3
include/Sensors.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
void sensors_init();
|
||||
138
include/Strings_.h
Normal file
138
include/Strings_.h
Normal file
@@ -0,0 +1,138 @@
|
||||
#pragma once
|
||||
|
||||
// #include <stdafx.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
class char_array {
|
||||
private:
|
||||
char *p_stringarray; //initial input array
|
||||
char *p_inputstring; //holds actual length data
|
||||
//char **pp_database_string; //allocate data database.cpp
|
||||
int stringsize; //holds array size to allocate memory
|
||||
int charinput; //holds array input size
|
||||
|
||||
public:
|
||||
inline char_array(); //inline so other functions can call on it
|
||||
inline ~char_array();
|
||||
inline void getinput(char *&); //retrieves user input
|
||||
inline void grabline(char *&); //retrieve line with whitespace included NOT COMPLETE, may not need
|
||||
inline int sortline(char **&, char *&); //sorts line into an array of strings and returns number of separate strings
|
||||
inline int arraysize(); //returns size of string array
|
||||
inline void printinput(); //print input string
|
||||
inline void changedefaultsize(); //change default input size NOT COMPLETE
|
||||
};
|
||||
|
||||
inline char_array::char_array() //constructor
|
||||
{
|
||||
stringsize = 0;
|
||||
charinput = 64;
|
||||
p_stringarray = new char[charinput];
|
||||
}
|
||||
|
||||
inline char_array::~char_array() //destructor
|
||||
{
|
||||
delete[] p_inputstring;
|
||||
delete[] p_stringarray;
|
||||
}
|
||||
|
||||
inline void char_array::getinput(char *&p_stringin) {
|
||||
stringsize = 0;
|
||||
|
||||
scanf("%63s", p_stringarray); //get input string
|
||||
|
||||
while (p_stringarray[stringsize] != 0) //finding out the size of string array
|
||||
{
|
||||
stringsize++;
|
||||
}
|
||||
stringsize++;
|
||||
|
||||
p_inputstring = new char[stringsize]; //reallocate memory block and set array inside
|
||||
for (int i = 0; i < stringsize; i++) {
|
||||
p_inputstring[i] = p_stringarray[i];
|
||||
}
|
||||
|
||||
p_inputstring[stringsize - 1] = '\x00';
|
||||
|
||||
p_stringin = new char[stringsize]; //set pp_stringin
|
||||
|
||||
p_stringin = p_inputstring;
|
||||
}
|
||||
|
||||
inline void char_array::grabline(char *&p_stringin) {
|
||||
stringsize = 0;
|
||||
std::cin.getline(p_stringarray, charinput);
|
||||
while (p_stringarray[stringsize] != 0) {
|
||||
stringsize++;
|
||||
}
|
||||
stringsize++;
|
||||
p_inputstring = new char[stringsize];
|
||||
|
||||
for (int i = 0; i < stringsize; i++) {
|
||||
p_inputstring[i] = p_stringarray[i];
|
||||
}
|
||||
|
||||
p_stringin = new char[stringsize];
|
||||
p_stringin = p_inputstring;
|
||||
}
|
||||
|
||||
inline int char_array::sortline(char **&pp_stringin, char *&p_string) {
|
||||
int position = 0; //position in string
|
||||
int charcount = 1; //how many characters there are
|
||||
int wordnum; //which word is being processed
|
||||
int wordcount = 1; //number of words in string
|
||||
int bookmark = 0; //holds last known position
|
||||
|
||||
while (p_string[position] == ' ') {
|
||||
position++;
|
||||
}
|
||||
|
||||
wordnum = position; //borrow wordnum to hold position value
|
||||
while (p_string[position] != '\x00') //find total inputted string word length
|
||||
{
|
||||
if ((p_string[position] == ' ') && ((p_string[position + 1] != ' ') || (p_string[position + 1] != '\x00'))) {
|
||||
wordcount++;
|
||||
}
|
||||
position++;
|
||||
}
|
||||
position = wordnum; //set position to original value
|
||||
for (wordnum = 0; wordnum < wordcount; wordnum++) {
|
||||
charcount = 1;
|
||||
while (p_string[position] == ' ') {
|
||||
position++;
|
||||
}
|
||||
while ((p_string[position] != ' ') && (p_string[position] != '\x00')) {
|
||||
position++;
|
||||
charcount++;
|
||||
}
|
||||
pp_stringin[wordnum] = new char[charcount];
|
||||
|
||||
for (int i = 0; i < charcount; i++) {
|
||||
pp_stringin[wordnum][i] = p_string[i + bookmark];
|
||||
}
|
||||
pp_stringin[wordnum][charcount - 1] = '\x00';
|
||||
bookmark = position + 1;
|
||||
}
|
||||
|
||||
return wordcount;
|
||||
}
|
||||
|
||||
inline int char_array::arraysize() {
|
||||
if (stringsize != 0) {
|
||||
return stringsize;
|
||||
} else {
|
||||
printf("Array size is set at 0\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline void char_array::printinput() {
|
||||
printf("%s", p_inputstring);
|
||||
}
|
||||
|
||||
inline void char_array::changedefaultsize() {
|
||||
printf("Input new default input string size: ");
|
||||
scanf("%i", charinput);
|
||||
}
|
||||
14
include/TimeUtils.h
Normal file
14
include/TimeUtils.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern int timeToMin(String Time);
|
||||
extern String GetDataDigital();
|
||||
extern String GetDate();
|
||||
extern String GetTimeWOsec();
|
||||
extern String GetTime();
|
||||
extern String GetTimeUnix();
|
||||
extern void reconfigTime();
|
||||
extern void saveConfig();
|
||||
extern String GetTimeUnix();
|
||||
extern void time_check();
|
||||
10
include/Timers.h
Normal file
10
include/Timers.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern void Timer_countdown_init();
|
||||
extern void addTimer(String number, String time);
|
||||
extern int readTimer(int number);
|
||||
extern void delTimer(String number);
|
||||
extern void timerStop();
|
||||
extern void delTimer(String number);
|
||||
3
include/Upgrade.h
Normal file
3
include/Upgrade.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
extern void initUpgrade();
|
||||
4
include/WiFiUtils.h
Normal file
4
include/WiFiUtils.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
extern bool StartAPMode();
|
||||
extern void ROUTER_Connecting();
|
||||
8
include/Widgets.h
Normal file
8
include/Widgets.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern void createWidget(String widget_name, String page_name, String page_number, String file, String topic);
|
||||
extern void createWidgetParam(String widget_name, String page_name, String page_number, String file, String topic, String name1, String param1, String name2, String param2, String name3, String param3);
|
||||
extern void choose_widget_and_create(String widget_name, String page_name, String page_number, String type, String topik);
|
||||
extern void createChart(String widget_name, String page_name, String page_number, String file, String topic, String maxCount);
|
||||
7
include/i2c_bus.h
Normal file
7
include/i2c_bus.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern void do_i2c_scanning();
|
||||
|
||||
extern String i2c_scan();
|
||||
31
include/main.h
Normal file
31
include/main.h
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
void getMemoryLoad(String text);
|
||||
|
||||
extern String jsonReadStr(String& json, String name);
|
||||
extern int jsonReadInt(String& json, String name);
|
||||
extern String jsonWriteInt(String& json, String name, int volume);
|
||||
extern String jsonWriteStr(String& json, String name, String volume);
|
||||
extern void saveConfig();
|
||||
extern String jsonWriteFloat(String& json, String name, float volume);
|
||||
|
||||
extern String getURL(String urls);
|
||||
|
||||
extern String writeFile(String fileName, String strings);
|
||||
extern String readFile(String fileName, size_t len);
|
||||
extern String addFile(String fileName, String strings);
|
||||
|
||||
extern String selectFromMarkerToMarker(String str, String found, int number);
|
||||
extern String selectToMarker(String str, String found);
|
||||
extern String deleteAfterDelimiter(String str, String found);
|
||||
extern String deleteBeforeDelimiter(String str, String found);
|
||||
extern String deleteBeforeDelimiterTo(String str, String found);
|
||||
|
||||
extern void servo_();
|
||||
extern boolean isDigitStr(String str);
|
||||
extern String jsonWriteStr(String& json, String name, String volume);
|
||||
|
||||
extern void led_blink(String satus);
|
||||
63
include/push_pushingbox.h
Normal file
63
include/push_pushingbox.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include "main.h"
|
||||
#include "set.h"
|
||||
|
||||
inline void Push_init() {
|
||||
server.on("/pushingboxDate", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
if (request->hasArg("pushingbox_id")) {
|
||||
jsonWriteStr(configSetup, "pushingbox_id", request->getParam("pushingbox_id")->value());
|
||||
}
|
||||
|
||||
saveConfig();
|
||||
|
||||
request->send(200, "text/text", "ok"); // отправляем ответ о выполнении
|
||||
});
|
||||
}
|
||||
|
||||
inline void pushControl() {
|
||||
String title = sCmd.next();
|
||||
title.replace("#", " ");
|
||||
String body = sCmd.next();
|
||||
body.replace("#", " ");
|
||||
|
||||
static String body_old;
|
||||
|
||||
const char* logServer = "api.pushingbox.com";
|
||||
String deviceId = jsonReadStr(configSetup, "pushingbox_id");
|
||||
|
||||
Serial.println("- starting client");
|
||||
|
||||
WiFiClient client_push;
|
||||
|
||||
Serial.println("- connecting to pushing server: " + String(logServer));
|
||||
if (!client_push.connect(logServer, 80)) {
|
||||
Serial.println("- not connected");
|
||||
} else {
|
||||
Serial.println("- succesfully connected");
|
||||
|
||||
String postStr = "devid=";
|
||||
postStr += String(deviceId);
|
||||
|
||||
postStr += "&title=";
|
||||
postStr += String(title);
|
||||
|
||||
postStr += "&body=";
|
||||
postStr += String(body);
|
||||
|
||||
postStr += "\r\n\r\n";
|
||||
|
||||
Serial.println("- sending data...");
|
||||
|
||||
client_push.print("POST /pushingbox HTTP/1.1\n");
|
||||
client_push.print("Host: api.pushingbox.com\n");
|
||||
client_push.print("Connection: close\n");
|
||||
client_push.print("Content-Type: application/x-www-form-urlencoded\n");
|
||||
client_push.print("Content-Length: ");
|
||||
client_push.print(postStr.length());
|
||||
client_push.print("\n\n");
|
||||
client_push.print(postStr);
|
||||
}
|
||||
client_push.stop();
|
||||
Serial.println("- stopping the client");
|
||||
}
|
||||
225
include/set.h
Normal file
225
include/set.h
Normal file
@@ -0,0 +1,225 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
/*******************************************************************
|
||||
**********************FIRMWARE SETTINGS****************************
|
||||
******************************************************************/
|
||||
String firmware_version = "2.3.3";
|
||||
boolean mb_4_of_memory = true;
|
||||
//#define OTA_enable
|
||||
//#define MDNS_enable
|
||||
//#define WS_enable
|
||||
//#define layout_in_ram
|
||||
#define UDP_enable
|
||||
/*==========================SENSORS===============================*/
|
||||
//#define level_enable
|
||||
//#define analog_enable
|
||||
//#define dallas_enable
|
||||
//#define dht_enable //подъедает оперативку сука
|
||||
//#define bmp_enable
|
||||
//#define bme_enable
|
||||
/*=========================LOGGING================================*/
|
||||
#define logging_enable
|
||||
/*==========================GEARS=================================*/
|
||||
#define stepper_enable
|
||||
#define servo_enable
|
||||
/*=========================OTHER==================================*/
|
||||
#define serial_enable
|
||||
#define push_enable
|
||||
/*================================================================*/
|
||||
#define wifi_mqtt_reconnecting 20000
|
||||
#define blink_pin 2
|
||||
#define tank_level_times_to_send 10 //после скольки выстрелов делать отправку данных
|
||||
#define statistics_update 1000 * 60 * 60 * 2
|
||||
/*================================================================*/
|
||||
|
||||
//===============общие библиотеки и объекты===============================
|
||||
#include <Arduino.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <FS.h>
|
||||
#include <SPIFFSEditor.h>
|
||||
#include <time.h>
|
||||
|
||||
//===============библиотеки и объекты для ESP8266=======================
|
||||
#ifdef ESP8266
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <ESP8266HTTPUpdateServer.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266httpUpdate.h>
|
||||
ESP8266HTTPUpdateServer httpUpdater;
|
||||
#include <WiFiUdp.h>
|
||||
WiFiUDP Udp;
|
||||
#include <Servo.h>
|
||||
Servo myServo1;
|
||||
Servo myServo2;
|
||||
#ifdef MDNS_enable
|
||||
#include <ESP8266mDNS.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//===============библиотеки и объекты для ESP32===========================
|
||||
#ifdef ESP32
|
||||
#include <AsyncTCP.h>
|
||||
#include <AsyncUDP.h>
|
||||
#include <HTTPClient.h>
|
||||
#include <HTTPUpdate.h>
|
||||
#include <SPIFFS.h>
|
||||
#include <WiFi.h>
|
||||
#include <analogWrite.h>
|
||||
AsyncUDP udp;
|
||||
#include <ESP32Servo.h>
|
||||
Servo myServo1;
|
||||
Servo myServo2;
|
||||
#ifdef MDNS_enable
|
||||
#include <ESPmDNS.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef OTA_enable
|
||||
#include <ArduinoOTA.h>
|
||||
#endif
|
||||
|
||||
AsyncWebServer server(80);
|
||||
|
||||
#ifdef WS_enable
|
||||
AsyncWebSocket ws("/ws");
|
||||
#endif
|
||||
|
||||
AsyncEventSource events("/events");
|
||||
#include <TickerScheduler.h>
|
||||
#include <time.h>
|
||||
enum { ROUTER_SEARCHING,
|
||||
WIFI_MQTT_CONNECTION_CHECK,
|
||||
SENSORS,
|
||||
STEPPER1,
|
||||
STEPPER2,
|
||||
LOG1,
|
||||
LOG2,
|
||||
LOG3,
|
||||
LOG4,
|
||||
LOG5,
|
||||
TIMER_COUNTDOWN,
|
||||
TIME,
|
||||
TIME_SYNC,
|
||||
STATISTICS,
|
||||
UDP,
|
||||
UDP_DB,
|
||||
TEST };
|
||||
TickerScheduler ts(TEST + 1);
|
||||
|
||||
#include <PubSubClient.h>
|
||||
WiFiClient espClient;
|
||||
PubSubClient client_mqtt(espClient);
|
||||
|
||||
#include <StringCommand.h>
|
||||
StringCommand sCmd;
|
||||
|
||||
#include <Bounce2.h>
|
||||
#define NUM_BUTTONS 6
|
||||
boolean but[NUM_BUTTONS];
|
||||
Bounce *buttons = new Bounce[NUM_BUTTONS];
|
||||
|
||||
#ifdef level_enable
|
||||
#include "GyverFilters.h" //настраивается в GyverHacks.h - MEDIAN_FILTER_SIZE
|
||||
GMedian medianFilter;
|
||||
#endif
|
||||
|
||||
#ifdef dallas_enable
|
||||
#include <DallasTemperature.h>
|
||||
#include <OneWire.h>
|
||||
OneWire *oneWire;
|
||||
DallasTemperature sensors;
|
||||
#endif
|
||||
|
||||
#ifdef dht_enable
|
||||
#include <DHTesp.h>
|
||||
DHTesp dht;
|
||||
#endif
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
#ifdef bmp_enable
|
||||
#include <Adafruit_BMP280.h>
|
||||
Adafruit_BMP280 bmp; // use I2C interface
|
||||
Adafruit_Sensor *bmp_temp = bmp.getTemperatureSensor();
|
||||
Adafruit_Sensor *bmp_pressure = bmp.getPressureSensor();
|
||||
#endif
|
||||
|
||||
#ifdef bme_enable
|
||||
#include <Adafruit_BME280.h>
|
||||
Adafruit_BME280 bme; // use I2C interface
|
||||
Adafruit_Sensor *bme_temp = bme.getTemperatureSensor();
|
||||
Adafruit_Sensor *bme_pressure = bme.getPressureSensor();
|
||||
Adafruit_Sensor *bme_humidity = bme.getHumiditySensor();
|
||||
#endif
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(14, 12);
|
||||
|
||||
//===============FIRMWARE VARS========================
|
||||
boolean just_load = true;
|
||||
const char *hostName = "IoT Manager";
|
||||
//JSON
|
||||
String configSetup = "{}";
|
||||
String configJson = "{}";
|
||||
String optionJson = "{}";
|
||||
//MQTT
|
||||
String chipID = "";
|
||||
String prex;
|
||||
String all_widgets = "";
|
||||
String scenario;
|
||||
String order_loop;
|
||||
//SENSORS
|
||||
String analog_value_names_list;
|
||||
int enter_to_analog_counter;
|
||||
|
||||
String level_value_name;
|
||||
|
||||
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};
|
||||
//============================0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14
|
||||
|
||||
//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;
|
||||
//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);
|
||||
#endif
|
||||
String received_ip;
|
||||
String received_udp_line;
|
||||
int udp_period;
|
||||
//i2c
|
||||
String i2c_list;
|
||||
Reference in New Issue
Block a user