diff --git a/components/rfid/CMakeLists.txt b/components/auth/CMakeLists.txt similarity index 75% rename from components/rfid/CMakeLists.txt rename to components/auth/CMakeLists.txt index 19ed16e..2177a47 100755 --- a/components/rfid/CMakeLists.txt +++ b/components/auth/CMakeLists.txt @@ -1,4 +1,4 @@ -set(srcs "src/rc522_2.c" "src/wiegand.c" "src/main_wiegand.c") +set(srcs "src/auth.c" "src/rc522_2.c" "src/wiegand.c" "src/main_wiegand.c") idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "include" diff --git a/components/auth/idf_component.yml b/components/auth/idf_component.yml new file mode 100755 index 0000000..973e925 --- /dev/null +++ b/components/auth/idf_component.yml @@ -0,0 +1,2 @@ +version: "2.6.0" +description: Authentication component diff --git a/components/auth/include/auth.h b/components/auth/include/auth.h new file mode 100644 index 0000000..5c9528e --- /dev/null +++ b/components/auth/include/auth.h @@ -0,0 +1,9 @@ +#ifndef AUTH_H +#define AUTH_H + +#include + +void auth_set_enable(bool value); +bool auth_get_enable(void); + +#endif // AUTH_H diff --git a/components/rfid/include/main_wiegand.h b/components/auth/include/main_wiegand.h old mode 100755 new mode 100644 similarity index 100% rename from components/rfid/include/main_wiegand.h rename to components/auth/include/main_wiegand.h diff --git a/components/rfid/include/rc522_2.h b/components/auth/include/rc522_2.h old mode 100755 new mode 100644 similarity index 100% rename from components/rfid/include/rc522_2.h rename to components/auth/include/rc522_2.h diff --git a/components/rfid/include/wiegand.h b/components/auth/include/wiegand.h old mode 100755 new mode 100644 similarity index 100% rename from components/rfid/include/wiegand.h rename to components/auth/include/wiegand.h diff --git a/components/auth/src/auth.c b/components/auth/src/auth.c new file mode 100644 index 0000000..524afb9 --- /dev/null +++ b/components/auth/src/auth.c @@ -0,0 +1,11 @@ +#include "auth.h" + +static bool enable = false; + +void auth_set_enable(bool value) { + enable = value; +} + +bool auth_get_enable(void) { + return enable; +} diff --git a/components/rfid/src/main_wiegand.c b/components/auth/src/main_wiegand.c old mode 100755 new mode 100644 similarity index 100% rename from components/rfid/src/main_wiegand.c rename to components/auth/src/main_wiegand.c diff --git a/components/rfid/src/rc522_2.c b/components/auth/src/rc522_2.c similarity index 99% rename from components/rfid/src/rc522_2.c rename to components/auth/src/rc522_2.c index ec9fd58..7ca1e7c 100755 --- a/components/rfid/src/rc522_2.c +++ b/components/auth/src/rc522_2.c @@ -8,8 +8,9 @@ #include "rc522_2.h" #include "esp_log.h" #include "evse_api.h" +#include "auth.h" -const static char *TAG = "RFID"; +const static char *TAG = "AUTH"; spi_device_handle_t spi; // Member variables @@ -2321,7 +2322,7 @@ void rc522_main(void *vParam) while (1) { - if (evse_is_require_auth()) + if (evse_is_require_auth() && auth_get_enable()) { r = PICC_IsNewCardPresent(); diff --git a/components/rfid/src/wiegand.c b/components/auth/src/wiegand.c old mode 100755 new mode 100644 similarity index 100% rename from components/rfid/src/wiegand.c rename to components/auth/src/wiegand.c diff --git a/components/rfid/idf_component.yml b/components/rfid/idf_component.yml deleted file mode 100755 index dae609c..0000000 --- a/components/rfid/idf_component.yml +++ /dev/null @@ -1,2 +0,0 @@ -version: "2.6.0" -description: MFRC522 driver