diff --git a/data/index.html b/data/index.html index f41ca65..3f6d3ba 100644 --- a/data/index.html +++ b/data/index.html @@ -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> diff --git a/src/hardware.cpp b/src/hardware.cpp index 67de4cc..d3a2a1f 100644 --- a/src/hardware.cpp +++ b/src/hardware.cpp @@ -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 } diff --git a/src/main.cpp b/src/main.cpp index 31de2b1..e124a83 100644 --- a/src/main.cpp +++ b/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 }