LibLogicalAccess
2.5.0
An Open Source RFID Library
|
#include <id3readerunit.hpp>
Classes | |
class | APDUWrapperGuard |
Public Member Functions | |
virtual | ~ID3ReaderUnit () |
ID3ReaderUnit (const std::string &name) | |
std::vector< std::shared_ptr< Chip > > | getChipList () override |
std::shared_ptr< Chip > | selectCard (std::shared_ptr< Chip >) |
PCSCReaderUnitType | getPCSCType () const override |
Get the PC/SC reader unit type. | |
bool | process_insertion (const std::string &cardType, unsigned int maxwait, const ElapsedTimeCounter &elapsed) override |
bool | connect (PCSCShareMode share_mode) override |
Connect to the card. | |
void | disconnect () override |
Disconnect from the card. | |
bool | connect () override |
Connect to the card. | |
virtual bool | connect (PCSCShareMode share_mode) |
Connect to the card. | |
![]() | |
PCSCReaderUnit (const std::string &name) | |
Constructor. | |
virtual | ~PCSCReaderUnit () |
Destructor. | |
std::string | getName () const override |
Get the reader unit name. | |
void | setName (const std::string &name) |
Set the reader unit name. | |
std::string | getConnectedName () override |
Get the connected reader unit name. | |
virtual PCSCReaderUnitType | getPCSCType () const |
Get the PC/SC reader unit type. | |
void | setCardType (std::string cardType) override |
Set the card type. | |
bool | waitInsertion (unsigned int maxwait) override |
Wait for a card insertion. | |
bool | waitRemoval (unsigned int maxwait) override |
Wait for a card removal. | |
bool | connect () override |
Connect to the card. | |
virtual bool | connect (PCSCShareMode share_mode) |
Connect to the card. | |
void | disconnect () override |
Disconnect from the card. | |
bool | isConnected () override |
Check if the handle is associated to a card (aka. "connected"). | |
bool | connectToReader () override |
Connect to the reader. Implicit connection on first command sent. | |
void | disconnectFromReader () override |
Disconnect from reader. | |
const SCARDHANDLE & | getHandle () const |
Get the low-level SCARDHANDLE. | |
unsigned long | getActiveProtocol () const |
Get the active protocol for the connected card. | |
PCSCShareMode | getShareMode () const |
Get the currently active share mode. | |
std::shared_ptr< Chip > | createChip (std::string type) override |
Create the chip object from card type. | |
std::shared_ptr< Chip > | getSingleChip () override |
Get the first and/or most accurate chip found. | |
std::vector< std::shared_ptr< Chip > > | getChipList () override |
Get chip available in the RFID rang. | |
virtual ByteVector | getCardSerialNumber () |
Get the card serial number. | |
std::string | getReaderSerialNumber () override |
Get a string hexadecimal representation of the reader serial number. | |
const ByteVector & | getATR () const |
Get the card ATR. | |
virtual std::shared_ptr< PCSCReaderCardAdapter > | getDefaultPCSCReaderCardAdapter () |
Get the default PC/SC reader/card adapter. | |
virtual std::shared_ptr< ReaderCardAdapter > | getReaderCardAdapter (std::string type) |
Get the PC/SC reader/card adapter for a card type. | |
void | serialize (boost::property_tree::ptree &parentNode) override |
Serialize the current object to XML. | |
void | unSerialize (boost::property_tree::ptree &node) override |
UnSerialize a XML node to the current object. | |
std::shared_ptr< ReaderUnitConfiguration > | getConfiguration () override |
Get the reader unit configuration. | |
void | setConfiguration (std::shared_ptr< ReaderUnitConfiguration > config) override |
Set the reader unit configuration. | |
virtual void | changeReaderKey (std::shared_ptr< ReaderMemoryKeyStorage > keystorage, const ByteVector &key) |
Change a key in reader memory. | |
std::shared_ptr< PCSCReaderUnitConfiguration > | getPCSCConfiguration () |
Get the PC/SC reader unit configuration. | |
std::shared_ptr< PCSCReaderProvider > | getPCSCReaderProvider () const |
void | makeProxy (std::shared_ptr< PCSCReaderUnit > readerUnit, std::shared_ptr< PCSCReaderUnitConfiguration > readerUnitConfig) |
Make the reader unit as a proxy to another. Use when listening on all PC/SC reader unit. | |
virtual void | getT_CL_ISOType (bool &isTypeA, bool &isTypeB) |
Get if the inserted card is from ISO 14443-4 A or B. | |
virtual void | cardConnected () |
std::shared_ptr< PCSCReaderUnit > | getProxyReaderUnit () const |
void | setCardTechnologies (const TechnoBitset &bitset) override |
TechnoBitset | getCardTechnologies () override |
std::shared_ptr< LCDDisplay > | getLCDDisplay () override |
Get the LCD Display for this reader unit. | |
void | setLCDDisplay (std::shared_ptr< LCDDisplay > d) override |
Get the LCD Display for this reader unit. | |
std::shared_ptr< LEDBuzzerDisplay > | getLEDBuzzerDisplay () override |
Get the LED/Buzzer Display for this reader unit. | |
void | setLEDBuzzerDisplay (std::shared_ptr< LEDBuzzerDisplay > lbd) override |
Get the LCD Display for this reader unit. | |
ReaderServicePtr | getService (const ReaderServiceType &type) override |
void | beginTransaction () |
void | endTransaction (DWORD dwDisposition=SCARD_LEAVE_CARD) |
void | reset (int action=0) |
Reconnect to the card. | |
void | setup_pcsc_connection (PCSCShareMode share_mode) |
void | teardown_pcsc_connection () |
![]() | |
ISO7816ReaderUnit (std::string rpt) | |
virtual | ~ISO7816ReaderUnit () |
bool | waitInsertion (unsigned int) override |
Wait for a card insertion. | |
bool | waitRemoval (unsigned int) override |
Wait for a card removal. | |
bool | isConnected () override |
Check if the card is connected. | |
void | setCardType (std::string) override |
Set the forced card type. | |
std::shared_ptr< Chip > | getSingleChip () override |
Get the first and/or most accurate chip found. | |
std::vector< std::shared_ptr< Chip > > | getChipList () override |
Get chip available in the RFID rang. | |
bool | connect () override |
Connect to the card. | |
void | disconnect () override |
Disconnect from the card. | |
virtual void | connectToSAM () |
bool | connectToReader () override |
Connect to the reader. Implicit connection on first command sent. | |
virtual void | disconnectFromSAM () |
void | disconnectFromReader () override |
Disconnect from reader. | |
virtual void | reloadReaderConfiguration () |
virtual void | setContext (const std::string &context) |
Set the client context. | |
virtual std::string | getContext () |
Get the client context. | |
std::string | getName () const override |
Get the reader unit name. | |
std::string | getReaderSerialNumber () override |
Get a string hexadecimal representation of the reader serial number. | |
std::shared_ptr< CardProbe > | createCardProbe () override |
virtual std::shared_ptr< SAMChip > | getSAMChip () |
Get The SAM Chip. | |
virtual void | setSAMChip (std::shared_ptr< SAMChip > t) |
Set the SAM Chip. | |
virtual std::shared_ptr< ISO7816ReaderUnit > | getSAMReaderUnit () |
Get The SAM ReaderUnit. | |
virtual void | setSAMReaderUnit (std::shared_ptr< ISO7816ReaderUnit > t) |
Set the SAM ReaderUnit. | |
![]() | |
ReaderUnit (std::string rpt) | |
Constructor. | |
virtual | ~ReaderUnit () |
Destructor. | |
std::string | getRPType () const |
Get the reader provider type. | |
virtual ByteVector | getPingCommand () const |
Get the reader ping command. | |
virtual bool | waitInsertion (unsigned int maxwait)=0 |
Wait for a card insertion. | |
virtual bool | waitInsertion (const ByteVector &identifier, unsigned int maxwait) |
Wait for a specific card insertion. | |
virtual bool | waitRemoval (unsigned int maxwait)=0 |
Wait for a card removal. | |
virtual bool | isConnected ()=0 |
Check if the card is connected. | |
std::string | getCardType () const |
Get the forced card type. | |
virtual void | setCardType (std::string cardType)=0 |
Set the forced card type. | |
virtual std::shared_ptr< Chip > | createChip (std::string type) |
Create the chip object from card type. | |
virtual std::shared_ptr< Chip > | createChip (std::string type, const ByteVector &identifier) |
Create the chip object from card type with identifier. | |
virtual ByteVector | getNumber (std::shared_ptr< Chip > chip) |
Get the number from the embedded licensing configuration. | |
virtual std::shared_ptr< Chip > | getSingleChip ()=0 |
Get the first and/or most accurate chip found. | |
virtual std::vector< std::shared_ptr< Chip > > | getChipList ()=0 |
Get chip available in the RFID rang. | |
virtual ByteVector | getNumber (std::shared_ptr< Chip > chip, std::shared_ptr< CardsFormatComposite > composite) |
Get the number from the reader format composite. | |
virtual bool | connect ()=0 |
Connect to the card. | |
virtual bool | reconnect (int action=0) |
Reconnect to the card with the currently active share mode on the same reader. | |
virtual void | disconnect ()=0 |
Disconnect from the card. | |
virtual bool | connectToReader ()=0 |
Connect to the reader. Implicit connection on first command sent. | |
virtual void | disconnectFromReader ()=0 |
Disconnect from reader. | |
virtual std::string | getName () const =0 |
Get the reader unit name. | |
virtual std::string | getConnectedName () |
Get the connected reader unit name. | |
virtual std::shared_ptr< ReaderUnitConfiguration > | getConfiguration () |
Get the reader unit configuration. | |
virtual void | setConfiguration (std::shared_ptr< ReaderUnitConfiguration > config) |
Set the reader unit configuration. | |
virtual std::shared_ptr< ReaderCardAdapter > | getDefaultReaderCardAdapter () |
Get the default reader/card adapter. | |
virtual void | setDefaultReaderCardAdapter (std::shared_ptr< ReaderCardAdapter > defaultRca) |
Set the default reader/card adapter. | |
virtual std::shared_ptr< DataTransport > | getDataTransport () const |
Get the data transport layer. | |
virtual void | setDataTransport (std::shared_ptr< DataTransport > dataTransport) |
Set the data transport layer. | |
virtual std::string | getReaderSerialNumber ()=0 |
Get a string hexadecimal representation of the reader serial number. | |
std::string | getDefaultXmlNodeName () const override |
Get the default Xml Node name for this object. | |
void | serialize (boost::property_tree::ptree &node) override |
Serialize the current object to XML. | |
void | unSerialize (boost::property_tree::ptree &node) override |
UnSerialize a XML node to the current object. | |
void | unSerialize (boost::property_tree::ptree &node, const std::string &rootNode) override |
UnSerialize object from a Xml node. | |
std::shared_ptr< ReaderProvider > | getReaderProvider () const |
Get the associated reader provider. | |
void | setReaderProvider (std::weak_ptr< ReaderProvider > provider) |
Set the associated reader provider. | |
virtual std::shared_ptr< LCDDisplay > | getLCDDisplay () |
Get the LCD Display for this reader unit. | |
virtual void | setLCDDisplay (std::shared_ptr< LCDDisplay > d) |
Get the LCD Display for this reader unit. | |
virtual std::shared_ptr< LEDBuzzerDisplay > | getLEDBuzzerDisplay () |
Get the LED/Buzzer Display for this reader unit. | |
virtual void | setLEDBuzzerDisplay (std::shared_ptr< LEDBuzzerDisplay > lbd) |
Get the LCD Display for this reader unit. | |
virtual void | setCardTechnologies (const TechnoBitset &bitset) |
virtual TechnoBitset | getCardTechnologies () |
virtual TechnoBitset | getPossibleCardTechnologies () |
virtual ReaderServicePtr | getService (const ReaderServiceType &type) |
virtual std::string | serialize () |
Serialize object to Xml Node string. | |
virtual void | serialize (boost::property_tree::ptree &parentNode)=0 |
Serialize object to Xml Node. | |
virtual void | unSerialize (boost::property_tree::ptree &node)=0 |
UnSerialize object from a Xml Node. | |
virtual void | unSerialize (const std::string &xmlstring, const std::string &rootNode) |
UnSerialize object from a Xml Node string. | |
virtual void | unSerialize (std::istream &is, const std::string &rootNode) |
UnSerialize object from a Xml node. | |
virtual void | unSerialize (boost::property_tree::ptree &node, const std::string &rootNode) |
UnSerialize object from a Xml node. | |
![]() | |
virtual | ~XmlSerializable ()=default |
virtual std::string | serialize () |
Serialize object to Xml Node string. | |
virtual std::string | serializeWithHeaders () |
Serialize object to Xml Node string, with xml headers. | |
virtual void | serialize (boost::property_tree::ptree &parentNode)=0 |
Serialize object to Xml Node. | |
virtual void | serializeToFile (const std::string &filename) |
Serialize object to a Xml file. | |
virtual void | unSerialize (boost::property_tree::ptree &node)=0 |
UnSerialize object from a Xml Node. | |
virtual void | unSerialize (const std::string &xmlstring, const std::string &rootNode) |
UnSerialize object from a Xml Node string. | |
virtual void | unSerialize (std::istream &is, const std::string &rootNode) |
UnSerialize object from a Xml node. | |
virtual void | unSerialize (boost::property_tree::ptree &node, const std::string &rootNode) |
UnSerialize object from a Xml node. | |
virtual void | unSerializeFromFile (const std::string &filename) |
UnSerialize object from a Xml file. | |
virtual std::string | getDefaultXmlNodeName () const =0 |
Get the default Xml Node name for this object. | |
Protected Member Functions | |
std::shared_ptr< CardProbe > | createCardProbe () override |
std::shared_ptr< Chip > | selectCard (uint8_t idx) |
bool | select_correct_card () |
void | power_card (bool power_on) |
ByteVector | getAtr (int idx) |
std::vector< CL1356PlusUtils::Info > | listCards () |
void | unfreeze () |
![]() | |
bool | reconnect (int action=0) override |
Reconnect to the card with the currently active share mode on the same reader. | |
std::shared_ptr< Chip > | adjustChip (std::shared_ptr< Chip > c) |
std::shared_ptr< ResultChecker > | createDefaultResultChecker () const override |
std::shared_ptr< CardProbe > | createCardProbe () override |
void | configure_mifareplus_chip (std::shared_ptr< Chip > c, std::shared_ptr< Commands > &commands, std::shared_ptr< ResultChecker > &resultChecker) const |
void | detect_mifareplus_security_level (std::shared_ptr< Chip > c) |
void | setSingleChip (std::shared_ptr< Chip > chip) |
Set the first and/or most accurate chip found. | |
std::shared_ptr< SAMChip > | getSAMChip () override |
Get The SAM Chip. | |
void | setSAMChip (std::shared_ptr< SAMChip > t) override |
Set the SAM Chip. | |
std::shared_ptr< ISO7816ReaderUnit > | getSAMReaderUnit () override |
Get The SAM ReaderUnit. | |
void | setSAMReaderUnit (std::shared_ptr< ISO7816ReaderUnit > t) override |
Set the SAM ReaderUnit. | |
std::tuple< SPtrStringVector, ReaderStateVector > | prepare_poll_parameters () |
void | waitInsertion_create_proxy (const std::string &reader_name) |
virtual bool | process_insertion (const std::string &cardType, unsigned int maxwait, const ElapsedTimeCounter &elapsed) |
![]() | |
std::shared_ptr< ResultChecker > | createDefaultResultChecker () const override |
std::shared_ptr< ISO7816ReaderProvider > | getISO7816ReaderProvider () const |
Get the ISO7816 reader provider. | |
std::shared_ptr< ISO7816ReaderUnitConfiguration > | getISO7816Configuration () |
Get the ISO7816 reader unit configuration. | |
bool | reconnect (int action) override |
Reconnect to the card with the currently active share mode on the same reader. | |
virtual std::shared_ptr< ResultChecker > | createDefaultResultChecker () const |
virtual std::shared_ptr< CardProbe > | createCardProbe () |
Protected Attributes | |
std::vector< std::shared_ptr< Chip > > | chips_ |
![]() | |
std::string | d_name |
The reader unit name. | |
std::string | d_connectedName |
The reader unit connected name. | |
std::unique_ptr< PCSCConnection > | connection_ |
ByteVector | atr_ |
std::shared_ptr< PCSCReaderUnit > | d_proxyReaderUnit |
The proxy reader unit. | |
![]() | |
std::shared_ptr< SAMChip > | d_sam_chip |
The SAM chip. | |
std::shared_ptr< ISO7816ReaderUnit > | d_sam_readerunit |
The SAM ReaderUnit used SAM Authentication. | |
std::string | d_client_context |
The client context. | |
std::string | d_sam_client_context |
The sam client context. | |
![]() | |
std::string | d_readerProviderType |
The associated reader provider type for the reader unit configuration. | |
std::string | d_card_type |
The forced card type. | |
std::weak_ptr< ReaderProvider > | d_readerProvider |
The associated reader provider for the reader unit. | |
std::shared_ptr< ReaderUnitConfiguration > | d_readerUnitConfig |
The reader unit configuration. | |
std::shared_ptr< Chip > | d_insertedChip |
The inserted chip. | |
std::shared_ptr< LCDDisplay > | d_lcdDisplay |
The inserted chip. | |
std::shared_ptr< LEDBuzzerDisplay > | d_ledBuzzerDisplay |
The inserted chip. | |
Additional Inherited Members | |
![]() | |
static std::shared_ptr< PCSCReaderUnit > | createPCSCReaderUnit (const std::string &readerName) |
![]() | |
static uint64_t | getFormatedNumber (const ByteVector &number, int padding) |
Get the number as decimal a number. | |
static std::string | getFormatedNumber (const ByteVector &number) |
Get a string hexadecimal representation of the number. | |
![]() | |
static std::string | removeXmlDeclaration (const std::string &xmlstring) |
Remove Xml declaration from a xml string. | |
static ByteVector | formatHexString (std::string hexstr) |
Format hex string to hex string with space. | |
![]() | |
using | SPtrStringVector = std::vector< std::shared_ptr< std::string > > |
using | ReaderStateVector = std::vector< SCARD_READERSTATE > |
![]() | |
static unsigned long long | atoull (const std::string &str) |
Implementation class for the CL1356+ card reader from ID3.
This reader supports handpicking the card to work with. Its the first reader in LLA whose getChipList()
may actually returns more than one chip.
How to use ?
If you do not plan to put multiple cards on the reader, then the API is similar to other reader, and everything should work as expected.
If you plan to put multiple card on the reader, and then pick one to work with, read below:
WaitInsertion() will wait for any card before returning, unless a card type has been forced: in that case it will wait for a card of the matching type.
Connect() will connect to the first card, unless a card type has been forced, in which case it will attempt to connect to a card matching the type.
getChipList() returns a list of Chip object. Theses are the available chip that have been detected by the reader. HOWEVER THE CHIP OBJECTS ARE NOT USABLE AS IS. It is required to call selectChip(idx) before, otherwise the reader will operate against the wrong card.
|
inlinevirtual |
|
explicit |
|
overridevirtual |
Connect to the card.
If the card handle was already connected, connect() first call disconnect(). If you intend to do a reconnection, call reconnect() instead.
Reimplemented from logicalaccess::PCSCReaderUnit.
|
virtual |
Connect to the card.
reader | The reader name. If an empty or invalid reader name is specified, connect will fail. |
share_mode | The share mode. |
If the card handle was already connected, connect() first call disconnect(). If you intend to do a reconnection, call reconnect() instead.
Reimplemented from logicalaccess::PCSCReaderUnit.
|
overridevirtual |
Connect to the card.
reader | The reader name. If an empty or invalid reader name is specified, connect will fail. |
share_mode | The share mode. |
If the card handle was already connected, connect() first call disconnect(). If you intend to do a reconnection, call reconnect() instead.
Reimplemented from logicalaccess::PCSCReaderUnit.
|
overrideprotectedvirtual |
Create a new CardProbe object that works with the current reader.
This is required because the behaviour of reader varies a lot when probing for cards.
The default implementation returns nullptr;
Reimplemented from logicalaccess::PCSCReaderUnit.
|
overridevirtual |
Disconnect from the card.
Reimplemented from logicalaccess::PCSCReaderUnit.
|
protected |
Get the ATR for the idx'th card
|
overridevirtual |
Reimplemented from logicalaccess::PCSCReaderUnit.
|
overridevirtual |
Get the PC/SC reader unit type.
Reimplemented from logicalaccess::PCSCReaderUnit.
|
protected |
Returns a list of cards information for cards that are available in the field.
The public method equivalent is getChipList() that returns a list of Chip object instead.
|
protected |
Power ON or OFF the currently selected card.
|
overridevirtual |
Give a chance to concrete reader implementation to do something just after a insertion has been detected.
This default implemented MUST be called explicitly if you override this method.
Reimplemented from logicalaccess::PCSCReaderUnit.
|
protected |
Select the correct card (if needed) based on the forced card type, if any. If forced card type is not set, this function is a noop.
Return false on failure. True otherwise.
High level chip selection.
The chip object must be part of the list returned by getChipList().
|
protected |
Select a card by its index.
Indexing starts at 0.
|
protected |
Unfreeze the card tracking.
This is required because command such as listCard while pause automatic card tracking.
|
protected |
Cache the list of chips when getChipList() is called.
This allows to offers a selectChip(Chip) call, in addition to the selectChip(n)