Leosac  0.8.0
Open Source Access Control
Leosac::Module::Wiegand::Strategy::WiegandPinNBitsOnly< NbBits > Class Template Reference

Strategy for ready PIN only. More...

#include <WiegandPinNBitsOnly.hpp>

+ Inheritance diagram for Leosac::Module::Wiegand::Strategy::WiegandPinNBitsOnly< NbBits >:
+ Collaboration diagram for Leosac::Module::Wiegand::Strategy::WiegandPinNBitsOnly< NbBits >:

Public Member Functions

 WiegandPinNBitsOnly (WiegandReaderImpl *reader, std::chrono::milliseconds pin_timeout, char pin_end_key)
 Create a strategy that read N bits-per-key PIN code. More...
 
virtual void timeout () override
 This is called when the module detect a timeout. More...
 
virtual bool completed () const override
 Did the strategy gather needed data? If this function returns true, that means that the strategy implementation successfully retrieve data from wiegand bits. More...
 
virtual void signal (zmqpp::socket &sock) override
 Tells the strategy implementation to send a message to the application containing the received credentials. More...
 
virtual const std::string & get_pin () const override
 Retrieve the pin code that was read from the reader. More...
 
virtual void reset () override
 Reset the strategy, meaning that the next time timeout() is called the behavior should be the same than the first time. More...
 
- Public Member Functions inherited from Leosac::Module::Wiegand::Strategy::PinReading
 PinReading (WiegandReaderImpl *reader)
 
- Public Member Functions inherited from Leosac::Module::Wiegand::Strategy::WiegandStrategy
 WiegandStrategy (WiegandReaderImpl *reader)
 
virtual ~WiegandStrategy ()=default
 
virtual void set_reader (WiegandReaderImpl *new_ptr)
 Update the pointer that points back to the associated reader. More...
 

Private Types

using TimePoint = std::chrono::system_clock::time_point
 

Private Member Functions

char extract_from_raw (uint8_t input) const
 Extract the character that was pressed from raw data. More...
 
void end_of_input ()
 Timeout or pin_end_key read. More...
 

Private Attributes

std::string inputs_
 
std::chrono::milliseconds pin_timeout_
 
char pin_end_key_
 
TimePoint last_update_
 
bool ready_
 Are we ready to submit the PIN code ? More...
 

Additional Inherited Members

- Protected Attributes inherited from Leosac::Module::Wiegand::Strategy::WiegandStrategy
WiegandReaderImplreader_
 

Detailed Description

template<unsigned int NbBits>
class Leosac::Module::Wiegand::Strategy::WiegandPinNBitsOnly< NbBits >

Strategy for ready PIN only.

The number of bits sent by the reader per key pressed is NbBits.

Definition at line 38 of file WiegandPinNBitsOnly.hpp.

Member Typedef Documentation

◆ TimePoint

template<unsigned int NbBits>
using Leosac::Module::Wiegand::Strategy::WiegandPinNBitsOnly< NbBits >::TimePoint = std::chrono::system_clock::time_point
private

Definition at line 80 of file WiegandPinNBitsOnly.hpp.

Constructor & Destructor Documentation

◆ WiegandPinNBitsOnly()

template<unsigned int NbBits>
WiegandPinNBitsOnly::WiegandPinNBitsOnly ( WiegandReaderImpl reader,
std::chrono::milliseconds  pin_timeout,
char  pin_end_key 
)

Create a strategy that read N bits-per-key PIN code.

Parameters
readerthe reader object we provide the strategy for.
pin_timeoutnb of msec before flushing user input to the system
pin_end_keykey ('1', '*', '5') that will trigger user input flushing.

Definition at line 28 of file WiegandPinNBitsOnly.cpp.

Member Function Documentation

◆ completed()

template<unsigned int NbBits>
bool WiegandPinNBitsOnly::completed ( ) const
overridevirtual

Did the strategy gather needed data? If this function returns true, that means that the strategy implementation successfully retrieve data from wiegand bits.

It successfully build a card_id, or a PIN code, etc. The reader implementation will call signal() if completed() returns true.

Implements Leosac::Module::Wiegand::Strategy::WiegandStrategy.

Definition at line 115 of file WiegandPinNBitsOnly.cpp.

◆ end_of_input()

template<unsigned int NbBits>
void WiegandPinNBitsOnly::end_of_input
private

Timeout or pin_end_key read.

If we have meaningful data, set ready to true.

Definition at line 106 of file WiegandPinNBitsOnly.cpp.

◆ extract_from_raw()

template<unsigned int NbBits>
char WiegandPinNBitsOnly::extract_from_raw ( uint8_t  input) const
private

Extract the character that was pressed from raw data.

Definition at line 40 of file WiegandPinNBitsOnly.cpp.

◆ get_pin()

template<unsigned int NbBits>
const std::string & WiegandPinNBitsOnly::get_pin ( ) const
overridevirtual

Retrieve the pin code that was read from the reader.

Implements Leosac::Module::Wiegand::Strategy::PinReading.

Definition at line 134 of file WiegandPinNBitsOnly.cpp.

◆ reset()

template<unsigned int NbBits>
void WiegandPinNBitsOnly::reset ( )
overridevirtual

Reset the strategy, meaning that the next time timeout() is called the behavior should be the same than the first time.

Basically, implementation should wipe its state (parts of PIN code read, card ID, etc).

Implements Leosac::Module::Wiegand::Strategy::WiegandStrategy.

Definition at line 140 of file WiegandPinNBitsOnly.cpp.

◆ signal()

template<unsigned int NbBits>
void WiegandPinNBitsOnly::signal ( zmqpp::socket &  sock)
overridevirtual

Tells the strategy implementation to send a message to the application containing the received credentials.

It is up to the strategy to format a correct message. This is required because only the strategy knows what kind of credential it can generate.

Parameters
sockthe socket where we write the message containing credentials.

Implements Leosac::Module::Wiegand::Strategy::WiegandStrategy.

Definition at line 121 of file WiegandPinNBitsOnly.cpp.

◆ timeout()

template<unsigned int NbBits>
void WiegandPinNBitsOnly::timeout ( )
overridevirtual

This is called when the module detect a timeout.

(2 ms of inactivity).

Implements Leosac::Module::Wiegand::Strategy::WiegandStrategy.

Definition at line 71 of file WiegandPinNBitsOnly.cpp.

Member Data Documentation

◆ inputs_

template<unsigned int NbBits>
std::string Leosac::Module::Wiegand::Strategy::WiegandPinNBitsOnly< NbBits >::inputs_
private

Definition at line 76 of file WiegandPinNBitsOnly.hpp.

◆ last_update_

template<unsigned int NbBits>
TimePoint Leosac::Module::Wiegand::Strategy::WiegandPinNBitsOnly< NbBits >::last_update_
private

Definition at line 81 of file WiegandPinNBitsOnly.hpp.

◆ pin_end_key_

template<unsigned int NbBits>
char Leosac::Module::Wiegand::Strategy::WiegandPinNBitsOnly< NbBits >::pin_end_key_
private

Definition at line 78 of file WiegandPinNBitsOnly.hpp.

◆ pin_timeout_

template<unsigned int NbBits>
std::chrono::milliseconds Leosac::Module::Wiegand::Strategy::WiegandPinNBitsOnly< NbBits >::pin_timeout_
private

Definition at line 77 of file WiegandPinNBitsOnly.hpp.

◆ ready_

template<unsigned int NbBits>
bool Leosac::Module::Wiegand::Strategy::WiegandPinNBitsOnly< NbBits >::ready_
private

Are we ready to submit the PIN code ?

Definition at line 86 of file WiegandPinNBitsOnly.hpp.


The documentation for this class was generated from the following files: