restructure

This commit is contained in:
Matthew Frost 2024-04-17 15:08:13 +02:00
parent d709308946
commit cfdd6ddca7
3 changed files with 50 additions and 70 deletions

View file

@ -226,6 +226,12 @@
<td>value</td> <td>value</td>
<td>Gets or sets the webhook unlock hook</td> <td>Gets or sets the webhook unlock hook</td>
</tr> </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> <tr>
<td style="text-align: left;">/users/create</td> <td style="text-align: left;">/users/create</td>
<td>GET, POST</td> <td>GET, POST</td>
@ -244,14 +250,6 @@
<td>cardid</td> <td>cardid</td>
<td>removes a local / backup user</td> <td>removes a local / backup user</td>
</tr> </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> </table>
</div> </div>
</div> </div>

View file

@ -18,7 +18,7 @@ void unlockDoor(bool silent) {
#endif #endif
#endif #endif
#ifdef SERIAL_DEBUG #ifdef SERIAL_DEBUG
Serial.println("door unlocked"); Serial.println("Unlocked");
#endif #endif
#ifdef LEDCTL_PIN #ifdef LEDCTL_PIN
@ -32,7 +32,7 @@ void unlockDoor(bool silent) {
} }
} }
#ifdef TINANCE2_BACKEND #ifdef TINANCE2_BACKEND
tinance2logrequest("Door Unlocked"); tinance2logrequest("Unlocked");
#endif #endif
#endif #endif
} }
@ -51,7 +51,7 @@ void lockDoor(bool silent) {
#endif #endif
#endif #endif
#ifdef SERIAL_DEBUG #ifdef SERIAL_DEBUG
Serial.println("door locked"); Serial.println("Locked");
#endif #endif
#ifdef LEDCTL_PIN #ifdef LEDCTL_PIN
@ -66,7 +66,7 @@ void lockDoor(bool silent) {
} }
#ifdef TINANCE2_BACKEND #ifdef TINANCE2_BACKEND
tinance2logrequest("Door Locked"); tinance2logrequest("Locked");
#endif #endif
#endif #endif
} }

View file

@ -107,9 +107,6 @@ void WiFiGotIP(WiFiEvent_t event, WiFiEventInfo_t info){
} }
#endif #endif
#ifdef WEB_SERVER
#endif
void handleInterrupt(int bitValue) { void handleInterrupt(int bitValue) {
static unsigned long lastInterruptTime = 0; static unsigned long lastInterruptTime = 0;
@ -149,48 +146,11 @@ void setup() {
Serial2.begin(9600, SERIAL_8N1, RXD, TXD); Serial2.begin(9600, SERIAL_8N1, RXD, TXD);
#endif #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 #ifdef LOCAL_ACL
acl.loadFromEEPROM(); acl.loadFromEEPROM();
#endif #endif
settings.loadFromEEPROM(); 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 #ifdef DATA0_PIN
pinMode(DATA0_PIN, INPUT_PULLUP); pinMode(DATA0_PIN, INPUT_PULLUP);
#endif #endif
@ -219,13 +179,6 @@ void setup() {
attachInterrupt(digitalPinToInterrupt(DATA1_PIN), handleData1Interrupt, FALLING); attachInterrupt(digitalPinToInterrupt(DATA1_PIN), handleData1Interrupt, FALLING);
#endif #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 RELAY1
#ifdef SERIAL_DEBUG #ifdef SERIAL_DEBUG
Serial.println("Enabling Relay: Locking Door"); Serial.println("Enabling Relay: Locking Door");
@ -244,20 +197,49 @@ void setup() {
#endif #endif
#endif #endif
#ifdef WEB_SERVER #ifdef WIFI
MainWebServer.begin(&server, http_username, http_password); webhooks_http.setReuse(true);
#ifdef LOCAL_ACL WiFi.onEvent(WiFiStationConnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_CONNECTED);
#ifdef LOCAL_ACL_API WiFi.onEvent(WiFiGotIP, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);
ACLWebServer.begin(&server, http_username, http_password); WiFi.onEvent(WiFiStationDisconnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
#endif connectToWiFi(ssid, password);
#endif #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"); tinance2logrequest("Device Rebooted, Setup Complete");
#endif #endif
} }