Files
IoTManager/src/iot_firmware.cpp

87 lines
1.5 KiB
C++
Raw Normal View History

2020-06-18 23:43:06 +02:00
#include "Global.h"
2020-06-17 23:30:48 +03:00
2020-06-20 14:27:58 +03:00
void not_async_actions();
2020-06-17 23:30:48 +03:00
void setup() {
2020-06-20 22:51:14 +03:00
Serial.begin(115200);
Serial.println();
Serial.println("--------------started----------------");
//Serial.setDebugOutput(true);
setChipId();
2020-06-20 14:27:58 +03:00
File_system_init();
2020-06-20 22:51:14 +03:00
Serial.println("[V] LittleFS");
2020-06-20 14:27:58 +03:00
CMD_init();
2020-06-20 22:51:14 +03:00
Serial.println("[V] Commands");
2020-06-20 14:27:58 +03:00
sensors_init();
2020-06-20 22:51:14 +03:00
Serial.println("[V] Sensors");
2020-06-20 14:27:58 +03:00
All_init();
2020-06-20 22:51:14 +03:00
Serial.println("[V] All");
2020-06-20 14:27:58 +03:00
ROUTER_Connecting();
Serial.println("[V] ROUTER_Connecting");
2020-06-20 22:51:14 +03:00
2020-06-20 14:27:58 +03:00
uptime_init();
Serial.println("[V] statistics_init");
2020-06-20 22:51:14 +03:00
2020-06-20 14:27:58 +03:00
initUpgrade();
Serial.println("[V] initUpgrade");
2020-06-20 22:51:14 +03:00
2020-06-20 14:27:58 +03:00
Web_server_init();
Serial.println("[V] Web_server_init");
2020-06-20 22:51:14 +03:00
2020-06-20 14:27:58 +03:00
web_init();
Serial.println("[V] web_init");
2020-06-20 22:51:14 +03:00
2020-06-20 14:27:58 +03:00
Time_Init();
Serial.println("[V] Time_Init");
2020-06-20 22:51:14 +03:00
2020-06-19 22:14:50 +02:00
#ifdef UDP_enable
2020-06-20 14:27:58 +03:00
UDP_init();
Serial.println("[V] UDP_init");
2020-06-19 22:14:50 +02:00
#endif
2020-06-17 23:30:48 +03:00
2020-06-20 14:27:58 +03:00
ts.add(
TEST, 10000, [&](void*) {
2020-06-20 22:51:14 +03:00
getMemoryLoad("[I] sysinfo ");
2020-06-20 14:27:58 +03:00
},
nullptr, true);
2020-06-17 23:30:48 +03:00
2020-06-20 14:27:58 +03:00
just_load = false;
2020-06-17 23:30:48 +03:00
}
void loop() {
#ifdef OTA_enable
2020-06-20 14:27:58 +03:00
ArduinoOTA.handle();
2020-06-17 23:30:48 +03:00
#endif
#ifdef WS_enable
2020-06-20 14:27:58 +03:00
ws.cleanupClients();
2020-06-17 23:30:48 +03:00
#endif
2020-06-20 14:27:58 +03:00
not_async_actions();
2020-06-17 23:30:48 +03:00
2020-06-20 14:27:58 +03:00
handleMQTT();
handleCMD_loop();
handleButton();
handleScenario();
2020-06-17 23:30:48 +03:00
#ifdef UDP_enable
2020-06-20 14:27:58 +03:00
handleUdp();
2020-06-17 23:30:48 +03:00
#endif
2020-06-20 14:27:58 +03:00
ts.update();
2020-06-17 23:30:48 +03:00
}
void not_async_actions() {
2020-06-20 14:27:58 +03:00
do_mqtt_connection();
do_upgrade_url();
do_upgrade();
2020-06-17 23:30:48 +03:00
#ifdef UDP_enable
2020-06-20 14:27:58 +03:00
do_udp_data_parse();
do_mqtt_send_settings_to_udp();
2020-06-17 23:30:48 +03:00
#endif
2020-06-20 14:27:58 +03:00
do_i2c_scanning();
2020-06-19 22:14:50 +02:00
}