#ifndef AUTH_H #define AUTH_H #include #include #ifdef __cplusplus extern "C" { #endif /// Tamanho máximo de uma tag RFID (incluindo '\0') #define AUTH_TAG_MAX_LEN 20 /// Estrutura de evento emitida após leitura de uma tag typedef struct { 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 a configuração (enabled) da NVS * - Inicia o leitor Wiegand * - Emite evento AUTH_EVENT_INIT com estado atual */ void auth_init(void); /** * @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 o sistema de autenticação está habilitado. */ bool auth_is_enabled(void); /** * @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 já está registrada como válida. */ bool auth_tag_exists(const char *tag); /** * @brief Lista todas as tags válidas atualmente registradas (via logs). */ void auth_list_tags(void); /** * @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 #endif // AUTH_H