fablab-bergamo / Fab-O-matic

RFID machine access solution for a Fab Lab, based on ESP32. Uses modern C++ with Arduino framework. Hardware project is included.
https://www.fablabbergamo.it/2024/06/03/fabomatic1/
MIT License
2 stars 3 forks source link

Save cached UID in EEPROM from time to time ? #12

Closed PBrunot closed 5 months ago

PBrunot commented 6 months ago

When the WiFi network is down, the whitelist is used to check for users RFID card to allow machine usage. Right now the whitelist is hard-coded in secrets\conf.hpp, requiring recompilation and update to change the whitelist.

Probably the whitelist should be merged with a cache of latest authorized users and saved in EEPROM like other config settings.

This would make the system more robust when the network goes down.

PBrunot commented 5 months ago

First this is no EEPROM on ESP32, only Flash memory which is used by Arduino EEPROM class. It seems to work for small size only.

I have added a cache of last 10 RFID cards with the following logic:

When the server cannot be reached (only in this case) the cache is searched and if the card is found, user is logged in with previous user level. In case the cache fails to find the card ID, then the whitelist is still searched, cache and whitelist are kept as two different concepts.

In terms of implementation, the cache has been added to the SavedConfig class and testcases have been extended to validate this. std::array have been used to ensure static allocation of cache, some stack warnings have appeared because SavedConfig is now quite a large object. However we still have plently of RAM so I didnt optimize.

See PR #13 + following commits for bugfixes.