dynamic memory
This commit is contained in:
parent
d1b423d6bf
commit
b5623e2a74
1 changed files with 39 additions and 3 deletions
|
@ -13,8 +13,6 @@
|
|||
#include <ArduinoJson.h>
|
||||
#include <AsyncJson.h>
|
||||
|
||||
|
||||
|
||||
class ACLWebServerClass{
|
||||
|
||||
public:
|
||||
|
@ -40,7 +38,7 @@ class ACLWebServerClass{
|
|||
}
|
||||
}
|
||||
// Create a JSON array to store the users
|
||||
StaticJsonDocument<512> jsonDoc;
|
||||
DynamicJsonDocument jsonDoc(ESP.getMaxAllocHeap());
|
||||
JsonArray usersArray = jsonDoc.to<JsonArray>();
|
||||
|
||||
// Retrieve the ACL data using the getter function
|
||||
|
@ -83,6 +81,19 @@ class ACLWebServerClass{
|
|||
String cardId = String(request->arg("cardId"));
|
||||
String desc = String(request->arg("desc"));
|
||||
|
||||
|
||||
if (!cardId.length() > 0 ) {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"cardId May not be Empty.\"}");
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
|
||||
if (!desc.length() > 0 ) {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"desc May not be Empty.\"}");
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
|
||||
if (acl.validateAccess(String(cardId))) {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"Duplicate ACL\"}");
|
||||
request->send(response);
|
||||
|
@ -120,6 +131,24 @@ class ACLWebServerClass{
|
|||
String cardId = String(request->arg("cardId"));
|
||||
String newCardId = String(request->arg("newCardId"));
|
||||
String desc = String(request->arg("desc"));
|
||||
|
||||
|
||||
|
||||
if (!cardId.length() > 0 ) {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"cardId May not be Empty.\"}");
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
if (!newCardId.length() > 0 ) {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"newCardId May not be Empty.\"}");
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
if (!desc.length() > 0 ) {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"desc May not be Empty.\"}");
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
acl.updateUser(cardId, newCardId, desc);
|
||||
acl.saveToEEPROM();
|
||||
request->send(201); // Created
|
||||
|
@ -138,6 +167,13 @@ class ACLWebServerClass{
|
|||
request->send(response);
|
||||
}
|
||||
String cardId = String(request->arg("cardId"));
|
||||
|
||||
|
||||
if (!cardId.length() > 0 ) {
|
||||
AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"cardId May not be Empty.\"}");
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
acl.removeUser(cardId);
|
||||
acl.saveToEEPROM();
|
||||
request->send(201); // Created
|
||||
|
|
Loading…
Reference in a new issue