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
|
_type: export
|
||||||
__export_format: 4
|
__export_format: 4
|
||||||
__export_date: 2023-06-13T15:14:59.180Z
|
__export_date: 2023-06-13T18:00:58.192Z
|
||||||
__export_source: insomnia.desktop.app:v2023.2.2
|
__export_source: insomnia.desktop.app:v2023.2.0
|
||||||
resources:
|
resources:
|
||||||
- _id: req_fab13abf4f6146a3b0db6955b4968837
|
- _id: req_dc09d3be399d4ef5be7264beec433bc8
|
||||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
parentId: fld_aa9bbbd53f414ce0a178a447d75b4283
|
||||||
modified: 1686669271336
|
modified: 1686678950521
|
||||||
created: 1680522514230
|
created: 1686668861396
|
||||||
url: http://{{ _.url }}/users
|
url: http://{{ _.url }}/state/relay1
|
||||||
name: Get Card ACL's
|
name: Door - State
|
||||||
description: ""
|
description: ""
|
||||||
method: GET
|
method: GET
|
||||||
body:
|
body:
|
||||||
mimeType: application/json
|
mimeType: application/json
|
||||||
text: "\n "
|
text: "\n"
|
||||||
parameters: []
|
parameters: []
|
||||||
headers:
|
headers:
|
||||||
- id: pair_cf9752f319fc4ce2bbc5c1d802d7a82b
|
- id: pair_cf9752f319fc4ce2bbc5c1d802d7a82b
|
||||||
|
@ -26,7 +26,7 @@ resources:
|
||||||
disabled: false
|
disabled: false
|
||||||
username: "{{ _.username }}"
|
username: "{{ _.username }}"
|
||||||
password: "{{ _.password }}"
|
password: "{{ _.password }}"
|
||||||
metaSortKey: -1680522514230
|
metaSortKey: -1679616163608.75
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
|
@ -35,84 +35,30 @@ resources:
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingFollowRedirects: global
|
settingFollowRedirects: global
|
||||||
_type: request
|
_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
|
parentId: null
|
||||||
modified: 1680522505347
|
modified: 1686673742300
|
||||||
created: 1680522505347
|
created: 1686673742300
|
||||||
name: my-spec.yaml
|
name: Card Reader API
|
||||||
description: ""
|
description: ""
|
||||||
scope: design
|
scope: design
|
||||||
_type: workspace
|
_type: workspace
|
||||||
- _id: req_c66870231d7e481e9924d79dd20a3469
|
- _id: req_84fb14db5570434bb244a18fe7eded4d
|
||||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
parentId: fld_aa9bbbd53f414ce0a178a447d75b4283
|
||||||
modified: 1686669269579
|
modified: 1686678956145
|
||||||
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
|
|
||||||
created: 1686666065894
|
created: 1686666065894
|
||||||
url: http://{{ _.url }}/gpio?output=relay1&state=0
|
url: http://{{ _.url }}/gpio?output=relay1&state=0
|
||||||
name: Relay 1 - Unlock
|
name: Door - Unlock
|
||||||
description: ""
|
description: ""
|
||||||
method: GET
|
method: GET
|
||||||
body:
|
body:
|
||||||
|
@ -130,7 +76,7 @@ resources:
|
||||||
disabled: false
|
disabled: false
|
||||||
username: "{{ _.username }}"
|
username: "{{ _.username }}"
|
||||||
password: "{{ _.password }}"
|
password: "{{ _.password }}"
|
||||||
metaSortKey: -1679162988316.875
|
metaSortKey: -1679616163571.25
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
|
@ -139,9 +85,41 @@ resources:
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingFollowRedirects: global
|
settingFollowRedirects: global
|
||||||
_type: request
|
_type: request
|
||||||
- _id: req_fbe2da3ea1b942149289048a145c2e1f
|
- _id: req_ca730b46474f4fdaae25aa07c64aaec1
|
||||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
parentId: fld_aa9bbbd53f414ce0a178a447d75b4283
|
||||||
modified: 1686669265389
|
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
|
created: 1686523684626
|
||||||
url: http://{{ _.url }}/users/create
|
url: http://{{ _.url }}/users/create
|
||||||
name: Create Card ACL
|
name: Create Card ACL
|
||||||
|
@ -179,9 +157,19 @@ resources:
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingFollowRedirects: global
|
settingFollowRedirects: global
|
||||||
_type: request
|
_type: request
|
||||||
- _id: req_60a5d5a1e2d444b18d05c1892f23ba0c
|
- _id: fld_4344c65132674719831f9ef4fcd55cc4
|
||||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
parentId: wrk_5b99c929e230492d9da3ab8c43602701
|
||||||
modified: 1686669263689
|
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
|
created: 1686527136306
|
||||||
url: http://{{ _.url }}/users/update
|
url: http://{{ _.url }}/users/update
|
||||||
name: Update Card ACL
|
name: Update Card ACL
|
||||||
|
@ -213,7 +201,7 @@ resources:
|
||||||
disabled: false
|
disabled: false
|
||||||
username: "{{ _.username }}"
|
username: "{{ _.username }}"
|
||||||
password: "{{ _.password }}"
|
password: "{{ _.password }}"
|
||||||
metaSortKey: -1678256637708.125
|
metaSortKey: -1678709812962.5
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
|
@ -222,9 +210,9 @@ resources:
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingFollowRedirects: global
|
settingFollowRedirects: global
|
||||||
_type: request
|
_type: request
|
||||||
- _id: req_df860cce04cf49c98c9abc4e92ec5a72
|
- _id: req_ab4edf71a18543e2aabd2e40e704b765
|
||||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
parentId: fld_4344c65132674719831f9ef4fcd55cc4
|
||||||
modified: 1686669260874
|
modified: 1686677018916
|
||||||
created: 1686526808857
|
created: 1686526808857
|
||||||
url: http://{{ _.url }}/users/remove
|
url: http://{{ _.url }}/users/remove
|
||||||
name: Remove Card ACL
|
name: Remove Card ACL
|
||||||
|
@ -248,7 +236,7 @@ resources:
|
||||||
disabled: false
|
disabled: false
|
||||||
username: "{{ _.username }}"
|
username: "{{ _.username }}"
|
||||||
password: "{{ _.password }}"
|
password: "{{ _.password }}"
|
||||||
metaSortKey: -1677803462403.75
|
metaSortKey: -1678709812912.5
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
|
@ -257,9 +245,115 @@ resources:
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingFollowRedirects: global
|
settingFollowRedirects: global
|
||||||
_type: request
|
_type: request
|
||||||
- _id: env_72c9ec50419adc3e8768056161ce4d086c486204
|
- _id: req_6512ec9f76814b2181703b074553b67e
|
||||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
parentId: fld_4344c65132674719831f9ef4fcd55cc4
|
||||||
modified: 1686669088807
|
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
|
created: 1680522505349
|
||||||
name: Base Environment
|
name: Base Environment
|
||||||
data:
|
data:
|
||||||
|
@ -275,18 +369,54 @@ resources:
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: 1680522505349
|
metaSortKey: 1680522505349
|
||||||
_type: environment
|
_type: environment
|
||||||
- _id: jar_72c9ec50419adc3e8768056161ce4d086c486204
|
- _id: jar_ec61023b847c4a93b0a913359b84575e
|
||||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
parentId: wrk_5b99c929e230492d9da3ab8c43602701
|
||||||
modified: 1680522505350
|
modified: 1680522505350
|
||||||
created: 1680522505350
|
created: 1680522505350
|
||||||
name: Default Jar
|
name: Default Jar
|
||||||
cookies: []
|
cookies: []
|
||||||
_type: cookie_jar
|
_type: cookie_jar
|
||||||
- _id: spc_deaf3f00ef8847429199de99aca75d06
|
- _id: spc_5485b8347b134baaa02ea692d9dcc01d
|
||||||
parentId: wrk_3465ebd3f0ef47dcac39369bc6f6475e
|
parentId: wrk_5b99c929e230492d9da3ab8c43602701
|
||||||
modified: 1680522505347
|
modified: 1686673742300
|
||||||
created: 1680522505347
|
created: 1686673742300
|
||||||
fileName: my-spec.yaml
|
fileName: Card Reader API
|
||||||
contents: ""
|
contents: ""
|
||||||
contentType: yaml
|
contentType: yaml
|
||||||
_type: api_spec
|
_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 <Arduino.h>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
|
|
||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
|
|
||||||
#ifdef WEB_SERVER
|
#ifdef WEB_SERVER
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "secrets.h"
|
#include "secrets.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
#ifdef WIFI
|
#ifdef WIFI
|
||||||
#include "WiFi.h"
|
#include "WiFi.h"
|
||||||
#endif
|
#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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Preferences preferences;
|
Preferences acl_preferences;
|
||||||
|
|
||||||
|
|
||||||
int ACL::getACLSize() const {
|
int ACL::getACLSize() const {
|
||||||
|
@ -110,24 +110,24 @@ int ACL::getACLSize() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACL::loadFromEEPROM() {
|
void ACL::loadFromEEPROM() {
|
||||||
preferences.begin("acl", true);
|
acl_preferences.begin("acl", true);
|
||||||
aclSize = preferences.getUInt("aclSize", 0);
|
aclSize = acl_preferences.getUInt("aclSize", 0);
|
||||||
acl = new User[aclSize];
|
acl = new User[aclSize];
|
||||||
for (int i = 0; i < aclSize; i++) {
|
for (int i = 0; i < aclSize; i++) {
|
||||||
String key = "user_" + String(i);
|
String key = "user_" + String(i);
|
||||||
acl[i].cardId = preferences.getString((key + "_cardId").c_str(), "");
|
acl[i].cardId = acl_preferences.getString((key + "_cardId").c_str(), "");
|
||||||
acl[i].desc = preferences.getString((key + "_desc").c_str(), "");
|
acl[i].desc = acl_preferences.getString((key + "_desc").c_str(), "");
|
||||||
}
|
}
|
||||||
preferences.end();
|
acl_preferences.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACL::saveToEEPROM() {
|
void ACL::saveToEEPROM() {
|
||||||
preferences.begin("acl", false);
|
acl_preferences.begin("acl", false);
|
||||||
preferences.putUInt("aclSize", aclSize);
|
acl_preferences.putUInt("aclSize", aclSize);
|
||||||
for (int i = 0; i < aclSize; i++) {
|
for (int i = 0; i < aclSize; i++) {
|
||||||
String key = "user_" + String(i);
|
String key = "user_" + String(i);
|
||||||
preferences.putString((key + "_cardId").c_str(), acl[i].cardId.c_str());
|
acl_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 + "_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
|
const unsigned long wifiRebootTimeout = 20000; // Delay before reboot after disconnect
|
||||||
unsigned int bitCount = 0; // Variable to keep track of the bit count
|
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.
|
unsigned int maxReaderWaitTime = 9000; // Variable to timeout reader after too long of no data.
|
||||||
|
Settings settings;
|
||||||
|
|
||||||
#ifdef WIFI
|
#ifdef WIFI
|
||||||
|
|
||||||
|
@ -268,6 +268,9 @@ void setup() {
|
||||||
acl.loadFromEEPROM();
|
acl.loadFromEEPROM();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
settings.loadFromEEPROM();
|
||||||
|
|
||||||
// Initialize SPIFFS
|
// Initialize SPIFFS
|
||||||
#ifdef WEB_SERVER
|
#ifdef WEB_SERVER
|
||||||
if(!SPIFFS.begin(true)){
|
if(!SPIFFS.begin(true)){
|
||||||
|
@ -347,6 +350,48 @@ void setup() {
|
||||||
});
|
});
|
||||||
#endif
|
#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>
|
// Send a GET request to <ESP_IP>/gpio?output=<paramOutput>&state=<paramState>
|
||||||
server.on("/gpio", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
server.on("/gpio", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
String paramOutput;
|
String paramOutput;
|
||||||
|
@ -471,13 +516,17 @@ void loop() {
|
||||||
#endif
|
#endif
|
||||||
// Perform actions for authorized access
|
// Perform actions for authorized access
|
||||||
#ifdef LATCH_DOOR
|
#ifdef LATCH_DOOR
|
||||||
unlockDoor(false);
|
if (!settings.DoorDisabled()) {
|
||||||
delay(RELAY_DELAY);
|
unlockDoor(false);
|
||||||
lockDoor();
|
delay(RELAY_DELAY);
|
||||||
|
lockDoor();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef TOGGLE_DOOR
|
#ifdef TOGGLE_DOOR
|
||||||
toggleDoor();
|
if (!settings.DoorDisabled()) {
|
||||||
delay(RELAY_DELAY);
|
toggleDoor();
|
||||||
|
delay(RELAY_DELAY);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#ifdef SERIAL_DEBUG
|
#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