Refactor rfid component to auth

This commit is contained in:
2025-06-07 22:40:43 +01:00
parent cdc55ee678
commit eae5ce241d
11 changed files with 26 additions and 5 deletions

View File

@@ -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}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"

View File

@@ -0,0 +1,2 @@
version: "2.6.0"
description: Authentication component

View File

@@ -0,0 +1,9 @@
#ifndef AUTH_H
#define AUTH_H
#include <stdbool.h>
void auth_set_enable(bool value);
bool auth_get_enable(void);
#endif // AUTH_H

View File

@@ -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;
}

View File

@@ -8,8 +8,9 @@
#include "rc522_2.h" #include "rc522_2.h"
#include "esp_log.h" #include "esp_log.h"
#include "evse_api.h" #include "evse_api.h"
#include "auth.h"
const static char *TAG = "RFID"; const static char *TAG = "AUTH";
spi_device_handle_t spi; spi_device_handle_t spi;
// Member variables // Member variables
@@ -2321,7 +2322,7 @@ void rc522_main(void *vParam)
while (1) while (1)
{ {
if (evse_is_require_auth()) if (evse_is_require_auth() && auth_get_enable())
{ {
r = PICC_IsNewCardPresent(); r = PICC_IsNewCardPresent();

View File

View File

@@ -1,2 +0,0 @@
version: "2.6.0"
description: MFRC522 driver