settings
This commit is contained in:
parent
1761bbeb8a
commit
95faf3f3f1
7 changed files with 353 additions and 122 deletions
|
@ -1,19 +1,19 @@
|
|||
_type: export
|
||||
__export_format: 4
|
||||
__export_date: 2023-06-13T15:14:59.180Z
|
||||
__export_source: insomnia.desktop.app:v2023.2.2
|
||||
__export_date: 2023-06-13T18:00:58.192Z
|
||||
__export_source: insomnia.desktop.app:v2023.2.0
|
||||
resources:
|
||||
- _id: req_fab13abf4f6146a3b0db6955b4968837
|
||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
||||
modified: 1686669271336
|
||||
created: 1680522514230
|
||||
url: http://{{ _.url }}/users
|
||||
name: Get Card ACL's
|
||||
- _id: req_dc09d3be399d4ef5be7264beec433bc8
|
||||
parentId: fld_aa9bbbd53f414ce0a178a447d75b4283
|
||||
modified: 1686678950521
|
||||
created: 1686668861396
|
||||
url: http://{{ _.url }}/state/relay1
|
||||
name: Door - State
|
||||
description: ""
|
||||
method: GET
|
||||
body:
|
||||
mimeType: application/json
|
||||
text: "\n "
|
||||
text: "\n"
|
||||
parameters: []
|
||||
headers:
|
||||
- id: pair_cf9752f319fc4ce2bbc5c1d802d7a82b
|
||||
|
@ -26,7 +26,7 @@ resources:
|
|||
disabled: false
|
||||
username: "{{ _.username }}"
|
||||
password: "{{ _.password }}"
|
||||
metaSortKey: -1680522514230
|
||||
metaSortKey: -1679616163608.75
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
|
@ -35,84 +35,30 @@ resources:
|
|||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
||||
- _id: fld_aa9bbbd53f414ce0a178a447d75b4283
|
||||
parentId: wrk_5b99c929e230492d9da3ab8c43602701
|
||||
modified: 1686677030616
|
||||
created: 1686677030616
|
||||
name: door / relay1
|
||||
description: ""
|
||||
environment: {}
|
||||
environmentPropertyOrder: null
|
||||
metaSortKey: -1686677030616
|
||||
_type: request_group
|
||||
- _id: wrk_5b99c929e230492d9da3ab8c43602701
|
||||
parentId: null
|
||||
modified: 1680522505347
|
||||
created: 1680522505347
|
||||
name: my-spec.yaml
|
||||
modified: 1686673742300
|
||||
created: 1686673742300
|
||||
name: Card Reader API
|
||||
description: ""
|
||||
scope: design
|
||||
_type: workspace
|
||||
- _id: req_c66870231d7e481e9924d79dd20a3469
|
||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
||||
modified: 1686669269579
|
||||
created: 1686657865280
|
||||
url: http://{{ _.url }}/gpio?output=relay1&state=1
|
||||
name: Relay 1 - Lock
|
||||
description: ""
|
||||
method: GET
|
||||
body:
|
||||
mimeType: application/json
|
||||
text: "\n"
|
||||
parameters: []
|
||||
headers:
|
||||
- id: pair_cf9752f319fc4ce2bbc5c1d802d7a82b
|
||||
name: Content-Type
|
||||
value: application/json
|
||||
description: ""
|
||||
authentication:
|
||||
type: basic
|
||||
useISO88591: false
|
||||
disabled: false
|
||||
username: "{{ _.username }}"
|
||||
password: "{{ _.password }}"
|
||||
metaSortKey: -1679616163621.25
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
settingDisableRenderRequestBody: false
|
||||
settingEncodeUrl: true
|
||||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: req_fa13d02a8e494b3bac5e8ebd9e43743d
|
||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
||||
modified: 1686669268206
|
||||
created: 1686668861396
|
||||
url: http://{{ _.url }}/state/relay1
|
||||
name: Relay 1 - State
|
||||
description: ""
|
||||
method: GET
|
||||
body:
|
||||
mimeType: application/json
|
||||
text: "\n"
|
||||
parameters: []
|
||||
headers:
|
||||
- id: pair_cf9752f319fc4ce2bbc5c1d802d7a82b
|
||||
name: Content-Type
|
||||
value: application/json
|
||||
description: ""
|
||||
authentication:
|
||||
type: basic
|
||||
useISO88591: false
|
||||
disabled: false
|
||||
username: "{{ _.username }}"
|
||||
password: "{{ _.password }}"
|
||||
metaSortKey: -1679389575969.0625
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
settingDisableRenderRequestBody: false
|
||||
settingEncodeUrl: true
|
||||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: req_1b2a0092b3244361b37c14cdffd76b12
|
||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
||||
modified: 1686669266737
|
||||
- _id: req_84fb14db5570434bb244a18fe7eded4d
|
||||
parentId: fld_aa9bbbd53f414ce0a178a447d75b4283
|
||||
modified: 1686678956145
|
||||
created: 1686666065894
|
||||
url: http://{{ _.url }}/gpio?output=relay1&state=0
|
||||
name: Relay 1 - Unlock
|
||||
name: Door - Unlock
|
||||
description: ""
|
||||
method: GET
|
||||
body:
|
||||
|
@ -130,7 +76,7 @@ resources:
|
|||
disabled: false
|
||||
username: "{{ _.username }}"
|
||||
password: "{{ _.password }}"
|
||||
metaSortKey: -1679162988316.875
|
||||
metaSortKey: -1679616163571.25
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
|
@ -139,9 +85,41 @@ resources:
|
|||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: req_fbe2da3ea1b942149289048a145c2e1f
|
||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
||||
modified: 1686669265389
|
||||
- _id: req_ca730b46474f4fdaae25aa07c64aaec1
|
||||
parentId: fld_aa9bbbd53f414ce0a178a447d75b4283
|
||||
modified: 1686678971440
|
||||
created: 1686657865280
|
||||
url: http://{{ _.url }}/gpio?output=relay1&state=1
|
||||
name: Door - Lock
|
||||
description: ""
|
||||
method: GET
|
||||
body:
|
||||
mimeType: application/json
|
||||
text: "\n"
|
||||
parameters: []
|
||||
headers:
|
||||
- id: pair_cf9752f319fc4ce2bbc5c1d802d7a82b
|
||||
name: Content-Type
|
||||
value: application/json
|
||||
description: ""
|
||||
authentication:
|
||||
type: basic
|
||||
useISO88591: false
|
||||
disabled: false
|
||||
username: "{{ _.username }}"
|
||||
password: "{{ _.password }}"
|
||||
metaSortKey: -1679616163521.25
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
settingDisableRenderRequestBody: false
|
||||
settingEncodeUrl: true
|
||||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: req_f2278f225ebe46409ee02f168da9edb4
|
||||
parentId: fld_4344c65132674719831f9ef4fcd55cc4
|
||||
modified: 1686677015417
|
||||
created: 1686523684626
|
||||
url: http://{{ _.url }}/users/create
|
||||
name: Create Card ACL
|
||||
|
@ -179,9 +157,19 @@ resources:
|
|||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: req_60a5d5a1e2d444b18d05c1892f23ba0c
|
||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
||||
modified: 1686669263689
|
||||
- _id: fld_4344c65132674719831f9ef4fcd55cc4
|
||||
parentId: wrk_5b99c929e230492d9da3ab8c43602701
|
||||
modified: 1686677012414
|
||||
created: 1686677012414
|
||||
name: acls
|
||||
description: ""
|
||||
environment: {}
|
||||
environmentPropertyOrder: null
|
||||
metaSortKey: -1686677012414
|
||||
_type: request_group
|
||||
- _id: req_e00a6efca48546e7982bc417d1d7036c
|
||||
parentId: fld_4344c65132674719831f9ef4fcd55cc4
|
||||
modified: 1686677016937
|
||||
created: 1686527136306
|
||||
url: http://{{ _.url }}/users/update
|
||||
name: Update Card ACL
|
||||
|
@ -213,7 +201,7 @@ resources:
|
|||
disabled: false
|
||||
username: "{{ _.username }}"
|
||||
password: "{{ _.password }}"
|
||||
metaSortKey: -1678256637708.125
|
||||
metaSortKey: -1678709812962.5
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
|
@ -222,9 +210,9 @@ resources:
|
|||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: req_df860cce04cf49c98c9abc4e92ec5a72
|
||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
||||
modified: 1686669260874
|
||||
- _id: req_ab4edf71a18543e2aabd2e40e704b765
|
||||
parentId: fld_4344c65132674719831f9ef4fcd55cc4
|
||||
modified: 1686677018916
|
||||
created: 1686526808857
|
||||
url: http://{{ _.url }}/users/remove
|
||||
name: Remove Card ACL
|
||||
|
@ -248,7 +236,7 @@ resources:
|
|||
disabled: false
|
||||
username: "{{ _.username }}"
|
||||
password: "{{ _.password }}"
|
||||
metaSortKey: -1677803462403.75
|
||||
metaSortKey: -1678709812912.5
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
|
@ -257,9 +245,115 @@ resources:
|
|||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: env_72c9ec50419adc3e8768056161ce4d086c486204
|
||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
||||
modified: 1686669088807
|
||||
- _id: req_6512ec9f76814b2181703b074553b67e
|
||||
parentId: fld_4344c65132674719831f9ef4fcd55cc4
|
||||
modified: 1686677053597
|
||||
created: 1680522514230
|
||||
url: http://{{ _.url }}/users
|
||||
name: Get Card ACL's
|
||||
description: ""
|
||||
method: GET
|
||||
body:
|
||||
mimeType: application/json
|
||||
text: "\n "
|
||||
parameters: []
|
||||
headers:
|
||||
- id: pair_cf9752f319fc4ce2bbc5c1d802d7a82b
|
||||
name: Content-Type
|
||||
value: application/json
|
||||
description: ""
|
||||
authentication:
|
||||
type: basic
|
||||
useISO88591: false
|
||||
disabled: false
|
||||
username: "{{ _.username }}"
|
||||
password: "{{ _.password }}"
|
||||
metaSortKey: -1678709812862.5
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
settingDisableRenderRequestBody: false
|
||||
settingEncodeUrl: true
|
||||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: req_6bb012113ee640bdb3b5259fdc333277
|
||||
parentId: fld_fa644d484dd64e78b90e3df0c486e7d6
|
||||
modified: 1686678985051
|
||||
created: 1686676992334
|
||||
url: http://{{ _.url }}/settings/get/DoorDisabled
|
||||
name: settings - get - DoorDisabled
|
||||
description: ""
|
||||
method: GET
|
||||
body:
|
||||
mimeType: application/json
|
||||
text: "\n"
|
||||
parameters: []
|
||||
headers:
|
||||
- id: pair_cf9752f319fc4ce2bbc5c1d802d7a82b
|
||||
name: Content-Type
|
||||
value: application/json
|
||||
description: ""
|
||||
authentication:
|
||||
type: basic
|
||||
useISO88591: false
|
||||
disabled: false
|
||||
username: "{{ _.username }}"
|
||||
password: "{{ _.password }}"
|
||||
metaSortKey: -1679446222882.1094
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
settingDisableRenderRequestBody: false
|
||||
settingEncodeUrl: true
|
||||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: fld_fa644d484dd64e78b90e3df0c486e7d6
|
||||
parentId: wrk_5b99c929e230492d9da3ab8c43602701
|
||||
modified: 1686677001223
|
||||
created: 1686677001223
|
||||
name: Settings
|
||||
description: ""
|
||||
environment: {}
|
||||
environmentPropertyOrder: null
|
||||
metaSortKey: -1686677001223
|
||||
_type: request_group
|
||||
- _id: req_5681a54a0b7f4109ad50da6cce36cc65
|
||||
parentId: fld_fa644d484dd64e78b90e3df0c486e7d6
|
||||
modified: 1686679008127
|
||||
created: 1686676506109
|
||||
url: http://{{ _.url }}/settings/set/DoorDisabled?value=0
|
||||
name: settings - set - DoorDisabled
|
||||
description: ""
|
||||
method: GET
|
||||
body:
|
||||
mimeType: application/json
|
||||
text: ""
|
||||
parameters: []
|
||||
headers:
|
||||
- id: pair_cf9752f319fc4ce2bbc5c1d802d7a82b
|
||||
name: Content-Type
|
||||
value: application/json
|
||||
description: ""
|
||||
authentication:
|
||||
type: basic
|
||||
useISO88591: false
|
||||
disabled: false
|
||||
username: "{{ _.username }}"
|
||||
password: "{{ _.password }}"
|
||||
metaSortKey: -1679446222832.1094
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
settingDisableRenderRequestBody: false
|
||||
settingEncodeUrl: true
|
||||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
_type: request
|
||||
- _id: env_22c2e08cc6484cf48f51f396216b2589
|
||||
parentId: wrk_5b99c929e230492d9da3ab8c43602701
|
||||
modified: 1686673750409
|
||||
created: 1680522505349
|
||||
name: Base Environment
|
||||
data:
|
||||
|
@ -275,18 +369,54 @@ resources:
|
|||
isPrivate: false
|
||||
metaSortKey: 1680522505349
|
||||
_type: environment
|
||||
- _id: jar_72c9ec50419adc3e8768056161ce4d086c486204
|
||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
||||
- _id: jar_ec61023b847c4a93b0a913359b84575e
|
||||
parentId: wrk_5b99c929e230492d9da3ab8c43602701
|
||||
modified: 1680522505350
|
||||
created: 1680522505350
|
||||
name: Default Jar
|
||||
cookies: []
|
||||
_type: cookie_jar
|
||||
- _id: spc_deaf3f00ef8847429199de99aca75d06
|
||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
||||
modified: 1680522505347
|
||||
created: 1680522505347
|
||||
fileName: my-spec.yaml
|
||||
- _id: spc_5485b8347b134baaa02ea692d9dcc01d
|
||||
parentId: wrk_5b99c929e230492d9da3ab8c43602701
|
||||
modified: 1686673742300
|
||||
created: 1686673742300
|
||||
fileName: Card Reader API
|
||||
contents: ""
|
||||
contentType: yaml
|
||||
_type: api_spec
|
||||
- _id: env_d0796e8d31204545aefdc3a375b47726
|
||||
parentId: env_22c2e08cc6484cf48f51f396216b2589
|
||||
modified: 1686673772099
|
||||
created: 1686673751428
|
||||
name: Test Reader Home
|
||||
data:
|
||||
username: admin
|
||||
password: B9mVYwa8$XtB7X8D3z9E
|
||||
url: 192.168.50.65
|
||||
dataPropertyOrder:
|
||||
"&":
|
||||
- username
|
||||
- password
|
||||
- url
|
||||
color: null
|
||||
isPrivate: false
|
||||
metaSortKey: 1686673751428
|
||||
_type: environment
|
||||
- _id: env_a092494d8f1e48bb9e9fb30abde28c3d
|
||||
parentId: env_22c2e08cc6484cf48f51f396216b2589
|
||||
modified: 1686673789502
|
||||
created: 1686673772806
|
||||
name: Techinc - Server Room
|
||||
data:
|
||||
username: admin
|
||||
password: B9mVYwa8$XtB7X8D3z9E
|
||||
url: 10.209.1.236
|
||||
dataPropertyOrder:
|
||||
"&":
|
||||
- username
|
||||
- password
|
||||
- url
|
||||
color: null
|
||||
isPrivate: false
|
||||
metaSortKey: 1686673772806
|
||||
_type: environment
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <Arduino.h>
|
||||
#include <initializer_list>
|
||||
#include <EEPROM.h>
|
||||
|
||||
#include <Preferences.h>
|
||||
|
||||
#ifdef WEB_SERVER
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
#include "hardware.h"
|
||||
#include <Arduino.h>
|
||||
#include "secrets.h"
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#ifdef WIFI
|
||||
#include "WiFi.h"
|
||||
#endif
|
||||
|
|
20
include/settings.h
Normal file
20
include/settings.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
#include <Preferences.h>
|
||||
|
||||
class Settings {
|
||||
private:
|
||||
bool disableDoor;
|
||||
|
||||
public:
|
||||
Settings();
|
||||
|
||||
void loadFromEEPROM();
|
||||
void saveToEEPROM();
|
||||
|
||||
void setDisableDoor(bool value);
|
||||
bool DoorDisabled();
|
||||
};
|
||||
|
||||
#endif // SETTINGS_H
|
22
src/ACL.cpp
22
src/ACL.cpp
|
@ -102,7 +102,7 @@ bool ACL::validateAccess(const String& cardId) {
|
|||
return false;
|
||||
}
|
||||
|
||||
Preferences preferences;
|
||||
Preferences acl_preferences;
|
||||
|
||||
|
||||
int ACL::getACLSize() const {
|
||||
|
@ -110,24 +110,24 @@ int ACL::getACLSize() const {
|
|||
}
|
||||
|
||||
void ACL::loadFromEEPROM() {
|
||||
preferences.begin("acl", true);
|
||||
aclSize = preferences.getUInt("aclSize", 0);
|
||||
acl_preferences.begin("acl", true);
|
||||
aclSize = acl_preferences.getUInt("aclSize", 0);
|
||||
acl = new User[aclSize];
|
||||
for (int i = 0; i < aclSize; i++) {
|
||||
String key = "user_" + String(i);
|
||||
acl[i].cardId = preferences.getString((key + "_cardId").c_str(), "");
|
||||
acl[i].desc = preferences.getString((key + "_desc").c_str(), "");
|
||||
acl[i].cardId = acl_preferences.getString((key + "_cardId").c_str(), "");
|
||||
acl[i].desc = acl_preferences.getString((key + "_desc").c_str(), "");
|
||||
}
|
||||
preferences.end();
|
||||
acl_preferences.end();
|
||||
}
|
||||
|
||||
void ACL::saveToEEPROM() {
|
||||
preferences.begin("acl", false);
|
||||
preferences.putUInt("aclSize", aclSize);
|
||||
acl_preferences.begin("acl", false);
|
||||
acl_preferences.putUInt("aclSize", aclSize);
|
||||
for (int i = 0; i < aclSize; i++) {
|
||||
String key = "user_" + String(i);
|
||||
preferences.putString((key + "_cardId").c_str(), acl[i].cardId.c_str());
|
||||
preferences.putString((key + "_desc").c_str(), acl[i].desc.c_str());
|
||||
acl_preferences.putString((key + "_cardId").c_str(), acl[i].cardId.c_str());
|
||||
acl_preferences.putString((key + "_desc").c_str(), acl[i].desc.c_str());
|
||||
}
|
||||
preferences.end();
|
||||
acl_preferences.end();
|
||||
}
|
61
src/main.cpp
61
src/main.cpp
|
@ -7,7 +7,7 @@ const unsigned long displayDelay = 1000; // Delay in milliseconds after which th
|
|||
const unsigned long wifiRebootTimeout = 20000; // Delay before reboot after disconnect
|
||||
unsigned int bitCount = 0; // Variable to keep track of the bit count
|
||||
unsigned int maxReaderWaitTime = 9000; // Variable to timeout reader after too long of no data.
|
||||
|
||||
Settings settings;
|
||||
|
||||
#ifdef WIFI
|
||||
|
||||
|
@ -268,6 +268,9 @@ void setup() {
|
|||
acl.loadFromEEPROM();
|
||||
#endif
|
||||
|
||||
|
||||
settings.loadFromEEPROM();
|
||||
|
||||
// Initialize SPIFFS
|
||||
#ifdef WEB_SERVER
|
||||
if(!SPIFFS.begin(true)){
|
||||
|
@ -347,6 +350,48 @@ void setup() {
|
|||
});
|
||||
#endif
|
||||
|
||||
server.on("/settings/get/DoorDisabled", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||
AsyncWebServerResponse *response = request->beginResponse(200, "application/json", "{\"value\":\""+String(settings.DoorDisabled())+"\"}");
|
||||
request->send(response);
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Send a GET request to <ESP_IP>/gpio?output=<paramOutput>&state=<paramState>
|
||||
server.on("/settings/set/DoorDisabled", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||
String value;
|
||||
|
||||
if(!request->authenticate(http_username, http_password))
|
||||
return request->requestAuthentication();
|
||||
|
||||
if (request->hasParam("value")) {
|
||||
value = request->getParam("value")->value();
|
||||
if (value == "0") {
|
||||
settings.setDisableDoor(0);
|
||||
AsyncWebServerResponse *response = request->beginResponse(200, "application/json", "{\"msg\":\"value set to 0\"}");
|
||||
request->send(response);
|
||||
}
|
||||
else if (value =="1") {
|
||||
settings.setDisableDoor(1);
|
||||
AsyncWebServerResponse *response = request->beginResponse(200, "application/json", "{\"msg\":\"value set to 1\"}");
|
||||
request->send(response);
|
||||
|
||||
} else {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"value should be 0 or 1\"}");
|
||||
request->send(response);
|
||||
}
|
||||
}
|
||||
else {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"Missing 'value' param.\"}");
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Send a GET request to <ESP_IP>/gpio?output=<paramOutput>&state=<paramState>
|
||||
server.on("/gpio", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||
String paramOutput;
|
||||
|
@ -471,13 +516,17 @@ void loop() {
|
|||
#endif
|
||||
// Perform actions for authorized access
|
||||
#ifdef LATCH_DOOR
|
||||
unlockDoor(false);
|
||||
delay(RELAY_DELAY);
|
||||
lockDoor();
|
||||
if (!settings.DoorDisabled()) {
|
||||
unlockDoor(false);
|
||||
delay(RELAY_DELAY);
|
||||
lockDoor();
|
||||
}
|
||||
#endif
|
||||
#ifdef TOGGLE_DOOR
|
||||
toggleDoor();
|
||||
delay(RELAY_DELAY);
|
||||
if (!settings.DoorDisabled()) {
|
||||
toggleDoor();
|
||||
delay(RELAY_DELAY);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
#ifdef SERIAL_DEBUG
|
||||
|
|
30
src/settings.cpp
Normal file
30
src/settings.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "settings.h"
|
||||
|
||||
|
||||
Preferences settings_preferences;
|
||||
|
||||
Settings::Settings() {
|
||||
// Set default value for disableDoor
|
||||
disableDoor = false;
|
||||
}
|
||||
|
||||
void Settings::loadFromEEPROM() {
|
||||
settings_preferences.begin("settings");
|
||||
disableDoor = settings_preferences.getBool("disableDoor", false);
|
||||
settings_preferences.end();
|
||||
}
|
||||
|
||||
void Settings::saveToEEPROM() {
|
||||
settings_preferences.begin("settings");
|
||||
settings_preferences.putBool("disableDoor", disableDoor);
|
||||
settings_preferences.end();
|
||||
}
|
||||
|
||||
void Settings::setDisableDoor(bool value) {
|
||||
disableDoor = value;
|
||||
saveToEEPROM(); // Save the setting immediately to Preferences
|
||||
}
|
||||
|
||||
bool Settings::DoorDisabled() {
|
||||
return disableDoor;
|
||||
}
|
Loading…
Reference in a new issue