new meter
This commit is contained in:
@@ -3,68 +3,80 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/queue.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Tamanho máximo da tag RFID (incluindo '\0')
|
||||
/// Tamanho máximo de uma tag RFID (incluindo '\0')
|
||||
#define AUTH_TAG_MAX_LEN 20
|
||||
|
||||
// Evento enviado ao EVSE Manager após leitura de tag
|
||||
/// Estrutura de evento emitida após leitura de uma tag
|
||||
typedef struct {
|
||||
char tag[AUTH_TAG_MAX_LEN]; // Tag lida
|
||||
bool authorized; // true se tag for válida
|
||||
char tag[AUTH_TAG_MAX_LEN]; ///< Tag lida
|
||||
bool authorized; ///< true se a tag for reconhecida como válida
|
||||
} auth_event_t;
|
||||
|
||||
/**
|
||||
* @brief Inicializa o sistema de autenticação.
|
||||
* Carrega configuração e inicia o leitor Wiegand (wg26).
|
||||
*
|
||||
* - Carrega a configuração (enabled) da NVS
|
||||
* - Inicia o leitor Wiegand
|
||||
* - Emite evento AUTH_EVENT_INIT com estado atual
|
||||
*/
|
||||
void auth_init(void);
|
||||
|
||||
/**
|
||||
* @brief Define a fila de eventos que receberá auth_event_t.
|
||||
*/
|
||||
void auth_set_event_queue(QueueHandle_t queue);
|
||||
|
||||
/**
|
||||
* @brief Ativa ou desativa o módulo de autenticação (RFID).
|
||||
* Essa configuração é salva em NVS.
|
||||
* @brief Ativa ou desativa o uso de autenticação via RFID.
|
||||
*
|
||||
* Esta configuração é persistida em NVS. Se desativado, o sistema
|
||||
* considerará todas as autorizações como aceitas.
|
||||
*
|
||||
* @param value true para ativar, false para desativar
|
||||
*/
|
||||
void auth_set_enabled(bool value);
|
||||
|
||||
/**
|
||||
* @brief Verifica se a autenticação está habilitada.
|
||||
* @brief Verifica se o sistema de autenticação está habilitado.
|
||||
*/
|
||||
bool auth_is_enabled(void);
|
||||
|
||||
/**
|
||||
* @brief Adiciona uma nova tag válida.
|
||||
* @brief Adiciona uma nova tag RFID à lista de autorizadas.
|
||||
*
|
||||
* @param tag String da tag (máx AUTH_TAG_MAX_LEN-1)
|
||||
* @return true se a tag foi adicionada, false se já existia ou inválida
|
||||
*/
|
||||
bool auth_add_tag(const char *tag);
|
||||
|
||||
/**
|
||||
* @brief Remove uma tag previamente cadastrada.
|
||||
*
|
||||
* @param tag String da tag
|
||||
* @return true se foi removida, false se não encontrada
|
||||
*/
|
||||
bool auth_remove_tag(const char *tag);
|
||||
|
||||
/**
|
||||
* @brief Verifica se uma tag está cadastrada.
|
||||
* @brief Verifica se uma tag já está registrada como válida.
|
||||
*/
|
||||
bool auth_tag_exists(const char *tag);
|
||||
|
||||
/**
|
||||
* @brief Lista as tags registradas (via ESP_LOG).
|
||||
* @brief Lista todas as tags válidas atualmente registradas (via logs).
|
||||
*/
|
||||
void auth_list_tags(void);
|
||||
|
||||
/**
|
||||
* @brief Processa uma tag lida (usado pelo leitor Wiegand).
|
||||
* @brief Processa uma tag RFID lida (chamada normalmente pelo leitor).
|
||||
*
|
||||
* - Verifica validade
|
||||
* - Emite evento AUTH_EVENT_TAG_PROCESSED
|
||||
* - Inicia timer de expiração se autorizada
|
||||
*/
|
||||
void auth_process_tag(const char *tag);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
21
components/auth/include/auth_events.h
Normal file
21
components/auth/include/auth_events.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "esp_event.h"
|
||||
|
||||
#define AUTH_EVENT_TAG_MAX_LEN 32
|
||||
|
||||
ESP_EVENT_DECLARE_BASE(AUTH_EVENTS);
|
||||
|
||||
typedef enum {
|
||||
AUTH_EVENT_TAG_PROCESSED,
|
||||
AUTH_EVENT_ENABLED_CHANGED,
|
||||
AUTH_EVENT_INIT,
|
||||
} auth_event_id_t;
|
||||
|
||||
typedef struct {
|
||||
char tag[AUTH_EVENT_TAG_MAX_LEN];
|
||||
bool authorized;
|
||||
} auth_tag_event_data_t;
|
||||
|
||||
typedef struct {
|
||||
bool enabled;
|
||||
} auth_enabled_event_data_t;
|
||||
Reference in New Issue
Block a user