forked from steff393/hgdo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
77 lines (61 loc) · 1.44 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) 2021 steff393, MIT license
#include <Arduino.h>
#include <ArduinoOTA.h>
#include <autoClose.h>
#include <button.h>
#include <globalConfig.h>
#include <keyPanel.h>
#include <LittleFS.h>
#include <logger.h>
#include <rfid.h>
#include <uap.h>
#include <WiFiManager.h>
#include <webServer.h>
#include <webSocket.h>
static bool _handlingOTA = false;
void setup() {
Serial.begin(115200);
Serial.println(F("\n\nStarting hgdo ;-)"));
logger_setup();
// define a GPIO as output
pinMode(PIN_DE_RE, OUTPUT);
if(!LittleFS.begin()){
Serial.println(F("An Error has occurred while mounting LittleFS"));
return;
}
loadConfig();
WiFiManager wifiManager;
char ssid[32]; strcpy(ssid, cfgApSsid);
char pass[63]; strcpy(pass, cfgApPass);
wifiManager.autoConnect(ssid, pass);
// setup the Webserver
webServer_setup();
webSocket_setup();
// setup the OTA server
ArduinoOTA.setHostname("hgdo");
ArduinoOTA.begin();
ArduinoOTA.onStart([]()
{
_handlingOTA = true;
});
uap_setup();
btn_setup();
key_setup();
rfid_setup();
Serial.print(F("Boot time: ")); Serial.println(millis());
Serial.print(F("Free heap: ")); Serial.println(ESP.getFreeHeap());
}
void loop() {
ArduinoOTA.handle();
if(!_handlingOTA) {
logger_loop();
uap_loop();
uap_loop_slow();
btn_loop();
key_loop();
rfid_loop();
ac_loop();
webServer_loop();
webSocket_loop();
}
}