restructure
This commit is contained in:
parent
d709308946
commit
cfdd6ddca7
3 changed files with 50 additions and 70 deletions
|
@ -226,6 +226,12 @@
|
|||
<td>value</td>
|
||||
<td>Gets or sets the webhook unlock hook</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left;">/users</td>
|
||||
<td>GET, POST</td>
|
||||
<td>N/A</td>
|
||||
<td>lists all local / backup user</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left;">/users/create</td>
|
||||
<td>GET, POST</td>
|
||||
|
@ -244,14 +250,6 @@
|
|||
<td>cardid</td>
|
||||
<td>removes a local / backup user</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left;">/users/users</td>
|
||||
<td>GET, POST</td>
|
||||
<td>N/A</td>
|
||||
<td>lists all local / backup user</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -18,7 +18,7 @@ void unlockDoor(bool silent) {
|
|||
#endif
|
||||
#endif
|
||||
#ifdef SERIAL_DEBUG
|
||||
Serial.println("door unlocked");
|
||||
Serial.println("Unlocked");
|
||||
#endif
|
||||
|
||||
#ifdef LEDCTL_PIN
|
||||
|
@ -32,7 +32,7 @@ void unlockDoor(bool silent) {
|
|||
}
|
||||
}
|
||||
#ifdef TINANCE2_BACKEND
|
||||
tinance2logrequest("Door Unlocked");
|
||||
tinance2logrequest("Unlocked");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ void lockDoor(bool silent) {
|
|||
#endif
|
||||
#endif
|
||||
#ifdef SERIAL_DEBUG
|
||||
Serial.println("door locked");
|
||||
Serial.println("Locked");
|
||||
#endif
|
||||
|
||||
#ifdef LEDCTL_PIN
|
||||
|
@ -66,7 +66,7 @@ void lockDoor(bool silent) {
|
|||
}
|
||||
|
||||
#ifdef TINANCE2_BACKEND
|
||||
tinance2logrequest("Door Locked");
|
||||
tinance2logrequest("Locked");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
98
src/main.cpp
98
src/main.cpp
|
@ -107,9 +107,6 @@ void WiFiGotIP(WiFiEvent_t event, WiFiEventInfo_t info){
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef WEB_SERVER
|
||||
|
||||
#endif
|
||||
|
||||
void handleInterrupt(int bitValue) {
|
||||
static unsigned long lastInterruptTime = 0;
|
||||
|
@ -149,48 +146,11 @@ void setup() {
|
|||
Serial2.begin(9600, SERIAL_8N1, RXD, TXD);
|
||||
#endif
|
||||
|
||||
#ifdef WEB_SERVER
|
||||
WiFi.disconnect(true);
|
||||
#endif
|
||||
|
||||
#ifdef TINANCE2_BACKEND_SYNC
|
||||
xTaskCreatePinnedToCore(tinance2SyncTaskFunction, "Task", 10000, NULL, 1, NULL, 1);
|
||||
#endif
|
||||
|
||||
#ifdef TINANCE2_BACKEND
|
||||
#endif
|
||||
|
||||
#ifdef WIFI
|
||||
webhooks_http.setReuse(true);
|
||||
#endif
|
||||
|
||||
#ifdef LOCAL_ACL
|
||||
acl.loadFromEEPROM();
|
||||
#endif
|
||||
|
||||
settings.loadFromEEPROM();
|
||||
|
||||
// Initialize SPIFFS
|
||||
#ifdef WEB_SERVER
|
||||
if(!SPIFFS.begin(true)){
|
||||
#ifdef SERIAL_DEBUG
|
||||
Serial.println("An Error has occurred while mounting SPIFFS");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef WEB_OTA_UPDATE
|
||||
ElegantOTA.setAutoReboot(false);
|
||||
ElegantOTA.onEnd([](bool success) {
|
||||
if (success) {
|
||||
ESP.restart();
|
||||
}
|
||||
});
|
||||
ElegantOTA.begin(&server, http_username, http_password);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef DATA0_PIN
|
||||
pinMode(DATA0_PIN, INPUT_PULLUP);
|
||||
#endif
|
||||
|
@ -219,13 +179,6 @@ void setup() {
|
|||
attachInterrupt(digitalPinToInterrupt(DATA1_PIN), handleData1Interrupt, FALLING);
|
||||
#endif
|
||||
|
||||
#ifdef WIFI
|
||||
WiFi.onEvent(WiFiStationConnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_CONNECTED);
|
||||
WiFi.onEvent(WiFiGotIP, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);
|
||||
WiFi.onEvent(WiFiStationDisconnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
|
||||
connectToWiFi(ssid, password);
|
||||
#endif
|
||||
|
||||
#ifdef RELAY1
|
||||
#ifdef SERIAL_DEBUG
|
||||
Serial.println("Enabling Relay: Locking Door");
|
||||
|
@ -244,20 +197,49 @@ void setup() {
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WEB_SERVER
|
||||
MainWebServer.begin(&server, http_username, http_password);
|
||||
#ifdef LOCAL_ACL
|
||||
#ifdef LOCAL_ACL_API
|
||||
ACLWebServer.begin(&server, http_username, http_password);
|
||||
#endif
|
||||
#ifdef WIFI
|
||||
webhooks_http.setReuse(true);
|
||||
WiFi.onEvent(WiFiStationConnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_CONNECTED);
|
||||
WiFi.onEvent(WiFiGotIP, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);
|
||||
WiFi.onEvent(WiFiStationDisconnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
|
||||
connectToWiFi(ssid, password);
|
||||
#endif
|
||||
server.begin();
|
||||
#endif
|
||||
|
||||
#ifdef TINANCE2_BACKEND
|
||||
// Initialize SPIFFS
|
||||
#ifdef WEB_SERVER
|
||||
if(!SPIFFS.begin(true)){
|
||||
#ifdef SERIAL_DEBUG
|
||||
Serial.println("An Error has occurred while mounting SPIFFS");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef WEB_OTA_UPDATE
|
||||
ElegantOTA.setAutoReboot(false);
|
||||
ElegantOTA.onEnd([](bool success) {
|
||||
if (success) {
|
||||
ESP.restart();
|
||||
}
|
||||
});
|
||||
ElegantOTA.begin(&server, http_username, http_password);
|
||||
#endif
|
||||
|
||||
MainWebServer.begin(&server, http_username, http_password);
|
||||
#ifdef LOCAL_ACL
|
||||
#ifdef LOCAL_ACL_API
|
||||
ACLWebServer.begin(&server, http_username, http_password);
|
||||
#endif
|
||||
#endif
|
||||
server.begin();
|
||||
#endif
|
||||
|
||||
#ifdef TINANCE2_BACKEND_SYNC
|
||||
xTaskCreatePinnedToCore(tinance2SyncTaskFunction, "Task", 10000, NULL, 1, NULL, 1);
|
||||
#endif
|
||||
|
||||
#ifdef TINANCE2_BACKEND
|
||||
tinance2logrequest("Device Rebooted, Setup Complete");
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue